diff --git a/src/test/ui/consts/const-eval/ub-ref.rs b/src/test/ui/consts/const-eval/ub-ref.rs index e8b101fed6d2f..bf812e6be0b1a 100644 --- a/src/test/ui/consts/const-eval/ub-ref.rs +++ b/src/test/ui/consts/const-eval/ub-ref.rs @@ -26,7 +26,7 @@ const REF_AS_USIZE: usize = unsafe { mem::transmute(&0) }; const REF_AS_USIZE_SLICE: &[usize] = &[unsafe { mem::transmute(&0) }]; //~^ ERROR it is undefined behavior to use this value -const REF_AS_USIZE_BOX_SLICE: Box<[usize]> = unsafe { mem::transmute::<&[usize], _>(&[mem::transmute(&0)]) }; +const REF_AS_USIZE_BOX_SLICE: Box<[usize]> = unsafe { mem::transmute(&[&0] as &[_]) }; //~^ ERROR it is undefined behavior to use this value const USIZE_AS_REF: &'static u8 = unsafe { mem::transmute(1337usize) }; diff --git a/src/test/ui/consts/const-eval/ub-ref.stderr b/src/test/ui/consts/const-eval/ub-ref.stderr index 429ae69eabfdb..17fe0c076403d 100644 --- a/src/test/ui/consts/const-eval/ub-ref.stderr +++ b/src/test/ui/consts/const-eval/ub-ref.stderr @@ -49,8 +49,8 @@ LL | const REF_AS_USIZE_SLICE: &[usize] = &[unsafe { mem::transmute(&0) }]; error[E0080]: it is undefined behavior to use this value --> $DIR/ub-ref.rs:29:1 | -LL | const REF_AS_USIZE_BOX_SLICE: Box<[usize]> = unsafe { mem::transmute::<&[usize], _>(&[mem::transmute(&0)]) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a pointer at ., but expected plain (non-pointer) bytes +LL | const REF_AS_USIZE_BOX_SLICE: Box<[usize]> = unsafe { mem::transmute(&[&0] as &[_]) }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a pointer at ., but expected plain (non-pointer) bytes | = 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. diff --git a/src/test/ui/consts/rfc-2203-const-array-repeat-exprs/fn-call-in-const.rs b/src/test/ui/consts/rfc-2203-const-array-repeat-exprs/fn-call-in-const.rs index da1bae1be8d4e..6bc7ebbc28284 100644 --- a/src/test/ui/consts/rfc-2203-const-array-repeat-exprs/fn-call-in-const.rs +++ b/src/test/ui/consts/rfc-2203-const-array-repeat-exprs/fn-call-in-const.rs @@ -1,7 +1,8 @@ // run-pass -#![allow(unused)] +#![allow(unused, incomplete_features)] #![feature(const_in_array_repeat_expressions)] +#![feature(inline_const)] // Some type that is not copyable. struct Bar; @@ -16,8 +17,6 @@ const fn type_copy() -> u32 { const _: [u32; 2] = [type_copy(); 2]; -// This is allowed because all promotion contexts use the explicit rules for promotability when -// inside an explicit const context. -const _: [Option; 2] = [type_no_copy(); 2]; +const _: [Option; 2] = [const { type_no_copy() }; 2]; fn main() {}