diff --git a/src/librustc/mir/interpret/error.rs b/src/librustc/mir/interpret/error.rs index 819c65e2503260649b7d395ee412c10377207cef..5cd1ced20220ae5e7a1aa28db45a87902c1e7322 100644 --- a/src/librustc/mir/interpret/error.rs +++ b/src/librustc/mir/interpret/error.rs @@ -100,6 +100,7 @@ pub fn report_as_lint(&self, tcx: TyCtxtAt<'a, 'gcx, 'tcx>, message: &str, lint_root: hir::HirId, + span: Option, ) -> ErrorHandled { let lint = self.struct_generic( tcx, @@ -108,6 +109,16 @@ pub fn report_as_lint(&self, ); match lint { Ok(mut lint) => { + if let Some(span) = span { + let primary_spans = lint.span.primary_spans().to_vec(); + // point at the actual error as the primary span + lint.replace_span_with(span); + // point to the `const` statement as a secondary span + // they don't have any label + for sp in primary_spans { + lint.span_label(sp, ""); + } + } lint.emit(); ErrorHandled::Reported }, diff --git a/src/librustc_mir/const_eval.rs b/src/librustc_mir/const_eval.rs index 79a3e0c5ee2482bf9549666682b9f746070b6b4e..08ede2f5e80a47288ad50f8746b82bffa67b529e 100644 --- a/src/librustc_mir/const_eval.rs +++ b/src/librustc_mir/const_eval.rs @@ -668,6 +668,7 @@ pub fn const_eval_raw_provider<'a, 'tcx>( tcx.at(tcx.def_span(def_id)), "any use of this value will cause an error", hir_id, + Some(err.span), ) }, // promoting runtime code is only allowed to error if it references broken constants @@ -684,6 +685,7 @@ pub fn const_eval_raw_provider<'a, 'tcx>( tcx.at(span), "reaching this expression at runtime will panic or abort", tcx.hir().as_local_hir_id(def_id).unwrap(), + Some(err.span), ) } // anything else (array lengths, enum initializers, constant patterns) are reported diff --git a/src/librustc_mir/transform/const_prop.rs b/src/librustc_mir/transform/const_prop.rs index d816968442058d74db9c54d5bd433fa766c5dbfa..33672a2b7745c8c276263604795aecaeabd447e2 100644 --- a/src/librustc_mir/transform/const_prop.rs +++ b/src/librustc_mir/transform/const_prop.rs @@ -237,6 +237,7 @@ fn use_ecx( self.ecx.tcx, "this expression will panic at runtime", lint_root, + None, ); } } diff --git a/src/test/ui/array_const_index-0.stderr b/src/test/ui/array_const_index-0.stderr index dfc89e0ae86adcb2a607f08c57f045c5f7cf9d5d..78d456d6c2e0e6450d81b893664ad3765c35e4e6 100644 --- a/src/test/ui/array_const_index-0.stderr +++ b/src/test/ui/array_const_index-0.stderr @@ -1,8 +1,8 @@ error: any use of this value will cause an error - --> $DIR/array_const_index-0.rs:2:1 + --> $DIR/array_const_index-0.rs:2:16 | LL | const B: i32 = (&A)[1]; - | ^^^^^^^^^^^^^^^-------^ + | ---------------^^^^^^^- | | | index out of bounds: the len is 0 but the index is 1 | diff --git a/src/test/ui/array_const_index-1.stderr b/src/test/ui/array_const_index-1.stderr index 3e912fad53a5f310045590d6ec484a491deb8e95..3e7360f935bb9cfdd6efda212cecda356aa5ba1b 100644 --- a/src/test/ui/array_const_index-1.stderr +++ b/src/test/ui/array_const_index-1.stderr @@ -1,8 +1,8 @@ error: any use of this value will cause an error - --> $DIR/array_const_index-1.rs:2:1 + --> $DIR/array_const_index-1.rs:2:16 | LL | const B: i32 = A[1]; - | ^^^^^^^^^^^^^^^----^ + | ---------------^^^^- | | | index out of bounds: the len is 0 but the index is 1 | diff --git a/src/test/ui/consts/const-err-early.stderr b/src/test/ui/consts/const-err-early.stderr index a61f9b303aa1517c0475de7c3e413791f91d4f49..9b0ef94a5b8c3660aef8a7daff287660d5c3af6a 100644 --- a/src/test/ui/consts/const-err-early.stderr +++ b/src/test/ui/consts/const-err-early.stderr @@ -1,8 +1,8 @@ error: any use of this value will cause an error - --> $DIR/const-err-early.rs:3:1 + --> $DIR/const-err-early.rs:3:19 | LL | pub const A: i8 = -std::i8::MIN; - | ^^^^^^^^^^^^^^^^^^-------------^ + | ------------------^^^^^^^^^^^^^- | | | attempt to negate with overflow | @@ -13,34 +13,34 @@ LL | #![deny(const_err)] | ^^^^^^^^^ error: any use of this value will cause an error - --> $DIR/const-err-early.rs:4:1 + --> $DIR/const-err-early.rs:4:19 | LL | pub const B: u8 = 200u8 + 200u8; - | ^^^^^^^^^^^^^^^^^^-------------^ + | ------------------^^^^^^^^^^^^^- | | | attempt to add with overflow error: any use of this value will cause an error - --> $DIR/const-err-early.rs:5:1 + --> $DIR/const-err-early.rs:5:19 | LL | pub const C: u8 = 200u8 * 4; - | ^^^^^^^^^^^^^^^^^^---------^ + | ------------------^^^^^^^^^- | | | attempt to multiply with overflow error: any use of this value will cause an error - --> $DIR/const-err-early.rs:6:1 + --> $DIR/const-err-early.rs:6:19 | LL | pub const D: u8 = 42u8 - (42u8 + 1); - | ^^^^^^^^^^^^^^^^^^-----------------^ + | ------------------^^^^^^^^^^^^^^^^^- | | | attempt to subtract with overflow error: any use of this value will cause an error - --> $DIR/const-err-early.rs:7:1 + --> $DIR/const-err-early.rs:7:19 | LL | pub const E: u8 = [5u8][1]; - | ^^^^^^^^^^^^^^^^^^--------^ + | ------------------^^^^^^^^- | | | index out of bounds: the len is 1 but the index is 1 diff --git a/src/test/ui/consts/const-err-multi.stderr b/src/test/ui/consts/const-err-multi.stderr index af62665c056b03d3898757aa42e8c0ab6577c520..c647f13fc7520f83c73cb9f31ae4be969a51790e 100644 --- a/src/test/ui/consts/const-err-multi.stderr +++ b/src/test/ui/consts/const-err-multi.stderr @@ -1,8 +1,8 @@ error: any use of this value will cause an error - --> $DIR/const-err-multi.rs:3:1 + --> $DIR/const-err-multi.rs:3:19 | LL | pub const A: i8 = -std::i8::MIN; - | ^^^^^^^^^^^^^^^^^^-------------^ + | ------------------^^^^^^^^^^^^^- | | | attempt to negate with overflow | @@ -13,26 +13,26 @@ LL | #![deny(const_err)] | ^^^^^^^^^ error: any use of this value will cause an error - --> $DIR/const-err-multi.rs:5:1 + --> $DIR/const-err-multi.rs:5:19 | LL | pub const B: i8 = A; - | ^^^^^^^^^^^^^^^^^^-^ + | ------------------^- | | | referenced constant has errors error: any use of this value will cause an error - --> $DIR/const-err-multi.rs:7:1 + --> $DIR/const-err-multi.rs:7:19 | LL | pub const C: u8 = A as u8; - | ^^^^^^^^^^^^^^^^^^-------^ + | ------------------^^^^^^^- | | | referenced constant has errors error: any use of this value will cause an error - --> $DIR/const-err-multi.rs:9:1 + --> $DIR/const-err-multi.rs:9:19 | LL | pub const D: i8 = 50 - A; - | ^^^^^^^^^^^^^^^^^^------^ + | ------------------^^^^^^- | | | referenced constant has errors diff --git a/src/test/ui/consts/const-err.stderr b/src/test/ui/consts/const-err.stderr index 082494b43c25bf662c08a5d41251db72131cf7f4..0ee9ecdef451dc9cbbc9046b337674e9e25f2c9e 100644 --- a/src/test/ui/consts/const-err.stderr +++ b/src/test/ui/consts/const-err.stderr @@ -1,8 +1,8 @@ warning: any use of this value will cause an error - --> $DIR/const-err.rs:10:1 + --> $DIR/const-err.rs:10:17 | LL | const FOO: u8 = [5u8][1]; - | ^^^^^^^^^^^^^^^^--------^ + | ----------------^^^^^^^^- | | | index out of bounds: the len is 1 but the index is 1 | 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 7722c7423fc87cd7ac6ec7ceacd15512e2fe937b..7f94d849c006c4610a292893af44d1a250ece4b3 100644 --- a/src/test/ui/consts/const-eval/conditional_array_execution.stderr +++ b/src/test/ui/consts/const-eval/conditional_array_execution.stderr @@ -1,8 +1,8 @@ warning: any use of this value will cause an error - --> $DIR/conditional_array_execution.rs:5:1 + --> $DIR/conditional_array_execution.rs:5:19 | LL | const FOO: u32 = [X - Y, Y - X][(X < Y) as usize]; - | ^^^^^^^^^^^^^^^^^^-----^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ------------------^^^^^--------------------------- | | | attempt to subtract with overflow | 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 4700c63adbcb3f39d3da7476db3cefab4a3809ef..a0dbcc88cea8a9da000689a7804cfee57da5159d 100644 --- a/src/test/ui/consts/const-eval/const-eval-overflow2.rs +++ b/src/test/ui/consts/const-eval/const-eval-overflow2.rs @@ -11,43 +11,51 @@ use std::{i8, i16, i32, i64, isize}; use std::{u8, u16, u32, u64, usize}; -const VALS_I8: (i8,) = //~ ERROR any use of this value will cause an error +const VALS_I8: (i8,) = ( i8::MIN - 1, ); + //~^^ ERROR any use of this value will cause an error -const VALS_I16: (i16,) = //~ ERROR any use of this value will cause an error +const VALS_I16: (i16,) = ( i16::MIN - 1, ); + //~^^ ERROR any use of this value will cause an error -const VALS_I32: (i32,) = //~ ERROR any use of this value will cause an error +const VALS_I32: (i32,) = ( i32::MIN - 1, ); + //~^^ ERROR any use of this value will cause an error -const VALS_I64: (i64,) = //~ ERROR any use of this value will cause an error +const VALS_I64: (i64,) = ( i64::MIN - 1, ); + //~^^ ERROR any use of this value will cause an error -const VALS_U8: (u8,) = //~ ERROR any use of this value will cause an error +const VALS_U8: (u8,) = ( u8::MIN - 1, ); + //~^^ ERROR any use of this value will cause an error -const VALS_U16: (u16,) = ( //~ ERROR any use of this value will cause an error +const VALS_U16: (u16,) = ( u16::MIN - 1, ); + //~^^ ERROR any use of this value will cause an error -const VALS_U32: (u32,) = ( //~ ERROR any use of this value will cause an error +const VALS_U32: (u32,) = ( u32::MIN - 1, ); + //~^^ ERROR any use of this value will cause an error -const VALS_U64: (u64,) = //~ ERROR any use of this value will cause an error +const VALS_U64: (u64,) = ( u64::MIN - 1, ); + //~^^ ERROR any use of this value will cause an error 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 44ee8b336c89c5f45595d99ddd183f1c995cb5df..419b3d52dbff1b4139d9c662d51d1d44c57991eb 100644 --- a/src/test/ui/consts/const-eval/const-eval-overflow2.stderr +++ b/src/test/ui/consts/const-eval/const-eval-overflow2.stderr @@ -1,12 +1,12 @@ error: any use of this value will cause an error - --> $DIR/const-eval-overflow2.rs:14:1 + --> $DIR/const-eval-overflow2.rs:16:6 | LL | / const VALS_I8: (i8,) = LL | | ( LL | | i8::MIN - 1, - | | ----------- attempt to subtract with overflow + | | ^^^^^^^^^^^ attempt to subtract with overflow LL | | ); - | |_______^ + | |_______- | note: lint level defined here --> $DIR/const-eval-overflow2.rs:8:9 @@ -15,72 +15,72 @@ LL | #![deny(const_err)] | ^^^^^^^^^ error: any use of this value will cause an error - --> $DIR/const-eval-overflow2.rs:19:1 + --> $DIR/const-eval-overflow2.rs:22:6 | LL | / const VALS_I16: (i16,) = LL | | ( LL | | i16::MIN - 1, - | | ------------ attempt to subtract with overflow + | | ^^^^^^^^^^^^ attempt to subtract with overflow LL | | ); - | |_______^ + | |_______- error: any use of this value will cause an error - --> $DIR/const-eval-overflow2.rs:24:1 + --> $DIR/const-eval-overflow2.rs:28:6 | LL | / const VALS_I32: (i32,) = LL | | ( LL | | i32::MIN - 1, - | | ------------ attempt to subtract with overflow + | | ^^^^^^^^^^^^ attempt to subtract with overflow LL | | ); - | |_______^ + | |_______- error: any use of this value will cause an error - --> $DIR/const-eval-overflow2.rs:29:1 + --> $DIR/const-eval-overflow2.rs:34:6 | LL | / const VALS_I64: (i64,) = LL | | ( LL | | i64::MIN - 1, - | | ------------ attempt to subtract with overflow + | | ^^^^^^^^^^^^ attempt to subtract with overflow LL | | ); - | |_______^ + | |_______- error: any use of this value will cause an error - --> $DIR/const-eval-overflow2.rs:34:1 + --> $DIR/const-eval-overflow2.rs:40:6 | LL | / const VALS_U8: (u8,) = LL | | ( LL | | u8::MIN - 1, - | | ----------- attempt to subtract with overflow + | | ^^^^^^^^^^^ attempt to subtract with overflow LL | | ); - | |_______^ + | |_______- error: any use of this value will cause an error - --> $DIR/const-eval-overflow2.rs:39:1 + --> $DIR/const-eval-overflow2.rs:45:6 | LL | / const VALS_U16: (u16,) = ( LL | | u16::MIN - 1, - | | ------------ attempt to subtract with overflow + | | ^^^^^^^^^^^^ attempt to subtract with overflow LL | | ); - | |_______^ + | |_______- error: any use of this value will cause an error - --> $DIR/const-eval-overflow2.rs:43:1 + --> $DIR/const-eval-overflow2.rs:50:6 | LL | / const VALS_U32: (u32,) = ( LL | | u32::MIN - 1, - | | ------------ attempt to subtract with overflow + | | ^^^^^^^^^^^^ attempt to subtract with overflow LL | | ); - | |_______^ + | |_______- error: any use of this value will cause an error - --> $DIR/const-eval-overflow2.rs:47:1 + --> $DIR/const-eval-overflow2.rs:56:6 | LL | / const VALS_U64: (u64,) = LL | | ( LL | | u64::MIN - 1, - | | ------------ attempt to subtract with overflow + | | ^^^^^^^^^^^^ attempt to subtract with overflow LL | | ); - | |_______^ + | |_______- 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 6bed90aa8ea65c2478caa66a7855738dd8514d46..da883671a60a3c6cbaebe860ab5da8100d7c8ac7 100644 --- a/src/test/ui/consts/const-eval/const-eval-overflow2b.rs +++ b/src/test/ui/consts/const-eval/const-eval-overflow2b.rs @@ -11,43 +11,51 @@ use std::{i8, i16, i32, i64, isize}; use std::{u8, u16, u32, u64, usize}; -const VALS_I8: (i8,) = //~ ERROR any use of this value will cause an error +const VALS_I8: (i8,) = ( i8::MAX + 1, ); + //~^^ ERROR any use of this value will cause an error -const VALS_I16: (i16,) = //~ ERROR any use of this value will cause an error +const VALS_I16: (i16,) = ( i16::MAX + 1, ); + //~^^ ERROR any use of this value will cause an error -const VALS_I32: (i32,) = //~ ERROR any use of this value will cause an error +const VALS_I32: (i32,) = ( i32::MAX + 1, ); + //~^^ ERROR any use of this value will cause an error -const VALS_I64: (i64,) = //~ ERROR any use of this value will cause an error +const VALS_I64: (i64,) = ( i64::MAX + 1, ); + //~^^ ERROR any use of this value will cause an error -const VALS_U8: (u8,) = //~ ERROR any use of this value will cause an error +const VALS_U8: (u8,) = ( u8::MAX + 1, ); + //~^^ ERROR any use of this value will cause an error -const VALS_U16: (u16,) = ( //~ ERROR any use of this value will cause an error +const VALS_U16: (u16,) = ( u16::MAX + 1, ); + //~^^ ERROR any use of this value will cause an error -const VALS_U32: (u32,) = ( //~ ERROR any use of this value will cause an error +const VALS_U32: (u32,) = ( u32::MAX + 1, ); + //~^^ ERROR any use of this value will cause an error -const VALS_U64: (u64,) = //~ ERROR any use of this value will cause an error +const VALS_U64: (u64,) = ( u64::MAX + 1, ); + //~^^ ERROR any use of this value will cause an error 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 69e165bef4a7a39437584ff7b7ffe4b011cb398b..2cfd34c9fc3c7661f8ac68b4ef5e2e2fc6818532 100644 --- a/src/test/ui/consts/const-eval/const-eval-overflow2b.stderr +++ b/src/test/ui/consts/const-eval/const-eval-overflow2b.stderr @@ -1,12 +1,12 @@ error: any use of this value will cause an error - --> $DIR/const-eval-overflow2b.rs:14:1 + --> $DIR/const-eval-overflow2b.rs:16:6 | LL | / const VALS_I8: (i8,) = LL | | ( LL | | i8::MAX + 1, - | | ----------- attempt to add with overflow + | | ^^^^^^^^^^^ attempt to add with overflow LL | | ); - | |_______^ + | |_______- | note: lint level defined here --> $DIR/const-eval-overflow2b.rs:8:9 @@ -15,72 +15,72 @@ LL | #![deny(const_err)] | ^^^^^^^^^ error: any use of this value will cause an error - --> $DIR/const-eval-overflow2b.rs:19:1 + --> $DIR/const-eval-overflow2b.rs:22:6 | LL | / const VALS_I16: (i16,) = LL | | ( LL | | i16::MAX + 1, - | | ------------ attempt to add with overflow + | | ^^^^^^^^^^^^ attempt to add with overflow LL | | ); - | |_______^ + | |_______- error: any use of this value will cause an error - --> $DIR/const-eval-overflow2b.rs:24:1 + --> $DIR/const-eval-overflow2b.rs:28:6 | LL | / const VALS_I32: (i32,) = LL | | ( LL | | i32::MAX + 1, - | | ------------ attempt to add with overflow + | | ^^^^^^^^^^^^ attempt to add with overflow LL | | ); - | |_______^ + | |_______- error: any use of this value will cause an error - --> $DIR/const-eval-overflow2b.rs:29:1 + --> $DIR/const-eval-overflow2b.rs:34:6 | LL | / const VALS_I64: (i64,) = LL | | ( LL | | i64::MAX + 1, - | | ------------ attempt to add with overflow + | | ^^^^^^^^^^^^ attempt to add with overflow LL | | ); - | |_______^ + | |_______- error: any use of this value will cause an error - --> $DIR/const-eval-overflow2b.rs:34:1 + --> $DIR/const-eval-overflow2b.rs:40:6 | LL | / const VALS_U8: (u8,) = LL | | ( LL | | u8::MAX + 1, - | | ----------- attempt to add with overflow + | | ^^^^^^^^^^^ attempt to add with overflow LL | | ); - | |_______^ + | |_______- error: any use of this value will cause an error - --> $DIR/const-eval-overflow2b.rs:39:1 + --> $DIR/const-eval-overflow2b.rs:45:6 | LL | / const VALS_U16: (u16,) = ( LL | | u16::MAX + 1, - | | ------------ attempt to add with overflow + | | ^^^^^^^^^^^^ attempt to add with overflow LL | | ); - | |_______^ + | |_______- error: any use of this value will cause an error - --> $DIR/const-eval-overflow2b.rs:43:1 + --> $DIR/const-eval-overflow2b.rs:50:6 | LL | / const VALS_U32: (u32,) = ( LL | | u32::MAX + 1, - | | ------------ attempt to add with overflow + | | ^^^^^^^^^^^^ attempt to add with overflow LL | | ); - | |_______^ + | |_______- error: any use of this value will cause an error - --> $DIR/const-eval-overflow2b.rs:47:1 + --> $DIR/const-eval-overflow2b.rs:56:6 | LL | / const VALS_U64: (u64,) = LL | | ( LL | | u64::MAX + 1, - | | ------------ attempt to add with overflow + | | ^^^^^^^^^^^^ attempt to add with overflow LL | | ); - | |_______^ + | |_______- 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 108251e4bd28149140e399c6e4fe1a4cbc5f6d7f..e87344405a103f5cf7bfa75ea19edbd8190639f1 100644 --- a/src/test/ui/consts/const-eval/const-eval-overflow2c.rs +++ b/src/test/ui/consts/const-eval/const-eval-overflow2c.rs @@ -11,43 +11,51 @@ use std::{i8, i16, i32, i64, isize}; use std::{u8, u16, u32, u64, usize}; -const VALS_I8: (i8,) = //~ ERROR any use of this value will cause an error +const VALS_I8: (i8,) = ( i8::MIN * 2, ); + //~^^ ERROR any use of this value will cause an error -const VALS_I16: (i16,) = //~ ERROR any use of this value will cause an error +const VALS_I16: (i16,) = ( i16::MIN * 2, ); + //~^^ ERROR any use of this value will cause an error -const VALS_I32: (i32,) = //~ ERROR any use of this value will cause an error +const VALS_I32: (i32,) = ( i32::MIN * 2, ); + //~^^ ERROR any use of this value will cause an error -const VALS_I64: (i64,) = //~ ERROR any use of this value will cause an error +const VALS_I64: (i64,) = ( i64::MIN * 2, ); + //~^^ ERROR any use of this value will cause an error -const VALS_U8: (u8,) = //~ ERROR any use of this value will cause an error +const VALS_U8: (u8,) = ( u8::MAX * 2, ); + //~^^ ERROR any use of this value will cause an error -const VALS_U16: (u16,) = ( //~ ERROR any use of this value will cause an error +const VALS_U16: (u16,) = ( u16::MAX * 2, ); + //~^^ ERROR any use of this value will cause an error -const VALS_U32: (u32,) = ( //~ ERROR any use of this value will cause an error +const VALS_U32: (u32,) = ( u32::MAX * 2, ); + //~^^ ERROR any use of this value will cause an error -const VALS_U64: (u64,) = //~ ERROR any use of this value will cause an error +const VALS_U64: (u64,) = ( u64::MAX * 2, ); + //~^^ ERROR any use of this value will cause an error 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 ba606f6d09de5f375826be3fd7cb407dc1e36738..5e63286c594d95165e49934dc8e1d99525a8a35a 100644 --- a/src/test/ui/consts/const-eval/const-eval-overflow2c.stderr +++ b/src/test/ui/consts/const-eval/const-eval-overflow2c.stderr @@ -1,12 +1,12 @@ error: any use of this value will cause an error - --> $DIR/const-eval-overflow2c.rs:14:1 + --> $DIR/const-eval-overflow2c.rs:16:6 | LL | / const VALS_I8: (i8,) = LL | | ( LL | | i8::MIN * 2, - | | ----------- attempt to multiply with overflow + | | ^^^^^^^^^^^ attempt to multiply with overflow LL | | ); - | |_______^ + | |_______- | note: lint level defined here --> $DIR/const-eval-overflow2c.rs:8:9 @@ -15,72 +15,72 @@ LL | #![deny(const_err)] | ^^^^^^^^^ error: any use of this value will cause an error - --> $DIR/const-eval-overflow2c.rs:19:1 + --> $DIR/const-eval-overflow2c.rs:22:6 | LL | / const VALS_I16: (i16,) = LL | | ( LL | | i16::MIN * 2, - | | ------------ attempt to multiply with overflow + | | ^^^^^^^^^^^^ attempt to multiply with overflow LL | | ); - | |_______^ + | |_______- error: any use of this value will cause an error - --> $DIR/const-eval-overflow2c.rs:24:1 + --> $DIR/const-eval-overflow2c.rs:28:6 | LL | / const VALS_I32: (i32,) = LL | | ( LL | | i32::MIN * 2, - | | ------------ attempt to multiply with overflow + | | ^^^^^^^^^^^^ attempt to multiply with overflow LL | | ); - | |_______^ + | |_______- error: any use of this value will cause an error - --> $DIR/const-eval-overflow2c.rs:29:1 + --> $DIR/const-eval-overflow2c.rs:34:6 | LL | / const VALS_I64: (i64,) = LL | | ( LL | | i64::MIN * 2, - | | ------------ attempt to multiply with overflow + | | ^^^^^^^^^^^^ attempt to multiply with overflow LL | | ); - | |_______^ + | |_______- error: any use of this value will cause an error - --> $DIR/const-eval-overflow2c.rs:34:1 + --> $DIR/const-eval-overflow2c.rs:40:6 | LL | / const VALS_U8: (u8,) = LL | | ( LL | | u8::MAX * 2, - | | ----------- attempt to multiply with overflow + | | ^^^^^^^^^^^ attempt to multiply with overflow LL | | ); - | |_______^ + | |_______- error: any use of this value will cause an error - --> $DIR/const-eval-overflow2c.rs:39:1 + --> $DIR/const-eval-overflow2c.rs:45:6 | LL | / const VALS_U16: (u16,) = ( LL | | u16::MAX * 2, - | | ------------ attempt to multiply with overflow + | | ^^^^^^^^^^^^ attempt to multiply with overflow LL | | ); - | |_______^ + | |_______- error: any use of this value will cause an error - --> $DIR/const-eval-overflow2c.rs:43:1 + --> $DIR/const-eval-overflow2c.rs:50:6 | LL | / const VALS_U32: (u32,) = ( LL | | u32::MAX * 2, - | | ------------ attempt to multiply with overflow + | | ^^^^^^^^^^^^ attempt to multiply with overflow LL | | ); - | |_______^ + | |_______- error: any use of this value will cause an error - --> $DIR/const-eval-overflow2c.rs:47:1 + --> $DIR/const-eval-overflow2c.rs:56:6 | LL | / const VALS_U64: (u64,) = LL | | ( LL | | u64::MAX * 2, - | | ------------ attempt to multiply with overflow + | | ^^^^^^^^^^^^ attempt to multiply with overflow LL | | ); - | |_______^ + | |_______- error: aborting due to 8 previous errors 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 786338222e3ba8c36149776b5e24251343bb88b7..284b06984a31c09505e43295b84c92f33348202a 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 @@ -7,28 +7,28 @@ LL | const I32_REF_USIZE_UNION: usize = unsafe { Nonsense { int_32_ref: &3 } = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler 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:27:5 + --> $DIR/const-pointer-values-in-various-types.rs:27:43 | LL | const I32_REF_U8_UNION: u8 = unsafe { Nonsense { int_32_ref: &3 }.uint_8 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^----------------------------------^^^ + | --------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | a raw memory access tried to access part of a pointer value as raw bytes | = note: #[deny(const_err)] on by default error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:30:5 + --> $DIR/const-pointer-values-in-various-types.rs:30:45 | LL | const I32_REF_U16_UNION: u16 = unsafe { Nonsense { int_32_ref: &3 }.uint_16 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-----------------------------------^^^ + | ----------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | a raw memory access tried to access part of a pointer value as raw bytes error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:33:5 + --> $DIR/const-pointer-values-in-various-types.rs:33:45 | LL | const I32_REF_U32_UNION: u32 = unsafe { Nonsense { int_32_ref: &3 }.uint_32 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-----------------------------------^^^ + | ----------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | a raw memory access tried to access part of a pointer value as raw bytes @@ -49,26 +49,26 @@ 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 rust compiler 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:42:5 + --> $DIR/const-pointer-values-in-various-types.rs:42:43 | LL | const I32_REF_I8_UNION: i8 = unsafe { Nonsense { int_32_ref: &3 }.int_8 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^---------------------------------^^^ + | --------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | a raw memory access tried to access part of a pointer value as raw bytes error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:45:5 + --> $DIR/const-pointer-values-in-various-types.rs:45:45 | LL | const I32_REF_I16_UNION: i16 = unsafe { Nonsense { int_32_ref: &3 }.int_16 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^----------------------------------^^^ + | ----------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | a raw memory access tried to access part of a pointer value as raw bytes error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:48:5 + --> $DIR/const-pointer-values-in-various-types.rs:48:45 | LL | const I32_REF_I32_UNION: i32 = unsafe { Nonsense { int_32_ref: &3 }.int_32 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^----------------------------------^^^ + | ----------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | a raw memory access tried to access part of a pointer value as raw bytes @@ -89,10 +89,10 @@ 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 rust compiler 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:57:5 + --> $DIR/const-pointer-values-in-various-types.rs:57:45 | LL | const I32_REF_F32_UNION: f32 = unsafe { Nonsense { int_32_ref: &3 }.float_32 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^------------------------------------^^^ + | ----------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | a raw memory access tried to access part of a pointer value as raw bytes @@ -105,42 +105,42 @@ 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 rust compiler 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:63:5 + --> $DIR/const-pointer-values-in-various-types.rs:63:47 | LL | const I32_REF_BOOL_UNION: bool = unsafe { Nonsense { int_32_ref: &3 }.truthy_falsey }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-----------------------------------------^^^ + | ------------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | a raw memory access tried to access part of a pointer value as raw bytes error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:66:5 + --> $DIR/const-pointer-values-in-various-types.rs:66:47 | LL | const I32_REF_CHAR_UNION: char = unsafe { Nonsense { int_32_ref: &3 }.character }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-------------------------------------^^^ + | ------------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | a raw memory access tried to access part of a pointer value as raw bytes error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:69:5 + --> $DIR/const-pointer-values-in-various-types.rs:69:39 | LL | const STR_U8_UNION: u8 = unsafe { Nonsense { stringy: "3" }.uint_8 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--------------------------------^^^ + | ----------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | a raw memory access tried to access part of a pointer value as raw bytes error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:72:5 + --> $DIR/const-pointer-values-in-various-types.rs:72:41 | LL | const STR_U16_UNION: u16 = unsafe { Nonsense { stringy: "3" }.uint_16 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^---------------------------------^^^ + | ------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | a raw memory access tried to access part of a pointer value as raw bytes error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:75:5 + --> $DIR/const-pointer-values-in-various-types.rs:75:41 | LL | const STR_U32_UNION: u32 = unsafe { Nonsense { stringy: "3" }.uint_32 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^---------------------------------^^^ + | ------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | a raw memory access tried to access part of a pointer value as raw bytes @@ -153,34 +153,34 @@ 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 rust compiler 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:81:5 + --> $DIR/const-pointer-values-in-various-types.rs:81:43 | LL | const STR_U128_UNION: u128 = unsafe { Nonsense { stringy: "3" }.uint_128 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^----------------------------------^^^ + | --------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | a raw memory access tried to access part of a pointer value as raw bytes error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:84:5 + --> $DIR/const-pointer-values-in-various-types.rs:84:39 | LL | const STR_I8_UNION: i8 = unsafe { Nonsense { stringy: "3" }.int_8 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-------------------------------^^^ + | ----------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | a raw memory access tried to access part of a pointer value as raw bytes error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:87:5 + --> $DIR/const-pointer-values-in-various-types.rs:87:41 | LL | const STR_I16_UNION: i16 = unsafe { Nonsense { stringy: "3" }.int_16 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--------------------------------^^^ + | ------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | a raw memory access tried to access part of a pointer value as raw bytes error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:90:5 + --> $DIR/const-pointer-values-in-various-types.rs:90:41 | LL | const STR_I32_UNION: i32 = unsafe { Nonsense { stringy: "3" }.int_32 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--------------------------------^^^ + | ------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | a raw memory access tried to access part of a pointer value as raw bytes @@ -193,18 +193,18 @@ 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 rust compiler 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:96:5 + --> $DIR/const-pointer-values-in-various-types.rs:96:43 | LL | const STR_I128_UNION: i128 = unsafe { Nonsense { stringy: "3" }.int_128 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^---------------------------------^^^ + | --------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | a raw memory access tried to access part of a pointer value as raw bytes error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:99:5 + --> $DIR/const-pointer-values-in-various-types.rs:99:41 | LL | const STR_F32_UNION: f32 = unsafe { Nonsense { stringy: "3" }.float_32 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^----------------------------------^^^ + | ------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | a raw memory access tried to access part of a pointer value as raw bytes @@ -217,18 +217,18 @@ 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 rust compiler 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:105:5 + --> $DIR/const-pointer-values-in-various-types.rs:105:43 | LL | const STR_BOOL_UNION: bool = unsafe { Nonsense { stringy: "3" }.truthy_falsey }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^---------------------------------------^^^ + | --------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | a raw memory access tried to access part of a pointer value as raw bytes error: any use of this value will cause an error - --> $DIR/const-pointer-values-in-various-types.rs:108:5 + --> $DIR/const-pointer-values-in-various-types.rs:108:43 | LL | const STR_CHAR_UNION: char = unsafe { Nonsense { stringy: "3" }.character }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-----------------------------------^^^ + | --------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | a raw memory access tried to access part of a pointer value as raw bytes diff --git a/src/test/ui/consts/const-eval/const_panic.stderr b/src/test/ui/consts/const-eval/const_panic.stderr index eecac7c71075b90782d641a2d7adf833114ca964..12c7e3d34ab9e14b0cc409929f1c0952057671ff 100644 --- a/src/test/ui/consts/const-eval/const_panic.stderr +++ b/src/test/ui/consts/const-eval/const_panic.stderr @@ -1,8 +1,8 @@ error: any use of this value will cause an error - --> $DIR/const_panic.rs:4:1 + --> $DIR/const_panic.rs:4:19 | LL | pub const Z: () = panic!("cheese"); - | ^^^^^^^^^^^^^^^^^^----------------^ + | ------------------^^^^^^^^^^^^^^^^- | | | the evaluated program panicked at 'cheese', $DIR/const_panic.rs:4:19 | @@ -10,20 +10,20 @@ LL | pub const Z: () = panic!("cheese"); = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) error: any use of this value will cause an error - --> $DIR/const_panic.rs:7:1 + --> $DIR/const_panic.rs:7:19 | LL | pub const Y: () = unreachable!(); - | ^^^^^^^^^^^^^^^^^^--------------^ + | ------------------^^^^^^^^^^^^^^- | | | the evaluated program panicked at 'internal error: entered unreachable code', $DIR/const_panic.rs:7:19 | = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) error: any use of this value will cause an error - --> $DIR/const_panic.rs:10:1 + --> $DIR/const_panic.rs:10:19 | LL | pub const X: () = unimplemented!(); - | ^^^^^^^^^^^^^^^^^^----------------^ + | ------------------^^^^^^^^^^^^^^^^- | | | the evaluated program panicked at 'not yet implemented', $DIR/const_panic.rs:10:19 | diff --git a/src/test/ui/consts/const-eval/const_panic_libcore.stderr b/src/test/ui/consts/const-eval/const_panic_libcore.stderr index 83c89c329dcf58a768011cacd8d34e89a54b97d4..9dddac49c92b80baf322dbcd2ff6322d09acaa30 100644 --- a/src/test/ui/consts/const-eval/const_panic_libcore.stderr +++ b/src/test/ui/consts/const-eval/const_panic_libcore.stderr @@ -1,8 +1,8 @@ error: any use of this value will cause an error - --> $DIR/const_panic_libcore.rs:5:1 + --> $DIR/const_panic_libcore.rs:5:15 | LL | const Z: () = panic!("cheese"); - | ^^^^^^^^^^^^^^----------------^ + | --------------^^^^^^^^^^^^^^^^- | | | the evaluated program panicked at 'cheese', $DIR/const_panic_libcore.rs:5:15 | @@ -10,20 +10,20 @@ LL | const Z: () = panic!("cheese"); = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) error: any use of this value will cause an error - --> $DIR/const_panic_libcore.rs:8:1 + --> $DIR/const_panic_libcore.rs:8:15 | LL | const Y: () = unreachable!(); - | ^^^^^^^^^^^^^^--------------^ + | --------------^^^^^^^^^^^^^^- | | | the evaluated program panicked at 'internal error: entered unreachable code', $DIR/const_panic_libcore.rs:8:15 | = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) error: any use of this value will cause an error - --> $DIR/const_panic_libcore.rs:11:1 + --> $DIR/const_panic_libcore.rs:11:15 | LL | const X: () = unimplemented!(); - | ^^^^^^^^^^^^^^----------------^ + | --------------^^^^^^^^^^^^^^^^- | | | the evaluated program panicked at 'not yet implemented', $DIR/const_panic_libcore.rs:11:15 | diff --git a/src/test/ui/consts/const-eval/const_panic_libcore_main.stderr b/src/test/ui/consts/const-eval/const_panic_libcore_main.stderr index 4cc48618e321223d7a36ba488f0b3985877964de..df04a03681127189606f0755e640362a047df49f 100644 --- a/src/test/ui/consts/const-eval/const_panic_libcore_main.stderr +++ b/src/test/ui/consts/const-eval/const_panic_libcore_main.stderr @@ -1,8 +1,8 @@ error: any use of this value will cause an error - --> $DIR/const_panic_libcore_main.rs:9:1 + --> $DIR/const_panic_libcore_main.rs:9:15 | LL | const Z: () = panic!("cheese"); - | ^^^^^^^^^^^^^^----------------^ + | --------------^^^^^^^^^^^^^^^^- | | | the evaluated program panicked at 'cheese', $DIR/const_panic_libcore_main.rs:9:15 | @@ -10,20 +10,20 @@ LL | const Z: () = panic!("cheese"); = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) error: any use of this value will cause an error - --> $DIR/const_panic_libcore_main.rs:12:1 + --> $DIR/const_panic_libcore_main.rs:12:15 | LL | const Y: () = unreachable!(); - | ^^^^^^^^^^^^^^--------------^ + | --------------^^^^^^^^^^^^^^- | | | the evaluated program panicked at 'internal error: entered unreachable code', $DIR/const_panic_libcore_main.rs:12:15 | = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) error: any use of this value will cause an error - --> $DIR/const_panic_libcore_main.rs:15:1 + --> $DIR/const_panic_libcore_main.rs:15:15 | LL | const X: () = unimplemented!(); - | ^^^^^^^^^^^^^^----------------^ + | --------------^^^^^^^^^^^^^^^^- | | | the evaluated program panicked at 'not yet implemented', $DIR/const_panic_libcore_main.rs:15:15 | diff --git a/src/test/ui/consts/const-eval/const_raw_ptr_ops.stderr b/src/test/ui/consts/const-eval/const_raw_ptr_ops.stderr index 773441182b4be7fde6e9ed1a032f8a33e14068ec..0d4c0b98879cc4008ba4a79a193345ae026cdcd5 100644 --- a/src/test/ui/consts/const-eval/const_raw_ptr_ops.stderr +++ b/src/test/ui/consts/const-eval/const_raw_ptr_ops.stderr @@ -1,34 +1,34 @@ error: any use of this value will cause an error - --> $DIR/const_raw_ptr_ops.rs:6:1 + --> $DIR/const_raw_ptr_ops.rs:6:26 | LL | const X: bool = unsafe { &1 as *const i32 == &2 as *const i32 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^------------------------------------^^^ + | -------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | "pointer arithmetic or comparison" needs an rfc before being allowed inside constants | = note: #[deny(const_err)] on by default error: any use of this value will cause an error - --> $DIR/const_raw_ptr_ops.rs:12:1 + --> $DIR/const_raw_ptr_ops.rs:12:28 | LL | const Y2: usize = unsafe { &1 as *const i32 as usize + 1 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^-----------------------------^^^ + | ---------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | "pointer arithmetic or comparison" needs an rfc before being allowed inside constants error: any use of this value will cause an error - --> $DIR/const_raw_ptr_ops.rs:16:1 + --> $DIR/const_raw_ptr_ops.rs:16:26 | LL | const Z2: i32 = unsafe { *(42 as *const i32) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^-------------------^^^ + | -------------------------^^^^^^^^^^^^^^^^^^^--- | | | a memory access tried to interpret some bytes as a pointer error: any use of this value will cause an error - --> $DIR/const_raw_ptr_ops.rs:17:1 + --> $DIR/const_raw_ptr_ops.rs:17:26 | LL | const Z3: i32 = unsafe { *(44 as *const i32) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^-------------------^^^ + | -------------------------^^^^^^^^^^^^^^^^^^^--- | | | a memory access tried to interpret some bytes as a pointer diff --git a/src/test/ui/consts/const-eval/issue-43197.stderr b/src/test/ui/consts/const-eval/issue-43197.stderr index 84c686102609e456307b66b68d2072763b0ffbf4..478e453fe0834f2a0e3d47d77fb34601bcf8bfc9 100644 --- a/src/test/ui/consts/const-eval/issue-43197.stderr +++ b/src/test/ui/consts/const-eval/issue-43197.stderr @@ -1,8 +1,8 @@ warning: any use of this value will cause an error - --> $DIR/issue-43197.rs:8:5 + --> $DIR/issue-43197.rs:8:20 | LL | const X: u32 = 0-1; - | ^^^^^^^^^^^^^^^---^ + | ---------------^^^- | | | attempt to subtract with overflow | @@ -13,10 +13,10 @@ LL | #![warn(const_err)] | ^^^^^^^^^ warning: any use of this value will cause an error - --> $DIR/issue-43197.rs:10:5 + --> $DIR/issue-43197.rs:10:24 | LL | const Y: u32 = foo(0-1); - | ^^^^^^^^^^^^^^^^^^^---^^ + | -------------------^^^-- | | | attempt to subtract with overflow diff --git a/src/test/ui/consts/const-eval/issue-49296.stderr b/src/test/ui/consts/const-eval/issue-49296.stderr index 37462db4c965e4308533e658cf064d91f2f39c7f..5a59a8b2dffcd2c6459d9817af8c1890295491c3 100644 --- a/src/test/ui/consts/const-eval/issue-49296.stderr +++ b/src/test/ui/consts/const-eval/issue-49296.stderr @@ -1,8 +1,8 @@ error: any use of this value will cause an error - --> $DIR/issue-49296.rs:18:1 + --> $DIR/issue-49296.rs:18:16 | LL | const X: u64 = *wat(42); - | ^^^^^^^^^^^^^^^--------^ + | ---------------^^^^^^^^- | | | dangling pointer was dereferenced | 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 29ebc31b634ad9a1459b77357bec4e2777daaa99..da560046c547c246764bbf5e4aef0ae8ccdbd6e2 100644 --- a/src/test/ui/consts/const-eval/issue-50814-2.stderr +++ b/src/test/ui/consts/const-eval/issue-50814-2.stderr @@ -1,8 +1,8 @@ error: any use of this value will cause an error - --> $DIR/issue-50814-2.rs:12:5 + --> $DIR/issue-50814-2.rs:12:24 | LL | const BAR: usize = [5, 6, 7][T::BOO]; - | ^^^^^^^^^^^^^^^^^^^-----------------^ + | -------------------^^^^^^^^^^^^^^^^^- | | | index out of bounds: the len is 3 but the index is 42 | diff --git a/src/test/ui/consts/const-eval/issue-50814.stderr b/src/test/ui/consts/const-eval/issue-50814.stderr index 6fbfb4d11fe5a012203a0b15b571ba2cc170b4b0..bc9443b26f5fd9489f859431722986143f4868c3 100644 --- a/src/test/ui/consts/const-eval/issue-50814.stderr +++ b/src/test/ui/consts/const-eval/issue-50814.stderr @@ -1,8 +1,8 @@ error: any use of this value will cause an error - --> $DIR/issue-50814.rs:13:5 + --> $DIR/issue-50814.rs:13:21 | LL | const MAX: u8 = A::MAX + B::MAX; - | ^^^^^^^^^^^^^^^^---------------^ + | ----------------^^^^^^^^^^^^^^^- | | | attempt to add with overflow | diff --git a/src/test/ui/consts/const-eval/promoted_errors.stderr b/src/test/ui/consts/const-eval/promoted_errors.stderr index c9d5ede61ade47c89e8fe420755173b9c80c3ea4..ca870c649f5b23f5cdc4456cc79ab64c4c988006 100644 --- a/src/test/ui/consts/const-eval/promoted_errors.stderr +++ b/src/test/ui/consts/const-eval/promoted_errors.stderr @@ -50,11 +50,15 @@ warning: reaching this expression at runtime will panic or abort --> $DIR/promoted_errors.rs:14:20 | LL | println!("{}", 1/(false as u32)); - | ^^^^^^^^^^^^^^^^ attempt to divide by zero + | ^^^^^^^^^^^^^^^^ + | | + | attempt to divide by zero warning: reaching this expression at runtime will panic or abort --> $DIR/promoted_errors.rs:9:20 | LL | println!("{}", 1/(1-1)); - | ^^^^^^^ attempt to divide by zero + | ^^^^^^^ + | | + | attempt to divide by zero 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 9395832108d93cbfa106d7d64ab5fccad12c00da..bd262b69da81a73feb2e6671bdfa59cf3eb7f306 100644 --- a/src/test/ui/consts/const-eval/pub_const_err.stderr +++ b/src/test/ui/consts/const-eval/pub_const_err.stderr @@ -1,8 +1,8 @@ warning: any use of this value will cause an error - --> $DIR/pub_const_err.rs:6:1 + --> $DIR/pub_const_err.rs:6:20 | LL | pub const Z: u32 = 0 - 1; - | ^^^^^^^^^^^^^^^^^^^-----^ + | -------------------^^^^^- | | | attempt to subtract with overflow | 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 6716f337f414812ee611ffcbf003b30e83d80c12..866d1753edb955dc1e9ed4c699cb67f43d5e718a 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 @@ -1,8 +1,8 @@ warning: any use of this value will cause an error - --> $DIR/pub_const_err_bin.rs:4:1 + --> $DIR/pub_const_err_bin.rs:4:20 | LL | pub const Z: u32 = 0 - 1; - | ^^^^^^^^^^^^^^^^^^^-----^ + | -------------------^^^^^- | | | attempt to subtract with overflow | 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 c0061f8b30cbc19c747aa96ab0cfc2acac99b29d..603efe449f143160fe88f5f52c2cd391c2589dd2 100644 --- a/src/test/ui/consts/const-eval/unused-broken-const.stderr +++ b/src/test/ui/consts/const-eval/unused-broken-const.stderr @@ -1,10 +1,10 @@ warning: due to multiple output types requested, the explicitly specified output file name will be adapted for each output type error: any use of this value will cause an error - --> $DIR/unused-broken-const.rs:5:1 + --> $DIR/unused-broken-const.rs:5:18 | LL | const FOO: i32 = [][0]; - | ^^^^^^^^^^^^^^^^^-----^ + | -----------------^^^^^- | | | index out of bounds: the len is 0 but the index is 0 | diff --git a/src/test/ui/consts/const-int-unchecked.stderr b/src/test/ui/consts/const-int-unchecked.stderr index 4382d9174b757bbf7bc3e883f3b453ae00168c9a..0fa82008711c9ad1befc144ad7e657705197aff5 100644 --- a/src/test/ui/consts/const-int-unchecked.stderr +++ b/src/test/ui/consts/const-int-unchecked.stderr @@ -1,322 +1,322 @@ error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:14:1 + --> $DIR/const-int-unchecked.rs:14:29 | 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 error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:16:1 + --> $DIR/const-int-unchecked.rs:16:31 | LL | const SHL_U16: u16 = unsafe { intrinsics::unchecked_shl(5_u16, 16) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^------------------------------------^^^ + | ------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | Overflowing shift by 16 in unchecked_shl error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:18:1 + --> $DIR/const-int-unchecked.rs:18:31 | LL | const SHL_U32: u32 = unsafe { intrinsics::unchecked_shl(5_u32, 32) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^------------------------------------^^^ + | ------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | Overflowing shift by 32 in unchecked_shl error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:20:1 + --> $DIR/const-int-unchecked.rs:20:31 | LL | const SHL_U64: u64 = unsafe { intrinsics::unchecked_shl(5_u64, 64) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^------------------------------------^^^ + | ------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | Overflowing shift by 64 in unchecked_shl error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:22:1 + --> $DIR/const-int-unchecked.rs:22:33 | LL | const SHL_U128: u128 = unsafe { intrinsics::unchecked_shl(5_u128, 128) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--------------------------------------^^^ + | --------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | Overflowing shift by 128 in unchecked_shl error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:27:1 + --> $DIR/const-int-unchecked.rs:27:29 | LL | const SHL_I8: i8 = unsafe { intrinsics::unchecked_shl(5_i8, 8) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^----------------------------------^^^ + | ----------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | Overflowing shift by 8 in unchecked_shl error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:29:1 + --> $DIR/const-int-unchecked.rs:29:31 | LL | const SHL_I16: i16 = unsafe { intrinsics::unchecked_shl(5_16, 16) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-----------------------------------^^^ + | ------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | Overflowing shift by 16 in unchecked_shl error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:31:1 + --> $DIR/const-int-unchecked.rs:31:31 | LL | const SHL_I32: i32 = unsafe { intrinsics::unchecked_shl(5_i32, 32) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^------------------------------------^^^ + | ------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | Overflowing shift by 32 in unchecked_shl error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:33:1 + --> $DIR/const-int-unchecked.rs:33:31 | LL | const SHL_I64: i64 = unsafe { intrinsics::unchecked_shl(5_i64, 64) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^------------------------------------^^^ + | ------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | Overflowing shift by 64 in unchecked_shl error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:35:1 + --> $DIR/const-int-unchecked.rs:35:33 | LL | const SHL_I128: i128 = unsafe { intrinsics::unchecked_shl(5_i128, 128) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--------------------------------------^^^ + | --------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | Overflowing shift by 128 in unchecked_shl error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:40:1 + --> $DIR/const-int-unchecked.rs:40:33 | LL | const SHL_I8_NEG: i8 = unsafe { intrinsics::unchecked_shl(5_i8, -1) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-----------------------------------^^^ + | --------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | Overflowing shift by 255 in unchecked_shl error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:42:1 + --> $DIR/const-int-unchecked.rs:42:35 | LL | const SHL_I16_NEG: i16 = unsafe { intrinsics::unchecked_shl(5_16, -1) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-----------------------------------^^^ + | ----------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | Overflowing shift by 65535 in unchecked_shl error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:44:1 + --> $DIR/const-int-unchecked.rs:44:35 | LL | const SHL_I32_NEG: i32 = unsafe { intrinsics::unchecked_shl(5_i32, -1) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^------------------------------------^^^ + | ----------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | Overflowing shift by 4294967295 in unchecked_shl error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:46:1 + --> $DIR/const-int-unchecked.rs:46:35 | LL | const SHL_I64_NEG: i64 = unsafe { intrinsics::unchecked_shl(5_i64, -1) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^------------------------------------^^^ + | ----------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | Overflowing shift by 18446744073709551615 in unchecked_shl error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:48:1 + --> $DIR/const-int-unchecked.rs:48:37 | LL | const SHL_I128_NEG: i128 = unsafe { intrinsics::unchecked_shl(5_i128, -1) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-------------------------------------^^^ + | ------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | Overflowing shift by 340282366920938463463374607431768211455 in unchecked_shl error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:54:1 + --> $DIR/const-int-unchecked.rs:54:40 | LL | const SHL_I8_NEG_RANDOM: i8 = unsafe { intrinsics::unchecked_shl(5_i8, -6) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-----------------------------------^^^ + | ---------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | Overflowing shift by 250 in unchecked_shl error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:56:1 + --> $DIR/const-int-unchecked.rs:56:42 | LL | const SHL_I16_NEG_RANDOM: i16 = unsafe { intrinsics::unchecked_shl(5_16, -13) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^------------------------------------^^^ + | -----------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | Overflowing shift by 65523 in unchecked_shl error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:58:1 + --> $DIR/const-int-unchecked.rs:58:42 | LL | const SHL_I32_NEG_RANDOM: i32 = unsafe { intrinsics::unchecked_shl(5_i32, -25) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-------------------------------------^^^ + | -----------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | Overflowing shift by 4294967271 in unchecked_shl error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:60:1 + --> $DIR/const-int-unchecked.rs:60:42 | LL | const SHL_I64_NEG_RANDOM: i64 = unsafe { intrinsics::unchecked_shl(5_i64, -30) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-------------------------------------^^^ + | -----------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | Overflowing shift by 18446744073709551586 in unchecked_shl error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:62:1 + --> $DIR/const-int-unchecked.rs:62:44 | LL | const SHL_I128_NEG_RANDOM: i128 = unsafe { intrinsics::unchecked_shl(5_i128, -93) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--------------------------------------^^^ + | -------------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | Overflowing shift by 340282366920938463463374607431768211363 in unchecked_shl error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:69:1 + --> $DIR/const-int-unchecked.rs:69:29 | LL | const SHR_U8: u8 = unsafe { intrinsics::unchecked_shr(5_u8, 8) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^----------------------------------^^^ + | ----------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | Overflowing shift by 8 in unchecked_shr error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:71:1 + --> $DIR/const-int-unchecked.rs:71:31 | LL | const SHR_U16: u16 = unsafe { intrinsics::unchecked_shr(5_u16, 16) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^------------------------------------^^^ + | ------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | Overflowing shift by 16 in unchecked_shr error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:73:1 + --> $DIR/const-int-unchecked.rs:73:31 | LL | const SHR_U32: u32 = unsafe { intrinsics::unchecked_shr(5_u32, 32) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^------------------------------------^^^ + | ------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | Overflowing shift by 32 in unchecked_shr error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:75:1 + --> $DIR/const-int-unchecked.rs:75:31 | LL | const SHR_U64: u64 = unsafe { intrinsics::unchecked_shr(5_u64, 64) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^------------------------------------^^^ + | ------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | Overflowing shift by 64 in unchecked_shr error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:77:1 + --> $DIR/const-int-unchecked.rs:77:33 | LL | const SHR_U128: u128 = unsafe { intrinsics::unchecked_shr(5_u128, 128) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--------------------------------------^^^ + | --------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | Overflowing shift by 128 in unchecked_shr error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:82:1 + --> $DIR/const-int-unchecked.rs:82:29 | LL | const SHR_I8: i8 = unsafe { intrinsics::unchecked_shr(5_i8, 8) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^----------------------------------^^^ + | ----------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | Overflowing shift by 8 in unchecked_shr error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:84:1 + --> $DIR/const-int-unchecked.rs:84:31 | LL | const SHR_I16: i16 = unsafe { intrinsics::unchecked_shr(5_16, 16) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-----------------------------------^^^ + | ------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | Overflowing shift by 16 in unchecked_shr error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:86:1 + --> $DIR/const-int-unchecked.rs:86:31 | LL | const SHR_I32: i32 = unsafe { intrinsics::unchecked_shr(5_i32, 32) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^------------------------------------^^^ + | ------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | Overflowing shift by 32 in unchecked_shr error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:88:1 + --> $DIR/const-int-unchecked.rs:88:31 | LL | const SHR_I64: i64 = unsafe { intrinsics::unchecked_shr(5_i64, 64) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^------------------------------------^^^ + | ------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | Overflowing shift by 64 in unchecked_shr error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:90:1 + --> $DIR/const-int-unchecked.rs:90:33 | LL | const SHR_I128: i128 = unsafe { intrinsics::unchecked_shr(5_i128, 128) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--------------------------------------^^^ + | --------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | Overflowing shift by 128 in unchecked_shr error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:95:1 + --> $DIR/const-int-unchecked.rs:95:33 | LL | const SHR_I8_NEG: i8 = unsafe { intrinsics::unchecked_shr(5_i8, -1) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-----------------------------------^^^ + | --------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | Overflowing shift by 255 in unchecked_shr error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:97:1 + --> $DIR/const-int-unchecked.rs:97:35 | LL | const SHR_I16_NEG: i16 = unsafe { intrinsics::unchecked_shr(5_16, -1) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-----------------------------------^^^ + | ----------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | Overflowing shift by 65535 in unchecked_shr error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:99:1 + --> $DIR/const-int-unchecked.rs:99:35 | LL | const SHR_I32_NEG: i32 = unsafe { intrinsics::unchecked_shr(5_i32, -1) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^------------------------------------^^^ + | ----------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | Overflowing shift by 4294967295 in unchecked_shr error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:101:1 + --> $DIR/const-int-unchecked.rs:101:35 | LL | const SHR_I64_NEG: i64 = unsafe { intrinsics::unchecked_shr(5_i64, -1) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^------------------------------------^^^ + | ----------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | Overflowing shift by 18446744073709551615 in unchecked_shr error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:103:1 + --> $DIR/const-int-unchecked.rs:103:37 | LL | const SHR_I128_NEG: i128 = unsafe { intrinsics::unchecked_shr(5_i128, -1) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-------------------------------------^^^ + | ------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | Overflowing shift by 340282366920938463463374607431768211455 in unchecked_shr error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:109:1 + --> $DIR/const-int-unchecked.rs:109:40 | LL | const SHR_I8_NEG_RANDOM: i8 = unsafe { intrinsics::unchecked_shr(5_i8, -6) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-----------------------------------^^^ + | ---------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | Overflowing shift by 250 in unchecked_shr error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:111:1 + --> $DIR/const-int-unchecked.rs:111:42 | LL | const SHR_I16_NEG_RANDOM: i16 = unsafe { intrinsics::unchecked_shr(5_16, -13) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^------------------------------------^^^ + | -----------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | Overflowing shift by 65523 in unchecked_shr error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:113:1 + --> $DIR/const-int-unchecked.rs:113:42 | LL | const SHR_I32_NEG_RANDOM: i32 = unsafe { intrinsics::unchecked_shr(5_i32, -25) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-------------------------------------^^^ + | -----------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | Overflowing shift by 4294967271 in unchecked_shr error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:115:1 + --> $DIR/const-int-unchecked.rs:115:42 | LL | const SHR_I64_NEG_RANDOM: i64 = unsafe { intrinsics::unchecked_shr(5_i64, -30) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-------------------------------------^^^ + | -----------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | Overflowing shift by 18446744073709551586 in unchecked_shr error: any use of this value will cause an error - --> $DIR/const-int-unchecked.rs:117:1 + --> $DIR/const-int-unchecked.rs:117:44 | LL | const SHR_I128_NEG_RANDOM: i128 = unsafe { intrinsics::unchecked_shr(5_i128, -93) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--------------------------------------^^^ + | -------------------------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--- | | | Overflowing shift by 340282366920938463463374607431768211363 in unchecked_shr 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 6ee92032bd7770764d761e183d1c7aaab39dd257..ef4fa126dca329389991af9f342f2fd102f08374 100644 --- a/src/test/ui/consts/const-len-underflow-separate-spans.stderr +++ b/src/test/ui/consts/const-len-underflow-separate-spans.stderr @@ -1,8 +1,8 @@ error: any use of this value will cause an error - --> $DIR/const-len-underflow-separate-spans.rs:7:1 + --> $DIR/const-len-underflow-separate-spans.rs:7:20 | LL | const LEN: usize = ONE - TWO; - | ^^^^^^^^^^^^^^^^^^^---------^ + | -------------------^^^^^^^^^- | | | attempt to subtract with overflow | diff --git a/src/test/ui/consts/const-slice-oob.stderr b/src/test/ui/consts/const-slice-oob.stderr index 1122665cf8e55b04c200b8d2f563fcc6cab03d79..c90cdbcb26970487f013f293faa7ffe282989966 100644 --- a/src/test/ui/consts/const-slice-oob.stderr +++ b/src/test/ui/consts/const-slice-oob.stderr @@ -1,8 +1,8 @@ error: any use of this value will cause an error - --> $DIR/const-slice-oob.rs:4:1 + --> $DIR/const-slice-oob.rs:4:18 | LL | const BAR: u32 = FOO[5]; - | ^^^^^^^^^^^^^^^^^------^ + | -----------------^^^^^^- | | | index out of bounds: the len is 3 but the index is 5 | diff --git a/src/test/ui/consts/dangling-alloc-id-ice.stderr b/src/test/ui/consts/dangling-alloc-id-ice.stderr index 87f84480bf66b93313f4088ddd7ef677c3446885..ba640b90e7d79a4c2ce05e0ac8cdf7ed154fa490 100644 --- a/src/test/ui/consts/dangling-alloc-id-ice.stderr +++ b/src/test/ui/consts/dangling-alloc-id-ice.stderr @@ -1,11 +1,17 @@ error: any use of this value will cause an error --> $DIR/dangling-alloc-id-ice.rs:8:1 | -LL | / const FOO: &() = { -LL | | let y = (); -LL | | unsafe { Foo { y: &y }.long_live_the_unit } -LL | | }; - | |__^ type validation failed: encountered dangling pointer in final constant +LL | const FOO: &() = { + | _^ + | |_| + | || +LL | || let y = (); +LL | || unsafe { Foo { y: &y }.long_live_the_unit } +LL | || }; + | || ^ + | ||__| + | |___type validation failed: encountered dangling pointer in final constant + | | = note: #[deny(const_err)] on by default diff --git a/src/test/ui/consts/dangling_raw_ptr.stderr b/src/test/ui/consts/dangling_raw_ptr.stderr index 0168c08f011d4c49426ce4b38dccf3be86f582dd..cedcbf819e2d82a1d7124c5adc5a108a5484bf65 100644 --- a/src/test/ui/consts/dangling_raw_ptr.stderr +++ b/src/test/ui/consts/dangling_raw_ptr.stderr @@ -1,11 +1,17 @@ error: any use of this value will cause an error --> $DIR/dangling_raw_ptr.rs:1:1 | -LL | / const FOO: *const u32 = { -LL | | let x = 42; -LL | | &x -LL | | }; - | |__^ type validation failed: encountered dangling pointer in final constant +LL | const FOO: *const u32 = { + | _^ + | |_| + | || +LL | || let x = 42; +LL | || &x +LL | || }; + | || ^ + | ||__| + | |___type validation failed: encountered dangling pointer in final constant + | | = note: #[deny(const_err)] on by default diff --git a/src/test/ui/error-codes/E0396-fixed.stderr b/src/test/ui/error-codes/E0396-fixed.stderr index 2923d97662868bd6b4a3cf071dc828e26843de7c..4b7f1fa82c26c23987e7402685663e9628b698c8 100644 --- a/src/test/ui/error-codes/E0396-fixed.stderr +++ b/src/test/ui/error-codes/E0396-fixed.stderr @@ -1,8 +1,8 @@ error: any use of this value will cause an error - --> $DIR/E0396-fixed.rs:5:1 + --> $DIR/E0396-fixed.rs:5:28 | LL | const VALUE: u8 = unsafe { *REG_ADDR }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^---------^^^ + | ---------------------------^^^^^^^^^--- | | | a memory access tried to interpret some bytes as a pointer | diff --git a/src/test/ui/issues/issue-43105.stderr b/src/test/ui/issues/issue-43105.stderr index 3cc0440d2c77a3ac1fb792084286c574ca7be23c..378fbe6d5c430e394f0a699bdfdb55499c7c7bee 100644 --- a/src/test/ui/issues/issue-43105.stderr +++ b/src/test/ui/issues/issue-43105.stderr @@ -5,10 +5,10 @@ LL | const NUM: u8 = xyz(); | ^^^^^ error: any use of this value will cause an error - --> $DIR/issue-43105.rs:3:1 + --> $DIR/issue-43105.rs:3:17 | LL | const NUM: u8 = xyz(); - | ^^^^^^^^^^^^^^^^-----^ + | ----------------^^^^^- | | | calling non-const function `xyz` |