Add and update more tests

This commit is contained in:
Oliver Scherer 2019-06-11 16:17:26 +02:00
parent 13f35de19d
commit 104b108406
2 changed files with 28 additions and 1 deletions

View file

@ -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

View 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!(),
}
}