Skip to content

Commit 6f1daa6

Browse files
committed
Auto merge of #140053 - ChrisDenton:rollup-tt00skl, r=ChrisDenton
Rollup of 7 pull requests Successful merges: - #139042 (Do not remove trivial `SwitchInt` in analysis MIR) - #139533 (add next_index to Enumerate) - #139843 (Setup editor file associations for non-rs extensions) - #140000 (skip llvm-config in autodiff check builds, when its unavailable) - #140008 (Improve `clean_maybe_renamed_item` function code a bit) - #140024 (Remove early exits from JumpThreading.) - #140039 (Add option for stable backport poll) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 610263b + be30ed1 commit 6f1daa6

File tree

3 files changed

+30
-1
lines changed

3 files changed

+30
-1
lines changed

src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ pub const MIRI_DEFAULT_ARGS: &[&str] = &[
169169
"-Zalways-encode-mir",
170170
"-Zextra-const-ub-checks",
171171
"-Zmir-emit-retag",
172-
"-Zmir-keep-place-mention",
172+
"-Zmir-preserve-ub",
173173
"-Zmir-opt-level=0",
174174
"-Zmir-enable-passes=-CheckAlignment,-CheckNull",
175175
// Deduplicating diagnostics means we miss events when tracking what happens during an
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Ensure that we don't optimize out `SwitchInt` reads even if that terminator
2+
// branches to the same basic block on every target, since the operand may have
3+
// side-effects that affect analysis of the MIR.
4+
//
5+
// See <https://github.com/rust-lang/miri/issues/4237>.
6+
7+
use std::mem::MaybeUninit;
8+
9+
fn main() {
10+
let uninit: MaybeUninit<i32> = MaybeUninit::uninit();
11+
let bad_ref: &i32 = unsafe { uninit.assume_init_ref() };
12+
let &(0 | _) = bad_ref;
13+
//~^ ERROR: Undefined Behavior: using uninitialized data, but this operation requires initialized memory
14+
}
+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
error: Undefined Behavior: using uninitialized data, but this operation requires initialized memory
2+
--> tests/fail/read_from_trivial_switch.rs:LL:CC
3+
|
4+
LL | let &(0 | _) = bad_ref;
5+
| ^^^^^^^^ using uninitialized data, but this operation requires initialized memory
6+
|
7+
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
8+
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
9+
= note: BACKTRACE:
10+
= note: inside `main` at tests/fail/read_from_trivial_switch.rs:LL:CC
11+
12+
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
13+
14+
error: aborting due to 1 previous error
15+

0 commit comments

Comments
 (0)