diff --git a/compiler/rustc_errors/src/emitter.rs b/compiler/rustc_errors/src/emitter.rs index 00882bb287a4f..ea62e21523028 100644 --- a/compiler/rustc_errors/src/emitter.rs +++ b/compiler/rustc_errors/src/emitter.rs @@ -645,7 +645,7 @@ impl EmitterWriter { margin: Margin, ) { // Tabs are assumed to have been replaced by spaces in calling code. - assert!(!source_string.contains('\t')); + debug_assert!(!source_string.contains('\t')); let line_len = source_string.len(); // Create the source line we will highlight. let left = margin.left(line_len); diff --git a/compiler/rustc_errors/src/styled_buffer.rs b/compiler/rustc_errors/src/styled_buffer.rs index a4dd0f391bd3a..ef71ee36ea36c 100644 --- a/compiler/rustc_errors/src/styled_buffer.rs +++ b/compiler/rustc_errors/src/styled_buffer.rs @@ -15,7 +15,7 @@ impl StyledBuffer { pub fn render(&self) -> Vec> { // Tabs are assumed to have been replaced by spaces in calling code. - assert!(self.text.iter().all(|r| !r.contains(&'\t'))); + debug_assert!(self.text.iter().all(|r| !r.contains(&'\t'))); let mut output: Vec> = vec![]; let mut styled_vec: Vec = vec![]; diff --git a/compiler/rustc_lint_defs/src/builtin.rs b/compiler/rustc_lint_defs/src/builtin.rs index 199be00990761..4337600384008 100644 --- a/compiler/rustc_lint_defs/src/builtin.rs +++ b/compiler/rustc_lint_defs/src/builtin.rs @@ -255,6 +255,10 @@ declare_lint! { pub CONST_ERR, Deny, "constant evaluation encountered erroneous expression", + @future_incompatible = FutureIncompatibleInfo { + reference: "issue #71800 ", + edition: None, + }; report_in_external_macro } diff --git a/compiler/rustc_typeck/src/check/check.rs b/compiler/rustc_typeck/src/check/check.rs index 0935dd86240b6..8e2b0bfd6629e 100644 --- a/compiler/rustc_typeck/src/check/check.rs +++ b/compiler/rustc_typeck/src/check/check.rs @@ -203,7 +203,6 @@ pub(super) fn check_fn<'a, 'tcx>( // possible cases. fcx.check_expr(&body.value); fcx.require_type_is_sized(declared_ret_ty, decl.output.span(), traits::SizedReturnType); - tcx.sess.delay_span_bug(decl.output.span(), "`!Sized` return type"); } else { fcx.require_type_is_sized(declared_ret_ty, decl.output.span(), traits::SizedReturnType); fcx.check_return_expr(&body.value); diff --git a/compiler/rustc_typeck/src/check/expr.rs b/compiler/rustc_typeck/src/check/expr.rs index 04c83a7665caa..33b1c0bb2c97c 100644 --- a/compiler/rustc_typeck/src/check/expr.rs +++ b/compiler/rustc_typeck/src/check/expr.rs @@ -1974,7 +1974,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { field_path.push(candidate_field.ident.normalize_to_macros_2_0()); let field_ty = candidate_field.ty(self.tcx, subst); - if let Some((nested_fields, _)) = self.get_field_candidates(span, &field_ty) { + if let Some((nested_fields, subst)) = self.get_field_candidates(span, &field_ty) { for field in nested_fields.iter() { let ident = field.ident.normalize_to_macros_2_0(); if ident == target_field { diff --git a/src/test/ui/array-slice-vec/array_const_index-0.rs b/src/test/ui/array-slice-vec/array_const_index-0.rs index 4021dfcc6eb7d..9ff7e2c569ab9 100644 --- a/src/test/ui/array-slice-vec/array_const_index-0.rs +++ b/src/test/ui/array-slice-vec/array_const_index-0.rs @@ -2,6 +2,7 @@ const A: &'static [i32] = &[]; const B: i32 = (&A)[1]; //~^ index out of bounds: the length is 0 but the index is 1 //~| ERROR any use of this value will cause an error +//~| WARN this was previously accepted by the compiler but is being phased out fn main() { let _ = B; diff --git a/src/test/ui/array-slice-vec/array_const_index-0.stderr b/src/test/ui/array-slice-vec/array_const_index-0.stderr index 7ccc3aa087e1e..641705e1c6875 100644 --- a/src/test/ui/array-slice-vec/array_const_index-0.stderr +++ b/src/test/ui/array-slice-vec/array_const_index-0.stderr @@ -7,6 +7,8 @@ LL | const B: i32 = (&A)[1]; | index out of bounds: the length is 0 but the index is 1 | = note: `#[deny(const_err)]` on by default + = 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 #71800 error: aborting due to previous error diff --git a/src/test/ui/array-slice-vec/array_const_index-1.rs b/src/test/ui/array-slice-vec/array_const_index-1.rs index d0ee1796c0ffc..f4326189c1917 100644 --- a/src/test/ui/array-slice-vec/array_const_index-1.rs +++ b/src/test/ui/array-slice-vec/array_const_index-1.rs @@ -2,6 +2,7 @@ const A: [i32; 0] = []; const B: i32 = A[1]; //~^ index out of bounds: the length is 0 but the index is 1 //~| ERROR any use of this value will cause an error +//~| WARN this was previously accepted by the compiler but is being phased out fn main() { let _ = B; diff --git a/src/test/ui/array-slice-vec/array_const_index-1.stderr b/src/test/ui/array-slice-vec/array_const_index-1.stderr index 37de61b9df01b..4d52d38af5e17 100644 --- a/src/test/ui/array-slice-vec/array_const_index-1.stderr +++ b/src/test/ui/array-slice-vec/array_const_index-1.stderr @@ -7,6 +7,8 @@ LL | const B: i32 = A[1]; | index out of bounds: the length is 0 but the index is 1 | = note: `#[deny(const_err)]` on by default + = 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 #71800 error: aborting due to previous error diff --git a/src/test/ui/associated-consts/defaults-not-assumed-fail.rs b/src/test/ui/associated-consts/defaults-not-assumed-fail.rs index b0a4c7722e3ce..3936e6a3bc722 100644 --- a/src/test/ui/associated-consts/defaults-not-assumed-fail.rs +++ b/src/test/ui/associated-consts/defaults-not-assumed-fail.rs @@ -7,6 +7,7 @@ trait Tr { // `Self::A` must not be assumed to hold inside the trait. const B: u8 = Self::A + 1; //~^ ERROR any use of this value will cause an error + //~| WARN this was previously accepted by the compiler but is being phased out } // An impl that doesn't override any constant will NOT cause a const eval error @@ -33,6 +34,7 @@ fn main() { assert_eq!(<() as Tr>::B, 0); // causes the error above //~^ ERROR evaluation of constant value failed //~| ERROR erroneous constant used + //~| WARN this was previously accepted by the compiler but is being phased out assert_eq!(::A, 254); assert_eq!(::B, 255); diff --git a/src/test/ui/associated-consts/defaults-not-assumed-fail.stderr b/src/test/ui/associated-consts/defaults-not-assumed-fail.stderr index cbaaed0508b98..d034a50299d50 100644 --- a/src/test/ui/associated-consts/defaults-not-assumed-fail.stderr +++ b/src/test/ui/associated-consts/defaults-not-assumed-fail.stderr @@ -7,19 +7,23 @@ LL | const B: u8 = Self::A + 1; | attempt to compute `u8::MAX + 1_u8`, which would overflow | = note: `#[deny(const_err)]` on by default + = 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 #71800 error[E0080]: evaluation of constant value failed - --> $DIR/defaults-not-assumed-fail.rs:33:16 + --> $DIR/defaults-not-assumed-fail.rs:34:16 | LL | assert_eq!(<() as Tr>::B, 0); // causes the error above | ^^^^^^^^^^^^^ referenced constant has errors error: erroneous constant used - --> $DIR/defaults-not-assumed-fail.rs:33:5 + --> $DIR/defaults-not-assumed-fail.rs:34:5 | LL | assert_eq!(<() as Tr>::B, 0); // causes the error above | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors | + = 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 #71800 = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 3 previous errors diff --git a/src/test/ui/const-ptr/out_of_bounds_read.stderr b/src/test/ui/const-ptr/out_of_bounds_read.stderr index ca65a079947e0..87b7c377b0036 100644 --- a/src/test/ui/const-ptr/out_of_bounds_read.stderr +++ b/src/test/ui/const-ptr/out_of_bounds_read.stderr @@ -15,6 +15,8 @@ LL | const _READ: u32 = unsafe { ptr::read(PAST_END_PTR) }; | ------------------------------------------------------ | = note: `#[deny(const_err)]` on by default + = 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 #71800 error: any use of this value will cause an error --> $SRC_DIR/core/src/intrinsics.rs:LL:COL @@ -32,6 +34,9 @@ LL | unsafe { copy_nonoverlapping(src, dst, count) } | LL | const _CONST_READ: u32 = unsafe { PAST_END_PTR.read() }; | -------------------------------------------------------- + | + = 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 #71800 error: any use of this value will cause an error --> $SRC_DIR/core/src/intrinsics.rs:LL:COL @@ -49,6 +54,9 @@ LL | unsafe { copy_nonoverlapping(src, dst, count) } | LL | const _MUT_READ: u32 = unsafe { (PAST_END_PTR as *mut u32).read() }; | -------------------------------------------------------------------- + | + = 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 #71800 error: aborting due to 3 previous errors diff --git a/src/test/ui/consts/assoc_const_generic_impl.rs b/src/test/ui/consts/assoc_const_generic_impl.rs index 83f334dca9e83..71d947b0c2c70 100644 --- a/src/test/ui/consts/assoc_const_generic_impl.rs +++ b/src/test/ui/consts/assoc_const_generic_impl.rs @@ -9,6 +9,7 @@ trait ZeroSized: Sized { impl ZeroSized for T { const I_AM_ZERO_SIZED: () = [()][std::mem::size_of::()]; //~ WARN any use of this value + //~| WARN this was previously accepted by the compiler but is being phased out fn requires_zero_size(self) { let () = Self::I_AM_ZERO_SIZED; //~ ERROR erroneous constant encountered println!("requires_zero_size called"); diff --git a/src/test/ui/consts/assoc_const_generic_impl.stderr b/src/test/ui/consts/assoc_const_generic_impl.stderr index db64ebe0c4ae0..96cb904fa1b19 100644 --- a/src/test/ui/consts/assoc_const_generic_impl.stderr +++ b/src/test/ui/consts/assoc_const_generic_impl.stderr @@ -11,9 +11,11 @@ note: the lint level is defined here | LL | #![warn(const_err)] | ^^^^^^^^^ + = 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 #71800 error: erroneous constant encountered - --> $DIR/assoc_const_generic_impl.rs:13:18 + --> $DIR/assoc_const_generic_impl.rs:14:18 | LL | let () = Self::I_AM_ZERO_SIZED; | ^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/consts/assume-type-intrinsics.stderr b/src/test/ui/consts/assume-type-intrinsics.stderr index ed09f74e9b1f2..d46ce44b7ba2d 100644 --- a/src/test/ui/consts/assume-type-intrinsics.stderr +++ b/src/test/ui/consts/assume-type-intrinsics.stderr @@ -16,6 +16,8 @@ LL | | }; | |______- | = note: `#[deny(const_err)]` on by default + = 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 #71800 error: aborting due to previous error diff --git a/src/test/ui/consts/const-err-early.rs b/src/test/ui/consts/const-err-early.rs index 13dfe7fac9900..d8f7635fe9bbe 100644 --- a/src/test/ui/consts/const-err-early.rs +++ b/src/test/ui/consts/const-err-early.rs @@ -1,10 +1,15 @@ #![deny(const_err)] pub const A: i8 = -i8::MIN; //~ ERROR const_err +//~| WARN this was previously accepted by the compiler but is being phased out pub const B: u8 = 200u8 + 200u8; //~ ERROR const_err +//~| WARN this was previously accepted by the compiler but is being phased out pub const C: u8 = 200u8 * 4; //~ ERROR const_err +//~| WARN this was previously accepted by the compiler but is being phased out pub const D: u8 = 42u8 - (42u8 + 1); //~ ERROR const_err +//~| WARN this was previously accepted by the compiler but is being phased out pub const E: u8 = [5u8][1]; //~ ERROR const_err +//~| WARN this was previously accepted by the compiler but is being phased out fn main() { let _a = A; diff --git a/src/test/ui/consts/const-err-early.stderr b/src/test/ui/consts/const-err-early.stderr index ec55139f17345..2b3d881738762 100644 --- a/src/test/ui/consts/const-err-early.stderr +++ b/src/test/ui/consts/const-err-early.stderr @@ -11,38 +11,52 @@ note: the lint level is defined here | LL | #![deny(const_err)] | ^^^^^^^^^ + = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-err-early.rs:4:19 + --> $DIR/const-err-early.rs:5:19 | LL | pub const B: u8 = 200u8 + 200u8; | ------------------^^^^^^^^^^^^^- | | | attempt to compute `200_u8 + 200_u8`, which would overflow + | + = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-err-early.rs:5:19 + --> $DIR/const-err-early.rs:7:19 | LL | pub const C: u8 = 200u8 * 4; | ------------------^^^^^^^^^- | | | attempt to compute `200_u8 * 4_u8`, which would overflow + | + = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-err-early.rs:6:19 + --> $DIR/const-err-early.rs:9:19 | LL | pub const D: u8 = 42u8 - (42u8 + 1); | ------------------^^^^^^^^^^^^^^^^^- | | | attempt to compute `42_u8 - 43_u8`, which would overflow + | + = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-err-early.rs:7:19 + --> $DIR/const-err-early.rs:11:19 | LL | pub const E: u8 = [5u8][1]; | ------------------^^^^^^^^- | | | index out of bounds: the length is 1 but the index is 1 + | + = 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 #71800 error: aborting due to 5 previous errors diff --git a/src/test/ui/consts/const-err-multi.rs b/src/test/ui/consts/const-err-multi.rs index ce74fae98162d..62552e1476ce2 100644 --- a/src/test/ui/consts/const-err-multi.rs +++ b/src/test/ui/consts/const-err-multi.rs @@ -2,12 +2,16 @@ pub const A: i8 = -i8::MIN; //~^ ERROR const_err +//~| WARN this was previously accepted by the compiler but is being phased out pub const B: i8 = A; //~^ ERROR const_err +//~| WARN this was previously accepted by the compiler but is being phased out pub const C: u8 = A as u8; //~^ ERROR const_err +//~| WARN this was previously accepted by the compiler but is being phased out pub const D: i8 = 50 - A; //~^ ERROR const_err +//~| WARN this was previously accepted by the compiler but is being phased out fn main() { let _ = (A, B, C, D); diff --git a/src/test/ui/consts/const-err-multi.stderr b/src/test/ui/consts/const-err-multi.stderr index b3123b4e35928..c8172e83d10e2 100644 --- a/src/test/ui/consts/const-err-multi.stderr +++ b/src/test/ui/consts/const-err-multi.stderr @@ -11,30 +11,41 @@ note: the lint level is defined here | LL | #![deny(const_err)] | ^^^^^^^^^ + = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-err-multi.rs:5:19 + --> $DIR/const-err-multi.rs:6:19 | LL | pub const B: i8 = A; | ------------------^- | | | referenced constant has errors + | + = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-err-multi.rs:7:19 + --> $DIR/const-err-multi.rs:9:19 | LL | pub const C: u8 = A as u8; | ------------------^------- | | | referenced constant has errors + | + = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-err-multi.rs:9:24 + --> $DIR/const-err-multi.rs:12:24 | LL | pub const D: i8 = 50 - A; | -----------------------^- | | | referenced constant has errors + | + = 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 #71800 error: aborting due to 4 previous errors diff --git a/src/test/ui/consts/const-err.rs b/src/test/ui/consts/const-err.rs index d1c5f4f3f32ee..031f2121a1ee2 100644 --- a/src/test/ui/consts/const-err.rs +++ b/src/test/ui/consts/const-err.rs @@ -10,6 +10,7 @@ fn black_box(_: T) { const FOO: u8 = [5u8][1]; //~^ WARN any use of this value will cause an error +//~| WARN this was previously accepted by the compiler but is being phased out 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 693b74c2c2f61..0c963874a8496 100644 --- a/src/test/ui/consts/const-err.stderr +++ b/src/test/ui/consts/const-err.stderr @@ -11,15 +11,17 @@ note: the lint level is defined here | LL | #![warn(const_err)] | ^^^^^^^^^ + = 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 #71800 error[E0080]: erroneous constant used - --> $DIR/const-err.rs:15:16 + --> $DIR/const-err.rs:16:16 | LL | black_box((FOO, FOO)); | ^^^ referenced constant has errors error[E0080]: erroneous constant used - --> $DIR/const-err.rs:15:21 + --> $DIR/const-err.rs:16:21 | LL | black_box((FOO, FOO)); | ^^^ referenced constant has errors diff --git a/src/test/ui/consts/const-eval/conditional_array_execution.rs b/src/test/ui/consts/const-eval/conditional_array_execution.rs index 2058d2e218473..9b99a685b6370 100644 --- a/src/test/ui/consts/const-eval/conditional_array_execution.rs +++ b/src/test/ui/consts/const-eval/conditional_array_execution.rs @@ -6,9 +6,11 @@ const X: u32 = 5; const Y: u32 = 6; const FOO: u32 = [X - Y, Y - X][(X < Y) as usize]; //~^ WARN any use of this value will cause an error +//~| WARN this was previously accepted by the compiler but is being phased out fn main() { println!("{}", FOO); //~^ ERROR //~| WARN erroneous constant used [const_err] + //~| WARN this was previously accepted by the compiler but is being phased out } diff --git a/src/test/ui/consts/const-eval/conditional_array_execution.stderr b/src/test/ui/consts/const-eval/conditional_array_execution.stderr index c2adff116ef20..356a7f58d8562 100644 --- a/src/test/ui/consts/const-eval/conditional_array_execution.stderr +++ b/src/test/ui/consts/const-eval/conditional_array_execution.stderr @@ -11,18 +11,23 @@ note: the lint level is defined here | LL | #![warn(const_err)] | ^^^^^^^^^ + = 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 #71800 error[E0080]: evaluation of constant value failed - --> $DIR/conditional_array_execution.rs:11:20 + --> $DIR/conditional_array_execution.rs:12:20 | LL | println!("{}", FOO); | ^^^ referenced constant has errors warning: erroneous constant used - --> $DIR/conditional_array_execution.rs:11:20 + --> $DIR/conditional_array_execution.rs:12:20 | LL | println!("{}", FOO); | ^^^ referenced constant has errors + | + = 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 #71800 error: aborting due to previous error; 2 warnings emitted 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 57a9dd55c8b55..b11f7d6983bfa 100644 --- a/src/test/ui/consts/const-eval/const-eval-overflow2.rs +++ b/src/test/ui/consts/const-eval/const-eval-overflow2.rs @@ -14,46 +14,54 @@ const VALS_I8: (i8,) = i8::MIN - 1, ); //~^^ ERROR any use of this value will cause an error + //~| WARN this was previously accepted by the compiler but is being phased out const VALS_I16: (i16,) = ( i16::MIN - 1, ); //~^^ ERROR any use of this value will cause an error + //~| WARN this was previously accepted by the compiler but is being phased out const VALS_I32: (i32,) = ( i32::MIN - 1, ); //~^^ ERROR any use of this value will cause an error + //~| WARN this was previously accepted by the compiler but is being phased out const VALS_I64: (i64,) = ( i64::MIN - 1, ); //~^^ ERROR any use of this value will cause an error + //~| WARN this was previously accepted by the compiler but is being phased out const VALS_U8: (u8,) = ( u8::MIN - 1, ); //~^^ ERROR any use of this value will cause an error + //~| WARN this was previously accepted by the compiler but is being phased out const VALS_U16: (u16,) = ( u16::MIN - 1, ); //~^^ ERROR any use of this value will cause an error + //~| WARN this was previously accepted by the compiler but is being phased out const VALS_U32: (u32,) = ( u32::MIN - 1, ); //~^^ ERROR any use of this value will cause an error + //~| WARN this was previously accepted by the compiler but is being phased out const VALS_U64: (u64,) = ( u64::MIN - 1, ); //~^^ ERROR any use of this value will cause an error + //~| WARN this was previously accepted by the compiler but is being phased out fn main() { foo(VALS_I8); 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 8864bc170f2ee..66e86c352d154 100644 --- a/src/test/ui/consts/const-eval/const-eval-overflow2.stderr +++ b/src/test/ui/consts/const-eval/const-eval-overflow2.stderr @@ -13,9 +13,11 @@ note: the lint level is defined here | LL | #![deny(const_err)] | ^^^^^^^^^ + = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-eval-overflow2.rs:20:6 + --> $DIR/const-eval-overflow2.rs:21:6 | LL | / const VALS_I16: (i16,) = LL | | ( @@ -23,9 +25,12 @@ LL | | i16::MIN - 1, | | ^^^^^^^^^^^^ attempt to compute `i16::MIN - 1_i16`, which would overflow LL | | ); | |_______- + | + = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-eval-overflow2.rs:26:6 + --> $DIR/const-eval-overflow2.rs:28:6 | LL | / const VALS_I32: (i32,) = LL | | ( @@ -33,9 +38,12 @@ LL | | i32::MIN - 1, | | ^^^^^^^^^^^^ attempt to compute `i32::MIN - 1_i32`, which would overflow LL | | ); | |_______- + | + = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-eval-overflow2.rs:32:6 + --> $DIR/const-eval-overflow2.rs:35:6 | LL | / const VALS_I64: (i64,) = LL | | ( @@ -43,9 +51,12 @@ LL | | i64::MIN - 1, | | ^^^^^^^^^^^^ attempt to compute `i64::MIN - 1_i64`, which would overflow LL | | ); | |_______- + | + = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-eval-overflow2.rs:38:6 + --> $DIR/const-eval-overflow2.rs:42:6 | LL | / const VALS_U8: (u8,) = LL | | ( @@ -53,27 +64,36 @@ LL | | u8::MIN - 1, | | ^^^^^^^^^^^ attempt to compute `0_u8 - 1_u8`, which would overflow LL | | ); | |_______- + | + = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-eval-overflow2.rs:43:6 + --> $DIR/const-eval-overflow2.rs:48:6 | LL | / const VALS_U16: (u16,) = ( LL | | u16::MIN - 1, | | ^^^^^^^^^^^^ attempt to compute `0_u16 - 1_u16`, which would overflow LL | | ); | |_______- + | + = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-eval-overflow2.rs:48:6 + --> $DIR/const-eval-overflow2.rs:54:6 | LL | / const VALS_U32: (u32,) = ( LL | | u32::MIN - 1, | | ^^^^^^^^^^^^ attempt to compute `0_u32 - 1_u32`, which would overflow LL | | ); | |_______- + | + = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-eval-overflow2.rs:54:6 + --> $DIR/const-eval-overflow2.rs:61:6 | LL | / const VALS_U64: (u64,) = LL | | ( @@ -81,6 +101,9 @@ LL | | u64::MIN - 1, | | ^^^^^^^^^^^^ attempt to compute `0_u64 - 1_u64`, which would overflow LL | | ); | |_______- + | + = 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 #71800 error: aborting due to 8 previous errors 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 e87952ab0f438..9c3ad8ef9b44e 100644 --- a/src/test/ui/consts/const-eval/const-eval-overflow2b.rs +++ b/src/test/ui/consts/const-eval/const-eval-overflow2b.rs @@ -14,46 +14,54 @@ const VALS_I8: (i8,) = i8::MAX + 1, ); //~^^ ERROR any use of this value will cause an error + //~| WARN this was previously accepted by the compiler but is being phased out const VALS_I16: (i16,) = ( i16::MAX + 1, ); //~^^ ERROR any use of this value will cause an error + //~| WARN this was previously accepted by the compiler but is being phased out const VALS_I32: (i32,) = ( i32::MAX + 1, ); //~^^ ERROR any use of this value will cause an error + //~| WARN this was previously accepted by the compiler but is being phased out const VALS_I64: (i64,) = ( i64::MAX + 1, ); //~^^ ERROR any use of this value will cause an error + //~| WARN this was previously accepted by the compiler but is being phased out const VALS_U8: (u8,) = ( u8::MAX + 1, ); //~^^ ERROR any use of this value will cause an error + //~| WARN this was previously accepted by the compiler but is being phased out const VALS_U16: (u16,) = ( u16::MAX + 1, ); //~^^ ERROR any use of this value will cause an error + //~| WARN this was previously accepted by the compiler but is being phased out const VALS_U32: (u32,) = ( u32::MAX + 1, ); //~^^ ERROR any use of this value will cause an error + //~| WARN this was previously accepted by the compiler but is being phased out const VALS_U64: (u64,) = ( u64::MAX + 1, ); //~^^ ERROR any use of this value will cause an error + //~| WARN this was previously accepted by the compiler but is being phased out fn main() { foo(VALS_I8); 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 e66e80c8f1937..3401ba4776500 100644 --- a/src/test/ui/consts/const-eval/const-eval-overflow2b.stderr +++ b/src/test/ui/consts/const-eval/const-eval-overflow2b.stderr @@ -13,9 +13,11 @@ note: the lint level is defined here | LL | #![deny(const_err)] | ^^^^^^^^^ + = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-eval-overflow2b.rs:20:6 + --> $DIR/const-eval-overflow2b.rs:21:6 | LL | / const VALS_I16: (i16,) = LL | | ( @@ -23,9 +25,12 @@ LL | | i16::MAX + 1, | | ^^^^^^^^^^^^ attempt to compute `i16::MAX + 1_i16`, which would overflow LL | | ); | |_______- + | + = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-eval-overflow2b.rs:26:6 + --> $DIR/const-eval-overflow2b.rs:28:6 | LL | / const VALS_I32: (i32,) = LL | | ( @@ -33,9 +38,12 @@ LL | | i32::MAX + 1, | | ^^^^^^^^^^^^ attempt to compute `i32::MAX + 1_i32`, which would overflow LL | | ); | |_______- + | + = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-eval-overflow2b.rs:32:6 + --> $DIR/const-eval-overflow2b.rs:35:6 | LL | / const VALS_I64: (i64,) = LL | | ( @@ -43,9 +51,12 @@ LL | | i64::MAX + 1, | | ^^^^^^^^^^^^ attempt to compute `i64::MAX + 1_i64`, which would overflow LL | | ); | |_______- + | + = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-eval-overflow2b.rs:38:6 + --> $DIR/const-eval-overflow2b.rs:42:6 | LL | / const VALS_U8: (u8,) = LL | | ( @@ -53,27 +64,36 @@ LL | | u8::MAX + 1, | | ^^^^^^^^^^^ attempt to compute `u8::MAX + 1_u8`, which would overflow LL | | ); | |_______- + | + = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-eval-overflow2b.rs:43:6 + --> $DIR/const-eval-overflow2b.rs:48:6 | LL | / const VALS_U16: (u16,) = ( LL | | u16::MAX + 1, | | ^^^^^^^^^^^^ attempt to compute `u16::MAX + 1_u16`, which would overflow LL | | ); | |_______- + | + = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-eval-overflow2b.rs:48:6 + --> $DIR/const-eval-overflow2b.rs:54:6 | LL | / const VALS_U32: (u32,) = ( LL | | u32::MAX + 1, | | ^^^^^^^^^^^^ attempt to compute `u32::MAX + 1_u32`, which would overflow LL | | ); | |_______- + | + = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-eval-overflow2b.rs:54:6 + --> $DIR/const-eval-overflow2b.rs:61:6 | LL | / const VALS_U64: (u64,) = LL | | ( @@ -81,6 +101,9 @@ LL | | u64::MAX + 1, | | ^^^^^^^^^^^^ attempt to compute `u64::MAX + 1_u64`, which would overflow LL | | ); | |_______- + | + = 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 #71800 error: aborting due to 8 previous errors 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 84d3dd20a924e..bac4d042e23c9 100644 --- a/src/test/ui/consts/const-eval/const-eval-overflow2c.rs +++ b/src/test/ui/consts/const-eval/const-eval-overflow2c.rs @@ -14,46 +14,54 @@ const VALS_I8: (i8,) = i8::MIN * 2, ); //~^^ ERROR any use of this value will cause an error + //~| WARN this was previously accepted by the compiler but is being phased out const VALS_I16: (i16,) = ( i16::MIN * 2, ); //~^^ ERROR any use of this value will cause an error + //~| WARN this was previously accepted by the compiler but is being phased out const VALS_I32: (i32,) = ( i32::MIN * 2, ); //~^^ ERROR any use of this value will cause an error + //~| WARN this was previously accepted by the compiler but is being phased out const VALS_I64: (i64,) = ( i64::MIN * 2, ); //~^^ ERROR any use of this value will cause an error + //~| WARN this was previously accepted by the compiler but is being phased out const VALS_U8: (u8,) = ( u8::MAX * 2, ); //~^^ ERROR any use of this value will cause an error + //~| WARN this was previously accepted by the compiler but is being phased out const VALS_U16: (u16,) = ( u16::MAX * 2, ); //~^^ ERROR any use of this value will cause an error + //~| WARN this was previously accepted by the compiler but is being phased out const VALS_U32: (u32,) = ( u32::MAX * 2, ); //~^^ ERROR any use of this value will cause an error + //~| WARN this was previously accepted by the compiler but is being phased out const VALS_U64: (u64,) = ( u64::MAX * 2, ); //~^^ ERROR any use of this value will cause an error + //~| WARN this was previously accepted by the compiler but is being phased out fn main() { foo(VALS_I8); 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 10e308938f3a1..93c64090f0eeb 100644 --- a/src/test/ui/consts/const-eval/const-eval-overflow2c.stderr +++ b/src/test/ui/consts/const-eval/const-eval-overflow2c.stderr @@ -13,9 +13,11 @@ note: the lint level is defined here | LL | #![deny(const_err)] | ^^^^^^^^^ + = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-eval-overflow2c.rs:20:6 + --> $DIR/const-eval-overflow2c.rs:21:6 | LL | / const VALS_I16: (i16,) = LL | | ( @@ -23,9 +25,12 @@ LL | | i16::MIN * 2, | | ^^^^^^^^^^^^ attempt to compute `i16::MIN * 2_i16`, which would overflow LL | | ); | |_______- + | + = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-eval-overflow2c.rs:26:6 + --> $DIR/const-eval-overflow2c.rs:28:6 | LL | / const VALS_I32: (i32,) = LL | | ( @@ -33,9 +38,12 @@ LL | | i32::MIN * 2, | | ^^^^^^^^^^^^ attempt to compute `i32::MIN * 2_i32`, which would overflow LL | | ); | |_______- + | + = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-eval-overflow2c.rs:32:6 + --> $DIR/const-eval-overflow2c.rs:35:6 | LL | / const VALS_I64: (i64,) = LL | | ( @@ -43,9 +51,12 @@ LL | | i64::MIN * 2, | | ^^^^^^^^^^^^ attempt to compute `i64::MIN * 2_i64`, which would overflow LL | | ); | |_______- + | + = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-eval-overflow2c.rs:38:6 + --> $DIR/const-eval-overflow2c.rs:42:6 | LL | / const VALS_U8: (u8,) = LL | | ( @@ -53,27 +64,36 @@ LL | | u8::MAX * 2, | | ^^^^^^^^^^^ attempt to compute `u8::MAX * 2_u8`, which would overflow LL | | ); | |_______- + | + = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-eval-overflow2c.rs:43:6 + --> $DIR/const-eval-overflow2c.rs:48:6 | LL | / const VALS_U16: (u16,) = ( LL | | u16::MAX * 2, | | ^^^^^^^^^^^^ attempt to compute `u16::MAX * 2_u16`, which would overflow LL | | ); | |_______- + | + = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-eval-overflow2c.rs:48:6 + --> $DIR/const-eval-overflow2c.rs:54:6 | LL | / const VALS_U32: (u32,) = ( LL | | u32::MAX * 2, | | ^^^^^^^^^^^^ attempt to compute `u32::MAX * 2_u32`, which would overflow LL | | ); | |_______- + | + = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-eval-overflow2c.rs:54:6 + --> $DIR/const-eval-overflow2c.rs:61:6 | LL | / const VALS_U64: (u64,) = LL | | ( @@ -81,6 +101,9 @@ LL | | u64::MAX * 2, | | ^^^^^^^^^^^^ attempt to compute `u64::MAX * 2_u64`, which would overflow LL | | ); | |_______- + | + = 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 #71800 error: aborting due to 8 previous errors diff --git a/src/test/ui/consts/const-eval/const-eval-query-stack.rs b/src/test/ui/consts/const-eval/const-eval-query-stack.rs index cbfeca2402666..8c3959cc11a43 100644 --- a/src/test/ui/consts/const-eval/const-eval-query-stack.rs +++ b/src/test/ui/consts/const-eval/const-eval-query-stack.rs @@ -18,6 +18,7 @@ #[warn(const_err)] const X: i32 = 1 / 0; //~WARN any use of this value will cause an error +//~| WARN this was previously accepted by the compiler but is being phased out fn main() { let x: &'static i32 = &X; diff --git a/src/test/ui/consts/const-eval/const-eval-query-stack.stderr b/src/test/ui/consts/const-eval/const-eval-query-stack.stderr index 3e727b84aed10..6a205ce9787f9 100644 --- a/src/test/ui/consts/const-eval/const-eval-query-stack.stderr +++ b/src/test/ui/consts/const-eval/const-eval-query-stack.stderr @@ -11,9 +11,11 @@ note: the lint level is defined here | LL | #[warn(const_err)] | ^^^^^^^^^ + = 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 #71800 error[E0080]: evaluation of constant value failed - --> $DIR/const-eval-query-stack.rs:23:28 + --> $DIR/const-eval-query-stack.rs:24:28 | LL | let x: &'static i32 = &X; | ^ referenced constant has errors diff --git a/src/test/ui/consts/const-eval/const-pointer-values-in-various-types.rs b/src/test/ui/consts/const-eval/const-pointer-values-in-various-types.rs index a2196db780ce0..90bc191020e26 100644 --- a/src/test/ui/consts/const-eval/const-pointer-values-in-various-types.rs +++ b/src/test/ui/consts/const-eval/const-pointer-values-in-various-types.rs @@ -27,12 +27,15 @@ fn main() { const I32_REF_U8_UNION: u8 = unsafe { Nonsense { int_32_ref: &3 }.uint_8 }; //~^ ERROR any use of this value will cause an error + //~| WARN this was previously accepted by the compiler but is being phased out const I32_REF_U16_UNION: u16 = unsafe { Nonsense { int_32_ref: &3 }.uint_16 }; //~^ ERROR any use of this value will cause an error + //~| WARN this was previously accepted by the compiler but is being phased out const I32_REF_U32_UNION: u32 = unsafe { Nonsense { int_32_ref: &3 }.uint_32 }; //~^ ERROR any use of this value will cause an error + //~| WARN this was previously accepted by the compiler but is being phased out const I32_REF_U64_UNION: u64 = unsafe { Nonsense { int_32_ref: &3 }.uint_64 }; //~^ ERROR it is undefined behavior to use this value @@ -42,12 +45,15 @@ fn main() { const I32_REF_I8_UNION: i8 = unsafe { Nonsense { int_32_ref: &3 }.int_8 }; //~^ ERROR any use of this value will cause an error + //~| WARN this was previously accepted by the compiler but is being phased out const I32_REF_I16_UNION: i16 = unsafe { Nonsense { int_32_ref: &3 }.int_16 }; //~^ ERROR any use of this value will cause an error + //~| WARN this was previously accepted by the compiler but is being phased out const I32_REF_I32_UNION: i32 = unsafe { Nonsense { int_32_ref: &3 }.int_32 }; //~^ ERROR any use of this value will cause an error + //~| WARN this was previously accepted by the compiler but is being phased out const I32_REF_I64_UNION: i64 = unsafe { Nonsense { int_32_ref: &3 }.int_64 }; //~^ ERROR it is undefined behavior to use this value @@ -57,55 +63,69 @@ fn main() { const I32_REF_F32_UNION: f32 = unsafe { Nonsense { int_32_ref: &3 }.float_32 }; //~^ ERROR any use of this value will cause an error + //~| WARN this was previously accepted by the compiler but is being phased out const I32_REF_F64_UNION: f64 = unsafe { Nonsense { int_32_ref: &3 }.float_64 }; //~^ ERROR it is undefined behavior to use this value const I32_REF_BOOL_UNION: bool = unsafe { Nonsense { int_32_ref: &3 }.truthy_falsey }; //~^ ERROR any use of this value will cause an error + //~| WARN this was previously accepted by the compiler but is being phased out const I32_REF_CHAR_UNION: char = unsafe { Nonsense { int_32_ref: &3 }.character }; //~^ ERROR any use of this value will cause an error + //~| WARN this was previously accepted by the compiler but is being phased out const STR_U8_UNION: u8 = unsafe { Nonsense { stringy: "3" }.uint_8 }; //~^ ERROR any use of this value will cause an error + //~| WARN this was previously accepted by the compiler but is being phased out const STR_U16_UNION: u16 = unsafe { Nonsense { stringy: "3" }.uint_16 }; //~^ ERROR any use of this value will cause an error + //~| WARN this was previously accepted by the compiler but is being phased out const STR_U32_UNION: u32 = unsafe { Nonsense { stringy: "3" }.uint_32 }; //~^ ERROR any use of this value will cause an error + //~| WARN this was previously accepted by the compiler but is being phased out const STR_U64_UNION: u64 = unsafe { Nonsense { stringy: "3" }.uint_64 }; //~^ ERROR it is undefined behavior to use this value const STR_U128_UNION: u128 = unsafe { Nonsense { stringy: "3" }.uint_128 }; //~^ ERROR any use of this value will cause an error + //~| WARN this was previously accepted by the compiler but is being phased out const STR_I8_UNION: i8 = unsafe { Nonsense { stringy: "3" }.int_8 }; //~^ ERROR any use of this value will cause an error + //~| WARN this was previously accepted by the compiler but is being phased out const STR_I16_UNION: i16 = unsafe { Nonsense { stringy: "3" }.int_16 }; //~^ ERROR any use of this value will cause an error + //~| WARN this was previously accepted by the compiler but is being phased out const STR_I32_UNION: i32 = unsafe { Nonsense { stringy: "3" }.int_32 }; //~^ ERROR any use of this value will cause an error + //~| WARN this was previously accepted by the compiler but is being phased out const STR_I64_UNION: i64 = unsafe { Nonsense { stringy: "3" }.int_64 }; //~^ ERROR it is undefined behavior to use this value const STR_I128_UNION: i128 = unsafe { Nonsense { stringy: "3" }.int_128 }; //~^ ERROR any use of this value will cause an error + //~| WARN this was previously accepted by the compiler but is being phased out const STR_F32_UNION: f32 = unsafe { Nonsense { stringy: "3" }.float_32 }; //~^ ERROR any use of this value will cause an error + //~| WARN this was previously accepted by the compiler but is being phased out const STR_F64_UNION: f64 = unsafe { Nonsense { stringy: "3" }.float_64 }; //~^ ERROR it is undefined behavior to use this value const STR_BOOL_UNION: bool = unsafe { Nonsense { stringy: "3" }.truthy_falsey }; //~^ ERROR any use of this value will cause an error + //~| WARN this was previously accepted by the compiler but is being phased out const STR_CHAR_UNION: char = unsafe { Nonsense { stringy: "3" }.character }; //~^ ERROR any use of this value will cause an error + //~| WARN this was previously accepted by the compiler but is being phased out } diff --git a/src/test/ui/consts/const-eval/const-pointer-values-in-various-types.stderr b/src/test/ui/consts/const-eval/const-pointer-values-in-various-types.stderr index fb0ed1bd5aa94..ccd13784784e1 100644 --- a/src/test/ui/consts/const-eval/const-pointer-values-in-various-types.stderr +++ b/src/test/ui/consts/const-eval/const-pointer-values-in-various-types.stderr @@ -15,25 +15,33 @@ LL | const I32_REF_U8_UNION: u8 = unsafe { Nonsense { int_32_ref: &3 }.uint_ | unable to turn pointer into raw bytes | = note: `#[deny(const_err)]` on by default + = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:31:45 + --> $DIR/const-pointer-values-in-various-types.rs:32:45 | LL | const I32_REF_U16_UNION: u16 = unsafe { Nonsense { int_32_ref: &3 }.uint_16 }; | ----------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | unable to turn pointer into raw bytes + | + = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:34:45 + --> $DIR/const-pointer-values-in-various-types.rs:36:45 | LL | const I32_REF_U32_UNION: u32 = unsafe { Nonsense { int_32_ref: &3 }.uint_32 }; | ----------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | unable to turn pointer into raw bytes + | + = 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 #71800 error[E0080]: it is undefined behavior to use this value - --> $DIR/const-pointer-values-in-various-types.rs:37:5 + --> $DIR/const-pointer-values-in-various-types.rs:40:5 | LL | const I32_REF_U64_UNION: u64 = unsafe { Nonsense { int_32_ref: &3 }.uint_64 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered pointer to alloc18, but expected initialized plain (non-pointer) bytes @@ -41,7 +49,7 @@ LL | const I32_REF_U64_UNION: u64 = unsafe { Nonsense { int_32_ref: &3 }.uin = 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. error[E0080]: it is undefined behavior to use this value - --> $DIR/const-pointer-values-in-various-types.rs:40:5 + --> $DIR/const-pointer-values-in-various-types.rs:43:5 | LL | const I32_REF_U128_UNION: u128 = unsafe { Nonsense { int_32_ref: &3 }.uint_128 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered uninitialized bytes, but expected initialized plain (non-pointer) bytes @@ -49,31 +57,40 @@ LL | const I32_REF_U128_UNION: u128 = unsafe { Nonsense { int_32_ref: &3 }.u = 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. error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:43:43 + --> $DIR/const-pointer-values-in-various-types.rs:46:43 | LL | const I32_REF_I8_UNION: i8 = unsafe { Nonsense { int_32_ref: &3 }.int_8 }; | --------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | unable to turn pointer into raw bytes + | + = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:46:45 + --> $DIR/const-pointer-values-in-various-types.rs:50:45 | LL | const I32_REF_I16_UNION: i16 = unsafe { Nonsense { int_32_ref: &3 }.int_16 }; | ----------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | unable to turn pointer into raw bytes + | + = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:49:45 + --> $DIR/const-pointer-values-in-various-types.rs:54:45 | LL | const I32_REF_I32_UNION: i32 = unsafe { Nonsense { int_32_ref: &3 }.int_32 }; | ----------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | unable to turn pointer into raw bytes + | + = 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 #71800 error[E0080]: it is undefined behavior to use this value - --> $DIR/const-pointer-values-in-various-types.rs:52:5 + --> $DIR/const-pointer-values-in-various-types.rs:58:5 | LL | const I32_REF_I64_UNION: i64 = unsafe { Nonsense { int_32_ref: &3 }.int_64 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered pointer to alloc38, but expected initialized plain (non-pointer) bytes @@ -81,7 +98,7 @@ LL | const I32_REF_I64_UNION: i64 = unsafe { Nonsense { int_32_ref: &3 }.int = 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. error[E0080]: it is undefined behavior to use this value - --> $DIR/const-pointer-values-in-various-types.rs:55:5 + --> $DIR/const-pointer-values-in-various-types.rs:61:5 | LL | const I32_REF_I128_UNION: i128 = unsafe { Nonsense { int_32_ref: &3 }.int_128 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered uninitialized bytes, but expected initialized plain (non-pointer) bytes @@ -89,15 +106,18 @@ LL | const I32_REF_I128_UNION: i128 = unsafe { Nonsense { int_32_ref: &3 }.i = 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. error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:58:45 + --> $DIR/const-pointer-values-in-various-types.rs:64:45 | LL | const I32_REF_F32_UNION: f32 = unsafe { Nonsense { int_32_ref: &3 }.float_32 }; | ----------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | unable to turn pointer into raw bytes + | + = 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 #71800 error[E0080]: it is undefined behavior to use this value - --> $DIR/const-pointer-values-in-various-types.rs:61:5 + --> $DIR/const-pointer-values-in-various-types.rs:68:5 | LL | const I32_REF_F64_UNION: f64 = unsafe { Nonsense { int_32_ref: &3 }.float_64 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered pointer to alloc50, but expected initialized plain (non-pointer) bytes @@ -105,47 +125,62 @@ LL | const I32_REF_F64_UNION: f64 = unsafe { Nonsense { int_32_ref: &3 }.flo = 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. error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:64:47 + --> $DIR/const-pointer-values-in-various-types.rs:71:47 | LL | const I32_REF_BOOL_UNION: bool = unsafe { Nonsense { int_32_ref: &3 }.truthy_falsey }; | ------------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | unable to turn pointer into raw bytes + | + = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:67:47 + --> $DIR/const-pointer-values-in-various-types.rs:75:47 | LL | const I32_REF_CHAR_UNION: char = unsafe { Nonsense { int_32_ref: &3 }.character }; | ------------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | unable to turn pointer into raw bytes + | + = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:70:39 + --> $DIR/const-pointer-values-in-various-types.rs:79:39 | LL | const STR_U8_UNION: u8 = unsafe { Nonsense { stringy: "3" }.uint_8 }; | ----------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | unable to turn pointer into raw bytes + | + = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:73:41 + --> $DIR/const-pointer-values-in-various-types.rs:83:41 | LL | const STR_U16_UNION: u16 = unsafe { Nonsense { stringy: "3" }.uint_16 }; | ------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | unable to turn pointer into raw bytes + | + = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:76:41 + --> $DIR/const-pointer-values-in-various-types.rs:87:41 | LL | const STR_U32_UNION: u32 = unsafe { Nonsense { stringy: "3" }.uint_32 }; | ------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | unable to turn pointer into raw bytes + | + = 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 #71800 error[E0080]: it is undefined behavior to use this value - --> $DIR/const-pointer-values-in-various-types.rs:79:5 + --> $DIR/const-pointer-values-in-various-types.rs:91:5 | LL | const STR_U64_UNION: u64 = unsafe { Nonsense { stringy: "3" }.uint_64 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered pointer to alloc71, but expected initialized plain (non-pointer) bytes @@ -153,39 +188,51 @@ LL | const STR_U64_UNION: u64 = unsafe { Nonsense { stringy: "3" }.uint_64 } = 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. error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:82:43 + --> $DIR/const-pointer-values-in-various-types.rs:94:43 | LL | const STR_U128_UNION: u128 = unsafe { Nonsense { stringy: "3" }.uint_128 }; | --------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | unable to turn pointer into raw bytes + | + = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:85:39 + --> $DIR/const-pointer-values-in-various-types.rs:98:39 | LL | const STR_I8_UNION: i8 = unsafe { Nonsense { stringy: "3" }.int_8 }; | ----------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | unable to turn pointer into raw bytes + | + = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:88:41 + --> $DIR/const-pointer-values-in-various-types.rs:102:41 | LL | const STR_I16_UNION: i16 = unsafe { Nonsense { stringy: "3" }.int_16 }; | ------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | unable to turn pointer into raw bytes + | + = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:91:41 + --> $DIR/const-pointer-values-in-various-types.rs:106:41 | LL | const STR_I32_UNION: i32 = unsafe { Nonsense { stringy: "3" }.int_32 }; | ------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | unable to turn pointer into raw bytes + | + = 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 #71800 error[E0080]: it is undefined behavior to use this value - --> $DIR/const-pointer-values-in-various-types.rs:94:5 + --> $DIR/const-pointer-values-in-various-types.rs:110:5 | LL | const STR_I64_UNION: i64 = unsafe { Nonsense { stringy: "3" }.int_64 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered pointer to alloc86, but expected initialized plain (non-pointer) bytes @@ -193,23 +240,29 @@ LL | const STR_I64_UNION: i64 = unsafe { Nonsense { stringy: "3" }.int_64 }; = 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. error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:97:43 + --> $DIR/const-pointer-values-in-various-types.rs:113:43 | LL | const STR_I128_UNION: i128 = unsafe { Nonsense { stringy: "3" }.int_128 }; | --------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | unable to turn pointer into raw bytes + | + = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:100:41 + --> $DIR/const-pointer-values-in-various-types.rs:117:41 | LL | const STR_F32_UNION: f32 = unsafe { Nonsense { stringy: "3" }.float_32 }; | ------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | unable to turn pointer into raw bytes + | + = 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 #71800 error[E0080]: it is undefined behavior to use this value - --> $DIR/const-pointer-values-in-various-types.rs:103:5 + --> $DIR/const-pointer-values-in-various-types.rs:121:5 | LL | const STR_F64_UNION: f64 = unsafe { Nonsense { stringy: "3" }.float_64 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered pointer to alloc95, but expected initialized plain (non-pointer) bytes @@ -217,20 +270,26 @@ LL | const STR_F64_UNION: f64 = unsafe { Nonsense { stringy: "3" }.float_64 = 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. error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:106:43 + --> $DIR/const-pointer-values-in-various-types.rs:124:43 | LL | const STR_BOOL_UNION: bool = unsafe { Nonsense { stringy: "3" }.truthy_falsey }; | --------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | unable to turn pointer into raw bytes + | + = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:109:43 + --> $DIR/const-pointer-values-in-various-types.rs:128:43 | LL | const STR_CHAR_UNION: char = unsafe { Nonsense { stringy: "3" }.character }; | --------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | unable to turn pointer into raw bytes + | + = 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 #71800 error: aborting due to 29 previous errors diff --git a/src/test/ui/consts/const-eval/const_panic.rs b/src/test/ui/consts/const-eval/const_panic.rs index 799c185fb8e4b..e9d66477d60a5 100644 --- a/src/test/ui/consts/const-eval/const_panic.rs +++ b/src/test/ui/consts/const-eval/const_panic.rs @@ -5,30 +5,40 @@ const MSG: &str = "hello"; const Z: () = std::panic!("cheese"); //~^ ERROR any use of this value will cause an error +//~| WARN this was previously accepted by the compiler but is being phased out const Z2: () = std::panic!(); //~^ ERROR any use of this value will cause an error +//~| WARN this was previously accepted by the compiler but is being phased out const Y: () = std::unreachable!(); //~^ ERROR any use of this value will cause an error +//~| WARN this was previously accepted by the compiler but is being phased out const X: () = std::unimplemented!(); //~^ ERROR any use of this value will cause an error +//~| WARN this was previously accepted by the compiler but is being phased out // const W: () = std::panic!(MSG); //~^ ERROR any use of this value will cause an error +//~| WARN this was previously accepted by the compiler but is being phased out const Z_CORE: () = core::panic!("cheese"); //~^ ERROR any use of this value will cause an error +//~| WARN this was previously accepted by the compiler but is being phased out const Z2_CORE: () = core::panic!(); //~^ ERROR any use of this value will cause an error +//~| WARN this was previously accepted by the compiler but is being phased out const Y_CORE: () = core::unreachable!(); //~^ ERROR any use of this value will cause an error +//~| WARN this was previously accepted by the compiler but is being phased out const X_CORE: () = core::unimplemented!(); //~^ ERROR any use of this value will cause an error +//~| WARN this was previously accepted by the compiler but is being phased out const W_CORE: () = core::panic!(MSG); //~^ ERROR any use of this value will cause an error +//~| WARN this was previously accepted by the compiler but is being phased out diff --git a/src/test/ui/consts/const-eval/const_panic.stderr b/src/test/ui/consts/const-eval/const_panic.stderr index c2711952d5837..713be5b662d54 100644 --- a/src/test/ui/consts/const-eval/const_panic.stderr +++ b/src/test/ui/consts/const-eval/const_panic.stderr @@ -7,96 +7,116 @@ LL | const Z: () = std::panic!("cheese"); | the evaluated program panicked at 'cheese', $DIR/const_panic.rs:6:15 | = note: `#[deny(const_err)]` on by default + = 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 #71800 = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) error: any use of this value will cause an error - --> $DIR/const_panic.rs:9:16 + --> $DIR/const_panic.rs:10:16 | LL | const Z2: () = std::panic!(); | ---------------^^^^^^^^^^^^^- | | - | the evaluated program panicked at 'explicit panic', $DIR/const_panic.rs:9:16 + | the evaluated program panicked at 'explicit panic', $DIR/const_panic.rs:10:16 | + = 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 #71800 = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) error: any use of this value will cause an error - --> $DIR/const_panic.rs:12:15 + --> $DIR/const_panic.rs:14:15 | LL | const Y: () = std::unreachable!(); | --------------^^^^^^^^^^^^^^^^^^^- | | - | the evaluated program panicked at 'internal error: entered unreachable code', $DIR/const_panic.rs:12:15 + | the evaluated program panicked at 'internal error: entered unreachable code', $DIR/const_panic.rs:14:15 | + = 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 #71800 = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) error: any use of this value will cause an error - --> $DIR/const_panic.rs:15:15 + --> $DIR/const_panic.rs:18:15 | LL | const X: () = std::unimplemented!(); | --------------^^^^^^^^^^^^^^^^^^^^^- | | - | the evaluated program panicked at 'not implemented', $DIR/const_panic.rs:15:15 + | the evaluated program panicked at 'not implemented', $DIR/const_panic.rs:18:15 | + = 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 #71800 = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) error: any use of this value will cause an error - --> $DIR/const_panic.rs:18:15 + --> $DIR/const_panic.rs:22:15 | LL | const W: () = std::panic!(MSG); | --------------^^^^^^^^^^^^^^^^- | | - | the evaluated program panicked at 'hello', $DIR/const_panic.rs:18:15 + | the evaluated program panicked at 'hello', $DIR/const_panic.rs:22:15 | + = 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 #71800 = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) error: any use of this value will cause an error - --> $DIR/const_panic.rs:21:20 + --> $DIR/const_panic.rs:26:20 | LL | const Z_CORE: () = core::panic!("cheese"); | -------------------^^^^^^^^^^^^^^^^^^^^^^- | | - | the evaluated program panicked at 'cheese', $DIR/const_panic.rs:21:20 + | the evaluated program panicked at 'cheese', $DIR/const_panic.rs:26:20 | + = 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 #71800 = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) error: any use of this value will cause an error - --> $DIR/const_panic.rs:24:21 + --> $DIR/const_panic.rs:30:21 | LL | const Z2_CORE: () = core::panic!(); | --------------------^^^^^^^^^^^^^^- | | - | the evaluated program panicked at 'explicit panic', $DIR/const_panic.rs:24:21 + | the evaluated program panicked at 'explicit panic', $DIR/const_panic.rs:30:21 | + = 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 #71800 = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) error: any use of this value will cause an error - --> $DIR/const_panic.rs:27:20 + --> $DIR/const_panic.rs:34:20 | LL | const Y_CORE: () = core::unreachable!(); | -------------------^^^^^^^^^^^^^^^^^^^^- | | - | the evaluated program panicked at 'internal error: entered unreachable code', $DIR/const_panic.rs:27:20 + | the evaluated program panicked at 'internal error: entered unreachable code', $DIR/const_panic.rs:34:20 | + = 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 #71800 = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) error: any use of this value will cause an error - --> $DIR/const_panic.rs:30:20 + --> $DIR/const_panic.rs:38:20 | LL | const X_CORE: () = core::unimplemented!(); | -------------------^^^^^^^^^^^^^^^^^^^^^^- | | - | the evaluated program panicked at 'not implemented', $DIR/const_panic.rs:30:20 + | the evaluated program panicked at 'not implemented', $DIR/const_panic.rs:38:20 | + = 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 #71800 = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) error: any use of this value will cause an error - --> $DIR/const_panic.rs:33:20 + --> $DIR/const_panic.rs:42:20 | LL | const W_CORE: () = core::panic!(MSG); | -------------------^^^^^^^^^^^^^^^^^- | | - | the evaluated program panicked at 'hello', $DIR/const_panic.rs:33:20 + | the evaluated program panicked at 'hello', $DIR/const_panic.rs:42:20 | + = 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 #71800 = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 10 previous errors diff --git a/src/test/ui/consts/const-eval/const_panic_libcore_bin.rs b/src/test/ui/consts/const-eval/const_panic_libcore_bin.rs index 6b03e847def14..0eb1e3eb94e52 100644 --- a/src/test/ui/consts/const-eval/const_panic_libcore_bin.rs +++ b/src/test/ui/consts/const-eval/const_panic_libcore_bin.rs @@ -8,12 +8,15 @@ use core::panic::PanicInfo; const Z: () = panic!("cheese"); //~^ ERROR any use of this value will cause an error +//~| WARN this was previously accepted by the compiler but is being phased out const Y: () = unreachable!(); //~^ ERROR any use of this value will cause an error +//~| WARN this was previously accepted by the compiler but is being phased out const X: () = unimplemented!(); //~^ ERROR any use of this value will cause an error +//~| WARN this was previously accepted by the compiler but is being phased out #[lang = "eh_personality"] fn eh() {} diff --git a/src/test/ui/consts/const-eval/const_panic_libcore_bin.stderr b/src/test/ui/consts/const-eval/const_panic_libcore_bin.stderr index 9eeddc464f5ad..7c33610faff0a 100644 --- a/src/test/ui/consts/const-eval/const_panic_libcore_bin.stderr +++ b/src/test/ui/consts/const-eval/const_panic_libcore_bin.stderr @@ -7,26 +7,32 @@ LL | const Z: () = panic!("cheese"); | the evaluated program panicked at 'cheese', $DIR/const_panic_libcore_bin.rs:9:15 | = note: `#[deny(const_err)]` on by default + = 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 #71800 = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) error: any use of this value will cause an error - --> $DIR/const_panic_libcore_bin.rs:12:15 + --> $DIR/const_panic_libcore_bin.rs:13:15 | LL | const Y: () = unreachable!(); | --------------^^^^^^^^^^^^^^- | | - | the evaluated program panicked at 'internal error: entered unreachable code', $DIR/const_panic_libcore_bin.rs:12:15 + | the evaluated program panicked at 'internal error: entered unreachable code', $DIR/const_panic_libcore_bin.rs:13:15 | + = 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 #71800 = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) error: any use of this value will cause an error - --> $DIR/const_panic_libcore_bin.rs:15:15 + --> $DIR/const_panic_libcore_bin.rs:17:15 | LL | const X: () = unimplemented!(); | --------------^^^^^^^^^^^^^^^^- | | - | the evaluated program panicked at 'not implemented', $DIR/const_panic_libcore_bin.rs:15:15 + | the evaluated program panicked at 'not implemented', $DIR/const_panic_libcore_bin.rs:17:15 | + = 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 #71800 = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 3 previous errors diff --git a/src/test/ui/consts/const-eval/const_raw_ptr_ops2.rs b/src/test/ui/consts/const-eval/const_raw_ptr_ops2.rs index d2a7623837a23..c6a623b293276 100644 --- a/src/test/ui/consts/const-eval/const_raw_ptr_ops2.rs +++ b/src/test/ui/consts/const-eval/const_raw_ptr_ops2.rs @@ -6,8 +6,11 @@ fn main() {} const Y: usize = unsafe { 42usize as *const i32 as usize + 1 }; // unconst and bad, will thus error in miri const Y2: usize = unsafe { &1 as *const i32 as usize + 1 }; //~ ERROR any use of this +//~| WARN this was previously accepted by the compiler but is being phased out // unconst and fine const Z: i32 = unsafe { *(&1 as *const i32) }; // unconst and bad, will thus error in miri const Z2: i32 = unsafe { *(42 as *const i32) }; //~ ERROR any use of this value will cause +//~| WARN this was previously accepted by the compiler but is being phased out const Z3: i32 = unsafe { *(44 as *const i32) }; //~ ERROR any use of this value will cause +//~| WARN this was previously accepted by the compiler but is being phased out diff --git a/src/test/ui/consts/const-eval/const_raw_ptr_ops2.stderr b/src/test/ui/consts/const-eval/const_raw_ptr_ops2.stderr index 93f2261745d6f..f207674ac1d01 100644 --- a/src/test/ui/consts/const-eval/const_raw_ptr_ops2.stderr +++ b/src/test/ui/consts/const-eval/const_raw_ptr_ops2.stderr @@ -7,22 +7,30 @@ LL | const Y2: usize = unsafe { &1 as *const i32 as usize + 1 }; | "pointer-to-integer cast" needs an rfc before being allowed inside constants | = note: `#[deny(const_err)]` on by default + = 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 #71800 error: any use of this value will cause an error - --> $DIR/const_raw_ptr_ops2.rs:12:26 + --> $DIR/const_raw_ptr_ops2.rs:13:26 | LL | const Z2: i32 = unsafe { *(42 as *const i32) }; | -------------------------^^^^^^^^^^^^^^^^^^^--- | | | unable to turn bytes into a pointer + | + = 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 #71800 error: any use of this value will cause an error - --> $DIR/const_raw_ptr_ops2.rs:13:26 + --> $DIR/const_raw_ptr_ops2.rs:15:26 | LL | const Z3: i32 = unsafe { *(44 as *const i32) }; | -------------------------^^^^^^^^^^^^^^^^^^^--- | | | unable to turn bytes into a pointer + | + = 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 #71800 error: aborting due to 3 previous errors diff --git a/src/test/ui/consts/const-eval/dangling.rs b/src/test/ui/consts/const-eval/dangling.rs index 72e97c03220fc..185d11605fdb5 100644 --- a/src/test/ui/consts/const-eval/dangling.rs +++ b/src/test/ui/consts/const-eval/dangling.rs @@ -6,8 +6,10 @@ use std::mem; const TEST: () = { unsafe { //~ NOTE let slice: *const [u8] = mem::transmute((1usize, usize::MAX)); let _val = &*slice; //~ ERROR: any use of this value will cause an error - //~^ NOTE: slice is bigger than largest supported object - //~^^ on by default + //~| NOTE: slice is bigger than largest supported object + //~| on by default + //~| WARN this was previously accepted by the compiler but is being phased out + //~| NOTE } }; fn main() {} diff --git a/src/test/ui/consts/const-eval/dangling.stderr b/src/test/ui/consts/const-eval/dangling.stderr index b9ddc93b03b84..a7f7cf13c5b0f 100644 --- a/src/test/ui/consts/const-eval/dangling.stderr +++ b/src/test/ui/consts/const-eval/dangling.stderr @@ -6,11 +6,14 @@ LL | | let slice: *const [u8] = mem::transmute((1usize, usize::MAX)); LL | | let _val = &*slice; | | ^^^^^^^ invalid metadata in wide pointer: slice is bigger than largest supported object LL | | +... | LL | | LL | | } }; | |____- | = note: `#[deny(const_err)]` on by default + = 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 #71800 error: aborting due to previous error diff --git a/src/test/ui/consts/const-eval/erroneous-const.rs b/src/test/ui/consts/const-eval/erroneous-const.rs index 16bf1adf7db3e..b79ce4a523f96 100644 --- a/src/test/ui/consts/const-eval/erroneous-const.rs +++ b/src/test/ui/consts/const-eval/erroneous-const.rs @@ -5,6 +5,7 @@ struct PrintName(T); impl PrintName { const VOID: () = [()][2]; //~WARN any use of this value will cause an error //~^ WARN this operation will panic at runtime + //~| WARN this was previously accepted by the compiler but is being phased out } const fn no_codegen() { diff --git a/src/test/ui/consts/const-eval/erroneous-const.stderr b/src/test/ui/consts/const-eval/erroneous-const.stderr index 040cc3fcf798d..16ed596628bf5 100644 --- a/src/test/ui/consts/const-eval/erroneous-const.stderr +++ b/src/test/ui/consts/const-eval/erroneous-const.stderr @@ -23,18 +23,20 @@ note: the lint level is defined here | LL | #![warn(const_err, unconditional_panic)] | ^^^^^^^^^ + = 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 #71800 error[E0080]: could not evaluate static initializer - --> $DIR/erroneous-const.rs:12:17 + --> $DIR/erroneous-const.rs:13:17 | LL | let _ = PrintName::::VOID; | ^^^^^^^^^^^^^^^^^^^^ | | | referenced constant has errors - | inside `no_codegen::` at $DIR/erroneous-const.rs:12:17 + | inside `no_codegen::` at $DIR/erroneous-const.rs:13:17 ... LL | pub static FOO: () = no_codegen::(); - | ------------------- inside `FOO` at $DIR/erroneous-const.rs:16:22 + | ------------------- inside `FOO` at $DIR/erroneous-const.rs:17:22 error: aborting due to previous error; 2 warnings emitted diff --git a/src/test/ui/consts/const-eval/heap/alloc_intrinsic_errors.rs b/src/test/ui/consts/const-eval/heap/alloc_intrinsic_errors.rs index 0d809ca9a622b..43d79badd7282 100644 --- a/src/test/ui/consts/const-eval/heap/alloc_intrinsic_errors.rs +++ b/src/test/ui/consts/const-eval/heap/alloc_intrinsic_errors.rs @@ -9,6 +9,7 @@ const fn foo() -> i32 { unsafe { let _ = intrinsics::const_allocate(4, 3) as * mut i32; //~^ error: any use of this value will cause an error [const_err] + //~| WARN this was previously accepted by the compiler but is being phased out } 1 diff --git a/src/test/ui/consts/const-eval/heap/alloc_intrinsic_errors.stderr b/src/test/ui/consts/const-eval/heap/alloc_intrinsic_errors.stderr index 41c1b977269a3..3d529ab4ca6e5 100644 --- a/src/test/ui/consts/const-eval/heap/alloc_intrinsic_errors.stderr +++ b/src/test/ui/consts/const-eval/heap/alloc_intrinsic_errors.stderr @@ -12,6 +12,8 @@ LL | let _ = intrinsics::const_allocate(4, 3) as * mut i32; | inside `FOO` at $DIR/alloc_intrinsic_errors.rs:7:18 | = note: `#[deny(const_err)]` on by default + = 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 #71800 error: aborting due to previous error diff --git a/src/test/ui/consts/const-eval/index-out-of-bounds-never-type.rs b/src/test/ui/consts/const-eval/index-out-of-bounds-never-type.rs index 795c5154f8155..8064cc49359ee 100644 --- a/src/test/ui/consts/const-eval/index-out-of-bounds-never-type.rs +++ b/src/test/ui/consts/const-eval/index-out-of-bounds-never-type.rs @@ -9,6 +9,7 @@ struct PrintName(T); impl PrintName { const VOID: ! = { let x = 0 * std::mem::size_of::(); [][x] }; //~^ WARN any use of this value will cause an error + //~| WARN this was previously accepted by the compiler but is being phased out } diff --git a/src/test/ui/consts/const-eval/index-out-of-bounds-never-type.stderr b/src/test/ui/consts/const-eval/index-out-of-bounds-never-type.stderr index 8647da90a37d4..73664fa49d189 100644 --- a/src/test/ui/consts/const-eval/index-out-of-bounds-never-type.stderr +++ b/src/test/ui/consts/const-eval/index-out-of-bounds-never-type.stderr @@ -11,9 +11,11 @@ note: the lint level is defined here | LL | #![warn(const_err, unconditional_panic)] | ^^^^^^^^^ + = 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 #71800 error: erroneous constant encountered - --> $DIR/index-out-of-bounds-never-type.rs:16:13 + --> $DIR/index-out-of-bounds-never-type.rs:17:13 | LL | let _ = PrintName::::VOID; | ^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/consts/const-eval/issue-43197.rs b/src/test/ui/consts/const-eval/issue-43197.rs index 7d1d33288a907..e15f8771dd73b 100644 --- a/src/test/ui/consts/const-eval/issue-43197.rs +++ b/src/test/ui/consts/const-eval/issue-43197.rs @@ -9,11 +9,15 @@ const fn foo(x: u32) -> u32 { fn main() { const X: u32 = 0 - 1; //~^ WARN any use of this value will cause + //~| WARN this was previously accepted by the compiler but is being phased out const Y: u32 = foo(0 - 1); //~^ WARN any use of this value will cause + //~| WARN this was previously accepted by the compiler but is being phased out println!("{} {}", X, Y); //~^ ERROR evaluation of constant value failed //~| ERROR evaluation of constant value failed //~| WARN erroneous constant used [const_err] //~| WARN erroneous constant used [const_err] + //~| WARN this was previously accepted by the compiler but is being phased out + //~| WARN this was previously accepted by the compiler but is being phased out } diff --git a/src/test/ui/consts/const-eval/issue-43197.stderr b/src/test/ui/consts/const-eval/issue-43197.stderr index 8c72b59141687..d4d8cbc669a7b 100644 --- a/src/test/ui/consts/const-eval/issue-43197.stderr +++ b/src/test/ui/consts/const-eval/issue-43197.stderr @@ -11,38 +11,49 @@ note: the lint level is defined here | LL | #![warn(const_err)] | ^^^^^^^^^ + = 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 #71800 warning: any use of this value will cause an error - --> $DIR/issue-43197.rs:12:24 + --> $DIR/issue-43197.rs:13:24 | LL | const Y: u32 = foo(0 - 1); | -------------------^^^^^-- | | | attempt to compute `0_u32 - 1_u32`, which would overflow + | + = 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 #71800 error[E0080]: evaluation of constant value failed - --> $DIR/issue-43197.rs:14:23 + --> $DIR/issue-43197.rs:16:23 | LL | println!("{} {}", X, Y); | ^ referenced constant has errors warning: erroneous constant used - --> $DIR/issue-43197.rs:14:23 + --> $DIR/issue-43197.rs:16:23 | LL | println!("{} {}", X, Y); | ^ referenced constant has errors + | + = 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 #71800 error[E0080]: evaluation of constant value failed - --> $DIR/issue-43197.rs:14:26 + --> $DIR/issue-43197.rs:16:26 | LL | println!("{} {}", X, Y); | ^ referenced constant has errors warning: erroneous constant used - --> $DIR/issue-43197.rs:14:26 + --> $DIR/issue-43197.rs:16:26 | LL | println!("{} {}", X, Y); | ^ referenced constant has errors + | + = 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 #71800 error: aborting due to 2 previous errors; 4 warnings emitted diff --git a/src/test/ui/consts/const-eval/issue-49296.rs b/src/test/ui/consts/const-eval/issue-49296.rs index c6caeeffd22dd..9fd9e8f36472d 100644 --- a/src/test/ui/consts/const-eval/issue-49296.rs +++ b/src/test/ui/consts/const-eval/issue-49296.rs @@ -18,6 +18,7 @@ const fn wat(x: u64) -> &'static u64 { } const X: u64 = *wat(42); //~^ ERROR any use of this value will cause an error +//~| WARN this was previously accepted by the compiler but is being phased out fn main() { println!("{}", X); diff --git a/src/test/ui/consts/const-eval/issue-49296.stderr b/src/test/ui/consts/const-eval/issue-49296.stderr index 9363ffbb996e4..0389471edb57c 100644 --- a/src/test/ui/consts/const-eval/issue-49296.stderr +++ b/src/test/ui/consts/const-eval/issue-49296.stderr @@ -7,6 +7,8 @@ LL | const X: u64 = *wat(42); | pointer to alloc1 was dereferenced after this allocation got freed | = note: `#[deny(const_err)]` on by default + = 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 #71800 error: aborting due to previous error diff --git a/src/test/ui/consts/const-eval/issue-50814-2.rs b/src/test/ui/consts/const-eval/issue-50814-2.rs index 8f5c8f097a2ca..15f4de0ae1b67 100644 --- a/src/test/ui/consts/const-eval/issue-50814-2.rs +++ b/src/test/ui/consts/const-eval/issue-50814-2.rs @@ -12,6 +12,7 @@ struct A(T); impl Foo for A { const BAR: usize = [5, 6, 7][T::BOO]; //~ ERROR any use of this value will cause an error + //~| WARN this was previously accepted by the compiler but is being phased out } fn foo() -> &'static usize { diff --git a/src/test/ui/consts/const-eval/issue-50814-2.stderr b/src/test/ui/consts/const-eval/issue-50814-2.stderr index f929f500cf9fb..0c52016549676 100644 --- a/src/test/ui/consts/const-eval/issue-50814-2.stderr +++ b/src/test/ui/consts/const-eval/issue-50814-2.stderr @@ -7,9 +7,11 @@ LL | const BAR: usize = [5, 6, 7][T::BOO]; | index out of bounds: the length is 3 but the index is 42 | = note: `#[deny(const_err)]` on by default + = 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 #71800 error[E0080]: evaluation of constant value failed - --> $DIR/issue-50814-2.rs:18:6 + --> $DIR/issue-50814-2.rs:19:6 | LL | & as Foo>::BAR | ^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors diff --git a/src/test/ui/consts/const-eval/issue-50814.rs b/src/test/ui/consts/const-eval/issue-50814.rs index 5c3635e4650cd..98229f919dd13 100644 --- a/src/test/ui/consts/const-eval/issue-50814.rs +++ b/src/test/ui/consts/const-eval/issue-50814.rs @@ -14,6 +14,7 @@ struct Sum(A,B); impl Unsigned for Sum { const MAX: u8 = A::MAX + B::MAX; //~^ ERROR any use of this value will cause an error [const_err] + //~| WARN this was previously accepted by the compiler but is being phased out } fn foo(_: T) -> &'static u8 { diff --git a/src/test/ui/consts/const-eval/issue-50814.stderr b/src/test/ui/consts/const-eval/issue-50814.stderr index 307fb3c8c9de1..cf82d1eef3e45 100644 --- a/src/test/ui/consts/const-eval/issue-50814.stderr +++ b/src/test/ui/consts/const-eval/issue-50814.stderr @@ -7,9 +7,11 @@ LL | const MAX: u8 = A::MAX + B::MAX; | attempt to compute `u8::MAX + u8::MAX`, which would overflow | = note: `#[deny(const_err)]` on by default + = 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 #71800 error[E0080]: evaluation of constant value failed - --> $DIR/issue-50814.rs:20:6 + --> $DIR/issue-50814.rs:21:6 | LL | &Sum::::MAX | ^^^^^^^^^^^^^^^^^ referenced constant has errors diff --git a/src/test/ui/consts/const-eval/panic-assoc-never-type.rs b/src/test/ui/consts/const-eval/panic-assoc-never-type.rs index 21ee64fa6d937..f76440298b3ca 100644 --- a/src/test/ui/consts/const-eval/panic-assoc-never-type.rs +++ b/src/test/ui/consts/const-eval/panic-assoc-never-type.rs @@ -10,6 +10,7 @@ struct PrintName; impl PrintName { const VOID: ! = panic!(); //~^ WARN any use of this value will cause an error + //~| WARN this was previously accepted by the compiler but is being phased out } fn main() { diff --git a/src/test/ui/consts/const-eval/panic-assoc-never-type.stderr b/src/test/ui/consts/const-eval/panic-assoc-never-type.stderr index 979f4a5904d1c..28a3ebede5038 100644 --- a/src/test/ui/consts/const-eval/panic-assoc-never-type.stderr +++ b/src/test/ui/consts/const-eval/panic-assoc-never-type.stderr @@ -11,10 +11,12 @@ note: the lint level is defined here | LL | #![warn(const_err)] | ^^^^^^^^^ + = 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 #71800 = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) error[E0080]: erroneous constant used - --> $DIR/panic-assoc-never-type.rs:16:13 + --> $DIR/panic-assoc-never-type.rs:17:13 | LL | let _ = PrintName::VOID; | ^^^^^^^^^^^^^^^ referenced constant has errors diff --git a/src/test/ui/consts/const-eval/panic-never-type.rs b/src/test/ui/consts/const-eval/panic-never-type.rs index 3b28b2fdd247e..c5139c575b15f 100644 --- a/src/test/ui/consts/const-eval/panic-never-type.rs +++ b/src/test/ui/consts/const-eval/panic-never-type.rs @@ -7,6 +7,7 @@ const VOID: ! = panic!(); //~^ WARN any use of this value will cause an error +//~| WARN this was previously accepted by the compiler but is being phased out fn main() { let _ = VOID; diff --git a/src/test/ui/consts/const-eval/panic-never-type.stderr b/src/test/ui/consts/const-eval/panic-never-type.stderr index af68a2ff44211..8f67dd6a8ba42 100644 --- a/src/test/ui/consts/const-eval/panic-never-type.stderr +++ b/src/test/ui/consts/const-eval/panic-never-type.stderr @@ -11,10 +11,12 @@ note: the lint level is defined here | LL | #![warn(const_err)] | ^^^^^^^^^ + = 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 #71800 = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) error[E0080]: erroneous constant used - --> $DIR/panic-never-type.rs:12:13 + --> $DIR/panic-never-type.rs:13:13 | LL | let _ = VOID; | ^^^^ referenced constant has errors diff --git a/src/test/ui/consts/const-eval/promoted_errors.noopt.stderr b/src/test/ui/consts/const-eval/promoted_errors.noopt.stderr index 1cd1be5309b90..6f266801bdb4a 100644 --- a/src/test/ui/consts/const-eval/promoted_errors.noopt.stderr +++ b/src/test/ui/consts/const-eval/promoted_errors.noopt.stderr @@ -6,12 +6,12 @@ LL | 0 - 1 | | | attempt to compute `0_u32 - 1_u32`, which would overflow | inside `overflow` at $DIR/promoted_errors.rs:13:5 - | inside `X` at $DIR/promoted_errors.rs:31:29 + | inside `X` at $DIR/promoted_errors.rs:33:29 ... LL | / const X: () = { LL | | let _x: &'static u32 = &overflow(); LL | | -LL | | let _x: &'static i32 = &div_by_zero1(); +LL | | ... | LL | | let _x: &'static i32 = &oob(); LL | | }; @@ -22,19 +22,24 @@ note: the lint level is defined here | LL | #![warn(const_err, arithmetic_overflow, unconditional_panic)] | ^^^^^^^^^ + = 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 #71800 warning: any use of this value will cause an error - --> $DIR/promoted_errors.rs:31:28 + --> $DIR/promoted_errors.rs:33:28 | LL | / const X: () = { LL | | let _x: &'static u32 = &overflow(); | | ^^^^^^^^^^^ referenced constant has errors LL | | -LL | | let _x: &'static i32 = &div_by_zero1(); +LL | | ... | LL | | let _x: &'static i32 = &oob(); LL | | }; | |__- + | + = 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 #71800 warning: 2 warnings emitted diff --git a/src/test/ui/consts/const-eval/promoted_errors.opt.stderr b/src/test/ui/consts/const-eval/promoted_errors.opt.stderr index ca62e21b61385..892f57bfdfc1b 100644 --- a/src/test/ui/consts/const-eval/promoted_errors.opt.stderr +++ b/src/test/ui/consts/const-eval/promoted_errors.opt.stderr @@ -1,17 +1,17 @@ warning: any use of this value will cause an error - --> $DIR/promoted_errors.rs:17:5 + --> $DIR/promoted_errors.rs:18:5 | LL | 1 / 0 | ^^^^^ | | | attempt to divide `1_i32` by zero - | inside `div_by_zero1` at $DIR/promoted_errors.rs:17:5 - | inside `X` at $DIR/promoted_errors.rs:33:29 + | inside `div_by_zero1` at $DIR/promoted_errors.rs:18:5 + | inside `X` at $DIR/promoted_errors.rs:36:29 ... LL | / const X: () = { LL | | let _x: &'static u32 = &overflow(); LL | | -LL | | let _x: &'static i32 = &div_by_zero1(); +LL | | ... | LL | | let _x: &'static i32 = &oob(); LL | | }; @@ -22,19 +22,25 @@ note: the lint level is defined here | LL | #![warn(const_err, arithmetic_overflow, unconditional_panic)] | ^^^^^^^^^ + = 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 #71800 warning: any use of this value will cause an error - --> $DIR/promoted_errors.rs:33:28 + --> $DIR/promoted_errors.rs:36:28 | LL | / const X: () = { LL | | let _x: &'static u32 = &overflow(); LL | | +LL | | LL | | let _x: &'static i32 = &div_by_zero1(); | | ^^^^^^^^^^^^^^^ referenced constant has errors ... | LL | | let _x: &'static i32 = &oob(); LL | | }; | |__- + | + = 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 #71800 warning: 2 warnings emitted diff --git a/src/test/ui/consts/const-eval/promoted_errors.opt_with_overflow_checks.stderr b/src/test/ui/consts/const-eval/promoted_errors.opt_with_overflow_checks.stderr index 1cd1be5309b90..6f266801bdb4a 100644 --- a/src/test/ui/consts/const-eval/promoted_errors.opt_with_overflow_checks.stderr +++ b/src/test/ui/consts/const-eval/promoted_errors.opt_with_overflow_checks.stderr @@ -6,12 +6,12 @@ LL | 0 - 1 | | | attempt to compute `0_u32 - 1_u32`, which would overflow | inside `overflow` at $DIR/promoted_errors.rs:13:5 - | inside `X` at $DIR/promoted_errors.rs:31:29 + | inside `X` at $DIR/promoted_errors.rs:33:29 ... LL | / const X: () = { LL | | let _x: &'static u32 = &overflow(); LL | | -LL | | let _x: &'static i32 = &div_by_zero1(); +LL | | ... | LL | | let _x: &'static i32 = &oob(); LL | | }; @@ -22,19 +22,24 @@ note: the lint level is defined here | LL | #![warn(const_err, arithmetic_overflow, unconditional_panic)] | ^^^^^^^^^ + = 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 #71800 warning: any use of this value will cause an error - --> $DIR/promoted_errors.rs:31:28 + --> $DIR/promoted_errors.rs:33:28 | LL | / const X: () = { LL | | let _x: &'static u32 = &overflow(); | | ^^^^^^^^^^^ referenced constant has errors LL | | -LL | | let _x: &'static i32 = &div_by_zero1(); +LL | | ... | LL | | let _x: &'static i32 = &oob(); LL | | }; | |__- + | + = 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 #71800 warning: 2 warnings emitted diff --git a/src/test/ui/consts/const-eval/promoted_errors.rs b/src/test/ui/consts/const-eval/promoted_errors.rs index a2136c8d09be4..7840f67c216c0 100644 --- a/src/test/ui/consts/const-eval/promoted_errors.rs +++ b/src/test/ui/consts/const-eval/promoted_errors.rs @@ -12,30 +12,33 @@ const fn overflow() -> u32 { 0 - 1 //[opt_with_overflow_checks,noopt]~^ WARN any use of this value will cause an error + //[opt_with_overflow_checks,noopt]~| WARN this was previously accepted by the compiler } const fn div_by_zero1() -> i32 { 1 / 0 //[opt]~^ WARN any use of this value will cause an error + //[opt]~| WARN this was previously accepted by the compiler but is being phased out } const fn div_by_zero2() -> i32 { - 1 / (1-1) + 1 / (1 - 1) } const fn div_by_zero3() -> i32 { 1 / (false as i32) } const fn oob() -> i32 { - [1,2,3][4] + [1, 2, 3][4] } const X: () = { let _x: &'static u32 = &overflow(); //[opt_with_overflow_checks,noopt]~^ WARN any use of this value will cause an error + //[opt_with_overflow_checks,noopt]~| WARN this was previously accepted by the compiler let _x: &'static i32 = &div_by_zero1(); //[opt]~^ WARN any use of this value will cause an error + //[opt]~| WARN this was previously accepted by the compiler but is being phased out let _x: &'static i32 = &div_by_zero2(); let _x: &'static i32 = &div_by_zero3(); let _x: &'static i32 = &oob(); }; -fn main() { -} +fn main() {} diff --git a/src/test/ui/consts/const-eval/pub_const_err.rs b/src/test/ui/consts/const-eval/pub_const_err.rs index ad165d40a76f2..5faacd556d479 100644 --- a/src/test/ui/consts/const-eval/pub_const_err.rs +++ b/src/test/ui/consts/const-eval/pub_const_err.rs @@ -5,5 +5,6 @@ pub const Z: u32 = 0 - 1; //~^ WARN any use of this value will cause an error +//~| WARN this was previously accepted by the compiler but is being phased out pub type Foo = [i32; 0 - 1]; diff --git a/src/test/ui/consts/const-eval/pub_const_err.stderr b/src/test/ui/consts/const-eval/pub_const_err.stderr index 5be0fd96723dd..dd47dca2b2e40 100644 --- a/src/test/ui/consts/const-eval/pub_const_err.stderr +++ b/src/test/ui/consts/const-eval/pub_const_err.stderr @@ -11,6 +11,8 @@ note: the lint level is defined here | LL | #![warn(const_err)] | ^^^^^^^^^ + = 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 #71800 warning: 1 warning emitted diff --git a/src/test/ui/consts/const-eval/pub_const_err_bin.rs b/src/test/ui/consts/const-eval/pub_const_err_bin.rs index 078e4c896df80..82eae25121e41 100644 --- a/src/test/ui/consts/const-eval/pub_const_err_bin.rs +++ b/src/test/ui/consts/const-eval/pub_const_err_bin.rs @@ -3,6 +3,7 @@ pub const Z: u32 = 0 - 1; //~^ WARN any use of this value will cause an error +//~| WARN this was previously accepted by the compiler but is being phased out pub type Foo = [i32; 0 - 1]; diff --git a/src/test/ui/consts/const-eval/pub_const_err_bin.stderr b/src/test/ui/consts/const-eval/pub_const_err_bin.stderr index 55f8a58ea9470..9f413fb8fd770 100644 --- a/src/test/ui/consts/const-eval/pub_const_err_bin.stderr +++ b/src/test/ui/consts/const-eval/pub_const_err_bin.stderr @@ -11,6 +11,8 @@ note: the lint level is defined here | LL | #![warn(const_err)] | ^^^^^^^^^ + = 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 #71800 warning: 1 warning emitted diff --git a/src/test/ui/consts/const-eval/ub-nonnull.rs b/src/test/ui/consts/const-eval/ub-nonnull.rs index 4b90b892dce9a..e4ced600b4cc4 100644 --- a/src/test/ui/consts/const-eval/ub-nonnull.rs +++ b/src/test/ui/consts/const-eval/ub-nonnull.rs @@ -16,6 +16,7 @@ const OUT_OF_BOUNDS_PTR: NonNull = { unsafe { let ptr: &[u8; 256] = mem::transmute(&0u8); // &0 gets promoted so it does not dangle // Use address-of-element for pointer arithmetic. This could wrap around to NULL! let out_of_bounds_ptr = &ptr[255]; //~ ERROR any use of this value will cause an error + //~| WARN this was previously accepted by the compiler but is being phased out mem::transmute(out_of_bounds_ptr) } }; diff --git a/src/test/ui/consts/const-eval/ub-nonnull.stderr b/src/test/ui/consts/const-eval/ub-nonnull.stderr index 39a568d054af4..94496b77fe773 100644 --- a/src/test/ui/consts/const-eval/ub-nonnull.stderr +++ b/src/test/ui/consts/const-eval/ub-nonnull.stderr @@ -14,6 +14,7 @@ LL | | let ptr: &[u8; 256] = mem::transmute(&0u8); // &0 gets promoted so it LL | | // Use address-of-element for pointer arithmetic. This could wrap around to NULL! LL | | let out_of_bounds_ptr = &ptr[255]; | | ^^^^^^^^ memory access failed: pointer must be in-bounds at offset 256, but is outside bounds of alloc10 which has size 1 +LL | | LL | | mem::transmute(out_of_bounds_ptr) LL | | } }; | |____- @@ -23,9 +24,11 @@ note: the lint level is defined here | LL | #[deny(const_err)] // this triggers a `const_err` so validation does not even happen | ^^^^^^^^^ + = 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 #71800 error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-nonnull.rs:22:1 + --> $DIR/ub-nonnull.rs:23:1 | LL | const NULL_U8: NonZeroU8 = unsafe { mem::transmute(0u8) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered 0, but expected something greater or equal to 1 @@ -33,7 +36,7 @@ LL | const NULL_U8: NonZeroU8 = unsafe { mem::transmute(0u8) }; = 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. error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-nonnull.rs:24:1 + --> $DIR/ub-nonnull.rs:25:1 | LL | const NULL_USIZE: NonZeroUsize = unsafe { mem::transmute(0usize) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered 0, but expected something greater or equal to 1 @@ -41,7 +44,7 @@ LL | const NULL_USIZE: NonZeroUsize = unsafe { mem::transmute(0usize) }; = 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. error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-nonnull.rs:32:1 + --> $DIR/ub-nonnull.rs:33:1 | LL | const UNINIT: NonZeroU8 = unsafe { MaybeUninit { uninit: () }.init }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered uninitialized bytes at .0, but expected initialized plain (non-pointer) bytes @@ -49,7 +52,7 @@ LL | const UNINIT: NonZeroU8 = unsafe { MaybeUninit { uninit: () }.init }; = 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. error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-nonnull.rs:40:1 + --> $DIR/ub-nonnull.rs:41:1 | LL | const BAD_RANGE1: RestrictedRange1 = unsafe { RestrictedRange1(42) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered 42, but expected something in the range 10..=30 @@ -57,7 +60,7 @@ LL | const BAD_RANGE1: RestrictedRange1 = unsafe { RestrictedRange1(42) }; = 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. error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-nonnull.rs:46:1 + --> $DIR/ub-nonnull.rs:47:1 | LL | const BAD_RANGE2: RestrictedRange2 = unsafe { RestrictedRange2(20) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered 20, but expected something less or equal to 10, or greater or equal to 30 diff --git a/src/test/ui/consts/const-eval/unused-broken-const.rs b/src/test/ui/consts/const-eval/unused-broken-const.rs index 56b16e224e5ad..3b4523681002e 100644 --- a/src/test/ui/consts/const-eval/unused-broken-const.rs +++ b/src/test/ui/consts/const-eval/unused-broken-const.rs @@ -4,5 +4,6 @@ const FOO: i32 = [][0]; //~^ ERROR any use of this value will cause an error +//~| WARN this was previously accepted by the compiler but is being phased out fn main() {} diff --git a/src/test/ui/consts/const-eval/unused-broken-const.stderr b/src/test/ui/consts/const-eval/unused-broken-const.stderr index 0cb13790f2f53..2ce60ec16a33f 100644 --- a/src/test/ui/consts/const-eval/unused-broken-const.stderr +++ b/src/test/ui/consts/const-eval/unused-broken-const.stderr @@ -7,6 +7,8 @@ LL | const FOO: i32 = [][0]; | index out of bounds: the length is 0 but the index is 0 | = note: `#[deny(const_err)]` on by default + = 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 #71800 error: aborting due to previous error diff --git a/src/test/ui/consts/const-eval/unwind-abort.rs b/src/test/ui/consts/const-eval/unwind-abort.rs index 2dc8e14bed545..10820986fa7d3 100644 --- a/src/test/ui/consts/const-eval/unwind-abort.rs +++ b/src/test/ui/consts/const-eval/unwind-abort.rs @@ -3,6 +3,7 @@ #[unwind(aborts)] const fn foo() { panic!() //~ ERROR any use of this value will cause an error [const_err] + //~| WARN this was previously accepted by the compiler but is being phased out } const _: () = foo(); diff --git a/src/test/ui/consts/const-eval/unwind-abort.stderr b/src/test/ui/consts/const-eval/unwind-abort.stderr index 8a90fdfc5751b..f13f2bfe9b110 100644 --- a/src/test/ui/consts/const-eval/unwind-abort.stderr +++ b/src/test/ui/consts/const-eval/unwind-abort.stderr @@ -6,12 +6,14 @@ LL | panic!() | | | the evaluated program panicked at 'explicit panic', $DIR/unwind-abort.rs:5:5 | inside `foo` at $SRC_DIR/std/src/panic.rs:LL:COL - | inside `_` at $DIR/unwind-abort.rs:8:15 + | inside `_` at $DIR/unwind-abort.rs:9:15 ... LL | const _: () = foo(); | -------------------- | = note: `#[deny(const_err)]` on by default + = 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 #71800 = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to previous error diff --git a/src/test/ui/consts/const-eval/validate_uninhabited_zsts.rs b/src/test/ui/consts/const-eval/validate_uninhabited_zsts.rs index 48a989bf58863..4e1c71cd60013 100644 --- a/src/test/ui/consts/const-eval/validate_uninhabited_zsts.rs +++ b/src/test/ui/consts/const-eval/validate_uninhabited_zsts.rs @@ -5,6 +5,7 @@ const fn foo() -> ! { unsafe { std::mem::transmute(()) } //~^ WARN any use of this value will cause an error [const_err] //~| WARN the type `!` does not permit zero-initialization [invalid_value] + //~| WARN this was previously accepted by the compiler but is being phased out } #[derive(Clone, Copy)] diff --git a/src/test/ui/consts/const-eval/validate_uninhabited_zsts.stderr b/src/test/ui/consts/const-eval/validate_uninhabited_zsts.stderr index 2adff5fc7d408..3f22fac11f65d 100644 --- a/src/test/ui/consts/const-eval/validate_uninhabited_zsts.stderr +++ b/src/test/ui/consts/const-eval/validate_uninhabited_zsts.stderr @@ -6,19 +6,21 @@ LL | unsafe { std::mem::transmute(()) } | | | transmuting to uninhabited type | inside `foo` at $DIR/validate_uninhabited_zsts.rs:5:14 - | inside `FOO` at $DIR/validate_uninhabited_zsts.rs:14:26 + | inside `FOO` at $DIR/validate_uninhabited_zsts.rs:15:26 ... LL | const FOO: [Empty; 3] = [foo(); 3]; | ----------------------------------- | note: the lint level is defined here - --> $DIR/validate_uninhabited_zsts.rs:13:8 + --> $DIR/validate_uninhabited_zsts.rs:14:8 | LL | #[warn(const_err)] | ^^^^^^^^^ + = 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 #71800 error[E0080]: it is undefined behavior to use this value - --> $DIR/validate_uninhabited_zsts.rs:17:1 + --> $DIR/validate_uninhabited_zsts.rs:18:1 | LL | const BAR: [Empty; 3] = [unsafe { std::mem::transmute(()) }; 3]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a value of uninhabited type Empty at [0] @@ -38,7 +40,7 @@ LL | unsafe { std::mem::transmute(()) } = note: the `!` type has no valid value warning: the type `Empty` does not permit zero-initialization - --> $DIR/validate_uninhabited_zsts.rs:17:35 + --> $DIR/validate_uninhabited_zsts.rs:18:35 | LL | const BAR: [Empty; 3] = [unsafe { std::mem::transmute(()) }; 3]; | ^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/consts/const-external-macro-const-err.rs b/src/test/ui/consts/const-external-macro-const-err.rs index 616d24f4a7bcf..440c42e32ef39 100644 --- a/src/test/ui/consts/const-external-macro-const-err.rs +++ b/src/test/ui/consts/const-external-macro-const-err.rs @@ -10,4 +10,5 @@ use external_macro::static_assert; fn main() { static_assert!(2 + 2 == 5); //~ ERROR + //~| WARN this was previously accepted by the compiler but is being phased out } diff --git a/src/test/ui/consts/const-external-macro-const-err.stderr b/src/test/ui/consts/const-external-macro-const-err.stderr index 350e4b24de100..21fdffa115b83 100644 --- a/src/test/ui/consts/const-external-macro-const-err.stderr +++ b/src/test/ui/consts/const-external-macro-const-err.stderr @@ -5,6 +5,8 @@ LL | static_assert!(2 + 2 == 5); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ index out of bounds: the length is 1 but the index is 1 | = note: `#[deny(const_err)]` on by default + = 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 #71800 = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to previous error diff --git a/src/test/ui/consts/const-int-unchecked.rs b/src/test/ui/consts/const-int-unchecked.rs index 1596093b2c14b..41d8f7a0972bc 100644 --- a/src/test/ui/consts/const-int-unchecked.rs +++ b/src/test/ui/consts/const-int-unchecked.rs @@ -14,54 +14,74 @@ use std::intrinsics; const SHL_U8: u8 = unsafe { intrinsics::unchecked_shl(5_u8, 8) }; //~^ ERROR any use of this value will cause an error +//~| WARN this was previously accepted by the compiler but is being phased out const SHL_U16: u16 = unsafe { intrinsics::unchecked_shl(5_u16, 16) }; //~^ ERROR any use of this value will cause an error +//~| WARN this was previously accepted by the compiler but is being phased out const SHL_U32: u32 = unsafe { intrinsics::unchecked_shl(5_u32, 32) }; //~^ ERROR any use of this value will cause an error +//~| WARN this was previously accepted by the compiler but is being phased out const SHL_U64: u64 = unsafe { intrinsics::unchecked_shl(5_u64, 64) }; //~^ ERROR any use of this value will cause an error +//~| WARN this was previously accepted by the compiler but is being phased out const SHL_U128: u128 = unsafe { intrinsics::unchecked_shl(5_u128, 128) }; //~^ ERROR any use of this value will cause an error +//~| WARN this was previously accepted by the compiler but is being phased out // signed types: const SHL_I8: i8 = unsafe { intrinsics::unchecked_shl(5_i8, 8) }; //~^ ERROR any use of this value will cause an error +//~| WARN this was previously accepted by the compiler but is being phased out const SHL_I16: i16 = unsafe { intrinsics::unchecked_shl(5_16, 16) }; //~^ ERROR any use of this value will cause an error +//~| WARN this was previously accepted by the compiler but is being phased out const SHL_I32: i32 = unsafe { intrinsics::unchecked_shl(5_i32, 32) }; //~^ ERROR any use of this value will cause an error +//~| WARN this was previously accepted by the compiler but is being phased out const SHL_I64: i64 = unsafe { intrinsics::unchecked_shl(5_i64, 64) }; //~^ ERROR any use of this value will cause an error +//~| WARN this was previously accepted by the compiler but is being phased out const SHL_I128: i128 = unsafe { intrinsics::unchecked_shl(5_i128, 128) }; //~^ ERROR any use of this value will cause an error +//~| WARN this was previously accepted by the compiler but is being phased out // and make sure we capture y < 0: const SHL_I8_NEG: i8 = unsafe { intrinsics::unchecked_shl(5_i8, -1) }; //~^ ERROR any use of this value will cause an error +//~| WARN this was previously accepted by the compiler but is being phased out const SHL_I16_NEG: i16 = unsafe { intrinsics::unchecked_shl(5_16, -1) }; //~^ ERROR any use of this value will cause an error +//~| WARN this was previously accepted by the compiler but is being phased out const SHL_I32_NEG: i32 = unsafe { intrinsics::unchecked_shl(5_i32, -1) }; //~^ ERROR any use of this value will cause an error +//~| WARN this was previously accepted by the compiler but is being phased out const SHL_I64_NEG: i64 = unsafe { intrinsics::unchecked_shl(5_i64, -1) }; //~^ ERROR any use of this value will cause an error +//~| WARN this was previously accepted by the compiler but is being phased out const SHL_I128_NEG: i128 = unsafe { intrinsics::unchecked_shl(5_i128, -1) }; //~^ ERROR any use of this value will cause an error +//~| WARN this was previously accepted by the compiler but is being phased out // and that there's no special relation to the value -1 by picking some // negative values at random: const SHL_I8_NEG_RANDOM: i8 = unsafe { intrinsics::unchecked_shl(5_i8, -6) }; //~^ ERROR any use of this value will cause an error +//~| WARN this was previously accepted by the compiler but is being phased out const SHL_I16_NEG_RANDOM: i16 = unsafe { intrinsics::unchecked_shl(5_16, -13) }; //~^ ERROR any use of this value will cause an error +//~| WARN this was previously accepted by the compiler but is being phased out const SHL_I32_NEG_RANDOM: i32 = unsafe { intrinsics::unchecked_shl(5_i32, -25) }; //~^ ERROR any use of this value will cause an error +//~| WARN this was previously accepted by the compiler but is being phased out const SHL_I64_NEG_RANDOM: i64 = unsafe { intrinsics::unchecked_shl(5_i64, -30) }; //~^ ERROR any use of this value will cause an error +//~| WARN this was previously accepted by the compiler but is being phased out const SHL_I128_NEG_RANDOM: i128 = unsafe { intrinsics::unchecked_shl(5_i128, -93) }; //~^ ERROR any use of this value will cause an error +//~| WARN this was previously accepted by the compiler but is being phased out // Repeat it all over for `unchecked_shr` @@ -69,74 +89,101 @@ const SHL_I128_NEG_RANDOM: i128 = unsafe { intrinsics::unchecked_shl(5_i128, -93 const SHR_U8: u8 = unsafe { intrinsics::unchecked_shr(5_u8, 8) }; //~^ ERROR any use of this value will cause an error +//~| WARN this was previously accepted by the compiler but is being phased out const SHR_U16: u16 = unsafe { intrinsics::unchecked_shr(5_u16, 16) }; //~^ ERROR any use of this value will cause an error +//~| WARN this was previously accepted by the compiler but is being phased out const SHR_U32: u32 = unsafe { intrinsics::unchecked_shr(5_u32, 32) }; //~^ ERROR any use of this value will cause an error +//~| WARN this was previously accepted by the compiler but is being phased out const SHR_U64: u64 = unsafe { intrinsics::unchecked_shr(5_u64, 64) }; //~^ ERROR any use of this value will cause an error +//~| WARN this was previously accepted by the compiler but is being phased out const SHR_U128: u128 = unsafe { intrinsics::unchecked_shr(5_u128, 128) }; //~^ ERROR any use of this value will cause an error +//~| WARN this was previously accepted by the compiler but is being phased out // signed types: const SHR_I8: i8 = unsafe { intrinsics::unchecked_shr(5_i8, 8) }; //~^ ERROR any use of this value will cause an error +//~| WARN this was previously accepted by the compiler but is being phased out const SHR_I16: i16 = unsafe { intrinsics::unchecked_shr(5_16, 16) }; //~^ ERROR any use of this value will cause an error +//~| WARN this was previously accepted by the compiler but is being phased out const SHR_I32: i32 = unsafe { intrinsics::unchecked_shr(5_i32, 32) }; //~^ ERROR any use of this value will cause an error +//~| WARN this was previously accepted by the compiler but is being phased out const SHR_I64: i64 = unsafe { intrinsics::unchecked_shr(5_i64, 64) }; //~^ ERROR any use of this value will cause an error +//~| WARN this was previously accepted by the compiler but is being phased out const SHR_I128: i128 = unsafe { intrinsics::unchecked_shr(5_i128, 128) }; //~^ ERROR any use of this value will cause an error +//~| WARN this was previously accepted by the compiler but is being phased out // and make sure we capture y < 0: const SHR_I8_NEG: i8 = unsafe { intrinsics::unchecked_shr(5_i8, -1) }; //~^ ERROR any use of this value will cause an error +//~| WARN this was previously accepted by the compiler but is being phased out const SHR_I16_NEG: i16 = unsafe { intrinsics::unchecked_shr(5_16, -1) }; //~^ ERROR any use of this value will cause an error +//~| WARN this was previously accepted by the compiler but is being phased out const SHR_I32_NEG: i32 = unsafe { intrinsics::unchecked_shr(5_i32, -1) }; //~^ ERROR any use of this value will cause an error +//~| WARN this was previously accepted by the compiler but is being phased out const SHR_I64_NEG: i64 = unsafe { intrinsics::unchecked_shr(5_i64, -1) }; //~^ ERROR any use of this value will cause an error +//~| WARN this was previously accepted by the compiler but is being phased out const SHR_I128_NEG: i128 = unsafe { intrinsics::unchecked_shr(5_i128, -1) }; //~^ ERROR any use of this value will cause an error +//~| WARN this was previously accepted by the compiler but is being phased out // and that there's no special relation to the value -1 by picking some // negative values at random: const SHR_I8_NEG_RANDOM: i8 = unsafe { intrinsics::unchecked_shr(5_i8, -6) }; //~^ ERROR any use of this value will cause an error +//~| WARN this was previously accepted by the compiler but is being phased out const SHR_I16_NEG_RANDOM: i16 = unsafe { intrinsics::unchecked_shr(5_16, -13) }; //~^ ERROR any use of this value will cause an error +//~| WARN this was previously accepted by the compiler but is being phased out const SHR_I32_NEG_RANDOM: i32 = unsafe { intrinsics::unchecked_shr(5_i32, -25) }; //~^ ERROR any use of this value will cause an error +//~| WARN this was previously accepted by the compiler but is being phased out const SHR_I64_NEG_RANDOM: i64 = unsafe { intrinsics::unchecked_shr(5_i64, -30) }; //~^ ERROR any use of this value will cause an error +//~| WARN this was previously accepted by the compiler but is being phased out const SHR_I128_NEG_RANDOM: i128 = unsafe { intrinsics::unchecked_shr(5_i128, -93) }; //~^ ERROR any use of this value will cause an error +//~| WARN this was previously accepted by the compiler but is being phased out // Other arithmetic functions: const _: u16 = unsafe { std::intrinsics::unchecked_add(40000u16, 30000) }; //~^ ERROR any use of this value will cause an error +//~| WARN this was previously accepted by the compiler but is being phased out const _: u32 = unsafe { std::intrinsics::unchecked_sub(14u32, 22) }; //~^ ERROR any use of this value will cause an error +//~| WARN this was previously accepted by the compiler but is being phased out const _: u16 = unsafe { std::intrinsics::unchecked_mul(300u16, 250u16) }; //~^ ERROR any use of this value will cause an error +//~| WARN this was previously accepted by the compiler but is being phased out const _: i32 = unsafe { std::intrinsics::unchecked_div(1, 0) }; //~^ ERROR any use of this value will cause an error +//~| WARN this was previously accepted by the compiler but is being phased out const _: i32 = unsafe { std::intrinsics::unchecked_div(i32::MIN, -1) }; //~^ ERROR any use of this value will cause an error +//~| WARN this was previously accepted by the compiler but is being phased out const _: i32 = unsafe { std::intrinsics::unchecked_rem(1, 0) }; //~^ ERROR any use of this value will cause an error +//~| WARN this was previously accepted by the compiler but is being phased out const _: i32 = unsafe { std::intrinsics::unchecked_rem(i32::MIN, -1) }; //~^ ERROR any use of this value will cause an error +//~| WARN this was previously accepted by the compiler but is being phased out fn main() {} diff --git a/src/test/ui/consts/const-int-unchecked.stderr b/src/test/ui/consts/const-int-unchecked.stderr index 0287b404e7d46..e5ecbbc71a7f6 100644 --- a/src/test/ui/consts/const-int-unchecked.stderr +++ b/src/test/ui/consts/const-int-unchecked.stderr @@ -7,374 +7,514 @@ LL | const SHL_U8: u8 = unsafe { intrinsics::unchecked_shl(5_u8, 8) }; | overflowing shift by 8 in `unchecked_shl` | = note: `#[deny(const_err)]` on by default + = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:17:31 + --> $DIR/const-int-unchecked.rs:18:31 | LL | const SHL_U16: u16 = unsafe { intrinsics::unchecked_shl(5_u16, 16) }; | ------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | overflowing shift by 16 in `unchecked_shl` + | + = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:19:31 + --> $DIR/const-int-unchecked.rs:21:31 | LL | const SHL_U32: u32 = unsafe { intrinsics::unchecked_shl(5_u32, 32) }; | ------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | overflowing shift by 32 in `unchecked_shl` + | + = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:21:31 + --> $DIR/const-int-unchecked.rs:24:31 | LL | const SHL_U64: u64 = unsafe { intrinsics::unchecked_shl(5_u64, 64) }; | ------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | overflowing shift by 64 in `unchecked_shl` + | + = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:23:33 + --> $DIR/const-int-unchecked.rs:27:33 | LL | const SHL_U128: u128 = unsafe { intrinsics::unchecked_shl(5_u128, 128) }; | --------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | overflowing shift by 128 in `unchecked_shl` + | + = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:28:29 + --> $DIR/const-int-unchecked.rs:33:29 | LL | const SHL_I8: i8 = unsafe { intrinsics::unchecked_shl(5_i8, 8) }; | ----------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | overflowing shift by 8 in `unchecked_shl` + | + = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:30:31 + --> $DIR/const-int-unchecked.rs:36:31 | LL | const SHL_I16: i16 = unsafe { intrinsics::unchecked_shl(5_16, 16) }; | ------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | overflowing shift by 16 in `unchecked_shl` + | + = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:32:31 + --> $DIR/const-int-unchecked.rs:39:31 | LL | const SHL_I32: i32 = unsafe { intrinsics::unchecked_shl(5_i32, 32) }; | ------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | overflowing shift by 32 in `unchecked_shl` + | + = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:34:31 + --> $DIR/const-int-unchecked.rs:42:31 | LL | const SHL_I64: i64 = unsafe { intrinsics::unchecked_shl(5_i64, 64) }; | ------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | overflowing shift by 64 in `unchecked_shl` + | + = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:36:33 + --> $DIR/const-int-unchecked.rs:45:33 | LL | const SHL_I128: i128 = unsafe { intrinsics::unchecked_shl(5_i128, 128) }; | --------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | overflowing shift by 128 in `unchecked_shl` + | + = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:41:33 + --> $DIR/const-int-unchecked.rs:51:33 | LL | const SHL_I8_NEG: i8 = unsafe { intrinsics::unchecked_shl(5_i8, -1) }; | --------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | overflowing shift by 255 in `unchecked_shl` + | + = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:43:35 + --> $DIR/const-int-unchecked.rs:54:35 | LL | const SHL_I16_NEG: i16 = unsafe { intrinsics::unchecked_shl(5_16, -1) }; | ----------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | overflowing shift by 65535 in `unchecked_shl` + | + = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:45:35 + --> $DIR/const-int-unchecked.rs:57:35 | LL | const SHL_I32_NEG: i32 = unsafe { intrinsics::unchecked_shl(5_i32, -1) }; | ----------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | overflowing shift by 4294967295 in `unchecked_shl` + | + = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:47:35 + --> $DIR/const-int-unchecked.rs:60:35 | LL | const SHL_I64_NEG: i64 = unsafe { intrinsics::unchecked_shl(5_i64, -1) }; | ----------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | overflowing shift by 18446744073709551615 in `unchecked_shl` + | + = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:49:37 + --> $DIR/const-int-unchecked.rs:63:37 | LL | const SHL_I128_NEG: i128 = unsafe { intrinsics::unchecked_shl(5_i128, -1) }; | ------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | overflowing shift by 340282366920938463463374607431768211455 in `unchecked_shl` + | + = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:55:40 + --> $DIR/const-int-unchecked.rs:70:40 | LL | const SHL_I8_NEG_RANDOM: i8 = unsafe { intrinsics::unchecked_shl(5_i8, -6) }; | ---------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | overflowing shift by 250 in `unchecked_shl` + | + = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:57:42 + --> $DIR/const-int-unchecked.rs:73:42 | LL | const SHL_I16_NEG_RANDOM: i16 = unsafe { intrinsics::unchecked_shl(5_16, -13) }; | -----------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | overflowing shift by 65523 in `unchecked_shl` + | + = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:59:42 + --> $DIR/const-int-unchecked.rs:76:42 | LL | const SHL_I32_NEG_RANDOM: i32 = unsafe { intrinsics::unchecked_shl(5_i32, -25) }; | -----------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | overflowing shift by 4294967271 in `unchecked_shl` + | + = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:61:42 + --> $DIR/const-int-unchecked.rs:79:42 | LL | const SHL_I64_NEG_RANDOM: i64 = unsafe { intrinsics::unchecked_shl(5_i64, -30) }; | -----------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | overflowing shift by 18446744073709551586 in `unchecked_shl` + | + = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:63:44 + --> $DIR/const-int-unchecked.rs:82:44 | LL | const SHL_I128_NEG_RANDOM: i128 = unsafe { intrinsics::unchecked_shl(5_i128, -93) }; | -------------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | overflowing shift by 340282366920938463463374607431768211363 in `unchecked_shl` + | + = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:70:29 + --> $DIR/const-int-unchecked.rs:90:29 | LL | const SHR_U8: u8 = unsafe { intrinsics::unchecked_shr(5_u8, 8) }; | ----------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | overflowing shift by 8 in `unchecked_shr` + | + = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:72:31 + --> $DIR/const-int-unchecked.rs:93:31 | LL | const SHR_U16: u16 = unsafe { intrinsics::unchecked_shr(5_u16, 16) }; | ------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | overflowing shift by 16 in `unchecked_shr` + | + = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:74:31 + --> $DIR/const-int-unchecked.rs:96:31 | LL | const SHR_U32: u32 = unsafe { intrinsics::unchecked_shr(5_u32, 32) }; | ------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | overflowing shift by 32 in `unchecked_shr` + | + = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:76:31 + --> $DIR/const-int-unchecked.rs:99:31 | LL | const SHR_U64: u64 = unsafe { intrinsics::unchecked_shr(5_u64, 64) }; | ------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | overflowing shift by 64 in `unchecked_shr` + | + = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:78:33 + --> $DIR/const-int-unchecked.rs:102:33 | LL | const SHR_U128: u128 = unsafe { intrinsics::unchecked_shr(5_u128, 128) }; | --------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | overflowing shift by 128 in `unchecked_shr` + | + = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:83:29 + --> $DIR/const-int-unchecked.rs:108:29 | LL | const SHR_I8: i8 = unsafe { intrinsics::unchecked_shr(5_i8, 8) }; | ----------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | overflowing shift by 8 in `unchecked_shr` + | + = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:85:31 + --> $DIR/const-int-unchecked.rs:111:31 | LL | const SHR_I16: i16 = unsafe { intrinsics::unchecked_shr(5_16, 16) }; | ------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | overflowing shift by 16 in `unchecked_shr` + | + = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:87:31 + --> $DIR/const-int-unchecked.rs:114:31 | LL | const SHR_I32: i32 = unsafe { intrinsics::unchecked_shr(5_i32, 32) }; | ------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | overflowing shift by 32 in `unchecked_shr` + | + = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:89:31 + --> $DIR/const-int-unchecked.rs:117:31 | LL | const SHR_I64: i64 = unsafe { intrinsics::unchecked_shr(5_i64, 64) }; | ------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | overflowing shift by 64 in `unchecked_shr` + | + = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:91:33 + --> $DIR/const-int-unchecked.rs:120:33 | LL | const SHR_I128: i128 = unsafe { intrinsics::unchecked_shr(5_i128, 128) }; | --------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | overflowing shift by 128 in `unchecked_shr` + | + = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:96:33 + --> $DIR/const-int-unchecked.rs:126:33 | LL | const SHR_I8_NEG: i8 = unsafe { intrinsics::unchecked_shr(5_i8, -1) }; | --------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | overflowing shift by 255 in `unchecked_shr` + | + = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:98:35 + --> $DIR/const-int-unchecked.rs:129:35 | LL | const SHR_I16_NEG: i16 = unsafe { intrinsics::unchecked_shr(5_16, -1) }; | ----------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | overflowing shift by 65535 in `unchecked_shr` + | + = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:100:35 + --> $DIR/const-int-unchecked.rs:132:35 | LL | const SHR_I32_NEG: i32 = unsafe { intrinsics::unchecked_shr(5_i32, -1) }; | ----------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | overflowing shift by 4294967295 in `unchecked_shr` + | + = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:102:35 + --> $DIR/const-int-unchecked.rs:135:35 | LL | const SHR_I64_NEG: i64 = unsafe { intrinsics::unchecked_shr(5_i64, -1) }; | ----------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | overflowing shift by 18446744073709551615 in `unchecked_shr` + | + = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:104:37 + --> $DIR/const-int-unchecked.rs:138:37 | LL | const SHR_I128_NEG: i128 = unsafe { intrinsics::unchecked_shr(5_i128, -1) }; | ------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | overflowing shift by 340282366920938463463374607431768211455 in `unchecked_shr` + | + = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:110:40 + --> $DIR/const-int-unchecked.rs:145:40 | LL | const SHR_I8_NEG_RANDOM: i8 = unsafe { intrinsics::unchecked_shr(5_i8, -6) }; | ---------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | overflowing shift by 250 in `unchecked_shr` + | + = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:112:42 + --> $DIR/const-int-unchecked.rs:148:42 | LL | const SHR_I16_NEG_RANDOM: i16 = unsafe { intrinsics::unchecked_shr(5_16, -13) }; | -----------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | overflowing shift by 65523 in `unchecked_shr` + | + = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:114:42 + --> $DIR/const-int-unchecked.rs:151:42 | LL | const SHR_I32_NEG_RANDOM: i32 = unsafe { intrinsics::unchecked_shr(5_i32, -25) }; | -----------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | overflowing shift by 4294967271 in `unchecked_shr` + | + = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:116:42 + --> $DIR/const-int-unchecked.rs:154:42 | LL | const SHR_I64_NEG_RANDOM: i64 = unsafe { intrinsics::unchecked_shr(5_i64, -30) }; | -----------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | overflowing shift by 18446744073709551586 in `unchecked_shr` + | + = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:118:44 + --> $DIR/const-int-unchecked.rs:157:44 | LL | const SHR_I128_NEG_RANDOM: i128 = unsafe { intrinsics::unchecked_shr(5_i128, -93) }; | -------------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | overflowing shift by 340282366920938463463374607431768211363 in `unchecked_shr` + | + = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:123:25 + --> $DIR/const-int-unchecked.rs:163:25 | LL | const _: u16 = unsafe { std::intrinsics::unchecked_add(40000u16, 30000) }; | ------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | overflow executing `unchecked_add` + | + = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:126:25 + --> $DIR/const-int-unchecked.rs:167:25 | LL | const _: u32 = unsafe { std::intrinsics::unchecked_sub(14u32, 22) }; | ------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | overflow executing `unchecked_sub` + | + = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:129:25 + --> $DIR/const-int-unchecked.rs:171:25 | LL | const _: u16 = unsafe { std::intrinsics::unchecked_mul(300u16, 250u16) }; | ------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | overflow executing `unchecked_mul` + | + = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:132:25 + --> $DIR/const-int-unchecked.rs:175:25 | LL | const _: i32 = unsafe { std::intrinsics::unchecked_div(1, 0) }; | ------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | dividing by zero + | + = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:134:25 + --> $DIR/const-int-unchecked.rs:178:25 | LL | const _: i32 = unsafe { std::intrinsics::unchecked_div(i32::MIN, -1) }; | ------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | overflow executing `unchecked_div` + | + = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:137:25 + --> $DIR/const-int-unchecked.rs:182:25 | LL | const _: i32 = unsafe { std::intrinsics::unchecked_rem(1, 0) }; | ------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | calculating the remainder with a divisor of zero + | + = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:139:25 + --> $DIR/const-int-unchecked.rs:185:25 | LL | const _: i32 = unsafe { std::intrinsics::unchecked_rem(i32::MIN, -1) }; | ------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | overflow executing `unchecked_rem` + | + = 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 #71800 error: aborting due to 47 previous errors diff --git a/src/test/ui/consts/const-len-underflow-separate-spans.rs b/src/test/ui/consts/const-len-underflow-separate-spans.rs index 01d2951b41613..7c3d1f320f2f6 100644 --- a/src/test/ui/consts/const-len-underflow-separate-spans.rs +++ b/src/test/ui/consts/const-len-underflow-separate-spans.rs @@ -6,6 +6,7 @@ const ONE: usize = 1; const TWO: usize = 2; const LEN: usize = ONE - TWO; //~^ ERROR any use of this value will cause an error +//~| WARN this was previously accepted by the compiler but is being phased out fn main() { let a: [i8; LEN] = unimplemented!(); diff --git a/src/test/ui/consts/const-len-underflow-separate-spans.stderr b/src/test/ui/consts/const-len-underflow-separate-spans.stderr index 2ab6d0ffdef4c..70f645a6c40e8 100644 --- a/src/test/ui/consts/const-len-underflow-separate-spans.stderr +++ b/src/test/ui/consts/const-len-underflow-separate-spans.stderr @@ -7,9 +7,11 @@ LL | const LEN: usize = ONE - TWO; | attempt to compute `1_usize - 2_usize`, which would overflow | = note: `#[deny(const_err)]` on by default + = 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 #71800 error[E0080]: evaluation of constant value failed - --> $DIR/const-len-underflow-separate-spans.rs:11:17 + --> $DIR/const-len-underflow-separate-spans.rs:12:17 | LL | let a: [i8; LEN] = unimplemented!(); | ^^^ referenced constant has errors diff --git a/src/test/ui/consts/const-mut-refs/mut_ref_in_final_dynamic_check.rs b/src/test/ui/consts/const-mut-refs/mut_ref_in_final_dynamic_check.rs index 1e856ec0a0acc..90977efd2b454 100644 --- a/src/test/ui/consts/const-mut-refs/mut_ref_in_final_dynamic_check.rs +++ b/src/test/ui/consts/const-mut-refs/mut_ref_in_final_dynamic_check.rs @@ -13,6 +13,7 @@ const fn helper() -> Option<&'static mut i32> { unsafe { // Undefined behaviour (integer as pointer), who doesn't love tests like this. // This code never gets executed, because the static checks fail before that. Some(&mut *(42 as *mut i32)) //~ ERROR any use of this value will cause an error + //~| WARN this was previously accepted by the compiler but is being phased out } } // The error is an evaluation error and not a validation error, so the error is reported // directly at the site where it occurs. diff --git a/src/test/ui/consts/const-mut-refs/mut_ref_in_final_dynamic_check.stderr b/src/test/ui/consts/const-mut-refs/mut_ref_in_final_dynamic_check.stderr index 0bbf84b71bb68..45ae055614b57 100644 --- a/src/test/ui/consts/const-mut-refs/mut_ref_in_final_dynamic_check.stderr +++ b/src/test/ui/consts/const-mut-refs/mut_ref_in_final_dynamic_check.stderr @@ -6,15 +6,17 @@ LL | Some(&mut *(42 as *mut i32)) | | | unable to turn bytes into a pointer | inside `helper` at $DIR/mut_ref_in_final_dynamic_check.rs:15:10 - | inside `A` at $DIR/mut_ref_in_final_dynamic_check.rs:19:29 + | inside `A` at $DIR/mut_ref_in_final_dynamic_check.rs:20:29 ... LL | const A: Option<&mut i32> = helper(); | ------------------------------------- | = note: `#[deny(const_err)]` on by default + = 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 #71800 error: encountered dangling pointer in final constant - --> $DIR/mut_ref_in_final_dynamic_check.rs:26:1 + --> $DIR/mut_ref_in_final_dynamic_check.rs:27:1 | LL | const B: Option<&mut i32> = helper2(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/consts/const-prop-read-static-in-const.rs b/src/test/ui/consts/const-prop-read-static-in-const.rs index 13b1b2d14125b..a65b707f012d0 100644 --- a/src/test/ui/consts/const-prop-read-static-in-const.rs +++ b/src/test/ui/consts/const-prop-read-static-in-const.rs @@ -3,6 +3,7 @@ #![allow(dead_code)] const TEST: u8 = MY_STATIC; //~ ERROR any use of this value will cause an error +//~| WARN this was previously accepted by the compiler but is being phased out static MY_STATIC: u8 = 4; diff --git a/src/test/ui/consts/const-prop-read-static-in-const.stderr b/src/test/ui/consts/const-prop-read-static-in-const.stderr index 7a517d1d7b363..94d3f1c614544 100644 --- a/src/test/ui/consts/const-prop-read-static-in-const.stderr +++ b/src/test/ui/consts/const-prop-read-static-in-const.stderr @@ -7,6 +7,8 @@ LL | const TEST: u8 = MY_STATIC; | constant accesses static | = note: `#[deny(const_err)]` on by default + = 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 #71800 warning: skipping const checks | diff --git a/src/test/ui/consts/const-size_of_val-align_of_val-extern-type.rs b/src/test/ui/consts/const-size_of_val-align_of_val-extern-type.rs index 09c7d5580deca..6653717778ba5 100644 --- a/src/test/ui/consts/const-size_of_val-align_of_val-extern-type.rs +++ b/src/test/ui/consts/const-size_of_val-align_of_val-extern-type.rs @@ -9,6 +9,8 @@ extern "C" { } const _SIZE: usize = unsafe { size_of_val(&4 as *const i32 as *const Opaque) }; //~ ERROR +//~| WARN this was previously accepted by the compiler but is being phased out const _ALIGN: usize = unsafe { min_align_of_val(&4 as *const i32 as *const Opaque) }; //~ ERROR +//~| WARN this was previously accepted by the compiler but is being phased out fn main() {} diff --git a/src/test/ui/consts/const-size_of_val-align_of_val-extern-type.stderr b/src/test/ui/consts/const-size_of_val-align_of_val-extern-type.stderr index d3f1b04d25154..a9211c17a6bc0 100644 --- a/src/test/ui/consts/const-size_of_val-align_of_val-extern-type.stderr +++ b/src/test/ui/consts/const-size_of_val-align_of_val-extern-type.stderr @@ -7,14 +7,19 @@ LL | const _SIZE: usize = unsafe { size_of_val(&4 as *const i32 as *const Opaque | `extern type` does not have known layout | = note: `#[deny(const_err)]` on by default + = 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 #71800 error: any use of this value will cause an error - --> $DIR/const-size_of_val-align_of_val-extern-type.rs:12:32 + --> $DIR/const-size_of_val-align_of_val-extern-type.rs:13:32 | LL | const _ALIGN: usize = unsafe { min_align_of_val(&4 as *const i32 as *const Opaque) }; | -------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | `extern type` does not have known layout + | + = 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 #71800 error: aborting due to 2 previous errors diff --git a/src/test/ui/consts/const-slice-oob.rs b/src/test/ui/consts/const-slice-oob.rs index 70852f8f56929..35e5a4d2233fe 100644 --- a/src/test/ui/consts/const-slice-oob.rs +++ b/src/test/ui/consts/const-slice-oob.rs @@ -4,6 +4,7 @@ const FOO: &'static[u32] = &[1, 2, 3]; const BAR: u32 = FOO[5]; //~^ index out of bounds: the length is 3 but the index is 5 //~| ERROR any use of this value will cause an error +//~| WARN this was previously accepted by the compiler but is being phased out 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 0077bafe9e628..6d2c79034d391 100644 --- a/src/test/ui/consts/const-slice-oob.stderr +++ b/src/test/ui/consts/const-slice-oob.stderr @@ -7,6 +7,8 @@ LL | const BAR: u32 = FOO[5]; | index out of bounds: the length is 3 but the index is 5 | = note: `#[deny(const_err)]` on by default + = 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 #71800 error: aborting due to previous error diff --git a/src/test/ui/consts/const-unwrap.stderr b/src/test/ui/consts/const-unwrap.stderr index b2e037c69cb00..86c2f1c4f8e13 100644 --- a/src/test/ui/consts/const-unwrap.stderr +++ b/src/test/ui/consts/const-unwrap.stderr @@ -14,6 +14,8 @@ LL | const BAR: i32 = Option::::None.unwrap(); | ---------------------------------------------- | = note: `#[deny(const_err)]` on by default + = 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 #71800 = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to previous error diff --git a/src/test/ui/consts/const_limit/const_eval_limit_reached.rs b/src/test/ui/consts/const_limit/const_eval_limit_reached.rs index 069dac00c9ace..773640b72e6ea 100644 --- a/src/test/ui/consts/const_limit/const_eval_limit_reached.rs +++ b/src/test/ui/consts/const_limit/const_eval_limit_reached.rs @@ -5,6 +5,7 @@ const X: usize = { let mut x = 0; while x != 1000 { //~^ ERROR any use of this value will cause an error + //~| WARN this was previously accepted by the compiler but is being phased out x += 1; } diff --git a/src/test/ui/consts/const_limit/const_eval_limit_reached.stderr b/src/test/ui/consts/const_limit/const_eval_limit_reached.stderr index 8785c9e54b9bf..10e54e0348cb7 100644 --- a/src/test/ui/consts/const_limit/const_eval_limit_reached.stderr +++ b/src/test/ui/consts/const_limit/const_eval_limit_reached.stderr @@ -6,6 +6,7 @@ LL | | let mut x = 0; LL | | while x != 1000 { | |_____^ LL | || +LL | || LL | || x += 1; LL | || } | ||_____^ exceeded interpreter step limit (see `#[const_eval_limit]`) @@ -15,6 +16,8 @@ LL | | }; | |__- | = note: `#[deny(const_err)]` on by default + = 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 #71800 error: aborting due to previous error diff --git a/src/test/ui/consts/const_unsafe_unreachable_ub.rs b/src/test/ui/consts/const_unsafe_unreachable_ub.rs index 11920d852e02f..0bd37876cc3f0 100644 --- a/src/test/ui/consts/const_unsafe_unreachable_ub.rs +++ b/src/test/ui/consts/const_unsafe_unreachable_ub.rs @@ -17,4 +17,5 @@ fn main() { assert_eq!(BAR, true); //~^ ERROR E0080 //~| ERROR erroneous constant + //~| WARN this was previously accepted by the compiler but is being phased out } diff --git a/src/test/ui/consts/const_unsafe_unreachable_ub.stderr b/src/test/ui/consts/const_unsafe_unreachable_ub.stderr index 6dddc7ff6e9d2..3f122b2a85912 100644 --- a/src/test/ui/consts/const_unsafe_unreachable_ub.stderr +++ b/src/test/ui/consts/const_unsafe_unreachable_ub.stderr @@ -19,6 +19,8 @@ note: the lint level is defined here | LL | #[warn(const_err)] | ^^^^^^^^^ + = 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 #71800 error[E0080]: evaluation of constant value failed --> $DIR/const_unsafe_unreachable_ub.rs:17:14 @@ -33,6 +35,8 @@ LL | assert_eq!(BAR, true); | ^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors | = note: `#[deny(const_err)]` on by default + = 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 #71800 = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 2 previous errors; 1 warning emitted diff --git a/src/test/ui/consts/control-flow/assert.const_panic.stderr b/src/test/ui/consts/control-flow/assert.const_panic.stderr index 03662a3520909..2f28c2e7bb642 100644 --- a/src/test/ui/consts/control-flow/assert.const_panic.stderr +++ b/src/test/ui/consts/control-flow/assert.const_panic.stderr @@ -7,6 +7,8 @@ LL | const _: () = assert!(false); | the evaluated program panicked at 'assertion failed: false', $DIR/assert.rs:10:15 | = note: `#[deny(const_err)]` on by default + = 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 #71800 = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to previous error diff --git a/src/test/ui/consts/control-flow/assert.rs b/src/test/ui/consts/control-flow/assert.rs index 90017fee19337..a21f28604bdea 100644 --- a/src/test/ui/consts/control-flow/assert.rs +++ b/src/test/ui/consts/control-flow/assert.rs @@ -10,5 +10,6 @@ const _: () = assert!(true); const _: () = assert!(false); //[stock]~^ ERROR panicking in constants is unstable //[const_panic]~^^ ERROR any use of this value will cause an error +//[const_panic]~| WARN this was previously accepted by the compiler but is being phased out fn main() {} diff --git a/src/test/ui/consts/issue-51559.rs b/src/test/ui/consts/issue-51559.rs index 69f0d8df0aa4a..cc644404f7d73 100644 --- a/src/test/ui/consts/issue-51559.rs +++ b/src/test/ui/consts/issue-51559.rs @@ -3,5 +3,6 @@ const BAR: *mut () = ((|| 3) as fn() -> i32) as *mut (); pub const FOO: usize = unsafe { BAR as usize }; //~^ ERROR any use of this value will cause an error +//~| WARN this was previously accepted by the compiler but is being phased out fn main() {} diff --git a/src/test/ui/consts/issue-51559.stderr b/src/test/ui/consts/issue-51559.stderr index 4d50ec818bce7..fbb40c890dd7b 100644 --- a/src/test/ui/consts/issue-51559.stderr +++ b/src/test/ui/consts/issue-51559.stderr @@ -7,6 +7,8 @@ LL | pub const FOO: usize = unsafe { BAR as usize }; | "pointer-to-integer cast" needs an rfc before being allowed inside constants | = note: `#[deny(const_err)]` on by default + = 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 #71800 error: aborting due to previous error diff --git a/src/test/ui/consts/issue-55878.stderr b/src/test/ui/consts/issue-55878.stderr index ede5487b65d39..a0e8fc70b6acd 100644 --- a/src/test/ui/consts/issue-55878.stderr +++ b/src/test/ui/consts/issue-55878.stderr @@ -16,6 +16,8 @@ LL | println!("Size: {}", std::mem::size_of::<[u8; u64::MAX as usize]>()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors | = note: `#[deny(const_err)]` on by default + = 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 #71800 error: aborting due to 2 previous errors diff --git a/src/test/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.rs b/src/test/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.rs index ba3b61a3fa732..7bbe9c87705a3 100644 --- a/src/test/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.rs +++ b/src/test/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.rs @@ -26,6 +26,8 @@ const U8_MUT2: &u8 = { //~ NOTE unsafe { &(*static_cross_crate::ZERO_REF)[0] } //~^ WARN [const_err] //~| NOTE constant accesses static + //~| WARN this was previously accepted by the compiler but is being phased out + //~| NOTE }; #[warn(const_err)] //~ NOTE const U8_MUT3: &u8 = { //~ NOTE @@ -33,6 +35,8 @@ const U8_MUT3: &u8 = { //~ NOTE //~^ WARN [const_err] //~| NOTE constant accesses static //~| NOTE in this expansion of panic! + //~| WARN this was previously accepted by the compiler but is being phased out + //~| NOTE }; pub fn test(x: &[u8; 1]) -> bool { diff --git a/src/test/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.stderr b/src/test/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.stderr index 4484a813a883d..a9d6fde6c05be 100644 --- a/src/test/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.stderr +++ b/src/test/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.stderr @@ -11,7 +11,7 @@ LL | | }; = 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. error: could not evaluate constant pattern - --> $DIR/const_refers_to_static_cross_crate.rs:40:9 + --> $DIR/const_refers_to_static_cross_crate.rs:44:9 | LL | SLICE_MUT => true, | ^^^^^^^^^ @@ -29,7 +29,7 @@ LL | | }; = 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. error: could not evaluate constant pattern - --> $DIR/const_refers_to_static_cross_crate.rs:49:9 + --> $DIR/const_refers_to_static_cross_crate.rs:53:9 | LL | U8_MUT => true, | ^^^^^^ @@ -42,6 +42,8 @@ LL | | unsafe { &(*static_cross_crate::ZERO_REF)[0] } | | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constant accesses static LL | | LL | | +LL | | +LL | | LL | | }; | |__- | @@ -50,57 +52,62 @@ note: the lint level is defined here | LL | #[warn(const_err)] | ^^^^^^^^^ + = 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 #71800 error: could not evaluate constant pattern - --> $DIR/const_refers_to_static_cross_crate.rs:60:9 + --> $DIR/const_refers_to_static_cross_crate.rs:64:9 | LL | U8_MUT2 => true, | ^^^^^^^ warning: any use of this value will cause an error - --> $DIR/const_refers_to_static_cross_crate.rs:32:51 + --> $DIR/const_refers_to_static_cross_crate.rs:34:51 | LL | / const U8_MUT3: &u8 = { LL | | unsafe { match static_cross_crate::OPT_ZERO { Some(ref u) => u, None => panic!() } } | | ^^^^^^^^^^^ constant accesses static LL | | LL | | +... | LL | | LL | | }; | |__- | note: the lint level is defined here - --> $DIR/const_refers_to_static_cross_crate.rs:30:8 + --> $DIR/const_refers_to_static_cross_crate.rs:32:8 | LL | #[warn(const_err)] | ^^^^^^^^^ + = 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 #71800 error: could not evaluate constant pattern - --> $DIR/const_refers_to_static_cross_crate.rs:68:9 + --> $DIR/const_refers_to_static_cross_crate.rs:72:9 | LL | U8_MUT3 => true, | ^^^^^^^ error: could not evaluate constant pattern - --> $DIR/const_refers_to_static_cross_crate.rs:40:9 + --> $DIR/const_refers_to_static_cross_crate.rs:44:9 | LL | SLICE_MUT => true, | ^^^^^^^^^ error: could not evaluate constant pattern - --> $DIR/const_refers_to_static_cross_crate.rs:49:9 + --> $DIR/const_refers_to_static_cross_crate.rs:53:9 | LL | U8_MUT => true, | ^^^^^^ error: could not evaluate constant pattern - --> $DIR/const_refers_to_static_cross_crate.rs:60:9 + --> $DIR/const_refers_to_static_cross_crate.rs:64:9 | LL | U8_MUT2 => true, | ^^^^^^^ error: could not evaluate constant pattern - --> $DIR/const_refers_to_static_cross_crate.rs:68:9 + --> $DIR/const_refers_to_static_cross_crate.rs:72:9 | LL | U8_MUT3 => true, | ^^^^^^^ @@ -138,27 +145,27 @@ help: skipping check that does not even have a feature gate LL | unsafe { &(*static_cross_crate::ZERO_REF)[0] } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: skipping check that does not even have a feature gate - --> $DIR/const_refers_to_static_cross_crate.rs:32:20 + --> $DIR/const_refers_to_static_cross_crate.rs:34:20 | LL | unsafe { match static_cross_crate::OPT_ZERO { Some(ref u) => u, None => panic!() } } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: skipping check that does not even have a feature gate - --> $DIR/const_refers_to_static_cross_crate.rs:32:20 + --> $DIR/const_refers_to_static_cross_crate.rs:34:20 | LL | unsafe { match static_cross_crate::OPT_ZERO { Some(ref u) => u, None => panic!() } } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: skipping check that does not even have a feature gate - --> $DIR/const_refers_to_static_cross_crate.rs:32:20 + --> $DIR/const_refers_to_static_cross_crate.rs:34:20 | LL | unsafe { match static_cross_crate::OPT_ZERO { Some(ref u) => u, None => panic!() } } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: skipping check for `const_panic` feature - --> $DIR/const_refers_to_static_cross_crate.rs:32:77 + --> $DIR/const_refers_to_static_cross_crate.rs:34:77 | LL | unsafe { match static_cross_crate::OPT_ZERO { Some(ref u) => u, None => panic!() } } | ^^^^^^^^ help: skipping check that does not even have a feature gate - --> $DIR/const_refers_to_static_cross_crate.rs:32:20 + --> $DIR/const_refers_to_static_cross_crate.rs:34:20 | LL | unsafe { match static_cross_crate::OPT_ZERO { Some(ref u) => u, None => panic!() } } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/consts/offset_from_ub.stderr b/src/test/ui/consts/offset_from_ub.stderr index ebe17e8730413..eb726f9cb113f 100644 --- a/src/test/ui/consts/offset_from_ub.stderr +++ b/src/test/ui/consts/offset_from_ub.stderr @@ -20,6 +20,8 @@ LL | | }; | |__- | = note: `#[deny(const_err)]` on by default + = 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 #71800 error: any use of this value will cause an error --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL @@ -38,6 +40,9 @@ LL | | LL | | unsafe { (42 as *const u8).offset_from(&5u8) as usize } LL | | }; | |__- + | + = 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 #71800 error: any use of this value will cause an error --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL @@ -59,6 +64,9 @@ LL | | let field_ptr = &data[1] as *const u8 as *const u16; LL | | unsafe { field_ptr.offset_from(base_ptr as *const u16) } LL | | }; | |__- + | + = 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 #71800 error: any use of this value will cause an error --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL @@ -78,6 +86,9 @@ LL | | let ptr = 0 as *const u8; LL | | unsafe { ptr.offset_from(ptr) } LL | | }; | |__- + | + = 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 #71800 error: any use of this value will cause an error --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL @@ -98,6 +109,9 @@ LL | | let ptr2 = 16 as *const u8; LL | | unsafe { ptr2.offset_from(ptr1) } LL | | }; | |__- + | + = 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 #71800 error: aborting due to 5 previous errors diff --git a/src/test/ui/consts/offset_ub.stderr b/src/test/ui/consts/offset_ub.stderr index e58db1efaf0e0..5e8b7a8e0b698 100644 --- a/src/test/ui/consts/offset_ub.stderr +++ b/src/test/ui/consts/offset_ub.stderr @@ -14,6 +14,8 @@ LL | pub const BEFORE_START: *const u8 = unsafe { (&0u8 as *const u8).offset(-1) | ------------------------------------------------------------------------------ | = note: `#[deny(const_err)]` on by default + = 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 #71800 error: any use of this value will cause an error --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL @@ -29,6 +31,9 @@ LL | unsafe { intrinsics::offset(self, count) } | LL | pub const AFTER_END: *const u8 = unsafe { (&0u8 as *const u8).offset(2) }; | -------------------------------------------------------------------------- + | + = 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 #71800 error: any use of this value will cause an error --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL @@ -44,6 +49,9 @@ LL | unsafe { intrinsics::offset(self, count) } | LL | pub const AFTER_ARRAY: *const u8 = unsafe { [0u8; 100].as_ptr().offset(101) }; | ------------------------------------------------------------------------------ + | + = 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 #71800 error: any use of this value will cause an error --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL @@ -59,6 +67,9 @@ LL | unsafe { intrinsics::offset(self, count) } | LL | pub const OVERFLOW: *const u16 = unsafe { [0u16; 1].as_ptr().offset(isize::MAX) }; | ---------------------------------------------------------------------------------- + | + = 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 #71800 error: any use of this value will cause an error --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL @@ -74,6 +85,9 @@ LL | unsafe { intrinsics::offset(self, count) } | LL | pub const UNDERFLOW: *const u16 = unsafe { [0u16; 1].as_ptr().offset(isize::MIN) }; | ----------------------------------------------------------------------------------- + | + = 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 #71800 error: any use of this value will cause an error --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL @@ -89,6 +103,9 @@ LL | unsafe { intrinsics::offset(self, count) } | LL | pub const OVERFLOW_ADDRESS_SPACE: *const u8 = unsafe { (usize::MAX as *const u8).offset(2) }; | --------------------------------------------------------------------------------------------- + | + = 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 #71800 error: any use of this value will cause an error --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL @@ -104,6 +121,9 @@ LL | unsafe { intrinsics::offset(self, count) } | LL | pub const UNDERFLOW_ADDRESS_SPACE: *const u8 = unsafe { (1 as *const u8).offset(-2) }; | -------------------------------------------------------------------------------------- + | + = 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 #71800 error: any use of this value will cause an error --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL @@ -119,6 +139,9 @@ LL | unsafe { intrinsics::offset(self, count) } | LL | pub const ZERO_SIZED_ALLOC: *const u8 = unsafe { [0u8; 0].as_ptr().offset(1) }; | ------------------------------------------------------------------------------- + | + = 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 #71800 error: any use of this value will cause an error --> $SRC_DIR/core/src/ptr/mut_ptr.rs:LL:COL @@ -134,6 +157,9 @@ LL | unsafe { intrinsics::offset(self, count) as *mut T } | LL | pub const DANGLING: *const u8 = unsafe { ptr::NonNull::::dangling().as_ptr().offset(4) }; | --------------------------------------------------------------------------------------------- + | + = 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 #71800 error: any use of this value will cause an error --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL @@ -149,6 +175,9 @@ LL | unsafe { intrinsics::offset(self, count) } | LL | pub const NULL_OFFSET_ZERO: *const u8 = unsafe { ptr::null::().offset(0) }; | ------------------------------------------------------------------------------- + | + = 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 #71800 error: any use of this value will cause an error --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL @@ -164,6 +193,9 @@ LL | unsafe { intrinsics::offset(self, count) } | LL | pub const UNDERFLOW_ABS: *const u8 = unsafe { (usize::MAX as *const u8).offset(isize::MIN) }; | --------------------------------------------------------------------------------------------- + | + = 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 #71800 error: aborting due to 11 previous errors diff --git a/src/test/ui/consts/ptr_comparisons.rs b/src/test/ui/consts/ptr_comparisons.rs index f16f6fd6de4ba..0570d817fcce5 100644 --- a/src/test/ui/consts/ptr_comparisons.rs +++ b/src/test/ui/consts/ptr_comparisons.rs @@ -66,13 +66,19 @@ const _: *const u8 = unsafe { std::ptr::addr_of!((*(FOO as *const usize as *const [u8; 1000]))[999]) }; //~^ ERROR any use of this value will cause an error //~| NOTE +//~| WARN this was previously accepted by the compiler but is being phased out +//~| NOTE const _: usize = unsafe { std::mem::transmute::<*const usize, usize>(FOO) + 4 }; //~^ ERROR any use of this value will cause an error //~| NOTE "pointer-to-integer cast" needs an rfc //~| NOTE +//~| WARN this was previously accepted by the compiler but is being phased out +//~| NOTE const _: usize = unsafe { *std::mem::transmute::<&&usize, &usize>(&FOO) + 4 }; //~^ ERROR any use of this value will cause an error //~| NOTE "pointer-to-integer cast" needs an rfc //~| NOTE +//~| WARN this was previously accepted by the compiler but is being phased out +//~| NOTE diff --git a/src/test/ui/consts/ptr_comparisons.stderr b/src/test/ui/consts/ptr_comparisons.stderr index 96b63c0acb0a1..c6c13e54137c5 100644 --- a/src/test/ui/consts/ptr_comparisons.stderr +++ b/src/test/ui/consts/ptr_comparisons.stderr @@ -14,6 +14,8 @@ LL | const _: *const usize = unsafe { (FOO as *const usize).offset(2) }; | ------------------------------------------------------------------- | = note: `#[deny(const_err)]` on by default + = 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 #71800 error: any use of this value will cause an error --> $DIR/ptr_comparisons.rs:66:33 @@ -24,22 +26,31 @@ LL | | unsafe { std::ptr::addr_of!((*(FOO as *const usize as *const [u8; 100 | |_________________________________^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^___- | | | memory access failed: pointer must be in-bounds at offset 1000, but is outside bounds of alloc2 which has size $WORD + | + = 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 #71800 error: any use of this value will cause an error - --> $DIR/ptr_comparisons.rs:70:27 + --> $DIR/ptr_comparisons.rs:72:27 | LL | const _: usize = unsafe { std::mem::transmute::<*const usize, usize>(FOO) + 4 }; | --------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | "pointer-to-integer cast" needs an rfc before being allowed inside constants + | + = 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 #71800 error: any use of this value will cause an error - --> $DIR/ptr_comparisons.rs:75:27 + --> $DIR/ptr_comparisons.rs:79:27 | LL | const _: usize = unsafe { *std::mem::transmute::<&&usize, &usize>(&FOO) + 4 }; | --------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | "pointer-to-integer cast" needs an rfc before being allowed inside constants + | + = 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 #71800 error: aborting due to 4 previous errors diff --git a/src/test/ui/consts/transmute-size-mismatch-before-typeck.rs b/src/test/ui/consts/transmute-size-mismatch-before-typeck.rs index 2817abfcaa8de..0f0068ac3bdc1 100644 --- a/src/test/ui/consts/transmute-size-mismatch-before-typeck.rs +++ b/src/test/ui/consts/transmute-size-mismatch-before-typeck.rs @@ -15,6 +15,7 @@ fn main() { const ZST: &[u8] = unsafe { std::mem::transmute(1usize) }; //~^ ERROR any use of this value will cause an error //~| ERROR cannot transmute between types of different sizes +//~| WARN this was previously accepted by the compiler but is being phased out // Once the `any use of this value will cause an error` disappears in this test, make sure to // remove the `TransmuteSizeDiff` error variant and make its emitter site an assertion again. diff --git a/src/test/ui/consts/transmute-size-mismatch-before-typeck.stderr b/src/test/ui/consts/transmute-size-mismatch-before-typeck.stderr index b4970c82adb3e..6e93aed70b65a 100644 --- a/src/test/ui/consts/transmute-size-mismatch-before-typeck.stderr +++ b/src/test/ui/consts/transmute-size-mismatch-before-typeck.stderr @@ -7,6 +7,8 @@ LL | const ZST: &[u8] = unsafe { std::mem::transmute(1usize) }; | transmuting `usize` to `&[u8]` is not possible, because these types do not have the same size | = note: `#[deny(const_err)]` on by default + = 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 #71800 error: could not evaluate constant pattern --> $DIR/transmute-size-mismatch-before-typeck.rs:10:9 diff --git a/src/test/ui/consts/uninhabited-const-issue-61744.rs b/src/test/ui/consts/uninhabited-const-issue-61744.rs index 2f4b7578d1c32..860628c39c371 100644 --- a/src/test/ui/consts/uninhabited-const-issue-61744.rs +++ b/src/test/ui/consts/uninhabited-const-issue-61744.rs @@ -2,6 +2,7 @@ pub const unsafe fn fake_type() -> T { hint_unreachable() //~ ERROR any use of this value will cause an error [const_err] + //~| WARN this was previously accepted by the compiler but is being phased out } pub const unsafe fn hint_unreachable() -> ! { diff --git a/src/test/ui/consts/uninhabited-const-issue-61744.stderr b/src/test/ui/consts/uninhabited-const-issue-61744.stderr index 1fb5ac11df0f0..e98eefc11c3c8 100644 --- a/src/test/ui/consts/uninhabited-const-issue-61744.stderr +++ b/src/test/ui/consts/uninhabited-const-issue-61744.stderr @@ -6,141 +6,143 @@ LL | hint_unreachable() | | | reached the configured maximum number of stack frames | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:8:5 + | inside `hint_unreachable` at $DIR/uninhabited-const-issue-61744.rs:9:5 | inside `fake_type::` at $DIR/uninhabited-const-issue-61744.rs:4:5 - | inside `::CONSTANT` at $DIR/uninhabited-const-issue-61744.rs:12:36 + | inside `::CONSTANT` at $DIR/uninhabited-const-issue-61744.rs:13:36 ... LL | const CONSTANT: i32 = unsafe { fake_type() }; | --------------------------------------------- | = note: `#[deny(const_err)]` on by default + = 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 #71800 error[E0080]: erroneous constant used - --> $DIR/uninhabited-const-issue-61744.rs:18:10 + --> $DIR/uninhabited-const-issue-61744.rs:19:10 | LL | dbg!(i32::CONSTANT); | ^^^^^^^^^^^^^ referenced constant has errors diff --git a/src/test/ui/error-codes/E0396-fixed.rs b/src/test/ui/error-codes/E0396-fixed.rs index 1029c75f17d2e..76dd857ea5616 100644 --- a/src/test/ui/error-codes/E0396-fixed.rs +++ b/src/test/ui/error-codes/E0396-fixed.rs @@ -4,6 +4,7 @@ const REG_ADDR: *const u8 = 0x5f3759df as *const u8; const VALUE: u8 = unsafe { *REG_ADDR }; //~^ ERROR any use of this value will cause an error +//~| WARN this was previously accepted by the compiler but is being phased out fn main() { } diff --git a/src/test/ui/error-codes/E0396-fixed.stderr b/src/test/ui/error-codes/E0396-fixed.stderr index 685055525627e..521394bdc8e01 100644 --- a/src/test/ui/error-codes/E0396-fixed.stderr +++ b/src/test/ui/error-codes/E0396-fixed.stderr @@ -7,6 +7,8 @@ LL | const VALUE: u8 = unsafe { *REG_ADDR }; | unable to turn bytes into a pointer | = note: `#[deny(const_err)]` on by default + = 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 #71800 error: aborting due to previous error diff --git a/src/test/ui/suggestions/non-existent-field-present-in-subfield.fixed b/src/test/ui/suggestions/non-existent-field-present-in-subfield.fixed index 167548a89defa..e58b4e6ca4d6f 100644 --- a/src/test/ui/suggestions/non-existent-field-present-in-subfield.fixed +++ b/src/test/ui/suggestions/non-existent-field-present-in-subfield.fixed @@ -3,7 +3,7 @@ struct Foo { first: Bar, _second: u32, - _third: u32, + _third: Vec, } struct Bar { @@ -32,7 +32,7 @@ fn main() { let d = D { test: e }; let c = C { c: d }; let bar = Bar { bar: c }; - let fooer = Foo { first: bar, _second: 4, _third: 5 }; + let fooer = Foo { first: bar, _second: 4, _third: Vec::new() }; let _test = &fooer.first.bar.c; //~^ ERROR no field diff --git a/src/test/ui/suggestions/non-existent-field-present-in-subfield.rs b/src/test/ui/suggestions/non-existent-field-present-in-subfield.rs index 81cc1af4dff52..7e273ac23d8c3 100644 --- a/src/test/ui/suggestions/non-existent-field-present-in-subfield.rs +++ b/src/test/ui/suggestions/non-existent-field-present-in-subfield.rs @@ -3,7 +3,7 @@ struct Foo { first: Bar, _second: u32, - _third: u32, + _third: Vec, } struct Bar { @@ -32,7 +32,7 @@ fn main() { let d = D { test: e }; let c = C { c: d }; let bar = Bar { bar: c }; - let fooer = Foo { first: bar, _second: 4, _third: 5 }; + let fooer = Foo { first: bar, _second: 4, _third: Vec::new() }; let _test = &fooer.c; //~^ ERROR no field diff --git a/src/test/ui/typeck/issue-80207-unsized-return.rs b/src/test/ui/typeck/issue-80207-unsized-return.rs new file mode 100644 index 0000000000000..75430da148239 --- /dev/null +++ b/src/test/ui/typeck/issue-80207-unsized-return.rs @@ -0,0 +1,20 @@ +// check-pass + +trait Foo { + fn do_stuff() -> Self; +} + +trait Bar { + type Output; +} + +impl Foo for dyn Bar +where + Self: Sized, +{ + fn do_stuff() -> Self { + todo!() + } +} + +fn main() {} diff --git a/src/tools/clippy/CHANGELOG.md b/src/tools/clippy/CHANGELOG.md index dadb6832d1fd7..c1032204a22cb 100644 --- a/src/tools/clippy/CHANGELOG.md +++ b/src/tools/clippy/CHANGELOG.md @@ -2079,6 +2079,7 @@ Released 2018-09-13 [`missing_docs_in_private_items`]: https://rust-lang.github.io/rust-clippy/master/index.html#missing_docs_in_private_items [`missing_errors_doc`]: https://rust-lang.github.io/rust-clippy/master/index.html#missing_errors_doc [`missing_inline_in_public_items`]: https://rust-lang.github.io/rust-clippy/master/index.html#missing_inline_in_public_items +[`missing_panics_doc`]: https://rust-lang.github.io/rust-clippy/master/index.html#missing_panics_doc [`missing_safety_doc`]: https://rust-lang.github.io/rust-clippy/master/index.html#missing_safety_doc [`mistyped_literal_suffixes`]: https://rust-lang.github.io/rust-clippy/master/index.html#mistyped_literal_suffixes [`mixed_case_hex_literals`]: https://rust-lang.github.io/rust-clippy/master/index.html#mixed_case_hex_literals diff --git a/src/tools/clippy/CONTRIBUTING.md b/src/tools/clippy/CONTRIBUTING.md index f2641a23f563b..5954ab25d1942 100644 --- a/src/tools/clippy/CONTRIBUTING.md +++ b/src/tools/clippy/CONTRIBUTING.md @@ -46,11 +46,12 @@ first read the [Basics docs](doc/basics.md).** ### Finding something to fix/improve -All issues on Clippy are mentored, if you want help with a bug just ask -@Manishearth, @flip1995, @phansch or @yaahc. +All issues on Clippy are mentored, if you want help simply ask @Manishearth, @flip1995, @phansch +or @llogiq directly by mentioning them in the issue or over on [Zulip]. This list may be out of date. +All currently active mentors can be found [here](https://github.com/rust-lang/highfive/blob/master/highfive/configs/rust-lang/rust-clippy.json#L3) -Some issues are easier than others. The [`good-first-issue`] label can be used to find the easy issues. -If you want to work on an issue, please leave a comment so that we can assign it to you! +Some issues are easier than others. The [`good-first-issue`] label can be used to find the easy +issues. You can use `@rustbot claim` to assign the issue to yourself. There are also some abandoned PRs, marked with [`S-inactive-closed`]. Pretty often these PRs are nearly completed and just need some extra steps diff --git a/src/tools/clippy/clippy_dev/src/bless.rs b/src/tools/clippy/clippy_dev/src/bless.rs index b877806946cfe..2a869e9d4491b 100644 --- a/src/tools/clippy/clippy_dev/src/bless.rs +++ b/src/tools/clippy/clippy_dev/src/bless.rs @@ -24,6 +24,9 @@ static CLIPPY_BUILD_TIME: SyncLazy> = SyncLazy::ne fs::metadata(path).ok()?.modified().ok() }); +/// # Panics +/// +/// Panics if the path to a test file is broken pub fn bless(ignore_timestamp: bool) { let test_suite_dirs = [ clippy_project_root().join("tests").join("ui"), diff --git a/src/tools/clippy/clippy_dev/src/fmt.rs b/src/tools/clippy/clippy_dev/src/fmt.rs index 6b528d219df27..4d0fdadbd85d1 100644 --- a/src/tools/clippy/clippy_dev/src/fmt.rs +++ b/src/tools/clippy/clippy_dev/src/fmt.rs @@ -8,7 +8,7 @@ use walkdir::WalkDir; #[derive(Debug)] pub enum CliError { - CommandFailed(String), + CommandFailed(String, String), IoError(io::Error), RustfmtNotInstalled, WalkDirError(walkdir::Error), @@ -75,8 +75,8 @@ pub fn run(check: bool, verbose: bool) { fn output_err(err: CliError) { match err { - CliError::CommandFailed(command) => { - eprintln!("error: A command failed! `{}`", command); + CliError::CommandFailed(command, stderr) => { + eprintln!("error: A command failed! `{}`\nstderr: {}", command, stderr); }, CliError::IoError(err) => { eprintln!("error: {}", err); @@ -136,12 +136,16 @@ fn exec( println!("{}", format_command(&program, &dir, args)); } - let mut child = Command::new(&program).current_dir(&dir).args(args.iter()).spawn()?; - let code = child.wait()?; - let success = code.success(); + let child = Command::new(&program).current_dir(&dir).args(args.iter()).spawn()?; + let output = child.wait_with_output()?; + let success = output.status.success(); if !context.check && !success { - return Err(CliError::CommandFailed(format_command(&program, &dir, args))); + let stderr = std::str::from_utf8(&output.stderr).unwrap_or(""); + return Err(CliError::CommandFailed( + format_command(&program, &dir, args), + String::from(stderr), + )); } Ok(success) @@ -177,7 +181,10 @@ fn rustfmt_test(context: &FmtContext) -> Result<(), CliError> { { Err(CliError::RustfmtNotInstalled) } else { - Err(CliError::CommandFailed(format_command(&program, &dir, args))) + Err(CliError::CommandFailed( + format_command(&program, &dir, args), + std::str::from_utf8(&output.stderr).unwrap_or("").to_string(), + )) } } diff --git a/src/tools/clippy/clippy_dev/src/lib.rs b/src/tools/clippy/clippy_dev/src/lib.rs index 24d70d433f367..01d1fc9211a94 100644 --- a/src/tools/clippy/clippy_dev/src/lib.rs +++ b/src/tools/clippy/clippy_dev/src/lib.rs @@ -236,6 +236,10 @@ pub struct FileChange { /// `path` is the relative path to the file on which you want to perform the replacement. /// /// See `replace_region_in_text` for documentation of the other options. +/// +/// # Panics +/// +/// Panics if the path could not read or then written pub fn replace_region_in_file( path: &Path, start: &str, @@ -283,6 +287,10 @@ where /// .new_lines; /// assert_eq!("replace_start\na different\ntext\nreplace_end", result); /// ``` +/// +/// # Panics +/// +/// Panics if start or end is not valid regex pub fn replace_region_in_text(text: &str, start: &str, end: &str, replace_start: bool, replacements: F) -> FileChange where F: FnOnce() -> Vec, @@ -329,6 +337,11 @@ where } /// Returns the path to the Clippy project directory +/// +/// # Panics +/// +/// Panics if the current directory could not be retrieved, there was an error reading any of the +/// Cargo.toml files or ancestor directory is the clippy root directory #[must_use] pub fn clippy_project_root() -> PathBuf { let current_dir = std::env::current_dir().unwrap(); diff --git a/src/tools/clippy/clippy_dev/src/ra_setup.rs b/src/tools/clippy/clippy_dev/src/ra_setup.rs index a8a6a2cb1bd6f..a3c329b578b20 100644 --- a/src/tools/clippy/clippy_dev/src/ra_setup.rs +++ b/src/tools/clippy/clippy_dev/src/ra_setup.rs @@ -8,6 +8,9 @@ use std::path::{Path, PathBuf}; // This allows rust analyzer to analyze rustc internals and show proper information inside clippy // code. See https://github.com/rust-analyzer/rust-analyzer/issues/3517 and https://github.com/rust-lang/rust-clippy/issues/5514 for details +/// # Panics +/// +/// Panics if `rustc_path` does not lead to a rustc repo or the files could not be read pub fn run(rustc_path: Option<&str>) { // we can unwrap here because the arg is required by clap let rustc_path = PathBuf::from(rustc_path.unwrap()); diff --git a/src/tools/clippy/clippy_dev/src/serve.rs b/src/tools/clippy/clippy_dev/src/serve.rs index a46c0e4d3f0a1..faa94859601e3 100644 --- a/src/tools/clippy/clippy_dev/src/serve.rs +++ b/src/tools/clippy/clippy_dev/src/serve.rs @@ -4,6 +4,9 @@ use std::process::Command; use std::thread; use std::time::{Duration, SystemTime}; +/// # Panics +/// +/// Panics if the python commands could not be spawned pub fn run(port: u16, lint: Option<&str>) -> ! { let mut url = Some(match lint { None => format!("http://localhost:{}", port), diff --git a/src/tools/clippy/clippy_lints/src/doc.rs b/src/tools/clippy/clippy_lints/src/doc.rs index fa0289c977c72..75e71eb1e4ce2 100644 --- a/src/tools/clippy/clippy_lints/src/doc.rs +++ b/src/tools/clippy/clippy_lints/src/doc.rs @@ -1,4 +1,7 @@ -use crate::utils::{implements_trait, is_entrypoint_fn, is_type_diagnostic_item, return_ty, span_lint}; +use crate::utils::{ + implements_trait, is_entrypoint_fn, is_type_diagnostic_item, match_panic_def_id, method_chain_args, return_ty, + span_lint, span_lint_and_note, +}; use if_chain::if_chain; use itertools::Itertools; use rustc_ast::ast::{Async, AttrKind, Attribute, FnKind, FnRetTy, ItemKind}; @@ -8,7 +11,10 @@ use rustc_data_structures::sync::Lrc; use rustc_errors::emitter::EmitterWriter; use rustc_errors::Handler; use rustc_hir as hir; +use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor}; +use rustc_hir::{Expr, ExprKind, QPath}; use rustc_lint::{LateContext, LateLintPass}; +use rustc_middle::hir::map::Map; use rustc_middle::lint::in_external_macro; use rustc_middle::ty; use rustc_parse::maybe_new_parser_from_source_str; @@ -122,6 +128,37 @@ declare_clippy_lint! { "`pub fn` returns `Result` without `# Errors` in doc comment" } +declare_clippy_lint! { + /// **What it does:** Checks the doc comments of publicly visible functions that + /// may panic and warns if there is no `# Panics` section. + /// + /// **Why is this bad?** Documenting the scenarios in which panicking occurs + /// can help callers who do not want to panic to avoid those situations. + /// + /// **Known problems:** None. + /// + /// **Examples:** + /// + /// Since the following function may panic it has a `# Panics` section in + /// its doc comment: + /// + /// ```rust + /// /// # Panics + /// /// + /// /// Will panic if y is 0 + /// pub fn divide_by(x: i32, y: i32) -> i32 { + /// if y == 0 { + /// panic!("Cannot divide by 0") + /// } else { + /// x / y + /// } + /// } + /// ``` + pub MISSING_PANICS_DOC, + pedantic, + "`pub fn` may panic without `# Panics` in doc comment" +} + declare_clippy_lint! { /// **What it does:** Checks for `fn main() { .. }` in doctests /// @@ -166,7 +203,9 @@ impl DocMarkdown { } } -impl_lint_pass!(DocMarkdown => [DOC_MARKDOWN, MISSING_SAFETY_DOC, MISSING_ERRORS_DOC, NEEDLESS_DOCTEST_MAIN]); +impl_lint_pass!(DocMarkdown => + [DOC_MARKDOWN, MISSING_SAFETY_DOC, MISSING_ERRORS_DOC, MISSING_PANICS_DOC, NEEDLESS_DOCTEST_MAIN] +); impl<'tcx> LateLintPass<'tcx> for DocMarkdown { fn check_crate(&mut self, cx: &LateContext<'tcx>, krate: &'tcx hir::Crate<'_>) { @@ -180,7 +219,15 @@ impl<'tcx> LateLintPass<'tcx> for DocMarkdown { if !(is_entrypoint_fn(cx, cx.tcx.hir().local_def_id(item.hir_id).to_def_id()) || in_external_macro(cx.tcx.sess, item.span)) { - lint_for_missing_headers(cx, item.hir_id, item.span, sig, headers, Some(body_id)); + let body = cx.tcx.hir().body(body_id); + let impl_item_def_id = cx.tcx.hir().local_def_id(item.hir_id); + let mut fpu = FindPanicUnwrap { + cx, + typeck_results: cx.tcx.typeck(impl_item_def_id), + panic_span: None, + }; + fpu.visit_expr(&body.value); + lint_for_missing_headers(cx, item.hir_id, item.span, sig, headers, Some(body_id), fpu.panic_span); } }, hir::ItemKind::Impl(ref impl_) => { @@ -200,7 +247,7 @@ impl<'tcx> LateLintPass<'tcx> for DocMarkdown { let headers = check_attrs(cx, &self.valid_idents, &item.attrs); if let hir::TraitItemKind::Fn(ref sig, ..) = item.kind { if !in_external_macro(cx.tcx.sess, item.span) { - lint_for_missing_headers(cx, item.hir_id, item.span, sig, headers, None); + lint_for_missing_headers(cx, item.hir_id, item.span, sig, headers, None, None); } } } @@ -211,7 +258,15 @@ impl<'tcx> LateLintPass<'tcx> for DocMarkdown { return; } if let hir::ImplItemKind::Fn(ref sig, body_id) = item.kind { - lint_for_missing_headers(cx, item.hir_id, item.span, sig, headers, Some(body_id)); + let body = cx.tcx.hir().body(body_id); + let impl_item_def_id = cx.tcx.hir().local_def_id(item.hir_id); + let mut fpu = FindPanicUnwrap { + cx, + typeck_results: cx.tcx.typeck(impl_item_def_id), + panic_span: None, + }; + fpu.visit_expr(&body.value); + lint_for_missing_headers(cx, item.hir_id, item.span, sig, headers, Some(body_id), fpu.panic_span); } } } @@ -223,6 +278,7 @@ fn lint_for_missing_headers<'tcx>( sig: &hir::FnSig<'_>, headers: DocHeaders, body_id: Option, + panic_span: Option, ) { if !cx.access_levels.is_exported(hir_id) { return; // Private functions do not require doc comments @@ -235,6 +291,16 @@ fn lint_for_missing_headers<'tcx>( "unsafe function's docs miss `# Safety` section", ); } + if !headers.panics && panic_span.is_some() { + span_lint_and_note( + cx, + MISSING_PANICS_DOC, + span, + "docs for function which may panic missing `# Panics` section", + panic_span, + "first possible panic found here", + ); + } if !headers.errors { if is_type_diagnostic_item(cx, return_ty(cx, hir_id), sym::result_type) { span_lint( @@ -321,6 +387,7 @@ pub fn strip_doc_comment_decoration(doc: &str, comment_kind: CommentKind, span: struct DocHeaders { safety: bool, errors: bool, + panics: bool, } fn check_attrs<'a>(cx: &LateContext<'_>, valid_idents: &FxHashSet, attrs: &'a [Attribute]) -> DocHeaders { @@ -338,6 +405,7 @@ fn check_attrs<'a>(cx: &LateContext<'_>, valid_idents: &FxHashSet, attrs return DocHeaders { safety: true, errors: true, + panics: true, }; } } @@ -353,6 +421,7 @@ fn check_attrs<'a>(cx: &LateContext<'_>, valid_idents: &FxHashSet, attrs return DocHeaders { safety: false, errors: false, + panics: false, }; } @@ -394,6 +463,7 @@ fn check_doc<'a, Events: Iterator, Range, Range o, Err(e) => e - 1, @@ -609,3 +680,47 @@ fn check_word(cx: &LateContext<'_>, word: &str, span: Span) { ); } } + +struct FindPanicUnwrap<'a, 'tcx> { + cx: &'a LateContext<'tcx>, + panic_span: Option, + typeck_results: &'tcx ty::TypeckResults<'tcx>, +} + +impl<'a, 'tcx> Visitor<'tcx> for FindPanicUnwrap<'a, 'tcx> { + type Map = Map<'tcx>; + + fn visit_expr(&mut self, expr: &'tcx Expr<'_>) { + if self.panic_span.is_some() { + return; + } + + // check for `begin_panic` + if_chain! { + if let ExprKind::Call(ref func_expr, _) = expr.kind; + if let ExprKind::Path(QPath::Resolved(_, ref path)) = func_expr.kind; + if let Some(path_def_id) = path.res.opt_def_id(); + if match_panic_def_id(self.cx, path_def_id); + then { + self.panic_span = Some(expr.span); + } + } + + // check for `unwrap` + if let Some(arglists) = method_chain_args(expr, &["unwrap"]) { + let reciever_ty = self.typeck_results.expr_ty(&arglists[0][0]).peel_refs(); + if is_type_diagnostic_item(self.cx, reciever_ty, sym::option_type) + || is_type_diagnostic_item(self.cx, reciever_ty, sym::result_type) + { + self.panic_span = Some(expr.span); + } + } + + // and check sub-expressions + intravisit::walk_expr(self, expr); + } + + fn nested_visit_map(&mut self) -> NestedVisitorMap { + NestedVisitorMap::OnlyBodies(self.cx.tcx.hir()) + } +} diff --git a/src/tools/clippy/clippy_lints/src/excessive_bools.rs b/src/tools/clippy/clippy_lints/src/excessive_bools.rs index fecde8e274348..6f22f65deac80 100644 --- a/src/tools/clippy/clippy_lints/src/excessive_bools.rs +++ b/src/tools/clippy/clippy_lints/src/excessive_bools.rs @@ -160,15 +160,17 @@ impl EarlyLintPass for ExcessiveBools { "consider using a state machine or refactoring bools into two-variant enums", ); } - } - ItemKind::Impl(box ImplKind { of_trait: None, items, .. }) + }, + ItemKind::Impl(box ImplKind { + of_trait: None, items, .. + }) | ItemKind::Trait(box TraitKind(.., items)) => { for item in items { if let AssocItemKind::Fn(box FnKind(_, fn_sig, _, _)) = &item.kind { self.check_fn_sig(cx, fn_sig, item.span); } } - } + }, ItemKind::Fn(box FnKind(_, fn_sig, _, _)) => self.check_fn_sig(cx, fn_sig, item.span), _ => (), } diff --git a/src/tools/clippy/clippy_lints/src/exhaustive_items.rs b/src/tools/clippy/clippy_lints/src/exhaustive_items.rs index 32b1299efce91..e3988d0038c23 100644 --- a/src/tools/clippy/clippy_lints/src/exhaustive_items.rs +++ b/src/tools/clippy/clippy_lints/src/exhaustive_items.rs @@ -75,10 +75,14 @@ impl LateLintPass<'_> for ExhaustiveItems { if cx.access_levels.is_exported(item.hir_id); if !item.attrs.iter().any(|a| a.has_name(sym::non_exhaustive)); then { - let (lint, msg) = if let ItemKind::Enum(..) = item.kind { - (EXHAUSTIVE_ENUMS, "exported enums should not be exhaustive") - } else { + let (lint, msg) = if let ItemKind::Struct(ref v, ..) = item.kind { + if v.fields().iter().any(|f| !f.vis.node.is_pub()) { + // skip structs with private fields + return; + } (EXHAUSTIVE_STRUCTS, "exported structs should not be exhaustive") + } else { + (EXHAUSTIVE_ENUMS, "exported enums should not be exhaustive") }; let suggestion_span = item.span.shrink_to_lo(); let indent = " ".repeat(indent_of(cx, item.span).unwrap_or(0)); diff --git a/src/tools/clippy/clippy_lints/src/lib.rs b/src/tools/clippy/clippy_lints/src/lib.rs index 54007c29c6c5e..5a40c00bd673a 100644 --- a/src/tools/clippy/clippy_lints/src/lib.rs +++ b/src/tools/clippy/clippy_lints/src/lib.rs @@ -592,6 +592,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf: &disallowed_method::DISALLOWED_METHOD, &doc::DOC_MARKDOWN, &doc::MISSING_ERRORS_DOC, + &doc::MISSING_PANICS_DOC, &doc::MISSING_SAFETY_DOC, &doc::NEEDLESS_DOCTEST_MAIN, &double_comparison::DOUBLE_COMPARISONS, @@ -1317,6 +1318,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf: LintId::of(&derive::UNSAFE_DERIVE_DESERIALIZE), LintId::of(&doc::DOC_MARKDOWN), LintId::of(&doc::MISSING_ERRORS_DOC), + LintId::of(&doc::MISSING_PANICS_DOC), LintId::of(&empty_enum::EMPTY_ENUM), LintId::of(&enum_variants::MODULE_NAME_REPETITIONS), LintId::of(&enum_variants::PUB_ENUM_VARIANT_NAMES), diff --git a/src/tools/clippy/clippy_lints/src/matches.rs b/src/tools/clippy/clippy_lints/src/matches.rs index 5f62d2d13165c..ba7b9bd04248d 100644 --- a/src/tools/clippy/clippy_lints/src/matches.rs +++ b/src/tools/clippy/clippy_lints/src/matches.rs @@ -1592,7 +1592,17 @@ where } }, (&Kind::End(a, _), &Kind::Start(b, _)) if a != Bound::Included(b) => (), - _ => return Some((a.range(), b.range())), + _ => { + // skip if the range `a` is completely included into the range `b` + if let Ordering::Equal | Ordering::Less = a.cmp(&b) { + let kind_a = Kind::End(a.range().node.1, a.range()); + let kind_b = Kind::End(b.range().node.1, b.range()); + if let Ordering::Equal | Ordering::Greater = kind_a.cmp(&kind_b) { + return None; + } + } + return Some((a.range(), b.range())); + }, } } diff --git a/src/tools/clippy/clippy_lints/src/utils/ast_utils.rs b/src/tools/clippy/clippy_lints/src/utils/ast_utils.rs index 69492e84e4ac5..642326469725f 100644 --- a/src/tools/clippy/clippy_lints/src/utils/ast_utils.rs +++ b/src/tools/clippy/clippy_lints/src/utils/ast_utils.rs @@ -247,7 +247,7 @@ pub fn eq_item_kind(l: &ItemKind, r: &ItemKind) -> bool { (ForeignMod(l), ForeignMod(r)) => { both(&l.abi, &r.abi, |l, r| eq_str_lit(l, r)) && over(&l.items, &r.items, |l, r| eq_item(l, r, eq_foreign_item_kind)) - } + }, (TyAlias(box TyAliasKind(ld, lg, lb, lt)), TyAlias(box TyAliasKind(rd, rg, rb, rt))) => { eq_defaultness(*ld, *rd) && eq_generics(lg, rg) @@ -259,7 +259,7 @@ pub fn eq_item_kind(l: &ItemKind, r: &ItemKind) -> bool { }, (Struct(lv, lg), Struct(rv, rg)) | (Union(lv, lg), Union(rv, rg)) => { eq_variant_data(lv, rv) && eq_generics(lg, rg) - } + }, (Trait(box TraitKind(la, lu, lg, lb, li)), Trait(box TraitKind(ra, ru, rg, rb, ri))) => { la == ra && matches!(lu, Unsafe::No) == matches!(ru, Unsafe::No) @@ -331,15 +331,10 @@ pub fn eq_foreign_item_kind(l: &ForeignItemKind, r: &ForeignItemKind) -> bool { pub fn eq_assoc_item_kind(l: &AssocItemKind, r: &AssocItemKind) -> bool { use AssocItemKind::*; match (l, r) { - (Const(ld, lt, le), Const(rd, rt, re)) => { - eq_defaultness(*ld, *rd) && eq_ty(lt, rt) && eq_expr_opt(le, re) - } + (Const(ld, lt, le), Const(rd, rt, re)) => eq_defaultness(*ld, *rd) && eq_ty(lt, rt) && eq_expr_opt(le, re), (Fn(box FnKind(ld, lf, lg, lb)), Fn(box FnKind(rd, rf, rg, rb))) => { - eq_defaultness(*ld, *rd) - && eq_fn_sig(lf, rf) - && eq_generics(lg, rg) - && both(lb, rb, |l, r| eq_block(l, r)) - } + eq_defaultness(*ld, *rd) && eq_fn_sig(lf, rf) && eq_generics(lg, rg) && both(lb, rb, |l, r| eq_block(l, r)) + }, (TyAlias(box TyAliasKind(ld, lg, lb, lt)), TyAlias(box TyAliasKind(rd, rg, rb, rt))) => { eq_defaultness(*ld, *rd) && eq_generics(lg, rg) diff --git a/src/tools/clippy/clippy_lints/src/utils/diagnostics.rs b/src/tools/clippy/clippy_lints/src/utils/diagnostics.rs index 6caa04f651fae..269be217c2d87 100644 --- a/src/tools/clippy/clippy_lints/src/utils/diagnostics.rs +++ b/src/tools/clippy/clippy_lints/src/utils/diagnostics.rs @@ -110,7 +110,7 @@ pub fn span_lint_and_help<'a, T: LintContext>( pub fn span_lint_and_note<'a, T: LintContext>( cx: &'a T, lint: &'static Lint, - span: Span, + span: impl Into, msg: &str, note_span: Option, note: &str, diff --git a/src/tools/clippy/clippy_lints/src/utils/internal_lints.rs b/src/tools/clippy/clippy_lints/src/utils/internal_lints.rs index 822863ca3e279..cccad243e1b59 100644 --- a/src/tools/clippy/clippy_lints/src/utils/internal_lints.rs +++ b/src/tools/clippy/clippy_lints/src/utils/internal_lints.rs @@ -760,7 +760,7 @@ impl<'tcx> LateLintPass<'tcx> for MatchTypeOnDiagItem { // Extract the path to the matched type if let Some(segments) = path_to_matched_type(cx, ty_path); let segments: Vec<&str> = segments.iter().map(|sym| &**sym).collect(); - if let Some(ty_did) = path_to_res(cx, &segments[..]).and_then(|res| res.opt_def_id()); + if let Some(ty_did) = path_to_res(cx, &segments[..]).opt_def_id(); // Check if the matched type is a diagnostic item let diag_items = cx.tcx.diagnostic_items(ty_did.krate); if let Some(item_name) = diag_items.iter().find_map(|(k, v)| if *v == ty_did { Some(k) } else { None }); @@ -833,7 +833,7 @@ fn path_to_matched_type(cx: &LateContext<'_>, expr: &hir::Expr<'_>) -> Option, path: &[&str]) -> bool { - if path_to_res(cx, path).is_some() { + if path_to_res(cx, path) != Res::Err { return true; } @@ -906,7 +906,7 @@ impl<'tcx> LateLintPass<'tcx> for InterningDefinedSymbol { } for &module in &[&paths::KW_MODULE, &paths::SYM_MODULE] { - if let Some(Res::Def(_, def_id)) = path_to_res(cx, module) { + if let Some(def_id) = path_to_res(cx, module).opt_def_id() { for item in cx.tcx.item_children(def_id).iter() { if_chain! { if let Res::Def(DefKind::Const, item_def_id) = item.res; diff --git a/src/tools/clippy/clippy_lints/src/utils/mod.rs b/src/tools/clippy/clippy_lints/src/utils/mod.rs index d0db3a67533bc..ef45f9fdcd5d4 100644 --- a/src/tools/clippy/clippy_lints/src/utils/mod.rs +++ b/src/tools/clippy/clippy_lints/src/utils/mod.rs @@ -309,7 +309,15 @@ pub fn match_path_ast(path: &ast::Path, segments: &[&str]) -> bool { /// Gets the definition associated to a path. #[allow(clippy::shadow_unrelated)] // false positive #6563 -pub fn path_to_res(cx: &LateContext<'_>, path: &[&str]) -> Option { +pub fn path_to_res(cx: &LateContext<'_>, path: &[&str]) -> Res { + macro_rules! try_res { + ($e:expr) => { + match $e { + Some(e) => e, + None => return Res::Err, + } + }; + } fn item_child_by_name<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId, name: &str) -> Option<&'tcx Export> { tcx.item_children(def_id) .iter() @@ -318,12 +326,12 @@ pub fn path_to_res(cx: &LateContext<'_>, path: &[&str]) -> Option { let (krate, first, path) = match *path { [krate, first, ref path @ ..] => (krate, first, path), - _ => return None, + _ => return Res::Err, }; let tcx = cx.tcx; let crates = tcx.crates(); - let krate = crates.iter().find(|&&num| tcx.crate_name(num).as_str() == krate)?; - let first = item_child_by_name(tcx, krate.as_def_id(), first)?; + let krate = try_res!(crates.iter().find(|&&num| tcx.crate_name(num).as_str() == krate)); + let first = try_res!(item_child_by_name(tcx, krate.as_def_id(), first)); let last = path .iter() .copied() @@ -343,21 +351,15 @@ pub fn path_to_res(cx: &LateContext<'_>, path: &[&str]) -> Option { } else { None } - })?; - Some(last.res) + }); + try_res!(last).res } /// Convenience function to get the `DefId` of a trait by path. /// It could be a trait or trait alias. pub fn get_trait_def_id(cx: &LateContext<'_>, path: &[&str]) -> Option { - let res = match path_to_res(cx, path) { - Some(res) => res, - None => return None, - }; - - match res { + match path_to_res(cx, path) { Res::Def(DefKind::Trait | DefKind::TraitAlias, trait_id) => Some(trait_id), - Res::Err => unreachable!("this trait resolution is impossible: {:?}", &path), _ => None, } } @@ -1532,10 +1534,11 @@ pub fn fn_def_id(cx: &LateContext<'_>, expr: &Expr<'_>) -> Option { ExprKind::Call( Expr { kind: ExprKind::Path(qpath), + hir_id: path_hir_id, .. }, .., - ) => cx.typeck_results().qpath_res(qpath, expr.hir_id).opt_def_id(), + ) => cx.typeck_results().qpath_res(qpath, *path_hir_id).opt_def_id(), _ => None, } } diff --git a/src/tools/clippy/clippy_lints/src/write.rs b/src/tools/clippy/clippy_lints/src/write.rs index b9e97077c540f..978a232bcfb3a 100644 --- a/src/tools/clippy/clippy_lints/src/write.rs +++ b/src/tools/clippy/clippy_lints/src/write.rs @@ -233,7 +233,11 @@ impl_lint_pass!(Write => [ impl EarlyLintPass for Write { fn check_item(&mut self, _: &EarlyContext<'_>, item: &Item) { - if let ItemKind::Impl(box ImplKind { of_trait: Some(trait_ref), .. }) = &item.kind { + if let ItemKind::Impl(box ImplKind { + of_trait: Some(trait_ref), + .. + }) = &item.kind + { let trait_name = trait_ref .path .segments diff --git a/src/tools/clippy/doc/adding_lints.md b/src/tools/clippy/doc/adding_lints.md index fd2a7d171d020..8fd1dea9aeef9 100644 --- a/src/tools/clippy/doc/adding_lints.md +++ b/src/tools/clippy/doc/adding_lints.md @@ -581,15 +581,15 @@ in the following steps: 3. Passing the configuration value to the lint impl struct: First find the struct construction in the [clippy_lints lib file](/clippy_lints/src/lib.rs). - Make sure that `clippy dev update_lints` added it beforehand. The configuration value is now - cloned or copied into a local value that is then passed to the impl struct like this: + The configuration value is now cloned or copied into a local value that is then passed to the + impl struct like this: ```rust // Default generated registration: - store.register_late_pass(|| box module::StructName); + store.register_*_pass(|| box module::StructName); // New registration with configuration value let configuration_ident = conf.configuration_ident.clone(); - store.register_late_pass(move || box module::StructName::new(configuration_ident)); + store.register_*_pass(move || box module::StructName::new(configuration_ident)); ``` Congratulations the work is almost done. The configuration value can now be accessed @@ -599,7 +599,7 @@ in the following steps: 1. The default configured value can be tested like any normal lint in [`tests/ui`](/tests/ui). 2. The configuration itself will be tested separately in [`tests/ui-toml`](/tests/ui-toml). Simply add a new subfolder with a fitting name. This folder contains a `clippy.toml` file - with the configuration value and a rust file that should be linted by clippy. The test can + with the configuration value and a rust file that should be linted by Clippy. The test can otherwise be written as usual. ## Cheatsheet diff --git a/src/tools/clippy/doc/basics.md b/src/tools/clippy/doc/basics.md index 57f83bdf32bc2..a9416f3b20b7a 100644 --- a/src/tools/clippy/doc/basics.md +++ b/src/tools/clippy/doc/basics.md @@ -109,7 +109,7 @@ See . | HIR | High-Level Intermediate Representation | | TCX | Type context | -This is a concise list of abbreviations that can come up during clippy development. An extensive +This is a concise list of abbreviations that can come up during Clippy development. An extensive general list can be found in the [rustc-dev-guide glossary][glossary]. Always feel free to ask if an abbreviation or meaning is unclear to you. diff --git a/src/tools/clippy/mini-macro/src/lib.rs b/src/tools/clippy/mini-macro/src/lib.rs index ba946563ec595..2b793589049ba 100644 --- a/src/tools/clippy/mini-macro/src/lib.rs +++ b/src/tools/clippy/mini-macro/src/lib.rs @@ -7,6 +7,9 @@ extern crate proc_macro; use proc_macro::{quote, TokenStream}; #[proc_macro_derive(ClippyMiniMacroTest)] +/// # Panics +/// +/// Panics if the macro derivation fails pub fn mini_macro(_: TokenStream) -> TokenStream { quote!( #[allow(unused)] diff --git a/src/tools/clippy/rust-toolchain b/src/tools/clippy/rust-toolchain index f55d55d706587..b617203bef6d8 100644 --- a/src/tools/clippy/rust-toolchain +++ b/src/tools/clippy/rust-toolchain @@ -1,3 +1,3 @@ [toolchain] -channel = "nightly-2021-01-30" +channel = "nightly-2021-02-03" components = ["llvm-tools-preview", "rustc-dev", "rust-src", "rustfmt"] diff --git a/src/tools/clippy/tests/ui/doc_panics.rs b/src/tools/clippy/tests/ui/doc_panics.rs new file mode 100644 index 0000000000000..7ef932f367b10 --- /dev/null +++ b/src/tools/clippy/tests/ui/doc_panics.rs @@ -0,0 +1,95 @@ +#![warn(clippy::missing_panics_doc)] +#![allow(clippy::option_map_unit_fn)] + +fn main() {} + +/// This needs to be documented +pub fn unwrap() { + let result = Err("Hi"); + result.unwrap() +} + +/// This needs to be documented +pub fn panic() { + panic!("This function panics") +} + +/// This needs to be documented +pub fn todo() { + todo!() +} + +/// This needs to be documented +pub fn inner_body(opt: Option) { + opt.map(|x| { + if x == 10 { + panic!() + } + }); +} + +/// This is documented +/// +/// # Panics +/// +/// Panics if `result` if an error +pub fn unwrap_documented() { + let result = Err("Hi"); + result.unwrap() +} + +/// This is documented +/// +/// # Panics +/// +/// Panics just because +pub fn panic_documented() { + panic!("This function panics") +} + +/// This is documented +/// +/// # Panics +/// +/// Panics if `opt` is Just(10) +pub fn inner_body_documented(opt: Option) { + opt.map(|x| { + if x == 10 { + panic!() + } + }); +} + +/// This is documented +/// +/// # Panics +/// +/// We still need to do this part +pub fn todo_documented() { + todo!() +} + +/// This is okay because it is private +fn unwrap_private() { + let result = Err("Hi"); + result.unwrap() +} + +/// This is okay because it is private +fn panic_private() { + panic!("This function panics") +} + +/// This is okay because it is private +fn todo_private() { + todo!() +} + +/// This is okay because it is private +fn inner_body_private(opt: Option) { + opt.map(|x| { + if x == 10 { + panic!() + } + }); +} diff --git a/src/tools/clippy/tests/ui/doc_panics.stderr b/src/tools/clippy/tests/ui/doc_panics.stderr new file mode 100644 index 0000000000000..c0c4e9e4fa7ee --- /dev/null +++ b/src/tools/clippy/tests/ui/doc_panics.stderr @@ -0,0 +1,67 @@ +error: docs for function which may panic missing `# Panics` section + --> $DIR/doc_panics.rs:7:1 + | +LL | / pub fn unwrap() { +LL | | let result = Err("Hi"); +LL | | result.unwrap() +LL | | } + | |_^ + | + = note: `-D clippy::missing-panics-doc` implied by `-D warnings` +note: first possible panic found here + --> $DIR/doc_panics.rs:9:5 + | +LL | result.unwrap() + | ^^^^^^^^^^^^^^^ + +error: docs for function which may panic missing `# Panics` section + --> $DIR/doc_panics.rs:13:1 + | +LL | / pub fn panic() { +LL | | panic!("This function panics") +LL | | } + | |_^ + | +note: first possible panic found here + --> $DIR/doc_panics.rs:14:5 + | +LL | panic!("This function panics") + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) + +error: docs for function which may panic missing `# Panics` section + --> $DIR/doc_panics.rs:18:1 + | +LL | / pub fn todo() { +LL | | todo!() +LL | | } + | |_^ + | +note: first possible panic found here + --> $DIR/doc_panics.rs:19:5 + | +LL | todo!() + | ^^^^^^^ + = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) + +error: docs for function which may panic missing `# Panics` section + --> $DIR/doc_panics.rs:23:1 + | +LL | / pub fn inner_body(opt: Option) { +LL | | opt.map(|x| { +LL | | if x == 10 { +LL | | panic!() +LL | | } +LL | | }); +LL | | } + | |_^ + | +note: first possible panic found here + --> $DIR/doc_panics.rs:26:13 + | +LL | panic!() + | ^^^^^^^^ + = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to 4 previous errors + diff --git a/src/tools/clippy/tests/ui/exhaustive_items.fixed b/src/tools/clippy/tests/ui/exhaustive_items.fixed index 8174a0175ab32..c209f5b4b7278 100644 --- a/src/tools/clippy/tests/ui/exhaustive_items.fixed +++ b/src/tools/clippy/tests/ui/exhaustive_items.fixed @@ -56,27 +56,36 @@ pub mod enums { pub mod structs { #[non_exhaustive] pub struct Exhaustive { - foo: u8, - bar: String, + pub foo: u8, + pub bar: String, } // no warning, already non_exhaustive #[non_exhaustive] pub struct NonExhaustive { - foo: u8, + pub foo: u8, + pub bar: String, + } + + // no warning, private fields + pub struct ExhaustivePrivateFieldTuple(u8); + + // no warning, private fields + pub struct ExhaustivePrivateField { + pub foo: u8, bar: String, } // no warning, private struct ExhaustivePrivate { - foo: u8, - bar: String, + pub foo: u8, + pub bar: String, } // no warning, private #[non_exhaustive] struct NonExhaustivePrivate { - foo: u8, - bar: String, + pub foo: u8, + pub bar: String, } } diff --git a/src/tools/clippy/tests/ui/exhaustive_items.rs b/src/tools/clippy/tests/ui/exhaustive_items.rs index b476f09f8a087..6f59dbf2da59b 100644 --- a/src/tools/clippy/tests/ui/exhaustive_items.rs +++ b/src/tools/clippy/tests/ui/exhaustive_items.rs @@ -53,27 +53,36 @@ pub mod enums { pub mod structs { pub struct Exhaustive { - foo: u8, - bar: String, + pub foo: u8, + pub bar: String, } // no warning, already non_exhaustive #[non_exhaustive] pub struct NonExhaustive { - foo: u8, + pub foo: u8, + pub bar: String, + } + + // no warning, private fields + pub struct ExhaustivePrivateFieldTuple(u8); + + // no warning, private fields + pub struct ExhaustivePrivateField { + pub foo: u8, bar: String, } // no warning, private struct ExhaustivePrivate { - foo: u8, - bar: String, + pub foo: u8, + pub bar: String, } // no warning, private #[non_exhaustive] struct NonExhaustivePrivate { - foo: u8, - bar: String, + pub foo: u8, + pub bar: String, } } diff --git a/src/tools/clippy/tests/ui/exhaustive_items.stderr b/src/tools/clippy/tests/ui/exhaustive_items.stderr index 7369fe75a4f74..8fbab535a9b25 100644 --- a/src/tools/clippy/tests/ui/exhaustive_items.stderr +++ b/src/tools/clippy/tests/ui/exhaustive_items.stderr @@ -41,8 +41,8 @@ error: exported structs should not be exhaustive --> $DIR/exhaustive_items.rs:55:5 | LL | / pub struct Exhaustive { -LL | | foo: u8, -LL | | bar: String, +LL | | pub foo: u8, +LL | | pub bar: String, LL | | } | |_____^ | diff --git a/src/tools/clippy/tests/ui/let_and_return.rs b/src/tools/clippy/tests/ui/let_and_return.rs index 73e550b3df891..e3561863c1e1f 100644 --- a/src/tools/clippy/tests/ui/let_and_return.rs +++ b/src/tools/clippy/tests/ui/let_and_return.rs @@ -117,7 +117,11 @@ mod no_lint_if_stmt_borrows { fn drop(&mut self) {} } - impl Foo<'_> { + impl<'a> Foo<'a> { + fn new(inner: &'a Inner) -> Self { + Self { inner } + } + fn value(&self) -> i32 { 42 } @@ -132,6 +136,12 @@ mod no_lint_if_stmt_borrows { let value = some_foo(&x).value(); value } + + fn test2() -> i32 { + let x = Inner {}; + let value = Foo::new(&x).value(); + value + } } } diff --git a/src/tools/clippy/tests/ui/let_and_return.stderr b/src/tools/clippy/tests/ui/let_and_return.stderr index fe878e5f20601..a6941dabeb88d 100644 --- a/src/tools/clippy/tests/ui/let_and_return.stderr +++ b/src/tools/clippy/tests/ui/let_and_return.stderr @@ -28,7 +28,7 @@ LL | 5 | error: returning the result of a `let` binding from a block - --> $DIR/let_and_return.rs:154:13 + --> $DIR/let_and_return.rs:164:13 | LL | let clone = Arc::clone(&self.foo); | ---------------------------------- unnecessary `let` binding diff --git a/src/tools/clippy/tests/ui/match_overlapping_arm.rs b/src/tools/clippy/tests/ui/match_overlapping_arm.rs index 97789bb766f89..44c51e8112a7d 100644 --- a/src/tools/clippy/tests/ui/match_overlapping_arm.rs +++ b/src/tools/clippy/tests/ui/match_overlapping_arm.rs @@ -57,6 +57,36 @@ fn overlapping() { _ => (), } + match 42 { + 5..7 => println!("5 .. 7"), + 0..10 => println!("0 .. 10"), + _ => (), + } + + match 42 { + 5..10 => println!("5 .. 10"), + 0..=10 => println!("0 ... 10"), + _ => (), + } + + match 42 { + 0..14 => println!("0 .. 14"), + 5..10 => println!("5 .. 10"), + _ => (), + } + + match 42 { + 5..14 => println!("5 .. 14"), + 0..=10 => println!("0 ... 10"), + _ => (), + } + + match 42 { + 0..7 => println!("0 .. 7"), + 0..=10 => println!("0 ... 10"), + _ => (), + } + /* // FIXME(JohnTitor): uncomment this once rustfmt knows half-open patterns match 42 { diff --git a/src/tools/clippy/tests/ui/match_overlapping_arm.stderr b/src/tools/clippy/tests/ui/match_overlapping_arm.stderr index eb20d5405a95e..f25a66d634e88 100644 --- a/src/tools/clippy/tests/ui/match_overlapping_arm.stderr +++ b/src/tools/clippy/tests/ui/match_overlapping_arm.stderr @@ -24,39 +24,39 @@ LL | FOO..=11 => println!("0 ... 11"), | ^^^^^^^^ error: some ranges overlap - --> $DIR/match_overlapping_arm.rs:26:9 + --> $DIR/match_overlapping_arm.rs:55:9 | -LL | 0..=5 => println!("0 ... 5"), +LL | 0..11 => println!("0 .. 11"), | ^^^^^ | note: overlaps with this - --> $DIR/match_overlapping_arm.rs:25:9 + --> $DIR/match_overlapping_arm.rs:56:9 | -LL | 2 => println!("2"), - | ^ +LL | 0..=11 => println!("0 ... 11"), + | ^^^^^^ error: some ranges overlap - --> $DIR/match_overlapping_arm.rs:32:9 + --> $DIR/match_overlapping_arm.rs:80:9 | -LL | 0..=2 => println!("0 ... 2"), - | ^^^^^ +LL | 0..=10 => println!("0 ... 10"), + | ^^^^^^ | note: overlaps with this - --> $DIR/match_overlapping_arm.rs:31:9 + --> $DIR/match_overlapping_arm.rs:79:9 | -LL | 2 => println!("2"), - | ^ +LL | 5..14 => println!("5 .. 14"), + | ^^^^^ error: some ranges overlap - --> $DIR/match_overlapping_arm.rs:55:9 + --> $DIR/match_overlapping_arm.rs:85:9 | -LL | 0..11 => println!("0 .. 11"), - | ^^^^^ +LL | 0..7 => println!("0 .. 7"), + | ^^^^ | note: overlaps with this - --> $DIR/match_overlapping_arm.rs:56:9 + --> $DIR/match_overlapping_arm.rs:86:9 | -LL | 0..=11 => println!("0 ... 11"), +LL | 0..=10 => println!("0 ... 10"), | ^^^^^^ error: aborting due to 5 previous errors diff --git a/src/tools/clippy/tests/ui/should_impl_trait/corner_cases.rs b/src/tools/clippy/tests/ui/should_impl_trait/corner_cases.rs index 6c5ffe6aba8b7..a7f8f54f2be04 100644 --- a/src/tools/clippy/tests/ui/should_impl_trait/corner_cases.rs +++ b/src/tools/clippy/tests/ui/should_impl_trait/corner_cases.rs @@ -8,7 +8,8 @@ clippy::unused_self, clippy::needless_lifetimes, clippy::missing_safety_doc, - clippy::wrong_self_convention + clippy::wrong_self_convention, + clippy::missing_panics_doc )] use std::ops::Mul; diff --git a/src/tools/clippy/tests/ui/should_impl_trait/method_list_1.rs b/src/tools/clippy/tests/ui/should_impl_trait/method_list_1.rs index f8d248fc98d82..69a3390b03b0b 100644 --- a/src/tools/clippy/tests/ui/should_impl_trait/method_list_1.rs +++ b/src/tools/clippy/tests/ui/should_impl_trait/method_list_1.rs @@ -8,7 +8,8 @@ clippy::unused_self, clippy::needless_lifetimes, clippy::missing_safety_doc, - clippy::wrong_self_convention + clippy::wrong_self_convention, + clippy::missing_panics_doc )] use std::ops::Mul; diff --git a/src/tools/clippy/tests/ui/should_impl_trait/method_list_1.stderr b/src/tools/clippy/tests/ui/should_impl_trait/method_list_1.stderr index 2b7d4628c3fa0..86c63946516ce 100644 --- a/src/tools/clippy/tests/ui/should_impl_trait/method_list_1.stderr +++ b/src/tools/clippy/tests/ui/should_impl_trait/method_list_1.stderr @@ -1,5 +1,5 @@ error: method `add` can be confused for the standard trait method `std::ops::Add::add` - --> $DIR/method_list_1.rs:25:5 + --> $DIR/method_list_1.rs:26:5 | LL | / pub fn add(self, other: T) -> T { LL | | unimplemented!() @@ -10,7 +10,7 @@ LL | | } = help: consider implementing the trait `std::ops::Add` or choosing a less ambiguous method name error: method `as_mut` can be confused for the standard trait method `std::convert::AsMut::as_mut` - --> $DIR/method_list_1.rs:29:5 + --> $DIR/method_list_1.rs:30:5 | LL | / pub fn as_mut(&mut self) -> &mut T { LL | | unimplemented!() @@ -20,7 +20,7 @@ LL | | } = help: consider implementing the trait `std::convert::AsMut` or choosing a less ambiguous method name error: method `as_ref` can be confused for the standard trait method `std::convert::AsRef::as_ref` - --> $DIR/method_list_1.rs:33:5 + --> $DIR/method_list_1.rs:34:5 | LL | / pub fn as_ref(&self) -> &T { LL | | unimplemented!() @@ -30,7 +30,7 @@ LL | | } = help: consider implementing the trait `std::convert::AsRef` or choosing a less ambiguous method name error: method `bitand` can be confused for the standard trait method `std::ops::BitAnd::bitand` - --> $DIR/method_list_1.rs:37:5 + --> $DIR/method_list_1.rs:38:5 | LL | / pub fn bitand(self, rhs: T) -> T { LL | | unimplemented!() @@ -40,7 +40,7 @@ LL | | } = help: consider implementing the trait `std::ops::BitAnd` or choosing a less ambiguous method name error: method `bitor` can be confused for the standard trait method `std::ops::BitOr::bitor` - --> $DIR/method_list_1.rs:41:5 + --> $DIR/method_list_1.rs:42:5 | LL | / pub fn bitor(self, rhs: Self) -> Self { LL | | unimplemented!() @@ -50,7 +50,7 @@ LL | | } = help: consider implementing the trait `std::ops::BitOr` or choosing a less ambiguous method name error: method `bitxor` can be confused for the standard trait method `std::ops::BitXor::bitxor` - --> $DIR/method_list_1.rs:45:5 + --> $DIR/method_list_1.rs:46:5 | LL | / pub fn bitxor(self, rhs: Self) -> Self { LL | | unimplemented!() @@ -60,7 +60,7 @@ LL | | } = help: consider implementing the trait `std::ops::BitXor` or choosing a less ambiguous method name error: method `borrow` can be confused for the standard trait method `std::borrow::Borrow::borrow` - --> $DIR/method_list_1.rs:49:5 + --> $DIR/method_list_1.rs:50:5 | LL | / pub fn borrow(&self) -> &str { LL | | unimplemented!() @@ -70,7 +70,7 @@ LL | | } = help: consider implementing the trait `std::borrow::Borrow` or choosing a less ambiguous method name error: method `borrow_mut` can be confused for the standard trait method `std::borrow::BorrowMut::borrow_mut` - --> $DIR/method_list_1.rs:53:5 + --> $DIR/method_list_1.rs:54:5 | LL | / pub fn borrow_mut(&mut self) -> &mut str { LL | | unimplemented!() @@ -80,7 +80,7 @@ LL | | } = help: consider implementing the trait `std::borrow::BorrowMut` or choosing a less ambiguous method name error: method `clone` can be confused for the standard trait method `std::clone::Clone::clone` - --> $DIR/method_list_1.rs:57:5 + --> $DIR/method_list_1.rs:58:5 | LL | / pub fn clone(&self) -> Self { LL | | unimplemented!() @@ -90,7 +90,7 @@ LL | | } = help: consider implementing the trait `std::clone::Clone` or choosing a less ambiguous method name error: method `cmp` can be confused for the standard trait method `std::cmp::Ord::cmp` - --> $DIR/method_list_1.rs:61:5 + --> $DIR/method_list_1.rs:62:5 | LL | / pub fn cmp(&self, other: &Self) -> Self { LL | | unimplemented!() @@ -100,7 +100,7 @@ LL | | } = help: consider implementing the trait `std::cmp::Ord` or choosing a less ambiguous method name error: method `deref` can be confused for the standard trait method `std::ops::Deref::deref` - --> $DIR/method_list_1.rs:69:5 + --> $DIR/method_list_1.rs:70:5 | LL | / pub fn deref(&self) -> &Self { LL | | unimplemented!() @@ -110,7 +110,7 @@ LL | | } = help: consider implementing the trait `std::ops::Deref` or choosing a less ambiguous method name error: method `deref_mut` can be confused for the standard trait method `std::ops::DerefMut::deref_mut` - --> $DIR/method_list_1.rs:73:5 + --> $DIR/method_list_1.rs:74:5 | LL | / pub fn deref_mut(&mut self) -> &mut Self { LL | | unimplemented!() @@ -120,7 +120,7 @@ LL | | } = help: consider implementing the trait `std::ops::DerefMut` or choosing a less ambiguous method name error: method `div` can be confused for the standard trait method `std::ops::Div::div` - --> $DIR/method_list_1.rs:77:5 + --> $DIR/method_list_1.rs:78:5 | LL | / pub fn div(self, rhs: Self) -> Self { LL | | unimplemented!() @@ -130,7 +130,7 @@ LL | | } = help: consider implementing the trait `std::ops::Div` or choosing a less ambiguous method name error: method `drop` can be confused for the standard trait method `std::ops::Drop::drop` - --> $DIR/method_list_1.rs:81:5 + --> $DIR/method_list_1.rs:82:5 | LL | / pub fn drop(&mut self) { LL | | unimplemented!() diff --git a/src/tools/clippy/tests/ui/should_impl_trait/method_list_2.rs b/src/tools/clippy/tests/ui/should_impl_trait/method_list_2.rs index ed5e0d384bf50..2cdc1a06fe689 100644 --- a/src/tools/clippy/tests/ui/should_impl_trait/method_list_2.rs +++ b/src/tools/clippy/tests/ui/should_impl_trait/method_list_2.rs @@ -8,7 +8,8 @@ clippy::unused_self, clippy::needless_lifetimes, clippy::missing_safety_doc, - clippy::wrong_self_convention + clippy::wrong_self_convention, + clippy::missing_panics_doc )] use std::ops::Mul; diff --git a/src/tools/clippy/tests/ui/should_impl_trait/method_list_2.stderr b/src/tools/clippy/tests/ui/should_impl_trait/method_list_2.stderr index b6fd435695698..0142e2991081c 100644 --- a/src/tools/clippy/tests/ui/should_impl_trait/method_list_2.stderr +++ b/src/tools/clippy/tests/ui/should_impl_trait/method_list_2.stderr @@ -1,5 +1,5 @@ error: method `eq` can be confused for the standard trait method `std::cmp::PartialEq::eq` - --> $DIR/method_list_2.rs:26:5 + --> $DIR/method_list_2.rs:27:5 | LL | / pub fn eq(&self, other: &Self) -> bool { LL | | unimplemented!() @@ -10,7 +10,7 @@ LL | | } = help: consider implementing the trait `std::cmp::PartialEq` or choosing a less ambiguous method name error: method `from_iter` can be confused for the standard trait method `std::iter::FromIterator::from_iter` - --> $DIR/method_list_2.rs:30:5 + --> $DIR/method_list_2.rs:31:5 | LL | / pub fn from_iter(iter: T) -> Self { LL | | unimplemented!() @@ -20,7 +20,7 @@ LL | | } = help: consider implementing the trait `std::iter::FromIterator` or choosing a less ambiguous method name error: method `from_str` can be confused for the standard trait method `std::str::FromStr::from_str` - --> $DIR/method_list_2.rs:34:5 + --> $DIR/method_list_2.rs:35:5 | LL | / pub fn from_str(s: &str) -> Result { LL | | unimplemented!() @@ -30,7 +30,7 @@ LL | | } = help: consider implementing the trait `std::str::FromStr` or choosing a less ambiguous method name error: method `hash` can be confused for the standard trait method `std::hash::Hash::hash` - --> $DIR/method_list_2.rs:38:5 + --> $DIR/method_list_2.rs:39:5 | LL | / pub fn hash(&self, state: &mut T) { LL | | unimplemented!() @@ -40,7 +40,7 @@ LL | | } = help: consider implementing the trait `std::hash::Hash` or choosing a less ambiguous method name error: method `index` can be confused for the standard trait method `std::ops::Index::index` - --> $DIR/method_list_2.rs:42:5 + --> $DIR/method_list_2.rs:43:5 | LL | / pub fn index(&self, index: usize) -> &Self { LL | | unimplemented!() @@ -50,7 +50,7 @@ LL | | } = help: consider implementing the trait `std::ops::Index` or choosing a less ambiguous method name error: method `index_mut` can be confused for the standard trait method `std::ops::IndexMut::index_mut` - --> $DIR/method_list_2.rs:46:5 + --> $DIR/method_list_2.rs:47:5 | LL | / pub fn index_mut(&mut self, index: usize) -> &mut Self { LL | | unimplemented!() @@ -60,7 +60,7 @@ LL | | } = help: consider implementing the trait `std::ops::IndexMut` or choosing a less ambiguous method name error: method `into_iter` can be confused for the standard trait method `std::iter::IntoIterator::into_iter` - --> $DIR/method_list_2.rs:50:5 + --> $DIR/method_list_2.rs:51:5 | LL | / pub fn into_iter(self) -> Self { LL | | unimplemented!() @@ -70,7 +70,7 @@ LL | | } = help: consider implementing the trait `std::iter::IntoIterator` or choosing a less ambiguous method name error: method `mul` can be confused for the standard trait method `std::ops::Mul::mul` - --> $DIR/method_list_2.rs:54:5 + --> $DIR/method_list_2.rs:55:5 | LL | / pub fn mul(self, rhs: Self) -> Self { LL | | unimplemented!() @@ -80,7 +80,7 @@ LL | | } = help: consider implementing the trait `std::ops::Mul` or choosing a less ambiguous method name error: method `neg` can be confused for the standard trait method `std::ops::Neg::neg` - --> $DIR/method_list_2.rs:58:5 + --> $DIR/method_list_2.rs:59:5 | LL | / pub fn neg(self) -> Self { LL | | unimplemented!() @@ -90,7 +90,7 @@ LL | | } = help: consider implementing the trait `std::ops::Neg` or choosing a less ambiguous method name error: method `next` can be confused for the standard trait method `std::iter::Iterator::next` - --> $DIR/method_list_2.rs:62:5 + --> $DIR/method_list_2.rs:63:5 | LL | / pub fn next(&mut self) -> Option { LL | | unimplemented!() @@ -100,7 +100,7 @@ LL | | } = help: consider implementing the trait `std::iter::Iterator` or choosing a less ambiguous method name error: method `not` can be confused for the standard trait method `std::ops::Not::not` - --> $DIR/method_list_2.rs:66:5 + --> $DIR/method_list_2.rs:67:5 | LL | / pub fn not(self) -> Self { LL | | unimplemented!() @@ -110,7 +110,7 @@ LL | | } = help: consider implementing the trait `std::ops::Not` or choosing a less ambiguous method name error: method `rem` can be confused for the standard trait method `std::ops::Rem::rem` - --> $DIR/method_list_2.rs:70:5 + --> $DIR/method_list_2.rs:71:5 | LL | / pub fn rem(self, rhs: Self) -> Self { LL | | unimplemented!() @@ -120,7 +120,7 @@ LL | | } = help: consider implementing the trait `std::ops::Rem` or choosing a less ambiguous method name error: method `shl` can be confused for the standard trait method `std::ops::Shl::shl` - --> $DIR/method_list_2.rs:74:5 + --> $DIR/method_list_2.rs:75:5 | LL | / pub fn shl(self, rhs: Self) -> Self { LL | | unimplemented!() @@ -130,7 +130,7 @@ LL | | } = help: consider implementing the trait `std::ops::Shl` or choosing a less ambiguous method name error: method `shr` can be confused for the standard trait method `std::ops::Shr::shr` - --> $DIR/method_list_2.rs:78:5 + --> $DIR/method_list_2.rs:79:5 | LL | / pub fn shr(self, rhs: Self) -> Self { LL | | unimplemented!() @@ -140,7 +140,7 @@ LL | | } = help: consider implementing the trait `std::ops::Shr` or choosing a less ambiguous method name error: method `sub` can be confused for the standard trait method `std::ops::Sub::sub` - --> $DIR/method_list_2.rs:82:5 + --> $DIR/method_list_2.rs:83:5 | LL | / pub fn sub(self, rhs: Self) -> Self { LL | | unimplemented!()