diff --git a/src/librustc_mir/const_eval.rs b/src/librustc_mir/const_eval.rs index 6ad1536a630..861d0b2f7e1 100644 --- a/src/librustc_mir/const_eval.rs +++ b/src/librustc_mir/const_eval.rs @@ -23,6 +23,7 @@ use rustc::mir; use rustc::ty::{self, Ty, TyCtxt, Instance, query::TyCtxtAt}; use rustc::ty::layout::{self, Size, LayoutOf, TyLayout}; use rustc::ty::subst::Subst; +use rustc::traits::Reveal; use rustc::util::nodemap::FxHashSet; use rustc_data_structures::indexed_vec::IndexVec; use rustc_data_structures::fx::FxHashMap; @@ -576,6 +577,16 @@ pub fn const_eval_provider<'a, 'tcx>( tcx: TyCtxt<'a, 'tcx, 'tcx>, key: ty::ParamEnvAnd<'tcx, GlobalId<'tcx>>, ) -> ::rustc::mir::interpret::ConstEvalResult<'tcx> { + if key.param_env.reveal == Reveal::All { + let mut key = key.clone(); + key.param_env.reveal = Reveal::UserFacing; + match tcx.const_eval(key) { + // try again with reveal all as requested + Err(ErrorHandled::TooGeneric) => {}, + // dedupliate calls + other => return other, + } + } tcx.const_eval_raw(key).and_then(|val| { validate_const(tcx, val, key) }) @@ -585,6 +596,16 @@ pub fn const_eval_raw_provider<'a, 'tcx>( tcx: TyCtxt<'a, 'tcx, 'tcx>, key: ty::ParamEnvAnd<'tcx, GlobalId<'tcx>>, ) -> ::rustc::mir::interpret::ConstEvalResult<'tcx> { + if key.param_env.reveal == Reveal::All { + let mut key = key.clone(); + key.param_env.reveal = Reveal::UserFacing; + match tcx.const_eval_raw(key) { + // try again with reveal all as requested + Err(ErrorHandled::TooGeneric) => {}, + // dedupliate calls + other => return other, + } + } trace!("const eval: {:?}", key); let cid = key.value; let def_id = cid.instance.def.def_id(); diff --git a/src/test/ui/array_const_index-0.rs b/src/test/ui/array_const_index-0.rs index 2403d50db39..0ad297eeb5c 100644 --- a/src/test/ui/array_const_index-0.rs +++ b/src/test/ui/array_const_index-0.rs @@ -12,7 +12,6 @@ const A: &'static [i32] = &[]; const B: i32 = (&A)[1]; //~^ index out of bounds: the len is 0 but the index is 1 //~| ERROR any use of this value will cause an error -//~| ERROR any use of this value will cause an error fn main() { let _ = B; //~ ERROR erroneous constant used diff --git a/src/test/ui/array_const_index-0.stderr b/src/test/ui/array_const_index-0.stderr index 95ed88bde10..38163b1f4b1 100644 --- a/src/test/ui/array_const_index-0.stderr +++ b/src/test/ui/array_const_index-0.stderr @@ -8,20 +8,12 @@ LL | const B: i32 = (&A)[1]; | = note: #[deny(const_err)] on by default -error: any use of this value will cause an error - --> $DIR/array_const_index-0.rs:12:1 - | -LL | const B: i32 = (&A)[1]; - | ^^^^^^^^^^^^^^^-------^ - | | - | index out of bounds: the len is 0 but the index is 1 - error[E0080]: erroneous constant used - --> $DIR/array_const_index-0.rs:18:13 + --> $DIR/array_const_index-0.rs:17:13 | LL | let _ = B; //~ ERROR erroneous constant used | ^ referenced constant has errors -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/array_const_index-1.rs b/src/test/ui/array_const_index-1.rs index 0a49348761c..4c7dcfbb347 100644 --- a/src/test/ui/array_const_index-1.rs +++ b/src/test/ui/array_const_index-1.rs @@ -12,7 +12,6 @@ const A: [i32; 0] = []; const B: i32 = A[1]; //~^ index out of bounds: the len is 0 but the index is 1 //~| ERROR any use of this value will cause an error -//~| ERROR any use of this value will cause an error fn main() { let _ = B; //~ ERROR erroneous constant used diff --git a/src/test/ui/array_const_index-1.stderr b/src/test/ui/array_const_index-1.stderr index 5fcfc14e2c0..b122e590c88 100644 --- a/src/test/ui/array_const_index-1.stderr +++ b/src/test/ui/array_const_index-1.stderr @@ -8,20 +8,12 @@ LL | const B: i32 = A[1]; | = note: #[deny(const_err)] on by default -error: any use of this value will cause an error - --> $DIR/array_const_index-1.rs:12:1 - | -LL | const B: i32 = A[1]; - | ^^^^^^^^^^^^^^^----^ - | | - | index out of bounds: the len is 0 but the index is 1 - error[E0080]: erroneous constant used - --> $DIR/array_const_index-1.rs:18:13 + --> $DIR/array_const_index-1.rs:17:13 | LL | let _ = B; //~ ERROR erroneous constant used | ^ referenced constant has errors -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/consts/const-err-early.rs b/src/test/ui/consts/const-err-early.rs index 488e6f49e14..1cbfb918427 100644 --- a/src/test/ui/consts/const-err-early.rs +++ b/src/test/ui/consts/const-err-early.rs @@ -11,7 +11,6 @@ #![deny(const_err)] pub const A: i8 = -std::i8::MIN; //~ ERROR const_err -//~^ ERROR const_err pub const B: u8 = 200u8 + 200u8; //~ ERROR const_err pub const C: u8 = 200u8 * 4; //~ ERROR const_err pub const D: u8 = 42u8 - (42u8 + 1); //~ ERROR const_err diff --git a/src/test/ui/consts/const-err-early.stderr b/src/test/ui/consts/const-err-early.stderr index 21c7bf0a70a..8cc112191b5 100644 --- a/src/test/ui/consts/const-err-early.stderr +++ b/src/test/ui/consts/const-err-early.stderr @@ -13,7 +13,7 @@ LL | #![deny(const_err)] | ^^^^^^^^^ error: any use of this value will cause an error - --> $DIR/const-err-early.rs:15:1 + --> $DIR/const-err-early.rs:14:1 | LL | pub const B: u8 = 200u8 + 200u8; //~ ERROR const_err | ^^^^^^^^^^^^^^^^^^-------------^ @@ -21,7 +21,7 @@ LL | pub const B: u8 = 200u8 + 200u8; //~ ERROR const_err | attempt to add with overflow error: any use of this value will cause an error - --> $DIR/const-err-early.rs:16:1 + --> $DIR/const-err-early.rs:15:1 | LL | pub const C: u8 = 200u8 * 4; //~ ERROR const_err | ^^^^^^^^^^^^^^^^^^---------^ @@ -29,7 +29,7 @@ LL | pub const C: u8 = 200u8 * 4; //~ ERROR const_err | attempt to multiply with overflow error: any use of this value will cause an error - --> $DIR/const-err-early.rs:17:1 + --> $DIR/const-err-early.rs:16:1 | LL | pub const D: u8 = 42u8 - (42u8 + 1); //~ ERROR const_err | ^^^^^^^^^^^^^^^^^^-----------------^ @@ -37,57 +37,49 @@ LL | pub const D: u8 = 42u8 - (42u8 + 1); //~ ERROR const_err | attempt to subtract with overflow error: any use of this value will cause an error - --> $DIR/const-err-early.rs:18:1 + --> $DIR/const-err-early.rs:17:1 | LL | pub const E: u8 = [5u8][1]; //~ ERROR const_err | ^^^^^^^^^^^^^^^^^^--------^ | | | index out of bounds: the len is 1 but the index is 1 -error: any use of this value will cause an error - --> $DIR/const-err-early.rs:13:1 - | -LL | pub const A: i8 = -std::i8::MIN; //~ ERROR const_err - | ^^^^^^^^^^^^^^^^^^-------------^ - | | - | attempt to negate with overflow - error[E0080]: erroneous constant used - --> $DIR/const-err-early.rs:21:14 + --> $DIR/const-err-early.rs:20:14 | LL | let _a = A; //~ ERROR erroneous constant used | ^ referenced constant has errors error[E0080]: erroneous constant used - --> $DIR/const-err-early.rs:22:14 + --> $DIR/const-err-early.rs:21:14 | LL | let _b = B; //~ ERROR erroneous constant used | ^ referenced constant has errors error[E0080]: erroneous constant used - --> $DIR/const-err-early.rs:23:14 + --> $DIR/const-err-early.rs:22:14 | LL | let _c = C; //~ ERROR erroneous constant used | ^ referenced constant has errors error[E0080]: erroneous constant used - --> $DIR/const-err-early.rs:24:14 + --> $DIR/const-err-early.rs:23:14 | LL | let _d = D; //~ ERROR erroneous constant used | ^ referenced constant has errors error[E0080]: erroneous constant used - --> $DIR/const-err-early.rs:25:14 + --> $DIR/const-err-early.rs:24:14 | LL | let _e = E; //~ ERROR erroneous constant used | ^ referenced constant has errors error: index out of bounds: the len is 1 but the index is 1 - --> $DIR/const-err-early.rs:26:14 + --> $DIR/const-err-early.rs:25:14 | LL | let _e = [6u8][1]; //~ ERROR index out of bounds | ^^^^^^^^ -error: aborting due to 12 previous errors +error: aborting due to 11 previous errors For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/consts/const-err-multi.rs b/src/test/ui/consts/const-err-multi.rs index c3960b83992..20eaebfbe56 100644 --- a/src/test/ui/consts/const-err-multi.rs +++ b/src/test/ui/consts/const-err-multi.rs @@ -12,7 +12,6 @@ pub const A: i8 = -std::i8::MIN; //~^ ERROR const_err -//~| ERROR const_err pub const B: i8 = A; //~^ ERROR const_err pub const C: u8 = A as u8; diff --git a/src/test/ui/consts/const-err-multi.stderr b/src/test/ui/consts/const-err-multi.stderr index 0717302dbf9..da6f31a3886 100644 --- a/src/test/ui/consts/const-err-multi.stderr +++ b/src/test/ui/consts/const-err-multi.stderr @@ -13,7 +13,7 @@ LL | #![deny(const_err)] | ^^^^^^^^^ error: any use of this value will cause an error - --> $DIR/const-err-multi.rs:16:1 + --> $DIR/const-err-multi.rs:15:1 | LL | pub const B: i8 = A; | ^^^^^^^^^^^^^^^^^^-^ @@ -21,7 +21,7 @@ LL | pub const B: i8 = A; | referenced constant has errors error: any use of this value will cause an error - --> $DIR/const-err-multi.rs:18:1 + --> $DIR/const-err-multi.rs:17:1 | LL | pub const C: u8 = A as u8; | ^^^^^^^^^^^^^^^^^^-------^ @@ -29,27 +29,19 @@ LL | pub const C: u8 = A as u8; | referenced constant has errors error: any use of this value will cause an error - --> $DIR/const-err-multi.rs:20:1 + --> $DIR/const-err-multi.rs:19:1 | LL | pub const D: i8 = 50 - A; | ^^^^^^^^^^^^^^^^^^------^ | | | referenced constant has errors -error: any use of this value will cause an error - --> $DIR/const-err-multi.rs:13:1 - | -LL | pub const A: i8 = -std::i8::MIN; - | ^^^^^^^^^^^^^^^^^^-------------^ - | | - | attempt to negate with overflow - error[E0080]: erroneous constant used - --> $DIR/const-err-multi.rs:24:13 + --> $DIR/const-err-multi.rs:23:13 | LL | let _ = (A, B, C, D); | ^^^^^^^^^^^^ referenced constant has errors -error: aborting due to 6 previous errors +error: aborting due to 5 previous errors For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/consts/const-err.rs b/src/test/ui/consts/const-err.rs index 7c59e8b9535..fff50c86646 100644 --- a/src/test/ui/consts/const-err.rs +++ b/src/test/ui/consts/const-err.rs @@ -19,7 +19,6 @@ fn black_box(_: T) { const FOO: u8 = [5u8][1]; //~^ WARN any use of this value will cause an error -//~| WARN any use of this value will cause an error fn main() { black_box((FOO, FOO)); diff --git a/src/test/ui/consts/const-err.stderr b/src/test/ui/consts/const-err.stderr index b46277f4b01..e2ef7c3d0d4 100644 --- a/src/test/ui/consts/const-err.stderr +++ b/src/test/ui/consts/const-err.stderr @@ -12,16 +12,8 @@ note: lint level defined here LL | #![warn(const_err)] | ^^^^^^^^^ -warning: any use of this value will cause an error - --> $DIR/const-err.rs:20:1 - | -LL | const FOO: u8 = [5u8][1]; - | ^^^^^^^^^^^^^^^^--------^ - | | - | index out of bounds: the len is 1 but the index is 1 - error[E0080]: erroneous constant used - --> $DIR/const-err.rs:25:15 + --> $DIR/const-err.rs:24:15 | LL | black_box((FOO, FOO)); | ^^^^^^^^^^ referenced constant has errors diff --git a/src/test/ui/consts/const-eval/const-eval-overflow2.rs b/src/test/ui/consts/const-eval/const-eval-overflow2.rs index ee29423a90c..c61a1b3edb7 100644 --- a/src/test/ui/consts/const-eval/const-eval-overflow2.rs +++ b/src/test/ui/consts/const-eval/const-eval-overflow2.rs @@ -22,7 +22,6 @@ use std::{i8, i16, i32, i64, isize}; use std::{u8, u16, u32, u64, usize}; const VALS_I8: (i8,) = //~ ERROR any use of this value will cause an error - //~^ const_err ( i8::MIN - 1, ); diff --git a/src/test/ui/consts/const-eval/const-eval-overflow2.stderr b/src/test/ui/consts/const-eval/const-eval-overflow2.stderr index f10a6eee6de..0484335fd0c 100644 --- a/src/test/ui/consts/const-eval/const-eval-overflow2.stderr +++ b/src/test/ui/consts/const-eval/const-eval-overflow2.stderr @@ -2,7 +2,6 @@ error: any use of this value will cause an error --> $DIR/const-eval-overflow2.rs:24:1 | LL | / const VALS_I8: (i8,) = //~ ERROR any use of this value will cause an error -LL | | //~^ const_err LL | | ( LL | | i8::MIN - 1, | | ----------- attempt to subtract with overflow @@ -16,7 +15,7 @@ LL | #![deny(const_err)] | ^^^^^^^^^ error: any use of this value will cause an error - --> $DIR/const-eval-overflow2.rs:30:1 + --> $DIR/const-eval-overflow2.rs:29:1 | LL | / const VALS_I16: (i16,) = //~ ERROR any use of this value will cause an error LL | | ( @@ -26,7 +25,7 @@ LL | | ); | |_______^ error: any use of this value will cause an error - --> $DIR/const-eval-overflow2.rs:35:1 + --> $DIR/const-eval-overflow2.rs:34:1 | LL | / const VALS_I32: (i32,) = //~ ERROR any use of this value will cause an error LL | | ( @@ -36,7 +35,7 @@ LL | | ); | |_______^ error: any use of this value will cause an error - --> $DIR/const-eval-overflow2.rs:40:1 + --> $DIR/const-eval-overflow2.rs:39:1 | LL | / const VALS_I64: (i64,) = //~ ERROR any use of this value will cause an error LL | | ( @@ -46,7 +45,7 @@ LL | | ); | |_______^ error: any use of this value will cause an error - --> $DIR/const-eval-overflow2.rs:45:1 + --> $DIR/const-eval-overflow2.rs:44:1 | LL | / const VALS_U8: (u8,) = //~ ERROR any use of this value will cause an error LL | | ( @@ -56,7 +55,7 @@ LL | | ); | |_______^ error: any use of this value will cause an error - --> $DIR/const-eval-overflow2.rs:50:1 + --> $DIR/const-eval-overflow2.rs:49:1 | LL | / const VALS_U16: (u16,) = ( //~ ERROR any use of this value will cause an error LL | | u16::MIN - 1, @@ -65,7 +64,7 @@ LL | | ); | |_______^ error: any use of this value will cause an error - --> $DIR/const-eval-overflow2.rs:54:1 + --> $DIR/const-eval-overflow2.rs:53:1 | LL | / const VALS_U32: (u32,) = ( //~ ERROR any use of this value will cause an error LL | | u32::MIN - 1, @@ -74,7 +73,7 @@ LL | | ); | |_______^ error: any use of this value will cause an error - --> $DIR/const-eval-overflow2.rs:58:1 + --> $DIR/const-eval-overflow2.rs:57:1 | LL | / const VALS_U64: (u64,) = //~ ERROR any use of this value will cause an error LL | | ( @@ -83,65 +82,54 @@ LL | | u64::MIN - 1, LL | | ); | |_______^ -error: any use of this value will cause an error - --> $DIR/const-eval-overflow2.rs:24:1 - | -LL | / const VALS_I8: (i8,) = //~ ERROR any use of this value will cause an error -LL | | //~^ const_err -LL | | ( -LL | | i8::MIN - 1, - | | ----------- attempt to subtract with overflow -LL | | ); - | |_______^ - error[E0080]: erroneous constant used - --> $DIR/const-eval-overflow2.rs:64:5 + --> $DIR/const-eval-overflow2.rs:63:5 | LL | foo(VALS_I8); //~ ERROR erroneous constant used | ^^^^^^^^^^^^ referenced constant has errors error[E0080]: erroneous constant used - --> $DIR/const-eval-overflow2.rs:65:5 + --> $DIR/const-eval-overflow2.rs:64:5 | LL | foo(VALS_I16); //~ ERROR erroneous constant used | ^^^^^^^^^^^^^ referenced constant has errors error[E0080]: erroneous constant used - --> $DIR/const-eval-overflow2.rs:66:5 + --> $DIR/const-eval-overflow2.rs:65:5 | LL | foo(VALS_I32); //~ ERROR erroneous constant used | ^^^^^^^^^^^^^ referenced constant has errors error[E0080]: erroneous constant used - --> $DIR/const-eval-overflow2.rs:67:5 + --> $DIR/const-eval-overflow2.rs:66:5 | LL | foo(VALS_I64); //~ ERROR erroneous constant used | ^^^^^^^^^^^^^ referenced constant has errors error[E0080]: erroneous constant used - --> $DIR/const-eval-overflow2.rs:69:5 + --> $DIR/const-eval-overflow2.rs:68:5 | LL | foo(VALS_U8); //~ ERROR erroneous constant used | ^^^^^^^^^^^^ referenced constant has errors error[E0080]: erroneous constant used - --> $DIR/const-eval-overflow2.rs:70:5 + --> $DIR/const-eval-overflow2.rs:69:5 | LL | foo(VALS_U16); //~ ERROR erroneous constant used | ^^^^^^^^^^^^^ referenced constant has errors error[E0080]: erroneous constant used - --> $DIR/const-eval-overflow2.rs:71:5 + --> $DIR/const-eval-overflow2.rs:70:5 | LL | foo(VALS_U32); //~ ERROR erroneous constant used | ^^^^^^^^^^^^^ referenced constant has errors error[E0080]: erroneous constant used - --> $DIR/const-eval-overflow2.rs:72:5 + --> $DIR/const-eval-overflow2.rs:71:5 | LL | foo(VALS_U64); //~ ERROR erroneous constant used | ^^^^^^^^^^^^^ referenced constant has errors -error: aborting due to 17 previous errors +error: aborting due to 16 previous errors For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/consts/const-eval/const-eval-overflow2b.rs b/src/test/ui/consts/const-eval/const-eval-overflow2b.rs index 55dc2a89405..47b0977ec1d 100644 --- a/src/test/ui/consts/const-eval/const-eval-overflow2b.rs +++ b/src/test/ui/consts/const-eval/const-eval-overflow2b.rs @@ -22,7 +22,6 @@ use std::{i8, i16, i32, i64, isize}; use std::{u8, u16, u32, u64, usize}; const VALS_I8: (i8,) = //~ ERROR any use of this value will cause an error - //~^ const_err ( i8::MAX + 1, ); diff --git a/src/test/ui/consts/const-eval/const-eval-overflow2b.stderr b/src/test/ui/consts/const-eval/const-eval-overflow2b.stderr index 3b78fb51a62..8922b35a0b2 100644 --- a/src/test/ui/consts/const-eval/const-eval-overflow2b.stderr +++ b/src/test/ui/consts/const-eval/const-eval-overflow2b.stderr @@ -2,7 +2,6 @@ error: any use of this value will cause an error --> $DIR/const-eval-overflow2b.rs:24:1 | LL | / const VALS_I8: (i8,) = //~ ERROR any use of this value will cause an error -LL | | //~^ const_err LL | | ( LL | | i8::MAX + 1, | | ----------- attempt to add with overflow @@ -16,7 +15,7 @@ LL | #![deny(const_err)] | ^^^^^^^^^ error: any use of this value will cause an error - --> $DIR/const-eval-overflow2b.rs:30:1 + --> $DIR/const-eval-overflow2b.rs:29:1 | LL | / const VALS_I16: (i16,) = //~ ERROR any use of this value will cause an error LL | | ( @@ -26,7 +25,7 @@ LL | | ); | |_______^ error: any use of this value will cause an error - --> $DIR/const-eval-overflow2b.rs:35:1 + --> $DIR/const-eval-overflow2b.rs:34:1 | LL | / const VALS_I32: (i32,) = //~ ERROR any use of this value will cause an error LL | | ( @@ -36,7 +35,7 @@ LL | | ); | |_______^ error: any use of this value will cause an error - --> $DIR/const-eval-overflow2b.rs:40:1 + --> $DIR/const-eval-overflow2b.rs:39:1 | LL | / const VALS_I64: (i64,) = //~ ERROR any use of this value will cause an error LL | | ( @@ -46,7 +45,7 @@ LL | | ); | |_______^ error: any use of this value will cause an error - --> $DIR/const-eval-overflow2b.rs:45:1 + --> $DIR/const-eval-overflow2b.rs:44:1 | LL | / const VALS_U8: (u8,) = //~ ERROR any use of this value will cause an error LL | | ( @@ -56,7 +55,7 @@ LL | | ); | |_______^ error: any use of this value will cause an error - --> $DIR/const-eval-overflow2b.rs:50:1 + --> $DIR/const-eval-overflow2b.rs:49:1 | LL | / const VALS_U16: (u16,) = ( //~ ERROR any use of this value will cause an error LL | | u16::MAX + 1, @@ -65,7 +64,7 @@ LL | | ); | |_______^ error: any use of this value will cause an error - --> $DIR/const-eval-overflow2b.rs:54:1 + --> $DIR/const-eval-overflow2b.rs:53:1 | LL | / const VALS_U32: (u32,) = ( //~ ERROR any use of this value will cause an error LL | | u32::MAX + 1, @@ -74,7 +73,7 @@ LL | | ); | |_______^ error: any use of this value will cause an error - --> $DIR/const-eval-overflow2b.rs:58:1 + --> $DIR/const-eval-overflow2b.rs:57:1 | LL | / const VALS_U64: (u64,) = //~ ERROR any use of this value will cause an error LL | | ( @@ -83,65 +82,54 @@ LL | | u64::MAX + 1, LL | | ); | |_______^ -error: any use of this value will cause an error - --> $DIR/const-eval-overflow2b.rs:24:1 - | -LL | / const VALS_I8: (i8,) = //~ ERROR any use of this value will cause an error -LL | | //~^ const_err -LL | | ( -LL | | i8::MAX + 1, - | | ----------- attempt to add with overflow -LL | | ); - | |_______^ - error[E0080]: erroneous constant used - --> $DIR/const-eval-overflow2b.rs:64:5 + --> $DIR/const-eval-overflow2b.rs:63:5 | LL | foo(VALS_I8); //~ ERROR erroneous constant used | ^^^^^^^^^^^^ referenced constant has errors error[E0080]: erroneous constant used - --> $DIR/const-eval-overflow2b.rs:65:5 + --> $DIR/const-eval-overflow2b.rs:64:5 | LL | foo(VALS_I16); //~ ERROR erroneous constant used | ^^^^^^^^^^^^^ referenced constant has errors error[E0080]: erroneous constant used - --> $DIR/const-eval-overflow2b.rs:66:5 + --> $DIR/const-eval-overflow2b.rs:65:5 | LL | foo(VALS_I32); //~ ERROR erroneous constant used | ^^^^^^^^^^^^^ referenced constant has errors error[E0080]: erroneous constant used - --> $DIR/const-eval-overflow2b.rs:67:5 + --> $DIR/const-eval-overflow2b.rs:66:5 | LL | foo(VALS_I64); //~ ERROR erroneous constant used | ^^^^^^^^^^^^^ referenced constant has errors error[E0080]: erroneous constant used - --> $DIR/const-eval-overflow2b.rs:69:5 + --> $DIR/const-eval-overflow2b.rs:68:5 | LL | foo(VALS_U8); //~ ERROR erroneous constant used | ^^^^^^^^^^^^ referenced constant has errors error[E0080]: erroneous constant used - --> $DIR/const-eval-overflow2b.rs:70:5 + --> $DIR/const-eval-overflow2b.rs:69:5 | LL | foo(VALS_U16); //~ ERROR erroneous constant used | ^^^^^^^^^^^^^ referenced constant has errors error[E0080]: erroneous constant used - --> $DIR/const-eval-overflow2b.rs:71:5 + --> $DIR/const-eval-overflow2b.rs:70:5 | LL | foo(VALS_U32); //~ ERROR erroneous constant used | ^^^^^^^^^^^^^ referenced constant has errors error[E0080]: erroneous constant used - --> $DIR/const-eval-overflow2b.rs:72:5 + --> $DIR/const-eval-overflow2b.rs:71:5 | LL | foo(VALS_U64); //~ ERROR erroneous constant used | ^^^^^^^^^^^^^ referenced constant has errors -error: aborting due to 17 previous errors +error: aborting due to 16 previous errors For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/consts/const-eval/const-eval-overflow2c.rs b/src/test/ui/consts/const-eval/const-eval-overflow2c.rs index 93ba11efc59..b4e1a0bc099 100644 --- a/src/test/ui/consts/const-eval/const-eval-overflow2c.rs +++ b/src/test/ui/consts/const-eval/const-eval-overflow2c.rs @@ -22,7 +22,6 @@ use std::{i8, i16, i32, i64, isize}; use std::{u8, u16, u32, u64, usize}; const VALS_I8: (i8,) = //~ ERROR any use of this value will cause an error - //~^ const_err ( i8::MIN * 2, ); diff --git a/src/test/ui/consts/const-eval/const-eval-overflow2c.stderr b/src/test/ui/consts/const-eval/const-eval-overflow2c.stderr index abaae4bd542..023156a40dd 100644 --- a/src/test/ui/consts/const-eval/const-eval-overflow2c.stderr +++ b/src/test/ui/consts/const-eval/const-eval-overflow2c.stderr @@ -2,7 +2,6 @@ error: any use of this value will cause an error --> $DIR/const-eval-overflow2c.rs:24:1 | LL | / const VALS_I8: (i8,) = //~ ERROR any use of this value will cause an error -LL | | //~^ const_err LL | | ( LL | | i8::MIN * 2, | | ----------- attempt to multiply with overflow @@ -16,7 +15,7 @@ LL | #![deny(const_err)] | ^^^^^^^^^ error: any use of this value will cause an error - --> $DIR/const-eval-overflow2c.rs:30:1 + --> $DIR/const-eval-overflow2c.rs:29:1 | LL | / const VALS_I16: (i16,) = //~ ERROR any use of this value will cause an error LL | | ( @@ -26,7 +25,7 @@ LL | | ); | |_______^ error: any use of this value will cause an error - --> $DIR/const-eval-overflow2c.rs:35:1 + --> $DIR/const-eval-overflow2c.rs:34:1 | LL | / const VALS_I32: (i32,) = //~ ERROR any use of this value will cause an error LL | | ( @@ -36,7 +35,7 @@ LL | | ); | |_______^ error: any use of this value will cause an error - --> $DIR/const-eval-overflow2c.rs:40:1 + --> $DIR/const-eval-overflow2c.rs:39:1 | LL | / const VALS_I64: (i64,) = //~ ERROR any use of this value will cause an error LL | | ( @@ -46,7 +45,7 @@ LL | | ); | |_______^ error: any use of this value will cause an error - --> $DIR/const-eval-overflow2c.rs:45:1 + --> $DIR/const-eval-overflow2c.rs:44:1 | LL | / const VALS_U8: (u8,) = //~ ERROR any use of this value will cause an error LL | | ( @@ -56,7 +55,7 @@ LL | | ); | |_______^ error: any use of this value will cause an error - --> $DIR/const-eval-overflow2c.rs:50:1 + --> $DIR/const-eval-overflow2c.rs:49:1 | LL | / const VALS_U16: (u16,) = ( //~ ERROR any use of this value will cause an error LL | | u16::MAX * 2, @@ -65,7 +64,7 @@ LL | | ); | |_______^ error: any use of this value will cause an error - --> $DIR/const-eval-overflow2c.rs:54:1 + --> $DIR/const-eval-overflow2c.rs:53:1 | LL | / const VALS_U32: (u32,) = ( //~ ERROR any use of this value will cause an error LL | | u32::MAX * 2, @@ -74,7 +73,7 @@ LL | | ); | |_______^ error: any use of this value will cause an error - --> $DIR/const-eval-overflow2c.rs:58:1 + --> $DIR/const-eval-overflow2c.rs:57:1 | LL | / const VALS_U64: (u64,) = //~ ERROR any use of this value will cause an error LL | | ( @@ -83,65 +82,54 @@ LL | | u64::MAX * 2, LL | | ); | |_______^ -error: any use of this value will cause an error - --> $DIR/const-eval-overflow2c.rs:24:1 - | -LL | / const VALS_I8: (i8,) = //~ ERROR any use of this value will cause an error -LL | | //~^ const_err -LL | | ( -LL | | i8::MIN * 2, - | | ----------- attempt to multiply with overflow -LL | | ); - | |_______^ - error[E0080]: erroneous constant used - --> $DIR/const-eval-overflow2c.rs:64:5 + --> $DIR/const-eval-overflow2c.rs:63:5 | LL | foo(VALS_I8); //~ ERROR erroneous constant used | ^^^^^^^^^^^^ referenced constant has errors error[E0080]: erroneous constant used - --> $DIR/const-eval-overflow2c.rs:65:5 + --> $DIR/const-eval-overflow2c.rs:64:5 | LL | foo(VALS_I16); //~ ERROR erroneous constant used | ^^^^^^^^^^^^^ referenced constant has errors error[E0080]: erroneous constant used - --> $DIR/const-eval-overflow2c.rs:66:5 + --> $DIR/const-eval-overflow2c.rs:65:5 | LL | foo(VALS_I32); //~ ERROR erroneous constant used | ^^^^^^^^^^^^^ referenced constant has errors error[E0080]: erroneous constant used - --> $DIR/const-eval-overflow2c.rs:67:5 + --> $DIR/const-eval-overflow2c.rs:66:5 | LL | foo(VALS_I64); //~ ERROR erroneous constant used | ^^^^^^^^^^^^^ referenced constant has errors error[E0080]: erroneous constant used - --> $DIR/const-eval-overflow2c.rs:69:5 + --> $DIR/const-eval-overflow2c.rs:68:5 | LL | foo(VALS_U8); //~ ERROR erroneous constant used | ^^^^^^^^^^^^ referenced constant has errors error[E0080]: erroneous constant used - --> $DIR/const-eval-overflow2c.rs:70:5 + --> $DIR/const-eval-overflow2c.rs:69:5 | LL | foo(VALS_U16); //~ ERROR erroneous constant used | ^^^^^^^^^^^^^ referenced constant has errors error[E0080]: erroneous constant used - --> $DIR/const-eval-overflow2c.rs:71:5 + --> $DIR/const-eval-overflow2c.rs:70:5 | LL | foo(VALS_U32); //~ ERROR erroneous constant used | ^^^^^^^^^^^^^ referenced constant has errors error[E0080]: erroneous constant used - --> $DIR/const-eval-overflow2c.rs:72:5 + --> $DIR/const-eval-overflow2c.rs:71:5 | LL | foo(VALS_U64); //~ ERROR erroneous constant used | ^^^^^^^^^^^^^ referenced constant has errors -error: aborting due to 17 previous errors +error: aborting due to 16 previous errors For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/consts/const-eval/transmute-const.stderr b/src/test/ui/consts/const-eval/transmute-const.stderr index c9beca7aa30..91faa4684c3 100644 --- a/src/test/ui/consts/const-eval/transmute-const.stderr +++ b/src/test/ui/consts/const-eval/transmute-const.stderr @@ -1,4 +1,4 @@ -error[E0080]: this static likely exhibits undefined behavior +error[E0080]: it is undefined behavior to use this value --> $DIR/transmute-const.rs:15:1 | LL | static FOO: bool = unsafe { mem::transmute(3u8) }; diff --git a/src/test/ui/consts/const-eval/union-const-eval-field.rs b/src/test/ui/consts/const-eval/union-const-eval-field.rs index 40d1f97a807..759dab6c256 100644 --- a/src/test/ui/consts/const-eval/union-const-eval-field.rs +++ b/src/test/ui/consts/const-eval/union-const-eval-field.rs @@ -35,7 +35,6 @@ const fn read_field2() -> Field2 { const fn read_field3() -> Field3 { const FIELD3: Field3 = unsafe { UNION.field3 }; //~ ERROR any use of this value - //~^ ERROR any use of this value FIELD3 //~^ erroneous constant used } diff --git a/src/test/ui/consts/const-eval/union-const-eval-field.stderr b/src/test/ui/consts/const-eval/union-const-eval-field.stderr index 39320791a3f..6a64f0c3671 100644 --- a/src/test/ui/consts/const-eval/union-const-eval-field.stderr +++ b/src/test/ui/consts/const-eval/union-const-eval-field.stderr @@ -6,20 +6,14 @@ LL | const FIELD3: Field3 = unsafe { UNION.field3 }; //~ ERROR any use of th | = note: #[deny(const_err)] on by default -error: any use of this value will cause an error - --> $DIR/union-const-eval-field.rs:37:5 - | -LL | const FIELD3: Field3 = unsafe { UNION.field3 }; //~ ERROR any use of this value - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attempted to read undefined bytes - error[E0080]: erroneous constant used - --> $DIR/union-const-eval-field.rs:39:5 + --> $DIR/union-const-eval-field.rs:38:5 | LL | FIELD3 | ^^^^^^ referenced constant has errors error[E0080]: evaluation of constant expression failed - --> $DIR/union-const-eval-field.rs:46:5 + --> $DIR/union-const-eval-field.rs:45:5 | LL | FIELD3 | ------ referenced constant has errors @@ -31,6 +25,6 @@ LL | assert_eq!(read_field3(), unsafe { UNION.field3 }); | = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) -error: aborting due to 4 previous errors +error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/consts/const-size_of-cycle.stderr b/src/test/ui/consts/const-size_of-cycle.stderr index ea5d7c176ff..0c8fdfb6da2 100644 --- a/src/test/ui/consts/const-size_of-cycle.stderr +++ b/src/test/ui/consts/const-size_of-cycle.stderr @@ -1,22 +1,27 @@ -error[E0391]: cycle detected when computing layout of `Foo` +error[E0391]: cycle detected when const-evaluating + checking `Foo::bytes::{{constant}}` + --> $DIR/const-size_of-cycle.rs:16:17 | +LL | bytes: [u8; std::mem::size_of::()] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: ...which requires const-evaluating `Foo::bytes::{{constant}}`... + --> $SRC_DIR/libcore/mem.rs:LL:COL + | +LL | unsafe { intrinsics::size_of::() } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: ...which requires computing layout of `Foo`... note: ...which requires normalizing `ParamEnvAnd { param_env: ParamEnv { caller_bounds: [], reveal: All }, value: [u8; _] }`... note: ...which requires const-evaluating + checking `Foo::bytes::{{constant}}`... --> $DIR/const-size_of-cycle.rs:16:17 | LL | bytes: [u8; std::mem::size_of::()] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ -note: ...which requires const-evaluating `Foo::bytes::{{constant}}`... - --> $SRC_DIR/libcore/mem.rs:LL:COL + = note: ...which again requires const-evaluating + checking `Foo::bytes::{{constant}}`, completing the cycle +note: cycle used when processing `Foo` + --> $DIR/const-size_of-cycle.rs:15:1 | -LL | intrinsics::size_of::() - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: ...which again requires computing layout of `Foo`, completing the cycle -note: cycle used when const-evaluating `Foo::bytes::{{constant}}` - --> $SRC_DIR/libcore/mem.rs:LL:COL - | -LL | intrinsics::size_of::() - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | struct Foo { + | ^^^^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/consts/const-slice-oob.rs b/src/test/ui/consts/const-slice-oob.rs index b71556735d9..cc7f86f97a1 100644 --- a/src/test/ui/consts/const-slice-oob.rs +++ b/src/test/ui/consts/const-slice-oob.rs @@ -14,7 +14,6 @@ const FOO: &'static[u32] = &[1, 2, 3]; const BAR: u32 = FOO[5]; //~^ index out of bounds: the len is 3 but the index is 5 //~| ERROR any use of this value will cause an error -//~| ERROR any use of this value will cause an error fn main() { let _ = BAR; diff --git a/src/test/ui/consts/const-slice-oob.stderr b/src/test/ui/consts/const-slice-oob.stderr index 8fd298a18d2..763afae62ea 100644 --- a/src/test/ui/consts/const-slice-oob.stderr +++ b/src/test/ui/consts/const-slice-oob.stderr @@ -8,20 +8,12 @@ LL | const BAR: u32 = FOO[5]; | = note: #[deny(const_err)] on by default -error: any use of this value will cause an error - --> $DIR/const-slice-oob.rs:14:1 - | -LL | const BAR: u32 = FOO[5]; - | ^^^^^^^^^^^^^^^^^------^ - | | - | index out of bounds: the len is 3 but the index is 5 - error[E0080]: erroneous constant used - --> $DIR/const-slice-oob.rs:20:13 + --> $DIR/const-slice-oob.rs:19:13 | LL | let _ = BAR; | ^^^ referenced constant has errors -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/issues/issue-44415.rs b/src/test/ui/issues/issue-44415.rs index bd50f93945c..6d55422dea0 100644 --- a/src/test/ui/issues/issue-44415.rs +++ b/src/test/ui/issues/issue-44415.rs @@ -8,15 +8,13 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -//~^^^^^^^^^^ ERROR cycle detected when computing layout of - - #![feature(core_intrinsics)] use std::intrinsics; struct Foo { bytes: [u8; unsafe { intrinsics::size_of::() }], + //~^ ERROR cycle detected when const-evaluating + checking x: usize, } diff --git a/src/test/ui/issues/issue-44415.stderr b/src/test/ui/issues/issue-44415.stderr index f20c2c73359..4345a5dbf43 100644 --- a/src/test/ui/issues/issue-44415.stderr +++ b/src/test/ui/issues/issue-44415.stderr @@ -1,22 +1,27 @@ -error[E0391]: cycle detected when computing layout of `Foo` - | -note: ...which requires normalizing `ParamEnvAnd { param_env: ParamEnv { caller_bounds: [], reveal: All }, value: [u8; _] }`... -note: ...which requires const-evaluating + checking `Foo::bytes::{{constant}}`... - --> $DIR/issue-44415.rs:19:17 +error[E0391]: cycle detected when const-evaluating + checking `Foo::bytes::{{constant}}` + --> $DIR/issue-44415.rs:17:17 | LL | bytes: [u8; unsafe { intrinsics::size_of::() }], | ^^^^^^ + | note: ...which requires const-evaluating `Foo::bytes::{{constant}}`... - --> $DIR/issue-44415.rs:19:26 + --> $DIR/issue-44415.rs:17:26 | LL | bytes: [u8; unsafe { intrinsics::size_of::() }], | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: ...which again requires computing layout of `Foo`, completing the cycle -note: cycle used when const-evaluating `Foo::bytes::{{constant}}` - --> $DIR/issue-44415.rs:19:26 +note: ...which requires computing layout of `Foo`... +note: ...which requires normalizing `ParamEnvAnd { param_env: ParamEnv { caller_bounds: [], reveal: All }, value: [u8; _] }`... +note: ...which requires const-evaluating + checking `Foo::bytes::{{constant}}`... + --> $DIR/issue-44415.rs:17:17 | LL | bytes: [u8; unsafe { intrinsics::size_of::() }], - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^ + = note: ...which again requires const-evaluating + checking `Foo::bytes::{{constant}}`, completing the cycle +note: cycle used when processing `Foo` + --> $DIR/issue-44415.rs:16:1 + | +LL | struct Foo { + | ^^^^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/recursion/recursive-static-definition.stderr b/src/test/ui/recursion/recursive-static-definition.stderr index 5bd0f90afbc..c9a5e5eb447 100644 --- a/src/test/ui/recursion/recursive-static-definition.stderr +++ b/src/test/ui/recursion/recursive-static-definition.stderr @@ -4,6 +4,11 @@ error[E0391]: cycle detected when const-evaluating `FOO` LL | pub static FOO: u32 = FOO; | ^^^ | +note: ...which requires const-evaluating `FOO`... + --> $DIR/recursive-static-definition.rs:11:1 + | +LL | pub static FOO: u32 = FOO; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: ...which again requires const-evaluating `FOO`, completing the cycle note: cycle used when const-evaluating + checking `FOO` --> $DIR/recursive-static-definition.rs:11:1