Skip to content

Commit

Permalink
test that both size_of_val and align_of_val panic
Browse files Browse the repository at this point in the history
  • Loading branch information
RalfJung committed Dec 11, 2023
1 parent f4d8faa commit 5f5e6b9
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
8 changes: 6 additions & 2 deletions tests/ui/extern/extern-types-size_of_val.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// run-fail
// check-run-results
// revisions: size align
// normalize-stderr-test "panicking\.rs:\d+:\d+:" -> "panicking.rs:"
#![feature(extern_types)]

Expand All @@ -13,6 +14,9 @@ fn main() {
let x: &A = unsafe { &*(1usize as *const A) };

// These don't have a dynamic size, so this should panic.
assert_eq!(size_of_val(x), 0);
assert_eq!(align_of_val(x), 1);
if cfg!(size) {
assert_eq!(size_of_val(x), 0);
} else {
assert_eq!(align_of_val(x), 1);
}
}
4 changes: 4 additions & 0 deletions tests/ui/extern/extern-types-size_of_val.size.run.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
thread 'main' panicked at library/core/src/panicking.rs:
attempted to compute the size or alignment of extern type `A`
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread caused non-unwinding panic. aborting.

0 comments on commit 5f5e6b9

Please sign in to comment.