Commit graph

41 commits

Author SHA1 Message Date
Albert Larsan
cf2dff2b1e
Move /src/test to /tests 2023-01-11 09:32:08 +00:00
Oli Scherer
cb26b35b12 Make some diagnostics not depend on the source of what they reference being available 2022-12-13 09:48:22 +00:00
Oli Scherer
99348a5330 Change CTFE backtraces to use note instead of label to preserve their order
labels are reordered within the file in which they are reported, which can mess up the stack trace
2022-12-06 18:59:46 +00:00
Oli Scherer
7782a2b70d Remove now-redundant file/line info from const backtraces 2022-12-06 18:59:46 +00:00
Ralf Jung
58f2ede15f interpret, ptr_offset_from: refactor and test too-far-apart check 2022-07-24 19:35:40 -04:00
Ralf Jung
924a4cd008 bless 2022-07-06 14:03:20 -04:00
Ralf Jung
46956f76ca adjust dangling-int-ptr error message 2022-07-05 08:08:24 -04:00
Ralf Jung
e5245ef1eb interpret: unify offset_from check with offset check 2022-06-09 20:47:06 -04:00
Scott McMurray
89a18cb600 Add unsigned_offset_from on pointers
Like we have `add`/`sub` which are the `usize` version of `offset`, this adds the `usize` equivalent of `offset_from`.  Like how `.add(d)` replaced a whole bunch of `.offset(d as isize)`, you can see from the changes here that it's fairly common that code actually knows the order between the pointers and *wants* a `usize`, not an `isize`.

As a bonus, this can do `sub nuw`+`udiv exact`, rather than `sub`+`sdiv exact`, which can be optimized slightly better because it doesn't have to worry about negatives.  That's why the slice iterators weren't using `offset_from`, though I haven't updated that code in this PR because slices are so perf-critical that I'll do it as its own change.

This is an intrinsic, like `offset_from`, so that it can eventually be allowed in CTFE.  It also allows checking the extra safety condition -- see the test confirming that CTFE catches it if you pass the pointers in the wrong order.
2022-05-11 17:16:25 -07:00
Jakob Degen
fe796cd0f6 Bless tests that broke in a trivial way due to change in deaggregation 2022-04-11 09:26:26 -04:00
Ralf Jung
63ed8e41ce adjust offset_from logic: check that both pointers are in-bounds 2022-03-10 18:59:58 -05:00
Jacob Pratt
0cdbeaa2a3
Stabilize const_raw_ptr_deref for *const T
This stabilizes dereferencing immutable raw pointers in const contexts.
It does not stabilize `*mut T` dereferencing. This is placed behind the
`const_raw_mut_ptr_deref` feature gate.
2021-11-06 17:05:15 -04:00
Fabian Wolff
f8372f876c Remove trailing whitespace from error messages 2021-08-04 10:48:30 +02:00
Ralf Jung
4759090d15 adjust tests 2021-07-14 18:17:49 +02:00
Ralf Jung
7475661678 improve test by using intrinsic directly 2021-06-18 19:43:03 +02:00
Ralf Jung
3061777c48 bless you 2021-06-18 19:31:56 +02:00
Ralf Jung
4dddc3818e fix null pointer error messages 2021-05-07 15:13:23 +02:00
Ralf Jung
abdba81d03 use CheckInAllocMsg::PointerArithmeticTest for ptr_offset error 2021-05-06 10:39:35 +02:00
Ralf Jung
8477d352ac make const_err a future incompat lint 2021-02-03 15:45:43 +01:00
Dan Aloni
07e7823c01 pretty: trim paths of unique symbols
If a symbol name can only be imported from one place for a type, and
as long as it was not glob-imported anywhere in the current crate, we
can trim its printed path and print only the name.

This has wide implications on error messages with types, for example,
shortening `std::vec::Vec` to just `Vec`, as long as there is no other
`Vec` importable anywhere.

This adds a new '-Z trim-diagnostic-paths=false' option to control this
feature.

On the good path, with no diagnosis printed, we should try to avoid
issuing this query, so we need to prevent trimmed_def_paths query on
several cases.

This change also relies on a previous commit that differentiates
between `Debug` and `Display` on various rustc types, where the latter
is trimmed and presented to the user and the former is not.
2020-09-02 22:26:37 +03:00
Ralf Jung
4f92f0d31b remove feature gate from tests 2020-08-22 15:07:32 +02:00
mark
2c31b45ae8 mv std libs to library/ 2020-07-27 19:51:13 -05:00
LeSeulArtichaut
6a7a6528f6 Bless failing tests 2020-06-30 21:03:34 +02:00
Oliver Scherer
819cde5dab Show the values and computation that would overflow a const evaluation or propagation 2020-06-26 10:08:52 +02:00
Ralf Jung
707bd7b213 rename InvalidIntPtrUsage 2020-05-01 10:50:04 +02:00
Ralf Jung
2feeb88b62 bless you 2020-05-01 10:50:04 +02:00
Eduard-Mihai Burtescu
8deff18529 tests: remove ignore directives from tests that mention core/alloc/std spans. 2020-04-02 11:48:34 +03:00
Ralf Jung
96deb950ac const backtrace: do not skip first frame 2020-03-31 17:58:14 +02:00
Ralf Jung
39e189d3bd bless tests 2020-03-30 20:26:48 +02:00
Mazdak Farrokhzad
a958314472
Rollup merge of #69839 - RalfJung:miri-error-cleanup, r=oli-obk
Miri error reform

Some time ago we started moving Miri errors into a few distinct categories, but we never classified all the old errors. That's what this PR does.

~~This is on top of https://github.com/rust-lang/rust/pull/69762; [relative diff](https://github.com/RalfJung/rust/compare/validity-errors...RalfJung:miri-error-cleanup).~~

r? @oli-obk

Fixes https://github.com/rust-lang/const-eval/issues/4
2020-03-18 18:03:40 +01:00
Ralf Jung
93436d8fd7 make error message less confusing 2020-03-11 19:44:23 +01:00
Ralf Jung
d02543a453 fmt, tweak messages and bless 2020-03-11 19:44:23 +01:00
Oliver Scherer
02dbb35b2b Deduplicate and clean up pretty printing logic 2020-03-11 09:10:48 +01:00
Esteban Küber
90bf0d2e33 Ignore i586-unknown-linux-gnu and i586-unknown-musl in tests 2019-12-28 12:26:48 -08:00
Christoph Schmidler
12d65c28a6 Split up ptr/mod.rs in libcore, one with implementation detail for const ptr and the other with mut ptr 2019-12-19 09:01:26 +01:00
Ralf Jung
21d284b6f0 also test different integers 2019-11-04 13:32:38 +01:00
Ralf Jung
3c944feb65 test offset_from with two integers 2019-11-04 13:32:38 +01:00
Ralf Jung
b93f48f71a adjust for missing spans on x86 test runner 2019-11-02 23:13:00 +01:00
Oliver Scherer
bf83ecf90e Update ui output 2019-10-19 13:12:18 +02:00
Oliver Scherer
94a6d4b1b8 Adjust const eval code to reflect offset_from docs 2019-10-18 13:00:19 +02:00
Oliver Scherer
88b5e945e0 Make <*const/mut T>::offset_from const fn 2019-10-11 10:40:49 +02:00