mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-23 15:23:46 +00:00
test that both size_of_val and align_of_val panic
This commit is contained in:
parent
df227f78c6
commit
a47416beb5
3
tests/ui/extern/extern-types-field-offset.rs
vendored
3
tests/ui/extern/extern-types-field-offset.rs
vendored
@ -1,6 +1,7 @@
|
||||
// run-fail
|
||||
// check-run-results
|
||||
// normalize-stderr-test "panicking\.rs:\d+:\d+:" -> "panicking.rs:"
|
||||
// exec-env:RUST_BACKTRACE=0
|
||||
// normalize-stderr-test: "(core/src/panicking\.rs):[0-9]+:[0-9]+" -> "$1:$$LINE:$$COL"
|
||||
#![feature(extern_types)]
|
||||
|
||||
extern "C" {
|
||||
|
@ -1,4 +1,4 @@
|
||||
thread 'main' panicked at library/core/src/panicking.rs:
|
||||
thread 'main' panicked at library/core/src/panicking.rs:$LINE:$COL:
|
||||
attempted to compute the size or alignment of extern type `Opaque`
|
||||
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
|
||||
thread caused non-unwinding panic. aborting.
|
||||
|
@ -1,4 +1,4 @@
|
||||
thread 'main' panicked at library/core/src/panicking.rs:
|
||||
thread 'main' panicked at library/core/src/panicking.rs:$LINE:$COL:
|
||||
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.
|
11
tests/ui/extern/extern-types-size_of_val.rs
vendored
11
tests/ui/extern/extern-types-size_of_val.rs
vendored
@ -1,6 +1,8 @@
|
||||
// run-fail
|
||||
// check-run-results
|
||||
// normalize-stderr-test "panicking\.rs:\d+:\d+:" -> "panicking.rs:"
|
||||
// exec-env:RUST_BACKTRACE=0
|
||||
// normalize-stderr-test: "(core/src/panicking\.rs):[0-9]+:[0-9]+" -> "$1:$$LINE:$$COL"
|
||||
// revisions: size align
|
||||
#![feature(extern_types)]
|
||||
|
||||
use std::mem::{align_of_val, size_of_val};
|
||||
@ -13,6 +15,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
tests/ui/extern/extern-types-size_of_val.size.run.stderr
vendored
Normal file
4
tests/ui/extern/extern-types-size_of_val.size.run.stderr
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
thread 'main' panicked at library/core/src/panicking.rs:$LINE:$COL:
|
||||
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.
|
Loading…
Reference in New Issue
Block a user