Add and update more tests
This commit is contained in:
parent
13f35de19d
commit
104b108406
@ -7,7 +7,7 @@ LL | *MUH.x.get() = 99;
|
||||
thread 'rustc' panicked at 'assertion failed: `(left != right)`
|
||||
left: `Const`,
|
||||
right: `Const`: UnsafeCells are not allowed behind references in constants. This should have been prevented statically by const qualification. If this were allowed one would be able to change a constant at one use site and other use sites may arbitrarily decide to change, too.', src/librustc_mir/interpret/intern.rs:126:17
|
||||
note: Run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
|
||||
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
|
||||
|
||||
error: internal compiler error: unexpected panic
|
||||
|
||||
|
27
src/test/ui/consts/packed_pattern2.rs
Normal file
27
src/test/ui/consts/packed_pattern2.rs
Normal file
@ -0,0 +1,27 @@
|
||||
// run-pass
|
||||
|
||||
#[derive(PartialEq, Eq, Copy, Clone)]
|
||||
#[repr(packed)]
|
||||
struct Foo {
|
||||
field: (u8, u16),
|
||||
}
|
||||
|
||||
#[derive(PartialEq, Eq, Copy, Clone)]
|
||||
#[repr(align(2))]
|
||||
struct Bar {
|
||||
a: Foo,
|
||||
}
|
||||
|
||||
const FOO: Bar = Bar {
|
||||
a: Foo {
|
||||
field: (5, 6),
|
||||
}
|
||||
};
|
||||
|
||||
fn main() {
|
||||
match FOO {
|
||||
Bar { a: Foo { field: (5, 6) } } => {},
|
||||
FOO => unreachable!(),
|
||||
_ => unreachable!(),
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user