From 5f5e6b94d8bdcc0780a980cd2213b8b355a4b73a Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Mon, 11 Dec 2023 13:38:14 +0100 Subject: [PATCH] test that both size_of_val and align_of_val panic --- ...n.stderr => extern-types-size_of_val.align.run.stderr} | 0 tests/ui/extern/extern-types-size_of_val.rs | 8 ++++++-- tests/ui/extern/extern-types-size_of_val.size.run.stderr | 4 ++++ 3 files changed, 10 insertions(+), 2 deletions(-) rename tests/ui/extern/{extern-types-size_of_val.run.stderr => extern-types-size_of_val.align.run.stderr} (100%) create mode 100644 tests/ui/extern/extern-types-size_of_val.size.run.stderr diff --git a/tests/ui/extern/extern-types-size_of_val.run.stderr b/tests/ui/extern/extern-types-size_of_val.align.run.stderr similarity index 100% rename from tests/ui/extern/extern-types-size_of_val.run.stderr rename to tests/ui/extern/extern-types-size_of_val.align.run.stderr diff --git a/tests/ui/extern/extern-types-size_of_val.rs b/tests/ui/extern/extern-types-size_of_val.rs index c48db60d40adf..c783c79891adb 100644 --- a/tests/ui/extern/extern-types-size_of_val.rs +++ b/tests/ui/extern/extern-types-size_of_val.rs @@ -1,5 +1,6 @@ // run-fail // check-run-results +// revisions: size align // normalize-stderr-test "panicking\.rs:\d+:\d+:" -> "panicking.rs:" #![feature(extern_types)] @@ -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); + } } diff --git a/tests/ui/extern/extern-types-size_of_val.size.run.stderr b/tests/ui/extern/extern-types-size_of_val.size.run.stderr new file mode 100644 index 0000000000000..cf39c71a04b19 --- /dev/null +++ b/tests/ui/extern/extern-types-size_of_val.size.run.stderr @@ -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.