summary refs log tree commit diff
path: root/tests/ui/consts/const-eval
AgeCommit message (Collapse)AuthorLines
2023-09-14don't point at const usage site for resolution-time errorsRalf Jung-23/+23
also share the code that emits the actual error
2023-09-05Auto merge of #115531 - RalfJung:read_via_copy, r=scottmcmbors-4/+26
read_via_copy: don't prematurely optimize away the read Always do the read to ensure consistent UB error messages in const-eval/Miri. r? `@scottmcm`
2023-09-04read_via_copy: don't prematurely optimize away the readRalf Jung-4/+26
2023-09-04Auto merge of #115513 - Urgau:normalize-msg-after-translate, r=petrochenkovbors-0/+16
Don't forget to normalize the translated message This PR adds a missing call to `normalize_whitespace` after translating an label. Fixes https://github.com/rust-lang/rust/issues/115498
2023-09-03Don't forget to normalize the translated messageUrgau-0/+16
2023-08-24Fix ub-int-array test for big-endian platformsUlrich Weigand-42/+10
As of commit 7767cbb3b0b332fd0a46e347ea7f68f20109d768, the tests/ui/consts/const-eval/ub-int-array.rs test is failing on big-endian platforms (in particular s390x), as the stderr output contains a hex dump that depends on endianness. Since this point intentionally verifies the hex dump to check the uninitialized byte markers, I think we should not simply standardize away the hex dump as is done with some of the other tests in this directory. However, most of the test is already endian-independent. The only exception is one line of hex dump, which can also be made endian-independent by choosing appropriate constants in the source code. Since the 32bit and 64bit stderr outputs were already (and remain) identical, I've merged them and removed the stderr-per-bitwidth marker. Fixes (again) https://github.com/rust-lang/rust/issues/105383.
2023-08-02const validation: point at where we found a pointer but expected an integerRalf Jung-131/+165
2023-08-02Auto merge of #114333 - RalfJung:dangling-ptr-offset, r=oli-obkbors-4/+4
Miri: fix error on dangling pointer inbounds offset We used to claim that the pointer was "dereferenced", but that is just not true. Can be reviewed commit-by-commit. The first commit is an unrelated rename that didn't seem worth splitting into its own PR. r? `@oli-obk`
2023-08-01properly track why we checked whether a pointer is in-boundsRalf Jung-4/+4
also simplify the in-bounds checking in Miri's borrow trackers
2023-08-01Auto merge of #112849 - m-ou-se:panic-message-format, r=thomccbors-1/+1
Change default panic handler message format. This changes the default panic hook's message format from: ``` thread '{thread}' panicked at '{message}', {location} ``` to ``` thread '{thread}' panicked at {location}: {message} ``` This puts the message on its own line without surrounding quotes, making it easiser to read. For example: Before: ``` thread 'main' panicked at 'env variable `IMPORTANT_PATH` should be set by `wrapper_script.sh`', src/main.rs:4:6 ``` After: ``` thread 'main' panicked at src/main.rs:4:6: env variable `IMPORTANT_PATH` should be set by `wrapper_script.sh` ``` --- See this PR by `@nyurik,` which does that for only multi-line messages (specifically because of `assert_eq`): https://github.com/rust-lang/rust/pull/111071 This is the change that does that for *all* panic messages.
2023-07-30Auto merge of #112843 - chenyukang:yukang-more-on-backtrace, r=workingjubileebors-1/+1
Print omitted frames count for short backtrace mode Fixes #111730
2023-07-30Rollup merge of #102198 - lukas-code:nonnull_as_ref, r=AmanieuMatthias Krüger-0/+30
`const`-stablilize `NonNull::as_ref` A bunch of pointer to reference methods have been made unstably const some time ago in #91823 under the feature gate `const_ptr_as_ref`. Out of these, `NonNull::as_ref` can be implemented as a `const fn` in stable rust today, so i hereby propose to const stabilize this function only. Tracking issue: #91822 ``@rustbot`` label +T-libs-api -T-libs
2023-07-29print omitted frames count for short backtrace modeyukang-1/+1
2023-07-29Change default panic handler message format.Mara Bos-1/+1
2023-07-25bless moreRalf Jung-7/+20
2023-07-25interpret: refactor projection code to work on a common trait, and use that ↵Ralf Jung-10/+29
for visitors
2023-07-24interpret: support projecting into Place::Local without force_allocationRalf Jung-1/+1
2023-07-16Add const-eval test for `#[target_feature(enable = ...)]` function callsEduardo Sánchez Muñoz-0/+26
2023-06-27Don't sort strings right after we just sorted by typesMichael Goulet-4/+4
2023-06-12Adjust UI tests for `unit_bindings`许杰友 Jieyou Xu (Joe)-10/+10
- Either explicitly annotate `let x: () = expr;` where `x` has unit type, or remove the unit binding to leave only `expr;` instead. - Fix disjoint-capture-in-same-closure test
2023-06-01Use translatable diagnostics in `rustc_const_eval`Deadbeef-31/+35
2023-05-31Remove const eval limit and implement an exponential backoff lint insteadOli Scherer-88/+177
2023-05-23add tests for const `NonNull::as_ref`Lukas Markeffsky-0/+30
2023-05-15Suppress "erroneous constant used" for constants tainted by errorsTomasz Miąsko-56/+0
When constant evaluation fails because its MIR is tainted by errors, suppress note indicating that erroneous constant was used, since those errors have to be fixed regardless of the constant being used or not.
2023-05-05Stabilize const_ptr_readbors-18/+17
2023-04-27bless testsThe 8472-4/+4
2023-04-21Ensure mir_drops_elaborated_and_const_checked when requiring codegen.Camille GILLOT-0/+2
2023-04-19Auto merge of #110061 - WaffleLapkin:duality_of_myself_and_this, r=cjgillotbors-0/+4
Add suggestion to use closure argument instead of a capture on borrowck error Fixes #109271 r? `@compiler-errors` This should probably be refined a bit, but opening a PR so that I don't forget anything.
2023-04-19Extend and use `hir::Node::body_id`Maybe Waffle-0/+4
2023-04-16fix library and rustdoc testsDeadbeef-38/+22
2023-04-15Only enable ConstProp at mir-opt-level >= 2.Camille GILLOT-8/+0
2023-04-03Perform match checking on THIR.Camille GILLOT-25/+5
2023-03-27Bless UI tests.Mara Bos-4/+4
2023-03-22Add `CastKind::Transmute` to MIRScott McMurray-7/+68
Updates `interpret`, `codegen_ssa`, and `codegen_cranelift` to consume the new cast instead of the intrinsic. Includes `CastTransmute` for custom MIR building, to be able to test the extra UB.
2023-03-21Detect uninhabited types early in const eval.Oli Scherer-27/+15
2023-03-16Don't allow new const panic through format flattening.Mara Bos-11/+21
panic!("a {}", "b") is still not allowed in const, even if the hir flattens to panic!("a b").
2023-03-11`MaybeUninit::assume_init_read` should have `noundef` load metadataScott McMurray-21/+3
I was looking into `array::IntoIter` optimization, and noticed that it wasn't annotating the loads with `noundef` for simple things like `array::IntoIter<i32, N>`. Turned out to be a more general problem as `MaybeUninit::assume_init_read` isn't marking the load as initialized (<https://rust.godbolt.org/z/Mxd8TPTnv>), which is unfortunate since that's basically its reason to exist. This PR lowers `ptr::read(p)` to `copy *p` in MIR, which fortuitiously also improves the IR we give to LLVM for things like `mem::replace`.
2023-03-05Use `nuw` when calculating slice lengths from `Range`sScott McMurray-0/+27
An `assume` would definitely not be worth it, but since the flag is almost free we might as well tell LLVM this, especially on `_unchecked` calls where there's no obvious way for it to deduce it. (Today neither safe nor unsafe indexing gets it: <https://rust.godbolt.org/z/G1jYT548s>)
2023-02-21Rollup merge of #108000 - y21:no-zero-init-for-uninhabited, r=jackh726Dylan DPC-16/+4
lint: don't suggest MaybeUninit::assume_init for uninhabited types Creating a zeroed uninhabited type such as `!` or an empty enum with `mem::zeroed()` (or transmuting `()` to `!`) currently triggers this lint: ```rs warning: the type `!` does not permit zero-initialization --> test.rs:5:23 | 5 | let _val: ! = mem::zeroed(); | ^^^^^^^^^^^^^ | | | this code causes undefined behavior when executed | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done | = note: the `!` type has no valid value ``` The `MaybeUninit` suggestion in the help message seems confusing/useless for uninhabited types, as such a type cannot be fully initialized in the first place (as the note implies). This PR limits this help message to inhabited types which can be initialized
2023-02-20basic dyn* support for MiriRalf Jung-6/+6
2023-02-18lint: don't suggest assume_init for uninhabited typesy21-16/+4
2023-02-15Fix unintentional UB in ui testsBen Kimock-1/+4
2023-02-07Tweak ICE messageEsteban Küber-3/+2
Modify main message to be more conversational and emit one fewer note.
2023-01-30Modify primary span label for E0308Esteban Küber-2/+2
The previous output was unintuitive to users.
2023-01-24Move const-eval/stable-metric ui testsBryan Garza-0/+204
2023-01-23Bless and update consts testsBryan Garza-8/+14
2023-01-11Move /src/test to /testsAlbert Larsan-0/+7807