From a47416beb5ed2569c3beb6d7eb64adf4a03bd982 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 --- tests/ui/extern/extern-types-field-offset.rs | 3 ++- tests/ui/extern/extern-types-field-offset.run.stderr | 2 +- ...derr => extern-types-size_of_val.align.run.stderr} | 2 +- tests/ui/extern/extern-types-size_of_val.rs | 11 ++++++++--- .../extern/extern-types-size_of_val.size.run.stderr | 4 ++++ 5 files changed, 16 insertions(+), 6 deletions(-) rename tests/ui/extern/{extern-types-size_of_val.run.stderr => extern-types-size_of_val.align.run.stderr} (73%) create mode 100644 tests/ui/extern/extern-types-size_of_val.size.run.stderr diff --git a/tests/ui/extern/extern-types-field-offset.rs b/tests/ui/extern/extern-types-field-offset.rs index f2682293dcf0c..9c364538025d1 100644 --- a/tests/ui/extern/extern-types-field-offset.rs +++ b/tests/ui/extern/extern-types-field-offset.rs @@ -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" { diff --git a/tests/ui/extern/extern-types-field-offset.run.stderr b/tests/ui/extern/extern-types-field-offset.run.stderr index d6ebf3e391dc4..1b04b860db5a6 100644 --- a/tests/ui/extern/extern-types-field-offset.run.stderr +++ b/tests/ui/extern/extern-types-field-offset.run.stderr @@ -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. 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 73% 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 index cf39c71a04b19..20c4d8785e846 100644 --- a/tests/ui/extern/extern-types-size_of_val.run.stderr +++ b/tests/ui/extern/extern-types-size_of_val.align.run.stderr @@ -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. diff --git a/tests/ui/extern/extern-types-size_of_val.rs b/tests/ui/extern/extern-types-size_of_val.rs index c48db60d40adf..4c4de873b7f0f 100644 --- a/tests/ui/extern/extern-types-size_of_val.rs +++ b/tests/ui/extern/extern-types-size_of_val.rs @@ -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); + } } 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..20c4d8785e846 --- /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:$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.