Skip to content

Commit 9b6f8e5

Browse files
committed
Add a test for OOB ranges
1 parent d7f5d78 commit 9b6f8e5

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

src/test/ui/layout/valid_range_oob.rs

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// failure-status: 101
2+
// normalize-stderr-test "note: .*\n\n" -> ""
3+
// normalize-stderr-test "thread 'rustc' panicked.*\n" -> ""
4+
// rustc-env:RUST_BACKTRACE=0
5+
6+
#![feature(rustc_attrs)]
7+
8+
#[rustc_layout_scalar_valid_range_end(257)]
9+
struct Foo(i8);
10+
11+
// Need to do in a constant, as runtime codegen
12+
// does not compute the layout of `Foo` in check builds.
13+
const FOO: Foo = unsafe { Foo(1) };
14+
15+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
error: internal compiler error: unexpected panic
2+
3+
query stack during panic:
4+
#0 [layout_of] computing layout of `Foo`
5+
#1 [eval_to_allocation_raw] const-evaluating + checking `FOO`
6+
end of query stack

0 commit comments

Comments
 (0)