Skip to content

Commit 703738a

Browse files
committed
Auto merge of #133818 - matthiaskrgr:rollup-iav1wq7, r=matthiaskrgr
Rollup of 7 pull requests Successful merges: - #132937 (a release operation synchronizes with an acquire operation) - #133681 (improve TagEncoding::Niche docs, sanity check, and UB checks) - #133726 (Add `core::arch::breakpoint` and test) - #133768 (Remove `generic_associated_types_extended` feature gate) - #133811 ([AIX] change AIX default codemodel=large) - #133812 (Update wasm-component-ld to 0.5.11) - #133813 (compiletest: explain that UI tests are expected not to compile by default) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 36614df + 0718ee2 commit 703738a

4 files changed

+45
-5
lines changed

tests/fail/breakpoint.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
#![feature(core_intrinsics)]
22

33
fn main() {
4-
unsafe {
5-
core::intrinsics::breakpoint() //~ ERROR: trace/breakpoint trap
6-
};
4+
core::intrinsics::breakpoint(); //~ ERROR: trace/breakpoint trap
75
}

tests/fail/breakpoint.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
error: abnormal termination: trace/breakpoint trap
22
--> tests/fail/breakpoint.rs:LL:CC
33
|
4-
LL | core::intrinsics::breakpoint()
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ trace/breakpoint trap
4+
LL | core::intrinsics::breakpoint();
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ trace/breakpoint trap
66
|
77
= note: BACKTRACE:
88
= note: inside `main` at tests/fail/breakpoint.rs:LL:CC
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Validity makes this fail at the wrong place.
2+
//@compile-flags: -Zmiri-disable-validation
3+
use std::mem;
4+
5+
// This enum has untagged variant idx 1, with niche_variants being 0..=2
6+
// and niche_start being 2.
7+
// That means the untagged variants is in the niche variant range!
8+
// However, using the corresponding value (2+1 = 3) is not a valid encoding of this variant.
9+
#[derive(Copy, Clone, PartialEq)]
10+
enum Foo {
11+
Var1,
12+
Var2(bool),
13+
Var3,
14+
}
15+
16+
fn main() {
17+
unsafe {
18+
assert!(Foo::Var2(false) == mem::transmute(0u8));
19+
assert!(Foo::Var2(true) == mem::transmute(1u8));
20+
assert!(Foo::Var1 == mem::transmute(2u8));
21+
assert!(Foo::Var3 == mem::transmute(4u8));
22+
23+
let invalid: Foo = mem::transmute(3u8);
24+
assert!(matches!(invalid, Foo::Var2(_)));
25+
//~^ ERROR: invalid tag
26+
}
27+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
error: Undefined Behavior: enum value has invalid tag: 0x03
2+
--> tests/fail/enum-untagged-variant-invalid-encoding.rs:LL:CC
3+
|
4+
LL | assert!(matches!(invalid, Foo::Var2(_)));
5+
| ^^^^^^^ enum value has invalid tag: 0x03
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/enum-untagged-variant-invalid-encoding.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)