Add a test for OOB ranges

This commit is contained in:
Oli Scherer 2022-11-07 10:26:23 +00:00
parent d7f5d784d7
commit 9b6f8e500c
2 changed files with 21 additions and 0 deletions

View File

@ -0,0 +1,15 @@
// failure-status: 101
// normalize-stderr-test "note: .*\n\n" -> ""
// normalize-stderr-test "thread 'rustc' panicked.*\n" -> ""
// rustc-env:RUST_BACKTRACE=0
#![feature(rustc_attrs)]
#[rustc_layout_scalar_valid_range_end(257)]
struct Foo(i8);
// Need to do in a constant, as runtime codegen
// does not compute the layout of `Foo` in check builds.
const FOO: Foo = unsafe { Foo(1) };
fn main() {}

View File

@ -0,0 +1,6 @@
error: internal compiler error: unexpected panic
query stack during panic:
#0 [layout_of] computing layout of `Foo`
#1 [eval_to_allocation_raw] const-evaluating + checking `FOO`
end of query stack