diff options
Diffstat (limited to 'tests/ui/consts')
47 files changed, 363 insertions, 142 deletions
diff --git a/tests/ui/consts/assert-type-intrinsics.stderr b/tests/ui/consts/assert-type-intrinsics.stderr index 70aec91e2..3c03b03de 100644 --- a/tests/ui/consts/assert-type-intrinsics.stderr +++ b/tests/ui/consts/assert-type-intrinsics.stderr @@ -2,19 +2,19 @@ error[E0080]: evaluation of constant value failed --> $DIR/assert-type-intrinsics.rs:12:9 | LL | MaybeUninit::<!>::uninit().assume_init(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ aborted execution: attempted to instantiate uninhabited type `!` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'aborted execution: attempted to instantiate uninhabited type `!`', $DIR/assert-type-intrinsics.rs:12:36 error[E0080]: evaluation of constant value failed --> $DIR/assert-type-intrinsics.rs:16:9 | LL | intrinsics::assert_mem_uninitialized_valid::<&'static i32>(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ aborted execution: attempted to leave type `&i32` uninitialized, which is invalid + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'aborted execution: attempted to leave type `&i32` uninitialized, which is invalid', $DIR/assert-type-intrinsics.rs:16:9 error[E0080]: evaluation of constant value failed --> $DIR/assert-type-intrinsics.rs:20:9 | LL | intrinsics::assert_zero_valid::<&'static i32>(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ aborted execution: attempted to zero-initialize type `&i32`, which is invalid + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'aborted execution: attempted to zero-initialize type `&i32`, which is invalid', $DIR/assert-type-intrinsics.rs:20:9 error: aborting due to 3 previous errors diff --git a/tests/ui/consts/assoc-const-elided-lifetime.rs b/tests/ui/consts/assoc-const-elided-lifetime.rs new file mode 100644 index 000000000..10cd33a8f --- /dev/null +++ b/tests/ui/consts/assoc-const-elided-lifetime.rs @@ -0,0 +1,19 @@ +#![deny(elided_lifetimes_in_associated_constant)] + +use std::marker::PhantomData; + +struct Foo<'a> { + x: PhantomData<&'a ()>, +} + +impl<'a> Foo<'a> { + const FOO: Foo<'_> = Foo { x: PhantomData::<&()> }; + //~^ ERROR `'_` cannot be used here + //~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + + const BAR: &() = &(); + //~^ ERROR `&` without an explicit lifetime name cannot be used here + //~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! +} + +fn main() {} diff --git a/tests/ui/consts/assoc-const-elided-lifetime.stderr b/tests/ui/consts/assoc-const-elided-lifetime.stderr new file mode 100644 index 000000000..a1eeaff4b --- /dev/null +++ b/tests/ui/consts/assoc-const-elided-lifetime.stderr @@ -0,0 +1,33 @@ +error: `'_` cannot be used here + --> $DIR/assoc-const-elided-lifetime.rs:10:20 + | +LL | const FOO: Foo<'_> = Foo { x: PhantomData::<&()> }; + | ^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #115010 <https://github.com/rust-lang/rust/issues/115010> +note: the lint level is defined here + --> $DIR/assoc-const-elided-lifetime.rs:1:9 + | +LL | #![deny(elided_lifetimes_in_associated_constant)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +help: use the `'static` lifetime + | +LL | const FOO: Foo<'static> = Foo { x: PhantomData::<&()> }; + | ~~~~~~~ + +error: `&` without an explicit lifetime name cannot be used here + --> $DIR/assoc-const-elided-lifetime.rs:14:16 + | +LL | const BAR: &() = &(); + | ^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #115010 <https://github.com/rust-lang/rust/issues/115010> +help: use the `'static` lifetime + | +LL | const BAR: &'static () = &(); + | +++++++ + +error: aborting due to 2 previous errors + diff --git a/tests/ui/consts/const-err-late.stderr b/tests/ui/consts/const-err-late.stderr index 149d3b523..85bc56bae 100644 --- a/tests/ui/consts/const-err-late.stderr +++ b/tests/ui/consts/const-err-late.stderr @@ -4,7 +4,7 @@ error[E0080]: evaluation of `S::<i32>::FOO` failed LL | const FOO: u8 = [5u8][1]; | ^^^^^^^^ index out of bounds: the length is 1 but the index is 1 -note: erroneous constant used +note: erroneous constant encountered --> $DIR/const-err-late.rs:19:16 | LL | black_box((S::<i32>::FOO, S::<u32>::FOO)); @@ -16,13 +16,13 @@ error[E0080]: evaluation of `S::<u32>::FOO` failed LL | const FOO: u8 = [5u8][1]; | ^^^^^^^^ index out of bounds: the length is 1 but the index is 1 -note: erroneous constant used +note: erroneous constant encountered --> $DIR/const-err-late.rs:19:31 | LL | black_box((S::<i32>::FOO, S::<u32>::FOO)); | ^^^^^^^^^^^^^ -note: erroneous constant used +note: erroneous constant encountered --> $DIR/const-err-late.rs:19:16 | LL | black_box((S::<i32>::FOO, S::<u32>::FOO)); diff --git a/tests/ui/consts/const-err-multi.stderr b/tests/ui/consts/const-err-multi.stderr index 28af8e5eb..1ad504b3a 100644 --- a/tests/ui/consts/const-err-multi.stderr +++ b/tests/ui/consts/const-err-multi.stderr @@ -4,19 +4,19 @@ error[E0080]: evaluation of constant value failed LL | pub const A: i8 = -i8::MIN; | ^^^^^^^^ attempt to negate `i8::MIN`, which would overflow -note: erroneous constant used +note: erroneous constant encountered --> $DIR/const-err-multi.rs:3:19 | LL | pub const B: i8 = A; | ^ -note: erroneous constant used +note: erroneous constant encountered --> $DIR/const-err-multi.rs:5:19 | LL | pub const C: u8 = A as u8; | ^ -note: erroneous constant used +note: erroneous constant encountered --> $DIR/const-err-multi.rs:7:24 | LL | pub const D: i8 = 50 - A; diff --git a/tests/ui/consts/const-eval/const_panic-normalize-tabs-115498.rs b/tests/ui/consts/const-eval/const_panic-normalize-tabs-115498.rs new file mode 100644 index 000000000..0bf2f0e66 --- /dev/null +++ b/tests/ui/consts/const-eval/const_panic-normalize-tabs-115498.rs @@ -0,0 +1,5 @@ +#![crate_type = "lib"] + +struct Bug([u8; panic!{"\t"}]); +//~^ ERROR evaluation of constant value failed +//~| NOTE: in this expansion of panic! diff --git a/tests/ui/consts/const-eval/const_panic-normalize-tabs-115498.stderr b/tests/ui/consts/const-eval/const_panic-normalize-tabs-115498.stderr new file mode 100644 index 000000000..82c63dd17 --- /dev/null +++ b/tests/ui/consts/const-eval/const_panic-normalize-tabs-115498.stderr @@ -0,0 +1,11 @@ +error[E0080]: evaluation of constant value failed + --> $DIR/const_panic-normalize-tabs-115498.rs:3:17 + | +LL | struct Bug([u8; panic!{"\t"}]); + | ^^^^^^^^^^^^ the evaluated program panicked at ' ', $DIR/const_panic-normalize-tabs-115498.rs:3:17 + | + = note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/consts/const-eval/erroneous-const.stderr b/tests/ui/consts/const-eval/erroneous-const.stderr index 770f95062..0e31520fd 100644 --- a/tests/ui/consts/const-eval/erroneous-const.stderr +++ b/tests/ui/consts/const-eval/erroneous-const.stderr @@ -4,7 +4,7 @@ error[E0080]: evaluation of `PrintName::<i32>::VOID` failed LL | const VOID: () = [()][2]; | ^^^^^^^ index out of bounds: the length is 1 but the index is 2 -note: erroneous constant used +note: erroneous constant encountered --> $DIR/erroneous-const.rs:13:13 | LL | PrintName::<T>::VOID; diff --git a/tests/ui/consts/const-eval/erroneous-const2.stderr b/tests/ui/consts/const-eval/erroneous-const2.stderr index 082c28765..4ca44694c 100644 --- a/tests/ui/consts/const-eval/erroneous-const2.stderr +++ b/tests/ui/consts/const-eval/erroneous-const2.stderr @@ -4,7 +4,7 @@ error[E0080]: evaluation of `PrintName::<i32>::VOID` failed LL | const VOID: () = [()][2]; | ^^^^^^^ index out of bounds: the length is 1 but the index is 2 -note: erroneous constant used +note: erroneous constant encountered --> $DIR/erroneous-const2.rs:13:9 | LL | PrintName::<i32>::VOID; diff --git a/tests/ui/consts/const-eval/issue-44578.stderr b/tests/ui/consts/const-eval/issue-44578.stderr index f3952809e..c7aaee942 100644 --- a/tests/ui/consts/const-eval/issue-44578.stderr +++ b/tests/ui/consts/const-eval/issue-44578.stderr @@ -4,13 +4,13 @@ error[E0080]: evaluation of `<Bar<u16, u8> as Foo>::AMT` failed LL | const AMT: usize = [A::AMT][(A::AMT > B::AMT) as usize]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ index out of bounds: the length is 1 but the index is 1 -note: erroneous constant used +note: erroneous constant encountered --> $DIR/issue-44578.rs:25:20 | LL | println!("{}", <Bar<u16, u8> as Foo>::AMT); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ -note: erroneous constant used +note: erroneous constant encountered --> $DIR/issue-44578.rs:25:20 | LL | println!("{}", <Bar<u16, u8> as Foo>::AMT); @@ -18,7 +18,7 @@ LL | println!("{}", <Bar<u16, u8> as Foo>::AMT); | = note: this note originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) -note: erroneous constant used +note: erroneous constant encountered --> $DIR/issue-44578.rs:25:20 | LL | println!("{}", <Bar<u16, u8> as Foo>::AMT); diff --git a/tests/ui/consts/const-eval/issue-50814-2.stderr b/tests/ui/consts/const-eval/issue-50814-2.stderr index 956f7aec9..450fb0023 100644 --- a/tests/ui/consts/const-eval/issue-50814-2.stderr +++ b/tests/ui/consts/const-eval/issue-50814-2.stderr @@ -4,7 +4,7 @@ error[E0080]: evaluation of `<A<()> as Foo<()>>::BAR` failed LL | const BAR: usize = [5, 6, 7][T::BOO]; | ^^^^^^^^^^^^^^^^^ index out of bounds: the length is 3 but the index is 42 -note: erroneous constant used +note: erroneous constant encountered --> $DIR/issue-50814-2.rs:18:6 | LL | &<A<T> as Foo<T>>::BAR diff --git a/tests/ui/consts/const-eval/issue-50814.stderr b/tests/ui/consts/const-eval/issue-50814.stderr index 05b6271f4..48a20d0bb 100644 --- a/tests/ui/consts/const-eval/issue-50814.stderr +++ b/tests/ui/consts/const-eval/issue-50814.stderr @@ -4,7 +4,7 @@ error[E0080]: evaluation of `<Sum<U8, U8> as Unsigned>::MAX` failed LL | const MAX: u8 = A::MAX + B::MAX; | ^^^^^^^^^^^^^^^ attempt to compute `u8::MAX + u8::MAX`, which would overflow -note: erroneous constant used +note: erroneous constant encountered --> $DIR/issue-50814.rs:20:6 | LL | &Sum::<U8, U8>::MAX diff --git a/tests/ui/consts/const-eval/panic-assoc-never-type.rs b/tests/ui/consts/const-eval/panic-assoc-never-type.rs index 1abe708d1..88ce5b0d8 100644 --- a/tests/ui/consts/const-eval/panic-assoc-never-type.rs +++ b/tests/ui/consts/const-eval/panic-assoc-never-type.rs @@ -11,5 +11,5 @@ impl PrintName { } fn main() { - let _ = PrintName::VOID; //~ erroneous constant used + let _ = PrintName::VOID; //~ erroneous constant encountered } diff --git a/tests/ui/consts/const-eval/panic-assoc-never-type.stderr b/tests/ui/consts/const-eval/panic-assoc-never-type.stderr index 7c36a3a42..4706497db 100644 --- a/tests/ui/consts/const-eval/panic-assoc-never-type.stderr +++ b/tests/ui/consts/const-eval/panic-assoc-never-type.stderr @@ -6,13 +6,13 @@ LL | const VOID: ! = panic!(); | = note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) -note: erroneous constant used +note: erroneous constant encountered --> $DIR/panic-assoc-never-type.rs:14:13 | LL | let _ = PrintName::VOID; | ^^^^^^^^^^^^^^^ -note: erroneous constant used +note: erroneous constant encountered --> $DIR/panic-assoc-never-type.rs:14:13 | LL | let _ = PrintName::VOID; diff --git a/tests/ui/consts/const-eval/raw-bytes.32bit.stderr b/tests/ui/consts/const-eval/raw-bytes.32bit.stderr index e087a0ebe..042e7eeb3 100644 --- a/tests/ui/consts/const-eval/raw-bytes.32bit.stderr +++ b/tests/ui/consts/const-eval/raw-bytes.32bit.stderr @@ -341,7 +341,7 @@ LL | const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }]; ╾ALLOC_ID╼ │ ╾──╼ } -note: erroneous constant used +note: erroneous constant encountered --> $DIR/raw-bytes.rs:160:40 | LL | const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }]; @@ -358,7 +358,7 @@ LL | const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3 ╾ALLOC_ID╼ │ ╾──╼ } -note: erroneous constant used +note: erroneous constant encountered --> $DIR/raw-bytes.rs:166:42 | LL | const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3u8) }, [false]); @@ -375,7 +375,7 @@ LL | const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::tran ╾ALLOC_ID╼ │ ╾──╼ } -note: erroneous constant used +note: erroneous constant encountered --> $DIR/raw-bytes.rs:170:42 | LL | const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::transmute(3u8) }]); diff --git a/tests/ui/consts/const-eval/raw-bytes.64bit.stderr b/tests/ui/consts/const-eval/raw-bytes.64bit.stderr index 4c655161f..8426a9505 100644 --- a/tests/ui/consts/const-eval/raw-bytes.64bit.stderr +++ b/tests/ui/consts/const-eval/raw-bytes.64bit.stderr @@ -341,7 +341,7 @@ LL | const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }]; ╾ALLOC_ID╼ │ ╾──────╼ } -note: erroneous constant used +note: erroneous constant encountered --> $DIR/raw-bytes.rs:160:40 | LL | const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }]; @@ -358,7 +358,7 @@ LL | const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3 ╾ALLOC_ID╼ │ ╾──────╼ } -note: erroneous constant used +note: erroneous constant encountered --> $DIR/raw-bytes.rs:166:42 | LL | const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3u8) }, [false]); @@ -375,7 +375,7 @@ LL | const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::tran ╾ALLOC_ID╼ │ ╾──────╼ } -note: erroneous constant used +note: erroneous constant encountered --> $DIR/raw-bytes.rs:170:42 | LL | const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::transmute(3u8) }]); diff --git a/tests/ui/consts/const-eval/ub-int-array.64bit.stderr b/tests/ui/consts/const-eval/ub-int-array.64bit.stderr deleted file mode 100644 index b3df41304..000000000 --- a/tests/ui/consts/const-eval/ub-int-array.64bit.stderr +++ /dev/null @@ -1,36 +0,0 @@ -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-int-array.rs:19:1 - | -LL | const UNINIT_INT_0: [u32; 3] = unsafe { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at [0]: encountered uninitialized memory, but expected an integer - | - = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. - = note: the raw bytes of the constant (size: 12, align: 4) { - __ __ __ __ 01 00 00 00 02 00 00 00 │ ░░░░........ - } - -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-int-array.rs:24:1 - | -LL | const UNINIT_INT_1: [u32; 3] = unsafe { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at [1]: encountered uninitialized memory, but expected an integer - | - = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. - = note: the raw bytes of the constant (size: 12, align: 4) { - 00 00 00 00 01 __ 01 01 02 02 __ 02 │ .....░....░. - } - -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-int-array.rs:42:1 - | -LL | const UNINIT_INT_2: [u32; 3] = unsafe { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at [2]: encountered uninitialized memory, but expected an integer - | - = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. - = note: the raw bytes of the constant (size: 12, align: 4) { - 00 00 00 00 01 01 01 01 02 02 02 __ │ ...........░ - } - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/consts/const-eval/ub-int-array.rs b/tests/ui/consts/const-eval/ub-int-array.rs index adcf376b9..cde0749dc 100644 --- a/tests/ui/consts/const-eval/ub-int-array.rs +++ b/tests/ui/consts/const-eval/ub-int-array.rs @@ -1,4 +1,3 @@ -// stderr-per-bitwidth //! Test the "array of int" fast path in validity checking, and in particular whether it //! points at the right array element. @@ -19,7 +18,12 @@ impl<T: Copy> MaybeUninit<T> { const UNINIT_INT_0: [u32; 3] = unsafe { //~^ ERROR it is undefined behavior to use this value //~| invalid value at [0] - mem::transmute([MaybeUninit { uninit: () }, MaybeUninit::new(1), MaybeUninit::new(2)]) + mem::transmute([ + MaybeUninit { uninit: () }, + // Constants chosen to achieve endianness-independent hex dump. + MaybeUninit::new(0x11111111), + MaybeUninit::new(0x22222222), + ]) }; const UNINIT_INT_1: [u32; 3] = unsafe { //~^ ERROR it is undefined behavior to use this value diff --git a/tests/ui/consts/const-eval/ub-int-array.32bit.stderr b/tests/ui/consts/const-eval/ub-int-array.stderr index b3df41304..c8efd7e1b 100644 --- a/tests/ui/consts/const-eval/ub-int-array.32bit.stderr +++ b/tests/ui/consts/const-eval/ub-int-array.stderr @@ -1,16 +1,16 @@ error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-int-array.rs:19:1 + --> $DIR/ub-int-array.rs:18:1 | LL | const UNINIT_INT_0: [u32; 3] = unsafe { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at [0]: encountered uninitialized memory, but expected an integer | = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. = note: the raw bytes of the constant (size: 12, align: 4) { - __ __ __ __ 01 00 00 00 02 00 00 00 │ ░░░░........ + __ __ __ __ 11 11 11 11 22 22 22 22 │ ░░░░...."""" } error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-int-array.rs:24:1 + --> $DIR/ub-int-array.rs:28:1 | LL | const UNINIT_INT_1: [u32; 3] = unsafe { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at [1]: encountered uninitialized memory, but expected an integer @@ -21,7 +21,7 @@ LL | const UNINIT_INT_1: [u32; 3] = unsafe { } error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-int-array.rs:42:1 + --> $DIR/ub-int-array.rs:46:1 | LL | const UNINIT_INT_2: [u32; 3] = unsafe { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at [2]: encountered uninitialized memory, but expected an integer diff --git a/tests/ui/consts/const-eval/ub-ref-ptr.stderr b/tests/ui/consts/const-eval/ub-ref-ptr.stderr index 0ee1e6087..6d5c36cea 100644 --- a/tests/ui/consts/const-eval/ub-ref-ptr.stderr +++ b/tests/ui/consts/const-eval/ub-ref-ptr.stderr @@ -60,7 +60,7 @@ LL | const REF_AS_USIZE_SLICE: &[usize] = &[unsafe { mem::transmute(&0) }]; = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -note: erroneous constant used +note: erroneous constant encountered --> $DIR/ub-ref-ptr.rs:36:38 | LL | const REF_AS_USIZE_SLICE: &[usize] = &[unsafe { mem::transmute(&0) }]; @@ -75,7 +75,7 @@ LL | const REF_AS_USIZE_BOX_SLICE: Box<[usize]> = unsafe { mem::transmute::<&[us = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported -note: erroneous constant used +note: erroneous constant encountered --> $DIR/ub-ref-ptr.rs:39:85 | LL | const REF_AS_USIZE_BOX_SLICE: Box<[usize]> = unsafe { mem::transmute::<&[usize], _>(&[mem::transmute(&0)]) }; diff --git a/tests/ui/consts/const-eval/ub-uninhabit.rs b/tests/ui/consts/const-eval/ub-uninhabit.rs index 10edae437..01600f545 100644 --- a/tests/ui/consts/const-eval/ub-uninhabit.rs +++ b/tests/ui/consts/const-eval/ub-uninhabit.rs @@ -1,7 +1,10 @@ // Strip out raw byte dumps to make comparison platform-independent: // normalize-stderr-test "(the raw bytes of the constant) \(size: [0-9]*, align: [0-9]*\)" -> "$1 (size: $$SIZE, align: $$ALIGN)" // normalize-stderr-test "([0-9a-f][0-9a-f] |╾─*a(lloc)?[0-9]+(\+[a-z0-9]+)?─*╼ )+ *│.*" -> "HEX_DUMP" +#![feature(core_intrinsics)] +#![feature(never_type)] +use std::intrinsics; use std::mem; #[derive(Copy, Clone)] @@ -15,11 +18,24 @@ union MaybeUninit<T: Copy> { const BAD_BAD_BAD: Bar = unsafe { MaybeUninit { uninit: () }.init }; //~^ ERROR evaluation of constant value failed +//~| constructing invalid value const BAD_BAD_REF: &Bar = unsafe { mem::transmute(1usize) }; //~^ ERROR it is undefined behavior to use this value +//~| constructing invalid value const BAD_BAD_ARRAY: [Bar; 1] = unsafe { MaybeUninit { uninit: () }.init }; //~^ ERROR evaluation of constant value failed +//~| constructing invalid value + + +const READ_NEVER: () = unsafe { + let mem = [0u32; 8]; + let ptr = mem.as_ptr().cast::<!>(); + let _val = intrinsics::read_via_copy(ptr); + //~^ ERROR evaluation of constant value failed + //~| constructing invalid value +}; + fn main() {} diff --git a/tests/ui/consts/const-eval/ub-uninhabit.stderr b/tests/ui/consts/const-eval/ub-uninhabit.stderr index f1ad0f04d..d26f4e036 100644 --- a/tests/ui/consts/const-eval/ub-uninhabit.stderr +++ b/tests/ui/consts/const-eval/ub-uninhabit.stderr @@ -1,11 +1,11 @@ error[E0080]: evaluation of constant value failed - --> $DIR/ub-uninhabit.rs:16:35 + --> $DIR/ub-uninhabit.rs:19:35 | LL | const BAD_BAD_BAD: Bar = unsafe { MaybeUninit { uninit: () }.init }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a value of uninhabited type `Bar` error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-uninhabit.rs:19:1 + --> $DIR/ub-uninhabit.rs:23:1 | LL | const BAD_BAD_REF: &Bar = unsafe { mem::transmute(1usize) }; | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a reference pointing to uninhabited type Bar @@ -16,11 +16,17 @@ LL | const BAD_BAD_REF: &Bar = unsafe { mem::transmute(1usize) }; } error[E0080]: evaluation of constant value failed - --> $DIR/ub-uninhabit.rs:22:42 + --> $DIR/ub-uninhabit.rs:27:42 | LL | const BAD_BAD_ARRAY: [Bar; 1] = unsafe { MaybeUninit { uninit: () }.init }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at [0]: encountered a value of uninhabited type `Bar` -error: aborting due to 3 previous errors +error[E0080]: evaluation of constant value failed + --> $DIR/ub-uninhabit.rs:35:16 + | +LL | let _val = intrinsics::read_via_copy(ptr); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a value of the never type `!` + +error: aborting due to 4 previous errors For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/consts/const-eval/ub-wide-ptr.stderr b/tests/ui/consts/const-eval/ub-wide-ptr.stderr index 02bbbf504..d8add67fa 100644 --- a/tests/ui/consts/const-eval/ub-wide-ptr.stderr +++ b/tests/ui/consts/const-eval/ub-wide-ptr.stderr @@ -139,7 +139,7 @@ LL | const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }]; HEX_DUMP } -note: erroneous constant used +note: erroneous constant encountered --> $DIR/ub-wide-ptr.rs:85:40 | LL | const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }]; @@ -156,7 +156,7 @@ LL | const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3 HEX_DUMP } -note: erroneous constant used +note: erroneous constant encountered --> $DIR/ub-wide-ptr.rs:92:42 | LL | const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3u8) }, [false]); @@ -173,7 +173,7 @@ LL | const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::tran HEX_DUMP } -note: erroneous constant used +note: erroneous constant encountered --> $DIR/ub-wide-ptr.rs:96:42 | LL | const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::transmute(3u8) }]); diff --git a/tests/ui/consts/const-eval/union-const-eval-field.stderr b/tests/ui/consts/const-eval/union-const-eval-field.stderr index 9899c56c0..ce260300f 100644 --- a/tests/ui/consts/const-eval/union-const-eval-field.stderr +++ b/tests/ui/consts/const-eval/union-const-eval-field.stderr @@ -4,13 +4,13 @@ error[E0080]: evaluation of constant value failed LL | const FIELD3: Field3 = unsafe { UNION.field3 }; | ^^^^^^^^^^^^ using uninitialized data, but this operation requires initialized memory -note: erroneous constant used +note: erroneous constant encountered --> $DIR/union-const-eval-field.rs:31:5 | LL | FIELD3 | ^^^^^^ -note: erroneous constant used +note: erroneous constant encountered --> $DIR/union-const-eval-field.rs:31:5 | LL | FIELD3 diff --git a/tests/ui/consts/const-float-bits-reject-conv.stderr b/tests/ui/consts/const-float-bits-reject-conv.stderr index 7ad022520..1511dab12 100644 --- a/tests/ui/consts/const-float-bits-reject-conv.stderr +++ b/tests/ui/consts/const-float-bits-reject-conv.stderr @@ -30,25 +30,25 @@ LL | const MASKED_NAN2: u32 = f32::NAN.to_bits() ^ 0x0055_5555; | ^^^^^^^^^^^^^^^^^^ = note: this error originates in the macro `$crate::panic::panic_2021` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) -note: erroneous constant used +note: erroneous constant encountered --> $DIR/const-float-bits-reject-conv.rs:35:34 | LL | const_assert!(f32::from_bits(MASKED_NAN1).is_nan()); | ^^^^^^^^^^^ -note: erroneous constant used +note: erroneous constant encountered --> $DIR/const-float-bits-reject-conv.rs:36:34 | LL | const_assert!(f32::from_bits(MASKED_NAN1).is_nan()); | ^^^^^^^^^^^ -note: erroneous constant used +note: erroneous constant encountered --> $DIR/const-float-bits-reject-conv.rs:42:34 | LL | const_assert!(f32::from_bits(MASKED_NAN1).to_bits(), MASKED_NAN1); | ^^^^^^^^^^^ -note: erroneous constant used +note: erroneous constant encountered --> $DIR/const-float-bits-reject-conv.rs:43:34 | LL | const_assert!(f32::from_bits(MASKED_NAN2).to_bits(), MASKED_NAN2); @@ -86,25 +86,25 @@ LL | const MASKED_NAN2: u64 = f64::NAN.to_bits() ^ 0x0005_5555_5555_5555; | ^^^^^^^^^^^^^^^^^^ = note: this error originates in the macro `$crate::panic::panic_2021` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) -note: erroneous constant used +note: erroneous constant encountered --> $DIR/const-float-bits-reject-conv.rs:57:34 | LL | const_assert!(f64::from_bits(MASKED_NAN1).is_nan()); | ^^^^^^^^^^^ -note: erroneous constant used +note: erroneous constant encountered --> $DIR/const-float-bits-reject-conv.rs:58:34 | LL | const_assert!(f64::from_bits(MASKED_NAN1).is_nan()); | ^^^^^^^^^^^ -note: erroneous constant used +note: erroneous constant encountered --> $DIR/const-float-bits-reject-conv.rs:61:34 | LL | const_assert!(f64::from_bits(MASKED_NAN1).to_bits(), MASKED_NAN1); | ^^^^^^^^^^^ -note: erroneous constant used +note: erroneous constant encountered --> $DIR/const-float-bits-reject-conv.rs:62:34 | LL | const_assert!(f64::from_bits(MASKED_NAN2).to_bits(), MASKED_NAN2); diff --git a/tests/ui/consts/const-len-underflow-separate-spans.next.stderr b/tests/ui/consts/const-len-underflow-separate-spans.next.stderr index d9208d070..b7b5b648c 100644 --- a/tests/ui/consts/const-len-underflow-separate-spans.next.stderr +++ b/tests/ui/consts/const-len-underflow-separate-spans.next.stderr @@ -4,7 +4,7 @@ error[E0080]: evaluation of constant value failed LL | const LEN: usize = ONE - TWO; | ^^^^^^^^^ attempt to compute `1_usize - 2_usize`, which would overflow -note: erroneous constant used +note: erroneous constant encountered --> $DIR/const-len-underflow-separate-spans.rs:14:17 | LL | let a: [i8; LEN] = unimplemented!(); diff --git a/tests/ui/consts/const-len-underflow-separate-spans.old.stderr b/tests/ui/consts/const-len-underflow-separate-spans.old.stderr index d9208d070..b7b5b648c 100644 --- a/tests/ui/consts/const-len-underflow-separate-spans.old.stderr +++ b/tests/ui/consts/const-len-underflow-separate-spans.old.stderr @@ -4,7 +4,7 @@ error[E0080]: evaluation of constant value failed LL | const LEN: usize = ONE - TWO; | ^^^^^^^^^ attempt to compute `1_usize - 2_usize`, which would overflow -note: erroneous constant used +note: erroneous constant encountered --> $DIR/const-len-underflow-separate-spans.rs:14:17 | LL | let a: [i8; LEN] = unimplemented!(); diff --git a/tests/ui/consts/const_in_pattern/issue-65466.rs b/tests/ui/consts/const_in_pattern/issue-65466.rs index 2b421f4c7..d45c32e17 100644 --- a/tests/ui/consts/const_in_pattern/issue-65466.rs +++ b/tests/ui/consts/const_in_pattern/issue-65466.rs @@ -15,7 +15,8 @@ const C: &[O<B>] = &[O::None]; fn main() { let x = O::None; match &[x][..] { - C => (), + C => (), //~WARN: the type must implement `PartialEq` + //~| previously accepted _ => (), } } diff --git a/tests/ui/consts/const_in_pattern/issue-65466.stderr b/tests/ui/consts/const_in_pattern/issue-65466.stderr new file mode 100644 index 000000000..9c80cb3a8 --- /dev/null +++ b/tests/ui/consts/const_in_pattern/issue-65466.stderr @@ -0,0 +1,23 @@ +warning: to use a constant of type `&[O<B>]` in a pattern, the type must implement `PartialEq` + --> $DIR/issue-65466.rs:18:9 + | +LL | C => (), + | ^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #116122 <https://github.com/rust-lang/rust/issues/116122> + = note: `#[warn(const_patterns_without_partial_eq)]` on by default + +warning: 1 warning emitted + +Future incompatibility report: Future breakage diagnostic: +warning: to use a constant of type `&[O<B>]` in a pattern, the type must implement `PartialEq` + --> $DIR/issue-65466.rs:18:9 + | +LL | C => (), + | ^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #116122 <https://github.com/rust-lang/rust/issues/116122> + = note: `#[warn(const_patterns_without_partial_eq)]` on by default + diff --git a/tests/ui/consts/effect_param.rs b/tests/ui/consts/effect_param.rs new file mode 100644 index 000000000..f11ec739f --- /dev/null +++ b/tests/ui/consts/effect_param.rs @@ -0,0 +1,11 @@ +//! Ensure we don't allow accessing const effect parameters from stable Rust. + +fn main() { + i8::checked_sub::<true>(42, 43); + //~^ ERROR: method takes 0 generic arguments but 1 generic argument was supplied +} + +const FOO: () = { + i8::checked_sub::<false>(42, 43); + //~^ ERROR: method takes 0 generic arguments but 1 generic argument was supplied +}; diff --git a/tests/ui/consts/effect_param.stderr b/tests/ui/consts/effect_param.stderr new file mode 100644 index 000000000..f8c4bfc02 --- /dev/null +++ b/tests/ui/consts/effect_param.stderr @@ -0,0 +1,19 @@ +error[E0107]: method takes 0 generic arguments but 1 generic argument was supplied + --> $DIR/effect_param.rs:9:9 + | +LL | i8::checked_sub::<false>(42, 43); + | ^^^^^^^^^^^--------- help: remove these generics + | | + | expected 0 generic arguments + +error[E0107]: method takes 0 generic arguments but 1 generic argument was supplied + --> $DIR/effect_param.rs:4:9 + | +LL | i8::checked_sub::<true>(42, 43); + | ^^^^^^^^^^^-------- help: remove these generics + | | + | expected 0 generic arguments + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0107`. diff --git a/tests/ui/consts/escaping-bound-var.rs b/tests/ui/consts/escaping-bound-var.rs new file mode 100644 index 000000000..7c1fbd24f --- /dev/null +++ b/tests/ui/consts/escaping-bound-var.rs @@ -0,0 +1,13 @@ +#![feature(generic_const_exprs)] +//~^ WARN the feature `generic_const_exprs` is incomplete + +fn test<'a>( + _: &'a (), +) -> [(); { + let x: &'a (); + //~^ ERROR cannot capture late-bound lifetime in constant + 1 +}] { +} + +fn main() {} diff --git a/tests/ui/consts/escaping-bound-var.stderr b/tests/ui/consts/escaping-bound-var.stderr new file mode 100644 index 000000000..d26ae2cee --- /dev/null +++ b/tests/ui/consts/escaping-bound-var.stderr @@ -0,0 +1,20 @@ +warning: the feature `generic_const_exprs` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/escaping-bound-var.rs:1:12 + | +LL | #![feature(generic_const_exprs)] + | ^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information + = note: `#[warn(incomplete_features)]` on by default + +error: cannot capture late-bound lifetime in constant + --> $DIR/escaping-bound-var.rs:7:13 + | +LL | fn test<'a>( + | -- lifetime defined here +... +LL | let x: &'a (); + | ^^ + +error: aborting due to previous error; 1 warning emitted + diff --git a/tests/ui/consts/fn_trait_refs.stderr b/tests/ui/consts/fn_trait_refs.stderr index bfebf6670..658a0b7b2 100644 --- a/tests/ui/consts/fn_trait_refs.stderr +++ b/tests/ui/consts/fn_trait_refs.stderr @@ -10,6 +10,66 @@ error[E0635]: unknown feature `const_cmp` LL | #![feature(const_cmp)] | ^^^^^^^^^ -error: aborting due to 2 previous errors +error: ~const can only be applied to `#[const_trait]` traits + --> $DIR/fn_trait_refs.rs:15:15 + | +LL | T: ~const Fn<()> + ~const Destruct, + | ^^^^^^ + +error: ~const can only be applied to `#[const_trait]` traits + --> $DIR/fn_trait_refs.rs:15:15 + | +LL | T: ~const Fn<()> + ~const Destruct, + | ^^^^^^ + +error: ~const can only be applied to `#[const_trait]` traits + --> $DIR/fn_trait_refs.rs:22:15 + | +LL | T: ~const FnMut<()> + ~const Destruct, + | ^^^^^^^^^ + +error: ~const can only be applied to `#[const_trait]` traits + --> $DIR/fn_trait_refs.rs:22:15 + | +LL | T: ~const FnMut<()> + ~const Destruct, + | ^^^^^^^^^ + +error: ~const can only be applied to `#[const_trait]` traits + --> $DIR/fn_trait_refs.rs:29:15 + | +LL | T: ~const FnOnce<()>, + | ^^^^^^^^^^ + +error: ~const can only be applied to `#[const_trait]` traits + --> $DIR/fn_trait_refs.rs:29:15 + | +LL | T: ~const FnOnce<()>, + | ^^^^^^^^^^ + +error: ~const can only be applied to `#[const_trait]` traits + --> $DIR/fn_trait_refs.rs:36:15 + | +LL | T: ~const Fn<()> + ~const Destruct, + | ^^^^^^ + +error: ~const can only be applied to `#[const_trait]` traits + --> $DIR/fn_trait_refs.rs:36:15 + | +LL | T: ~const Fn<()> + ~const Destruct, + | ^^^^^^ + +error: ~const can only be applied to `#[const_trait]` traits + --> $DIR/fn_trait_refs.rs:50:15 + | +LL | T: ~const FnMut<()> + ~const Destruct, + | ^^^^^^^^^ + +error: ~const can only be applied to `#[const_trait]` traits + --> $DIR/fn_trait_refs.rs:50:15 + | +LL | T: ~const FnMut<()> + ~const Destruct, + | ^^^^^^^^^ + +error: aborting due to 12 previous errors For more information about this error, try `rustc --explain E0635`. diff --git a/tests/ui/consts/invalid-union.32bit.stderr b/tests/ui/consts/invalid-union.32bit.stderr index 0dd18a557..b6cf060e5 100644 --- a/tests/ui/consts/invalid-union.32bit.stderr +++ b/tests/ui/consts/invalid-union.32bit.stderr @@ -9,13 +9,13 @@ LL | fn main() { ╾─alloc7──╼ │ ╾──╼ } -note: erroneous constant used +note: erroneous constant encountered --> $DIR/invalid-union.rs:43:25 | LL | let _: &'static _ = &C; | ^^ -note: erroneous constant used +note: erroneous constant encountered --> $DIR/invalid-union.rs:43:25 | LL | let _: &'static _ = &C; diff --git a/tests/ui/consts/invalid-union.64bit.stderr b/tests/ui/consts/invalid-union.64bit.stderr index 07f36ee28..e3a3ef62c 100644 --- a/tests/ui/consts/invalid-union.64bit.stderr +++ b/tests/ui/consts/invalid-union.64bit.stderr @@ -9,13 +9,13 @@ LL | fn main() { ╾───────alloc7────────╼ │ ╾──────╼ } -note: erroneous constant used +note: erroneous constant encountered --> $DIR/invalid-union.rs:43:25 | LL | let _: &'static _ = &C; | ^^ -note: erroneous constant used +note: erroneous constant encountered --> $DIR/invalid-union.rs:43:25 | LL | let _: &'static _ = &C; diff --git a/tests/ui/consts/issue-105536-const-val-roundtrip-ptr-eq.rs b/tests/ui/consts/issue-105536-const-val-roundtrip-ptr-eq.rs new file mode 100644 index 000000000..1615399be --- /dev/null +++ b/tests/ui/consts/issue-105536-const-val-roundtrip-ptr-eq.rs @@ -0,0 +1,31 @@ +// run-pass + +// This does not reflect a stable guarantee (we guarantee very little for equality of pointers +// around `const`), but it would be good to understand what is happening if these assertions ever +// fail. +use std::ptr::NonNull; +use std::slice::from_raw_parts; + +const PTR_U8: *const u8 = NonNull::dangling().as_ptr(); +const CONST_U8_REF: &[u8] = unsafe { from_raw_parts(PTR_U8, 0) }; +const CONST_U8_PTR: *const u8 = unsafe { from_raw_parts(PTR_U8, 0).as_ptr() }; +static STATIC_U8_REF: &[u8] = unsafe { from_raw_parts(PTR_U8, 0) }; + +const PTR_U16: *const u16 = NonNull::dangling().as_ptr(); +const CONST_U16_REF: &[u16] = unsafe { from_raw_parts(PTR_U16, 0) }; + +const fn const_u8_fn() -> &'static [u8] { + unsafe { from_raw_parts(PTR_U8, 0) } +} + +fn main() { + let ptr_u8 = unsafe { from_raw_parts(PTR_U8, 0) }.as_ptr(); + let ptr_u16 = unsafe { from_raw_parts(PTR_U16, 0) }.as_ptr(); + + assert_eq!(ptr_u8, PTR_U8); + assert_eq!(ptr_u8, CONST_U8_PTR); + assert_eq!(ptr_u8, const_u8_fn().as_ptr()); + assert_eq!(ptr_u8, STATIC_U8_REF.as_ptr()); + assert_eq!(ptr_u16, CONST_U16_REF.as_ptr()); + assert_eq!(ptr_u8, CONST_U8_REF.as_ptr()); +} diff --git a/tests/ui/consts/issue-36163.stderr b/tests/ui/consts/issue-36163.stderr index 190b41062..6fcfe3ed2 100644 --- a/tests/ui/consts/issue-36163.stderr +++ b/tests/ui/consts/issue-36163.stderr @@ -1,15 +1,25 @@ -error[E0391]: cycle detected when const-evaluating + checking `Foo::B::{constant#0}` +error[E0391]: cycle detected when simplifying constant for the type system `Foo::B::{constant#0}` --> $DIR/issue-36163.rs:4:9 | LL | B = A, | ^ | +note: ...which requires const-evaluating + checking `Foo::B::{constant#0}`... + --> $DIR/issue-36163.rs:4:9 + | +LL | B = A, + | ^ +note: ...which requires simplifying constant for the type system `A`... + --> $DIR/issue-36163.rs:1:1 + | +LL | const A: isize = Foo::B as isize; + | ^^^^^^^^^^^^^^ note: ...which requires const-evaluating + checking `A`... --> $DIR/issue-36163.rs:1:18 | LL | const A: isize = Foo::B as isize; | ^^^^^^^^^^^^^^^ - = note: ...which again requires const-evaluating + checking `Foo::B::{constant#0}`, completing the cycle + = note: ...which again requires simplifying constant for the type system `Foo::B::{constant#0}`, completing the cycle note: cycle used when simplifying constant for the type system `Foo::B::{constant#0}` --> $DIR/issue-36163.rs:4:9 | diff --git a/tests/ui/consts/miri_unleashed/assoc_const.stderr b/tests/ui/consts/miri_unleashed/assoc_const.stderr index d97097d35..274b1de7e 100644 --- a/tests/ui/consts/miri_unleashed/assoc_const.stderr +++ b/tests/ui/consts/miri_unleashed/assoc_const.stderr @@ -13,13 +13,13 @@ note: inside `<String as Bar<Vec<u32>, String>>::F` LL | const F: u32 = (U::X, 42).1; | ^ -note: erroneous constant used +note: erroneous constant encountered --> $DIR/assoc_const.rs:29:13 | LL | let y = <String as Bar<Vec<u32>, String>>::F; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -note: erroneous constant used +note: erroneous constant encountered --> $DIR/assoc_const.rs:29:13 | LL | let y = <String as Bar<Vec<u32>, String>>::F; diff --git a/tests/ui/consts/miri_unleashed/assoc_const_2.stderr b/tests/ui/consts/miri_unleashed/assoc_const_2.stderr index ae7b03fc9..c8e4cab4e 100644 --- a/tests/ui/consts/miri_unleashed/assoc_const_2.stderr +++ b/tests/ui/consts/miri_unleashed/assoc_const_2.stderr @@ -4,13 +4,13 @@ error[E0080]: evaluation of `<std::string::String as Bar<std::string::String>>:: LL | const F: u32 = 100 / U::X; | ^^^^^^^^^^ attempt to divide `100_u32` by zero -note: erroneous constant used +note: erroneous constant encountered --> $DIR/assoc_const_2.rs:27:13 | LL | let y = <String as Bar<String>>::F; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ -note: erroneous constant used +note: erroneous constant encountered --> $DIR/assoc_const_2.rs:27:13 | LL | let y = <String as Bar<String>>::F; diff --git a/tests/ui/consts/missing-larger-array-impl.stderr b/tests/ui/consts/missing-larger-array-impl.stderr index b8f6cb5ef..fe9d0f6e6 100644 --- a/tests/ui/consts/missing-larger-array-impl.stderr +++ b/tests/ui/consts/missing-larger-array-impl.stderr @@ -1,8 +1,8 @@ error[E0277]: the trait bound `[X; 35]: Default` is not satisfied - --> $DIR/missing-larger-array-impl.rs:7:5 + --> $DIR/missing-larger-array-impl.rs:7:6 | LL | <[X; 35] as Default>::default(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Default` is not implemented for `[X; 35]` + | ^^^^^^^ the trait `Default` is not implemented for `[X; 35]` | = help: the following other types implement trait `Default`: [T; 0] diff --git a/tests/ui/consts/std/alloc.32bit.stderr b/tests/ui/consts/std/alloc.32bit.stderr index 8c83df53d..da805de45 100644 --- a/tests/ui/consts/std/alloc.32bit.stderr +++ b/tests/ui/consts/std/alloc.32bit.stderr @@ -1,5 +1,5 @@ error[E0080]: it is undefined behavior to use this value - --> $DIR/alloc.rs:12:1 + --> $DIR/alloc.rs:11:1 | LL | const LAYOUT_INVALID_ZERO: Layout = unsafe { Layout::from_size_align_unchecked(0x1000, 0x00) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .align.0.<enum-tag>: encountered 0x00000000, but expected a valid enum tag @@ -10,7 +10,7 @@ LL | const LAYOUT_INVALID_ZERO: Layout = unsafe { Layout::from_size_align_unchec } error[E0080]: it is undefined behavior to use this value - --> $DIR/alloc.rs:16:1 + --> $DIR/alloc.rs:15:1 | LL | const LAYOUT_INVALID_THREE: Layout = unsafe { Layout::from_size_align_unchecked(9, 3) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .align.0.<enum-tag>: encountered 0x00000003, but expected a valid enum tag diff --git a/tests/ui/consts/std/alloc.64bit.stderr b/tests/ui/consts/std/alloc.64bit.stderr index addedad17..094503e10 100644 --- a/tests/ui/consts/std/alloc.64bit.stderr +++ b/tests/ui/consts/std/alloc.64bit.stderr @@ -1,5 +1,5 @@ error[E0080]: it is undefined behavior to use this value - --> $DIR/alloc.rs:12:1 + --> $DIR/alloc.rs:11:1 | LL | const LAYOUT_INVALID_ZERO: Layout = unsafe { Layout::from_size_align_unchecked(0x1000, 0x00) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .align.0.<enum-tag>: encountered 0x0000000000000000, but expected a valid enum tag @@ -10,7 +10,7 @@ LL | const LAYOUT_INVALID_ZERO: Layout = unsafe { Layout::from_size_align_unchec } error[E0080]: it is undefined behavior to use this value - --> $DIR/alloc.rs:16:1 + --> $DIR/alloc.rs:15:1 | LL | const LAYOUT_INVALID_THREE: Layout = unsafe { Layout::from_size_align_unchecked(9, 3) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .align.0.<enum-tag>: encountered 0x0000000000000003, but expected a valid enum tag diff --git a/tests/ui/consts/std/alloc.rs b/tests/ui/consts/std/alloc.rs index 9abf35d63..0a2c2f4de 100644 --- a/tests/ui/consts/std/alloc.rs +++ b/tests/ui/consts/std/alloc.rs @@ -1,5 +1,4 @@ // stderr-per-bitwidth -// ignore-debug (the debug assertions change the error) // Strip out raw byte dumps to make comparison platform-independent: // normalize-stderr-test "(the raw bytes of the constant) \(size: [0-9]*, align: [0-9]*\)" -> "$1 (size: $$SIZE, align: $$ALIGN)" // normalize-stderr-test "([0-9a-f][0-9a-f] |╾─*a(lloc)?[0-9]+(\+[a-z0-9]+)?─*╼ )+ *│.*" -> "HEX_DUMP" diff --git a/tests/ui/consts/uninhabited-const-issue-61744.stderr b/tests/ui/consts/uninhabited-const-issue-61744.stderr index adefbf336..f48e6c4ce 100644 --- a/tests/ui/consts/uninhabited-const-issue-61744.stderr +++ b/tests/ui/consts/uninhabited-const-issue-61744.stderr @@ -645,13 +645,13 @@ note: inside `<i32 as Const>::CONSTANT` LL | const CONSTANT: i32 = unsafe { fake_type() }; | ^^^^^^^^^^^ -note: erroneous constant used +note: erroneous constant encountered --> $DIR/uninhabited-const-issue-61744.rs:18:10 | LL | dbg!(i32::CONSTANT); | ^^^^^^^^^^^^^ -note: erroneous constant used +note: erroneous constant encountered --> $DIR/uninhabited-const-issue-61744.rs:18:10 | LL | dbg!(i32::CONSTANT); diff --git a/tests/ui/consts/unstable-const-fn-in-libcore.rs b/tests/ui/consts/unstable-const-fn-in-libcore.rs index 61e28117e..b62a74039 100644 --- a/tests/ui/consts/unstable-const-fn-in-libcore.rs +++ b/tests/ui/consts/unstable-const-fn-in-libcore.rs @@ -1,3 +1,5 @@ +// known-bug: #110395 +// FIXME check-pass // This is a non-regression test for const-qualification of unstable items in libcore // as explained in issue #67053. // const-qualification could miss some `const fn`s if they were unstable and the feature @@ -15,12 +17,12 @@ impl<T> Opt<T> { #[rustc_const_unstable(feature = "foo", issue = "none")] #[stable(feature = "rust1", since = "1.0.0")] const fn unwrap_or_else<F: ~const FnOnce() -> T>(self, f: F) -> T { - //~^ ERROR destructor of - //~| ERROR destructor of + //FIXME ~^ ERROR destructor of + //FIXME ~| ERROR destructor of match self { Opt::Some(t) => t, Opt::None => f(), - //~^ ERROR cannot call + //FIXME ~^ ERROR cannot call } } } diff --git a/tests/ui/consts/unstable-const-fn-in-libcore.stderr b/tests/ui/consts/unstable-const-fn-in-libcore.stderr index 95d7b7e85..b75f99a72 100644 --- a/tests/ui/consts/unstable-const-fn-in-libcore.stderr +++ b/tests/ui/consts/unstable-const-fn-in-libcore.stderr @@ -1,34 +1,8 @@ -error[E0015]: cannot call non-const closure in constant functions - --> $DIR/unstable-const-fn-in-libcore.rs:22:26 - | -LL | Opt::None => f(), - | ^^^ - | - = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants -help: consider further restricting this bound - | -LL | const fn unwrap_or_else<F: ~const FnOnce() -> T + ~const std::ops::FnOnce<()>>(self, f: F) -> T { - | +++++++++++++++++++++++++++++ - -error[E0493]: destructor of `F` cannot be evaluated at compile-time - --> $DIR/unstable-const-fn-in-libcore.rs:17:60 - | -LL | const fn unwrap_or_else<F: ~const FnOnce() -> T>(self, f: F) -> T { - | ^ the destructor for this type cannot be evaluated in constant functions -... -LL | } - | - value is dropped here - -error[E0493]: destructor of `Opt<T>` cannot be evaluated at compile-time - --> $DIR/unstable-const-fn-in-libcore.rs:17:54 +error: ~const can only be applied to `#[const_trait]` traits + --> $DIR/unstable-const-fn-in-libcore.rs:19:39 | LL | const fn unwrap_or_else<F: ~const FnOnce() -> T>(self, f: F) -> T { - | ^^^^ the destructor for this type cannot be evaluated in constant functions -... -LL | } - | - value is dropped here + | ^^^^^^^^^^^^^ -error: aborting due to 3 previous errors +error: aborting due to previous error -Some errors have detailed explanations: E0015, E0493. -For more information about an error, try `rustc --explain E0015`. |