From 03ac54aed6f728ab4e5e18a10b5c3887782924cf Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Tue, 24 Sep 2019 16:14:43 +0200 Subject: [PATCH 01/12] Add const-eval support for SIMD types, insert, and extract --- src/librustc_mir/interpret/intrinsics.rs | 20 +++++++- src/librustc_mir/interpret/operand.rs | 15 ++++++ src/librustc_mir/interpret/place.rs | 34 +++++++++++++ src/librustc_mir/interpret/terminator.rs | 4 +- .../ui/consts/const-eval/const_eval-simd.rs | 24 ++++++++++ .../consts/const-eval/const_eval-simd.stderr | 48 +++++++++++++++++++ 6 files changed, 143 insertions(+), 2 deletions(-) create mode 100644 src/test/ui/consts/const-eval/const_eval-simd.rs create mode 100644 src/test/ui/consts/const-eval/const_eval-simd.stderr diff --git a/src/librustc_mir/interpret/intrinsics.rs b/src/librustc_mir/interpret/intrinsics.rs index ec09e69ec8537..0ede068190597 100644 --- a/src/librustc_mir/interpret/intrinsics.rs +++ b/src/librustc_mir/interpret/intrinsics.rs @@ -239,7 +239,25 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { "transmute" => { self.copy_op_transmute(args[0], dest)?; } - + "simd_insert" => { + let mut vector = self.read_vector(args[0])?; + let index = self.read_scalar(args[1])?.to_u32()? as usize; + let scalar = self.read_immediate(args[2])?; + if vector[index].layout.size == scalar.layout.size { + vector[index] = scalar; + } else { + throw_ub_format!( + "Inserting `{:?}` with size `{}` to a vector element place of size `{}`", + scalar, scalar.layout.size.bytes(), vector[index].layout.size.bytes() + ); + } + self.write_vector(vector, dest)?; + } + "simd_extract" => { + let index = self.read_scalar(args[1])?.to_u32()? as _; + let scalar = self.read_immediate(self.operand_field(args[0], index)?)?; + self.write_immediate(*scalar, dest)?; + } _ => return Ok(false), } diff --git a/src/librustc_mir/interpret/operand.rs b/src/librustc_mir/interpret/operand.rs index dd214c4a031f7..184e2ee9516fc 100644 --- a/src/librustc_mir/interpret/operand.rs +++ b/src/librustc_mir/interpret/operand.rs @@ -335,6 +335,21 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { } } + /// Read vector from operand `op` + pub fn read_vector(&self, op: OpTy<'tcx, M::PointerTag>) + -> InterpResult<'tcx, Vec>> { + if let layout::Abi::Vector { count, .. } = op.layout.abi { + assert_ne!(count, 0); + let mut scalars = Vec::new(); + for index in 0..count { + scalars.push(self.read_immediate(self.operand_field(op, index as _)?)?); + } + Ok(scalars) + } else { + bug!("type is not a vector: {:?}, abi: {:?}", op.layout.ty, op.layout.abi); + } + } + /// Read a scalar from a place pub fn read_scalar( &self, diff --git a/src/librustc_mir/interpret/place.rs b/src/librustc_mir/interpret/place.rs index c3660fb7a2e28..9154e2666c598 100644 --- a/src/librustc_mir/interpret/place.rs +++ b/src/librustc_mir/interpret/place.rs @@ -696,6 +696,40 @@ where Ok(()) } + /// Writes the `scalar` to the `index`-th element of the `vector`. + pub fn write_scalar_to_vector( + &mut self, + scalar: ImmTy<'tcx, M::PointerTag>, + vector: PlaceTy<'tcx, M::PointerTag>, + index: usize, + ) -> InterpResult<'tcx> { + let index = index as u64; + let place = self.place_field(vector, index)?; + self.write_immediate(*scalar, place)?; + Ok(()) + } + + /// Writes the `scalars` to the `vector`. + pub fn write_vector( + &mut self, + scalars: Vec>, + vector: PlaceTy<'tcx, M::PointerTag>, + ) -> InterpResult<'tcx> { + assert_ne!(scalars.len(), 0); + match vector.layout.ty.sty { + ty::Adt(def, ..) if def.repr.simd() => { + let tcx = &*self.tcx; + let count = vector.layout.ty.simd_size(*tcx); + assert_eq!(count, scalars.len()); + for index in 0..scalars.len() { + self.write_scalar_to_vector(scalars[index], vector, index)?; + } + } + _ => bug!("not a vector"), + } + Ok(()) + } + /// Write an `Immediate` to memory. #[inline(always)] pub fn write_immediate_to_mplace( diff --git a/src/librustc_mir/interpret/terminator.rs b/src/librustc_mir/interpret/terminator.rs index 8310ef02f9669..a324c58512406 100644 --- a/src/librustc_mir/interpret/terminator.rs +++ b/src/librustc_mir/interpret/terminator.rs @@ -249,7 +249,9 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { match instance.def { ty::InstanceDef::Intrinsic(..) => { - if caller_abi != Abi::RustIntrinsic { + if let Abi::RustIntrinsic | Abi::PlatformIntrinsic = caller_abi { + // ok + } else { throw_unsup!(FunctionAbiMismatch(caller_abi, Abi::RustIntrinsic)) } // The intrinsic itself cannot diverge, so if we got here without a return diff --git a/src/test/ui/consts/const-eval/const_eval-simd.rs b/src/test/ui/consts/const-eval/const_eval-simd.rs new file mode 100644 index 0000000000000..a0f088cc636fc --- /dev/null +++ b/src/test/ui/consts/const-eval/const_eval-simd.rs @@ -0,0 +1,24 @@ +// run-pass +// compile-flags: -Zunleash-the-miri-inside-of-you +#![feature(repr_simd)] +#![feature(platform_intrinsics)] +#![allow(non_camel_case_types)] + +#[repr(simd)] struct i8x1(i8); + +extern "platform-intrinsic" { + fn simd_insert(x: T, idx: u32, val: U) -> T; + fn simd_extract(x: T, idx: u32) -> U; +} + +const fn foo(x: i8x1) -> i8 { + unsafe { simd_insert(x, 0_u32, 42_i8) }.0 +} + +fn main() { + const V: i8x1 = i8x1(13); + const X: i8 = foo(V); + const Y: i8 = unsafe { simd_extract(V, 0) }; + assert_eq!(X, 42); + assert_eq!(Y, 13); +} diff --git a/src/test/ui/consts/const-eval/const_eval-simd.stderr b/src/test/ui/consts/const-eval/const_eval-simd.stderr new file mode 100644 index 0000000000000..7fc068718b0be --- /dev/null +++ b/src/test/ui/consts/const-eval/const_eval-simd.stderr @@ -0,0 +1,48 @@ +warning: skipping const checks + --> $DIR/const_eval-simd.rs:22:5 + | +LL | assert_eq!(X, 42); + | ^^^^^^^^^^^^^^^^^^ + | + = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) + +warning: skipping const checks + --> $DIR/const_eval-simd.rs:22:5 + | +LL | assert_eq!(X, 42); + | ^^^^^^^^^^^^^^^^^^ + | + = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) + +warning: skipping const checks + --> $DIR/const_eval-simd.rs:22:5 + | +LL | assert_eq!(X, 42); + | ^^^^^^^^^^^^^^^^^^ + | + = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) + +warning: skipping const checks + --> $DIR/const_eval-simd.rs:23:5 + | +LL | assert_eq!(Y, 13); + | ^^^^^^^^^^^^^^^^^^ + | + = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) + +warning: skipping const checks + --> $DIR/const_eval-simd.rs:23:5 + | +LL | assert_eq!(Y, 13); + | ^^^^^^^^^^^^^^^^^^ + | + = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) + +warning: skipping const checks + --> $DIR/const_eval-simd.rs:23:5 + | +LL | assert_eq!(Y, 13); + | ^^^^^^^^^^^^^^^^^^ + | + = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) + From 75d8199ab1f41be3f58b5f5331eb642714f42732 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Tue, 24 Sep 2019 16:48:17 +0200 Subject: [PATCH 02/12] Add a fail test --- .../consts/const-eval/const_eval-simd_fail.rs | 20 +++++++++++++++++++ .../const-eval/const_eval-simd_fail.stderr | 16 +++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 src/test/ui/consts/const-eval/const_eval-simd_fail.rs create mode 100644 src/test/ui/consts/const-eval/const_eval-simd_fail.stderr diff --git a/src/test/ui/consts/const-eval/const_eval-simd_fail.rs b/src/test/ui/consts/const-eval/const_eval-simd_fail.rs new file mode 100644 index 0000000000000..20c839a81a04e --- /dev/null +++ b/src/test/ui/consts/const-eval/const_eval-simd_fail.rs @@ -0,0 +1,20 @@ +// compile-flags: -Zunleash-the-miri-inside-of-you +#![feature(repr_simd)] +#![feature(platform_intrinsics)] +#![allow(non_camel_case_types)] + +#[repr(simd)] struct i8x1(i8); + +extern "platform-intrinsic" { + fn simd_insert(x: T, idx: u32, val: U) -> T; +} + +const fn foo(x: i8x1) -> i8 { + // 42 is a i16 that does not fit in a i8 + unsafe { simd_insert(x, 0_u32, 42_i16) }.0 //~ ERROR +} + +fn main() { + const V: i8x1 = i8x1(13); + const X: i8 = foo(V); +} diff --git a/src/test/ui/consts/const-eval/const_eval-simd_fail.stderr b/src/test/ui/consts/const-eval/const_eval-simd_fail.stderr new file mode 100644 index 0000000000000..9f76287979a60 --- /dev/null +++ b/src/test/ui/consts/const-eval/const_eval-simd_fail.stderr @@ -0,0 +1,16 @@ +error: any use of this value will cause an error + --> $DIR/const_eval-simd_fail.rs:14:14 + | +LL | unsafe { simd_insert(x, 0_u32, 42_i16) }.0 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | Inserting `i16` with size `2` to a vector element place of size `1` + | inside call to `foo` at $DIR/const_eval-simd_fail.rs:19:19 +... +LL | const X: i8 = foo(V); + | --------------------- + | + = note: `#[deny(const_err)]` on by default + +error: aborting due to previous error + From f0bbd2b71c4861efc11599fe763f80b5de4490cd Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Tue, 24 Sep 2019 16:52:03 +0200 Subject: [PATCH 03/12] Move tests to SIMD subdirectory --- src/librustc_mir/interpret/intrinsics.rs | 4 ++-- .../insert_extract-fail.rs} | 0 .../insert_extract-fail.stderr} | 4 ++-- .../{const_eval-simd.rs => simd/insert_extract.rs} | 0 .../insert_extract.stderr} | 12 ++++++------ 5 files changed, 10 insertions(+), 10 deletions(-) rename src/test/ui/consts/const-eval/{const_eval-simd_fail.rs => simd/insert_extract-fail.rs} (100%) rename src/test/ui/consts/const-eval/{const_eval-simd_fail.stderr => simd/insert_extract-fail.stderr} (77%) rename src/test/ui/consts/const-eval/{const_eval-simd.rs => simd/insert_extract.rs} (100%) rename src/test/ui/consts/const-eval/{const_eval-simd.stderr => simd/insert_extract.stderr} (87%) diff --git a/src/librustc_mir/interpret/intrinsics.rs b/src/librustc_mir/interpret/intrinsics.rs index 0ede068190597..630f5010b8598 100644 --- a/src/librustc_mir/interpret/intrinsics.rs +++ b/src/librustc_mir/interpret/intrinsics.rs @@ -247,8 +247,8 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { vector[index] = scalar; } else { throw_ub_format!( - "Inserting `{:?}` with size `{}` to a vector element place of size `{}`", - scalar, scalar.layout.size.bytes(), vector[index].layout.size.bytes() + "Inserting `{}` with size `{}` to a vector element place of size `{}`", + scalar.layout.ty, scalar.layout.size.bytes(), vector[index].layout.size.bytes() ); } self.write_vector(vector, dest)?; diff --git a/src/test/ui/consts/const-eval/const_eval-simd_fail.rs b/src/test/ui/consts/const-eval/simd/insert_extract-fail.rs similarity index 100% rename from src/test/ui/consts/const-eval/const_eval-simd_fail.rs rename to src/test/ui/consts/const-eval/simd/insert_extract-fail.rs diff --git a/src/test/ui/consts/const-eval/const_eval-simd_fail.stderr b/src/test/ui/consts/const-eval/simd/insert_extract-fail.stderr similarity index 77% rename from src/test/ui/consts/const-eval/const_eval-simd_fail.stderr rename to src/test/ui/consts/const-eval/simd/insert_extract-fail.stderr index 9f76287979a60..cf4e6887f16d5 100644 --- a/src/test/ui/consts/const-eval/const_eval-simd_fail.stderr +++ b/src/test/ui/consts/const-eval/simd/insert_extract-fail.stderr @@ -1,11 +1,11 @@ error: any use of this value will cause an error - --> $DIR/const_eval-simd_fail.rs:14:14 + --> $DIR/insert_extract-fail.rs:14:14 | LL | unsafe { simd_insert(x, 0_u32, 42_i16) }.0 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | | Inserting `i16` with size `2` to a vector element place of size `1` - | inside call to `foo` at $DIR/const_eval-simd_fail.rs:19:19 + | inside call to `foo` at $DIR/insert_extract-fail.rs:19:19 ... LL | const X: i8 = foo(V); | --------------------- diff --git a/src/test/ui/consts/const-eval/const_eval-simd.rs b/src/test/ui/consts/const-eval/simd/insert_extract.rs similarity index 100% rename from src/test/ui/consts/const-eval/const_eval-simd.rs rename to src/test/ui/consts/const-eval/simd/insert_extract.rs diff --git a/src/test/ui/consts/const-eval/const_eval-simd.stderr b/src/test/ui/consts/const-eval/simd/insert_extract.stderr similarity index 87% rename from src/test/ui/consts/const-eval/const_eval-simd.stderr rename to src/test/ui/consts/const-eval/simd/insert_extract.stderr index 7fc068718b0be..51510273a791b 100644 --- a/src/test/ui/consts/const-eval/const_eval-simd.stderr +++ b/src/test/ui/consts/const-eval/simd/insert_extract.stderr @@ -1,5 +1,5 @@ warning: skipping const checks - --> $DIR/const_eval-simd.rs:22:5 + --> $DIR/insert_extract.rs:22:5 | LL | assert_eq!(X, 42); | ^^^^^^^^^^^^^^^^^^ @@ -7,7 +7,7 @@ LL | assert_eq!(X, 42); = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) warning: skipping const checks - --> $DIR/const_eval-simd.rs:22:5 + --> $DIR/insert_extract.rs:22:5 | LL | assert_eq!(X, 42); | ^^^^^^^^^^^^^^^^^^ @@ -15,7 +15,7 @@ LL | assert_eq!(X, 42); = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) warning: skipping const checks - --> $DIR/const_eval-simd.rs:22:5 + --> $DIR/insert_extract.rs:22:5 | LL | assert_eq!(X, 42); | ^^^^^^^^^^^^^^^^^^ @@ -23,7 +23,7 @@ LL | assert_eq!(X, 42); = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) warning: skipping const checks - --> $DIR/const_eval-simd.rs:23:5 + --> $DIR/insert_extract.rs:23:5 | LL | assert_eq!(Y, 13); | ^^^^^^^^^^^^^^^^^^ @@ -31,7 +31,7 @@ LL | assert_eq!(Y, 13); = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) warning: skipping const checks - --> $DIR/const_eval-simd.rs:23:5 + --> $DIR/insert_extract.rs:23:5 | LL | assert_eq!(Y, 13); | ^^^^^^^^^^^^^^^^^^ @@ -39,7 +39,7 @@ LL | assert_eq!(Y, 13); = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) warning: skipping const checks - --> $DIR/const_eval-simd.rs:23:5 + --> $DIR/insert_extract.rs:23:5 | LL | assert_eq!(Y, 13); | ^^^^^^^^^^^^^^^^^^ From e6239bb81796715f66ec468b70d8779f8ccac6bd Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Tue, 24 Sep 2019 17:02:01 +0200 Subject: [PATCH 04/12] Add some more tests --- .../consts/const-eval/simd/insert_extract.rs | 47 ++- .../const-eval/simd/insert_extract.stderr | 276 ++++++++++++++++-- 2 files changed, 296 insertions(+), 27 deletions(-) diff --git a/src/test/ui/consts/const-eval/simd/insert_extract.rs b/src/test/ui/consts/const-eval/simd/insert_extract.rs index a0f088cc636fc..136965bf68abf 100644 --- a/src/test/ui/consts/const-eval/simd/insert_extract.rs +++ b/src/test/ui/consts/const-eval/simd/insert_extract.rs @@ -5,20 +5,49 @@ #![allow(non_camel_case_types)] #[repr(simd)] struct i8x1(i8); +#[repr(simd)] struct u16x2(u16, u16); +#[repr(simd)] struct f32x3(f32, f32, f32); extern "platform-intrinsic" { fn simd_insert(x: T, idx: u32, val: U) -> T; fn simd_extract(x: T, idx: u32) -> U; } -const fn foo(x: i8x1) -> i8 { - unsafe { simd_insert(x, 0_u32, 42_i8) }.0 -} - fn main() { - const V: i8x1 = i8x1(13); - const X: i8 = foo(V); - const Y: i8 = unsafe { simd_extract(V, 0) }; - assert_eq!(X, 42); - assert_eq!(Y, 13); + { + const U: i8x1 = i8x1(13); + const V: i8x1 = unsafe { simd_insert(U, 0_u32, 42_i8) }; + const X0: i8 = V.0; + const Y0: i8 = unsafe { simd_extract(V, 0) }; + assert_eq!(X0, 42); + assert_eq!(Y0, 42); + } + { + const U: u16x2 = u16x2(13, 14); + const V: u16x2 = unsafe { simd_insert(U, 1_u32, 42_u16) }; + const X0: u16 = V.0; + const X1: u16 = V.1; + const Y0: u16 = unsafe { simd_extract(V, 0) }; + const Y1: u16 = unsafe { simd_extract(V, 1) }; + assert_eq!(X0, 13); + assert_eq!(X1, 42); + assert_eq!(Y0, 13); + assert_eq!(Y1, 42); + } + { + const U: f32x3 = f32x3(13., 14., 15.); + const V: f32x3 = unsafe { simd_insert(U, 1_u32, 42_f32) }; + const X0: f32 = V.0; + const X1: f32 = V.1; + const X2: f32 = V.2; + const Y0: f32 = unsafe { simd_extract(V, 0) }; + const Y1: f32 = unsafe { simd_extract(V, 1) }; + const Y2: f32 = unsafe { simd_extract(V, 2) }; + assert_eq!(X0, 13.); + assert_eq!(X1, 42.); + assert_eq!(X2, 15.); + assert_eq!(Y0, 13.); + assert_eq!(Y1, 42.); + assert_eq!(Y2, 15.); + } } diff --git a/src/test/ui/consts/const-eval/simd/insert_extract.stderr b/src/test/ui/consts/const-eval/simd/insert_extract.stderr index 51510273a791b..8975241403e74 100644 --- a/src/test/ui/consts/const-eval/simd/insert_extract.stderr +++ b/src/test/ui/consts/const-eval/simd/insert_extract.stderr @@ -1,48 +1,288 @@ warning: skipping const checks - --> $DIR/insert_extract.rs:22:5 + --> $DIR/insert_extract.rs:22:9 | -LL | assert_eq!(X, 42); - | ^^^^^^^^^^^^^^^^^^ +LL | assert_eq!(X0, 42); + | ^^^^^^^^^^^^^^^^^^^ | = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) warning: skipping const checks - --> $DIR/insert_extract.rs:22:5 + --> $DIR/insert_extract.rs:22:9 | -LL | assert_eq!(X, 42); - | ^^^^^^^^^^^^^^^^^^ +LL | assert_eq!(X0, 42); + | ^^^^^^^^^^^^^^^^^^^ | = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) warning: skipping const checks - --> $DIR/insert_extract.rs:22:5 + --> $DIR/insert_extract.rs:22:9 | -LL | assert_eq!(X, 42); - | ^^^^^^^^^^^^^^^^^^ +LL | assert_eq!(X0, 42); + | ^^^^^^^^^^^^^^^^^^^ | = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) warning: skipping const checks - --> $DIR/insert_extract.rs:23:5 + --> $DIR/insert_extract.rs:23:9 | -LL | assert_eq!(Y, 13); - | ^^^^^^^^^^^^^^^^^^ +LL | assert_eq!(Y0, 42); + | ^^^^^^^^^^^^^^^^^^^ | = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) warning: skipping const checks - --> $DIR/insert_extract.rs:23:5 + --> $DIR/insert_extract.rs:23:9 | -LL | assert_eq!(Y, 13); - | ^^^^^^^^^^^^^^^^^^ +LL | assert_eq!(Y0, 42); + | ^^^^^^^^^^^^^^^^^^^ | = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) warning: skipping const checks - --> $DIR/insert_extract.rs:23:5 + --> $DIR/insert_extract.rs:23:9 | -LL | assert_eq!(Y, 13); - | ^^^^^^^^^^^^^^^^^^ +LL | assert_eq!(Y0, 42); + | ^^^^^^^^^^^^^^^^^^^ + | + = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) + +warning: skipping const checks + --> $DIR/insert_extract.rs:32:9 + | +LL | assert_eq!(X0, 13); + | ^^^^^^^^^^^^^^^^^^^ + | + = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) + +warning: skipping const checks + --> $DIR/insert_extract.rs:32:9 + | +LL | assert_eq!(X0, 13); + | ^^^^^^^^^^^^^^^^^^^ + | + = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) + +warning: skipping const checks + --> $DIR/insert_extract.rs:32:9 + | +LL | assert_eq!(X0, 13); + | ^^^^^^^^^^^^^^^^^^^ + | + = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) + +warning: skipping const checks + --> $DIR/insert_extract.rs:33:9 + | +LL | assert_eq!(X1, 42); + | ^^^^^^^^^^^^^^^^^^^ + | + = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) + +warning: skipping const checks + --> $DIR/insert_extract.rs:33:9 + | +LL | assert_eq!(X1, 42); + | ^^^^^^^^^^^^^^^^^^^ + | + = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) + +warning: skipping const checks + --> $DIR/insert_extract.rs:33:9 + | +LL | assert_eq!(X1, 42); + | ^^^^^^^^^^^^^^^^^^^ + | + = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) + +warning: skipping const checks + --> $DIR/insert_extract.rs:34:9 + | +LL | assert_eq!(Y0, 13); + | ^^^^^^^^^^^^^^^^^^^ + | + = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) + +warning: skipping const checks + --> $DIR/insert_extract.rs:34:9 + | +LL | assert_eq!(Y0, 13); + | ^^^^^^^^^^^^^^^^^^^ + | + = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) + +warning: skipping const checks + --> $DIR/insert_extract.rs:34:9 + | +LL | assert_eq!(Y0, 13); + | ^^^^^^^^^^^^^^^^^^^ + | + = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) + +warning: skipping const checks + --> $DIR/insert_extract.rs:35:9 + | +LL | assert_eq!(Y1, 42); + | ^^^^^^^^^^^^^^^^^^^ + | + = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) + +warning: skipping const checks + --> $DIR/insert_extract.rs:35:9 + | +LL | assert_eq!(Y1, 42); + | ^^^^^^^^^^^^^^^^^^^ + | + = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) + +warning: skipping const checks + --> $DIR/insert_extract.rs:35:9 + | +LL | assert_eq!(Y1, 42); + | ^^^^^^^^^^^^^^^^^^^ + | + = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) + +warning: skipping const checks + --> $DIR/insert_extract.rs:46:9 + | +LL | assert_eq!(X0, 13.); + | ^^^^^^^^^^^^^^^^^^^^ + | + = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) + +warning: skipping const checks + --> $DIR/insert_extract.rs:46:9 + | +LL | assert_eq!(X0, 13.); + | ^^^^^^^^^^^^^^^^^^^^ + | + = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) + +warning: skipping const checks + --> $DIR/insert_extract.rs:46:9 + | +LL | assert_eq!(X0, 13.); + | ^^^^^^^^^^^^^^^^^^^^ + | + = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) + +warning: skipping const checks + --> $DIR/insert_extract.rs:47:9 + | +LL | assert_eq!(X1, 42.); + | ^^^^^^^^^^^^^^^^^^^^ + | + = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) + +warning: skipping const checks + --> $DIR/insert_extract.rs:47:9 + | +LL | assert_eq!(X1, 42.); + | ^^^^^^^^^^^^^^^^^^^^ + | + = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) + +warning: skipping const checks + --> $DIR/insert_extract.rs:47:9 + | +LL | assert_eq!(X1, 42.); + | ^^^^^^^^^^^^^^^^^^^^ + | + = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) + +warning: skipping const checks + --> $DIR/insert_extract.rs:48:9 + | +LL | assert_eq!(X2, 15.); + | ^^^^^^^^^^^^^^^^^^^^ + | + = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) + +warning: skipping const checks + --> $DIR/insert_extract.rs:48:9 + | +LL | assert_eq!(X2, 15.); + | ^^^^^^^^^^^^^^^^^^^^ + | + = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) + +warning: skipping const checks + --> $DIR/insert_extract.rs:48:9 + | +LL | assert_eq!(X2, 15.); + | ^^^^^^^^^^^^^^^^^^^^ + | + = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) + +warning: skipping const checks + --> $DIR/insert_extract.rs:49:9 + | +LL | assert_eq!(Y0, 13.); + | ^^^^^^^^^^^^^^^^^^^^ + | + = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) + +warning: skipping const checks + --> $DIR/insert_extract.rs:49:9 + | +LL | assert_eq!(Y0, 13.); + | ^^^^^^^^^^^^^^^^^^^^ + | + = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) + +warning: skipping const checks + --> $DIR/insert_extract.rs:49:9 + | +LL | assert_eq!(Y0, 13.); + | ^^^^^^^^^^^^^^^^^^^^ + | + = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) + +warning: skipping const checks + --> $DIR/insert_extract.rs:50:9 + | +LL | assert_eq!(Y1, 42.); + | ^^^^^^^^^^^^^^^^^^^^ + | + = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) + +warning: skipping const checks + --> $DIR/insert_extract.rs:50:9 + | +LL | assert_eq!(Y1, 42.); + | ^^^^^^^^^^^^^^^^^^^^ + | + = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) + +warning: skipping const checks + --> $DIR/insert_extract.rs:50:9 + | +LL | assert_eq!(Y1, 42.); + | ^^^^^^^^^^^^^^^^^^^^ + | + = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) + +warning: skipping const checks + --> $DIR/insert_extract.rs:51:9 + | +LL | assert_eq!(Y2, 15.); + | ^^^^^^^^^^^^^^^^^^^^ + | + = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) + +warning: skipping const checks + --> $DIR/insert_extract.rs:51:9 + | +LL | assert_eq!(Y2, 15.); + | ^^^^^^^^^^^^^^^^^^^^ + | + = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) + +warning: skipping const checks + --> $DIR/insert_extract.rs:51:9 + | +LL | assert_eq!(Y2, 15.); + | ^^^^^^^^^^^^^^^^^^^^ | = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) From 3a6e96e8bc8b7285c5a9b357d0e5e8dd9c191edf Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Wed, 25 Sep 2019 10:28:53 +0200 Subject: [PATCH 05/12] Allow simd_insert and simd_extract in const_fn --- src/librustc_mir/transform/qualify_consts.rs | 2 + .../const-eval/simd/insert_extract-fail.rs | 2 +- .../consts/const-eval/simd/insert_extract.rs | 2 +- .../const-eval/simd/insert_extract.stderr | 288 ------------------ 4 files changed, 4 insertions(+), 290 deletions(-) delete mode 100644 src/test/ui/consts/const-eval/simd/insert_extract.stderr diff --git a/src/librustc_mir/transform/qualify_consts.rs b/src/librustc_mir/transform/qualify_consts.rs index 795721f3b3f28..8a6dcd1d2b476 100644 --- a/src/librustc_mir/transform/qualify_consts.rs +++ b/src/librustc_mir/transform/qualify_consts.rs @@ -557,6 +557,8 @@ impl Qualif for IsNotPromotable { | "saturating_add" | "saturating_sub" | "transmute" + | "simd_insert" + | "simd_extract" => return true, _ => {} diff --git a/src/test/ui/consts/const-eval/simd/insert_extract-fail.rs b/src/test/ui/consts/const-eval/simd/insert_extract-fail.rs index 20c839a81a04e..bbfae997e7241 100644 --- a/src/test/ui/consts/const-eval/simd/insert_extract-fail.rs +++ b/src/test/ui/consts/const-eval/simd/insert_extract-fail.rs @@ -1,4 +1,4 @@ -// compile-flags: -Zunleash-the-miri-inside-of-you +#![feature(const_fn)] #![feature(repr_simd)] #![feature(platform_intrinsics)] #![allow(non_camel_case_types)] diff --git a/src/test/ui/consts/const-eval/simd/insert_extract.rs b/src/test/ui/consts/const-eval/simd/insert_extract.rs index 136965bf68abf..d3462d802ea4e 100644 --- a/src/test/ui/consts/const-eval/simd/insert_extract.rs +++ b/src/test/ui/consts/const-eval/simd/insert_extract.rs @@ -1,5 +1,5 @@ // run-pass -// compile-flags: -Zunleash-the-miri-inside-of-you +#![feature(const_fn)] #![feature(repr_simd)] #![feature(platform_intrinsics)] #![allow(non_camel_case_types)] diff --git a/src/test/ui/consts/const-eval/simd/insert_extract.stderr b/src/test/ui/consts/const-eval/simd/insert_extract.stderr deleted file mode 100644 index 8975241403e74..0000000000000 --- a/src/test/ui/consts/const-eval/simd/insert_extract.stderr +++ /dev/null @@ -1,288 +0,0 @@ -warning: skipping const checks - --> $DIR/insert_extract.rs:22:9 - | -LL | assert_eq!(X0, 42); - | ^^^^^^^^^^^^^^^^^^^ - | - = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) - -warning: skipping const checks - --> $DIR/insert_extract.rs:22:9 - | -LL | assert_eq!(X0, 42); - | ^^^^^^^^^^^^^^^^^^^ - | - = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) - -warning: skipping const checks - --> $DIR/insert_extract.rs:22:9 - | -LL | assert_eq!(X0, 42); - | ^^^^^^^^^^^^^^^^^^^ - | - = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) - -warning: skipping const checks - --> $DIR/insert_extract.rs:23:9 - | -LL | assert_eq!(Y0, 42); - | ^^^^^^^^^^^^^^^^^^^ - | - = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) - -warning: skipping const checks - --> $DIR/insert_extract.rs:23:9 - | -LL | assert_eq!(Y0, 42); - | ^^^^^^^^^^^^^^^^^^^ - | - = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) - -warning: skipping const checks - --> $DIR/insert_extract.rs:23:9 - | -LL | assert_eq!(Y0, 42); - | ^^^^^^^^^^^^^^^^^^^ - | - = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) - -warning: skipping const checks - --> $DIR/insert_extract.rs:32:9 - | -LL | assert_eq!(X0, 13); - | ^^^^^^^^^^^^^^^^^^^ - | - = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) - -warning: skipping const checks - --> $DIR/insert_extract.rs:32:9 - | -LL | assert_eq!(X0, 13); - | ^^^^^^^^^^^^^^^^^^^ - | - = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) - -warning: skipping const checks - --> $DIR/insert_extract.rs:32:9 - | -LL | assert_eq!(X0, 13); - | ^^^^^^^^^^^^^^^^^^^ - | - = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) - -warning: skipping const checks - --> $DIR/insert_extract.rs:33:9 - | -LL | assert_eq!(X1, 42); - | ^^^^^^^^^^^^^^^^^^^ - | - = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) - -warning: skipping const checks - --> $DIR/insert_extract.rs:33:9 - | -LL | assert_eq!(X1, 42); - | ^^^^^^^^^^^^^^^^^^^ - | - = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) - -warning: skipping const checks - --> $DIR/insert_extract.rs:33:9 - | -LL | assert_eq!(X1, 42); - | ^^^^^^^^^^^^^^^^^^^ - | - = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) - -warning: skipping const checks - --> $DIR/insert_extract.rs:34:9 - | -LL | assert_eq!(Y0, 13); - | ^^^^^^^^^^^^^^^^^^^ - | - = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) - -warning: skipping const checks - --> $DIR/insert_extract.rs:34:9 - | -LL | assert_eq!(Y0, 13); - | ^^^^^^^^^^^^^^^^^^^ - | - = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) - -warning: skipping const checks - --> $DIR/insert_extract.rs:34:9 - | -LL | assert_eq!(Y0, 13); - | ^^^^^^^^^^^^^^^^^^^ - | - = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) - -warning: skipping const checks - --> $DIR/insert_extract.rs:35:9 - | -LL | assert_eq!(Y1, 42); - | ^^^^^^^^^^^^^^^^^^^ - | - = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) - -warning: skipping const checks - --> $DIR/insert_extract.rs:35:9 - | -LL | assert_eq!(Y1, 42); - | ^^^^^^^^^^^^^^^^^^^ - | - = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) - -warning: skipping const checks - --> $DIR/insert_extract.rs:35:9 - | -LL | assert_eq!(Y1, 42); - | ^^^^^^^^^^^^^^^^^^^ - | - = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) - -warning: skipping const checks - --> $DIR/insert_extract.rs:46:9 - | -LL | assert_eq!(X0, 13.); - | ^^^^^^^^^^^^^^^^^^^^ - | - = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) - -warning: skipping const checks - --> $DIR/insert_extract.rs:46:9 - | -LL | assert_eq!(X0, 13.); - | ^^^^^^^^^^^^^^^^^^^^ - | - = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) - -warning: skipping const checks - --> $DIR/insert_extract.rs:46:9 - | -LL | assert_eq!(X0, 13.); - | ^^^^^^^^^^^^^^^^^^^^ - | - = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) - -warning: skipping const checks - --> $DIR/insert_extract.rs:47:9 - | -LL | assert_eq!(X1, 42.); - | ^^^^^^^^^^^^^^^^^^^^ - | - = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) - -warning: skipping const checks - --> $DIR/insert_extract.rs:47:9 - | -LL | assert_eq!(X1, 42.); - | ^^^^^^^^^^^^^^^^^^^^ - | - = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) - -warning: skipping const checks - --> $DIR/insert_extract.rs:47:9 - | -LL | assert_eq!(X1, 42.); - | ^^^^^^^^^^^^^^^^^^^^ - | - = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) - -warning: skipping const checks - --> $DIR/insert_extract.rs:48:9 - | -LL | assert_eq!(X2, 15.); - | ^^^^^^^^^^^^^^^^^^^^ - | - = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) - -warning: skipping const checks - --> $DIR/insert_extract.rs:48:9 - | -LL | assert_eq!(X2, 15.); - | ^^^^^^^^^^^^^^^^^^^^ - | - = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) - -warning: skipping const checks - --> $DIR/insert_extract.rs:48:9 - | -LL | assert_eq!(X2, 15.); - | ^^^^^^^^^^^^^^^^^^^^ - | - = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) - -warning: skipping const checks - --> $DIR/insert_extract.rs:49:9 - | -LL | assert_eq!(Y0, 13.); - | ^^^^^^^^^^^^^^^^^^^^ - | - = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) - -warning: skipping const checks - --> $DIR/insert_extract.rs:49:9 - | -LL | assert_eq!(Y0, 13.); - | ^^^^^^^^^^^^^^^^^^^^ - | - = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) - -warning: skipping const checks - --> $DIR/insert_extract.rs:49:9 - | -LL | assert_eq!(Y0, 13.); - | ^^^^^^^^^^^^^^^^^^^^ - | - = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) - -warning: skipping const checks - --> $DIR/insert_extract.rs:50:9 - | -LL | assert_eq!(Y1, 42.); - | ^^^^^^^^^^^^^^^^^^^^ - | - = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) - -warning: skipping const checks - --> $DIR/insert_extract.rs:50:9 - | -LL | assert_eq!(Y1, 42.); - | ^^^^^^^^^^^^^^^^^^^^ - | - = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) - -warning: skipping const checks - --> $DIR/insert_extract.rs:50:9 - | -LL | assert_eq!(Y1, 42.); - | ^^^^^^^^^^^^^^^^^^^^ - | - = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) - -warning: skipping const checks - --> $DIR/insert_extract.rs:51:9 - | -LL | assert_eq!(Y2, 15.); - | ^^^^^^^^^^^^^^^^^^^^ - | - = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) - -warning: skipping const checks - --> $DIR/insert_extract.rs:51:9 - | -LL | assert_eq!(Y2, 15.); - | ^^^^^^^^^^^^^^^^^^^^ - | - = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) - -warning: skipping const checks - --> $DIR/insert_extract.rs:51:9 - | -LL | assert_eq!(Y2, 15.); - | ^^^^^^^^^^^^^^^^^^^^ - | - = note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) - From 97ce904340f416b47c2b9790d550346bef5d7f7f Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Wed, 25 Sep 2019 10:33:12 +0200 Subject: [PATCH 06/12] Remove unreachable code --- src/librustc_mir/interpret/terminator.rs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/librustc_mir/interpret/terminator.rs b/src/librustc_mir/interpret/terminator.rs index a324c58512406..8666c937ce4c2 100644 --- a/src/librustc_mir/interpret/terminator.rs +++ b/src/librustc_mir/interpret/terminator.rs @@ -249,11 +249,6 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { match instance.def { ty::InstanceDef::Intrinsic(..) => { - if let Abi::RustIntrinsic | Abi::PlatformIntrinsic = caller_abi { - // ok - } else { - throw_unsup!(FunctionAbiMismatch(caller_abi, Abi::RustIntrinsic)) - } // The intrinsic itself cannot diverge, so if we got here without a return // place... (can happen e.g., for transmute returning `!`) let dest = match dest { From 02b3234a7766694616e3396c17e9ff08859a785d Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Wed, 25 Sep 2019 10:34:44 +0200 Subject: [PATCH 07/12] Tidy --- src/librustc_mir/interpret/intrinsics.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/librustc_mir/interpret/intrinsics.rs b/src/librustc_mir/interpret/intrinsics.rs index 630f5010b8598..fc1ec61c9629e 100644 --- a/src/librustc_mir/interpret/intrinsics.rs +++ b/src/librustc_mir/interpret/intrinsics.rs @@ -248,7 +248,8 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { } else { throw_ub_format!( "Inserting `{}` with size `{}` to a vector element place of size `{}`", - scalar.layout.ty, scalar.layout.size.bytes(), vector[index].layout.size.bytes() + scalar.layout.ty, + scalar.layout.size.bytes(), vector[index].layout.size.bytes() ); } self.write_vector(vector, dest)?; From 5976674a717f61167a930df0c1fa1fe4106a439e Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Wed, 25 Sep 2019 12:54:23 +0200 Subject: [PATCH 08/12] Refactor --- src/librustc_mir/interpret/intrinsics.rs | 57 ++++++++++++++----- src/librustc_mir/interpret/operand.rs | 19 +++---- src/librustc_mir/interpret/place.rs | 34 ----------- .../const-eval/simd/insert_extract-fail.rs | 7 +++ .../ui/consts/const-eval/simd/read_fail.rs | 17 ++++++ 5 files changed, 76 insertions(+), 58 deletions(-) create mode 100644 src/test/ui/consts/const-eval/simd/read_fail.rs diff --git a/src/librustc_mir/interpret/intrinsics.rs b/src/librustc_mir/interpret/intrinsics.rs index fc1ec61c9629e..586611397e344 100644 --- a/src/librustc_mir/interpret/intrinsics.rs +++ b/src/librustc_mir/interpret/intrinsics.rs @@ -240,24 +240,55 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { self.copy_op_transmute(args[0], dest)?; } "simd_insert" => { - let mut vector = self.read_vector(args[0])?; - let index = self.read_scalar(args[1])?.to_u32()? as usize; + let index = self.read_scalar(args[1])?.to_u32()? as u64; let scalar = self.read_immediate(args[2])?; - if vector[index].layout.size == scalar.layout.size { - vector[index] = scalar; - } else { - throw_ub_format!( - "Inserting `{}` with size `{}` to a vector element place of size `{}`", - scalar.layout.ty, - scalar.layout.size.bytes(), vector[index].layout.size.bytes() - ); + let input = args[0]; + let (len, e_ty) = self.read_vector_ty(input); + assert!( + index < len, + "index `{}` must be in bounds of vector type `{}`: `[0, {})`", + index, e_ty, len + ); + assert_eq!( + args[0].layout, dest.layout, + "Return type `{}` must match vector type `{}`", + dest.layout.ty, input.layout.ty + ); + assert_eq!( + scalar.layout.ty, e_ty, + "Scalar type `{}` must match vector element type `{}`", + scalar.layout.ty, e_ty + ); + + for i in 0..len { + let place = self.place_field(dest, index)?; + if i == index { + self.write_immediate(*scalar, place)?; + } else { + self.write_immediate( + *self.read_immediate(self.operand_field(input, index)?)?, + place + )?; + }; } - self.write_vector(vector, dest)?; } "simd_extract" => { let index = self.read_scalar(args[1])?.to_u32()? as _; - let scalar = self.read_immediate(self.operand_field(args[0], index)?)?; - self.write_immediate(*scalar, dest)?; + let (len, e_ty) = self.read_vector_ty(args[0]); + assert!( + index < len, + "index `{}` must be in bounds of vector type `{}`: `[0, {})`", + index, e_ty, len + ); + assert_eq!( + e_ty, dest.layout.ty, + "Return type `{}` must match vector element type `{}`", + dest.layout.ty, e_ty + ); + self.write_immediate( + *self.read_immediate(self.operand_field(args[0], index)?)?, + dest + )?; } _ => return Ok(false), } diff --git a/src/librustc_mir/interpret/operand.rs b/src/librustc_mir/interpret/operand.rs index 184e2ee9516fc..c5771e4f34378 100644 --- a/src/librustc_mir/interpret/operand.rs +++ b/src/librustc_mir/interpret/operand.rs @@ -335,18 +335,15 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { } } - /// Read vector from operand `op` - pub fn read_vector(&self, op: OpTy<'tcx, M::PointerTag>) - -> InterpResult<'tcx, Vec>> { - if let layout::Abi::Vector { count, .. } = op.layout.abi { - assert_ne!(count, 0); - let mut scalars = Vec::new(); - for index in 0..count { - scalars.push(self.read_immediate(self.operand_field(op, index as _)?)?); - } - Ok(scalars) + /// Read vector length and element type + pub fn read_vector_ty( + &self, op: OpTy<'tcx, M::PointerTag> + ) + -> (u64, &rustc::ty::TyS<'tcx>) { + if let layout::Abi::Vector { .. } = op.layout.abi { + (op.layout.ty.simd_size(*self.tcx) as _, op.layout.ty.simd_type(*self.tcx)) } else { - bug!("type is not a vector: {:?}, abi: {:?}", op.layout.ty, op.layout.abi); + bug!("Type `{}` is not a SIMD vector type", op.layout.ty) } } diff --git a/src/librustc_mir/interpret/place.rs b/src/librustc_mir/interpret/place.rs index 9154e2666c598..c3660fb7a2e28 100644 --- a/src/librustc_mir/interpret/place.rs +++ b/src/librustc_mir/interpret/place.rs @@ -696,40 +696,6 @@ where Ok(()) } - /// Writes the `scalar` to the `index`-th element of the `vector`. - pub fn write_scalar_to_vector( - &mut self, - scalar: ImmTy<'tcx, M::PointerTag>, - vector: PlaceTy<'tcx, M::PointerTag>, - index: usize, - ) -> InterpResult<'tcx> { - let index = index as u64; - let place = self.place_field(vector, index)?; - self.write_immediate(*scalar, place)?; - Ok(()) - } - - /// Writes the `scalars` to the `vector`. - pub fn write_vector( - &mut self, - scalars: Vec>, - vector: PlaceTy<'tcx, M::PointerTag>, - ) -> InterpResult<'tcx> { - assert_ne!(scalars.len(), 0); - match vector.layout.ty.sty { - ty::Adt(def, ..) if def.repr.simd() => { - let tcx = &*self.tcx; - let count = vector.layout.ty.simd_size(*tcx); - assert_eq!(count, scalars.len()); - for index in 0..scalars.len() { - self.write_scalar_to_vector(scalars[index], vector, index)?; - } - } - _ => bug!("not a vector"), - } - Ok(()) - } - /// Write an `Immediate` to memory. #[inline(always)] pub fn write_immediate_to_mplace( diff --git a/src/test/ui/consts/const-eval/simd/insert_extract-fail.rs b/src/test/ui/consts/const-eval/simd/insert_extract-fail.rs index bbfae997e7241..1d1df8d25a406 100644 --- a/src/test/ui/consts/const-eval/simd/insert_extract-fail.rs +++ b/src/test/ui/consts/const-eval/simd/insert_extract-fail.rs @@ -7,6 +7,7 @@ extern "platform-intrinsic" { fn simd_insert(x: T, idx: u32, val: U) -> T; + fn simd_extract(x: T, idx: u32) -> U; } const fn foo(x: i8x1) -> i8 { @@ -14,7 +15,13 @@ const fn foo(x: i8x1) -> i8 { unsafe { simd_insert(x, 0_u32, 42_i16) }.0 //~ ERROR } +const fn bar(x: i8x1) -> i16 { + // the i8 is not a i16: + unsafe { simd_extract(x, 0_u32) } //~ ERROR +} + fn main() { const V: i8x1 = i8x1(13); const X: i8 = foo(V); + const Y: i16 = bar(V); } diff --git a/src/test/ui/consts/const-eval/simd/read_fail.rs b/src/test/ui/consts/const-eval/simd/read_fail.rs new file mode 100644 index 0000000000000..c5109c16e4c6d --- /dev/null +++ b/src/test/ui/consts/const-eval/simd/read_fail.rs @@ -0,0 +1,17 @@ +#![feature(const_fn)] +#![feature(platform_intrinsics)] +#![allow(non_camel_case_types)] + +extern "platform-intrinsic" { + fn simd_extract(x: T, idx: u32) -> U; +} + +const fn foo(x: i8) -> i8 { + // i8 is not a vector type: + unsafe { simd_extract(x, 0_u32) } //~ ERROR +} + +fn main() { + const V: i8 = 13; + const X: i8 = foo(V); +} From e74a268db511d4f124425c981300ebfaea0d64ee Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Wed, 25 Sep 2019 13:39:20 +0200 Subject: [PATCH 09/12] Test errors --- src/librustc_mir/interpret/intrinsics.rs | 25 +++++++---------- .../consts/const-eval/simd/extract-fail0.rs | 22 +++++++++++++++ .../const-eval/simd/extract-fail0.stderr | 15 +++++++++++ .../consts/const-eval/simd/extract-fail1.rs | 22 +++++++++++++++ .../const-eval/simd/extract-fail1.stderr | 15 +++++++++++ .../consts/const-eval/simd/extract-fail2.rs | 22 +++++++++++++++ .../const-eval/simd/extract-fail2.stderr | 13 +++++++++ .../ui/consts/const-eval/simd/insert-fail0.rs | 22 +++++++++++++++ .../const-eval/simd/insert-fail0.stderr | 15 +++++++++++ .../ui/consts/const-eval/simd/insert-fail1.rs | 22 +++++++++++++++ .../const-eval/simd/insert-fail1.stderr | 13 +++++++++ .../const-eval/simd/insert_extract-fail.rs | 27 ------------------- .../simd/insert_extract-fail.stderr | 16 ----------- .../ui/consts/const-eval/simd/read_fail.rs | 17 ------------ 14 files changed, 191 insertions(+), 75 deletions(-) create mode 100644 src/test/ui/consts/const-eval/simd/extract-fail0.rs create mode 100644 src/test/ui/consts/const-eval/simd/extract-fail0.stderr create mode 100644 src/test/ui/consts/const-eval/simd/extract-fail1.rs create mode 100644 src/test/ui/consts/const-eval/simd/extract-fail1.stderr create mode 100644 src/test/ui/consts/const-eval/simd/extract-fail2.rs create mode 100644 src/test/ui/consts/const-eval/simd/extract-fail2.stderr create mode 100644 src/test/ui/consts/const-eval/simd/insert-fail0.rs create mode 100644 src/test/ui/consts/const-eval/simd/insert-fail0.stderr create mode 100644 src/test/ui/consts/const-eval/simd/insert-fail1.rs create mode 100644 src/test/ui/consts/const-eval/simd/insert-fail1.stderr delete mode 100644 src/test/ui/consts/const-eval/simd/insert_extract-fail.rs delete mode 100644 src/test/ui/consts/const-eval/simd/insert_extract-fail.stderr delete mode 100644 src/test/ui/consts/const-eval/simd/read_fail.rs diff --git a/src/librustc_mir/interpret/intrinsics.rs b/src/librustc_mir/interpret/intrinsics.rs index 586611397e344..5fc23b4a69ec5 100644 --- a/src/librustc_mir/interpret/intrinsics.rs +++ b/src/librustc_mir/interpret/intrinsics.rs @@ -241,16 +241,16 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { } "simd_insert" => { let index = self.read_scalar(args[1])?.to_u32()? as u64; - let scalar = self.read_immediate(args[2])?; + let scalar = args[2]; let input = args[0]; let (len, e_ty) = self.read_vector_ty(input); assert!( index < len, - "index `{}` must be in bounds of vector type `{}`: `[0, {})`", + "Index `{}` must be in bounds of vector type `{}`: `[0, {})`", index, e_ty, len ); assert_eq!( - args[0].layout, dest.layout, + input.layout, dest.layout, "Return type `{}` must match vector type `{}`", dest.layout.ty, input.layout.ty ); @@ -261,15 +261,13 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { ); for i in 0..len { - let place = self.place_field(dest, index)?; - if i == index { - self.write_immediate(*scalar, place)?; + let place = self.place_field(dest, i)?; + let value = if i == index { + scalar } else { - self.write_immediate( - *self.read_immediate(self.operand_field(input, index)?)?, - place - )?; + self.operand_field(input, i)? }; + self.copy_op(value, place)?; } } "simd_extract" => { @@ -277,7 +275,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { let (len, e_ty) = self.read_vector_ty(args[0]); assert!( index < len, - "index `{}` must be in bounds of vector type `{}`: `[0, {})`", + "index `{}` is out-of-bounds of vector type `{}` with length `{}`", index, e_ty, len ); assert_eq!( @@ -285,10 +283,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { "Return type `{}` must match vector element type `{}`", dest.layout.ty, e_ty ); - self.write_immediate( - *self.read_immediate(self.operand_field(args[0], index)?)?, - dest - )?; + self.copy_op(self.operand_field(args[0], index)?, dest)?; } _ => return Ok(false), } diff --git a/src/test/ui/consts/const-eval/simd/extract-fail0.rs b/src/test/ui/consts/const-eval/simd/extract-fail0.rs new file mode 100644 index 0000000000000..d2c313ddd0cd4 --- /dev/null +++ b/src/test/ui/consts/const-eval/simd/extract-fail0.rs @@ -0,0 +1,22 @@ +// failure-status: 101 +// rustc-env:RUST_BACKTRACE=0 +#![feature(const_fn)] +#![feature(repr_simd)] +#![feature(platform_intrinsics)] +#![allow(non_camel_case_types)] + +#[repr(simd)] struct i8x1(i8); + +extern "platform-intrinsic" { + fn simd_extract(x: T, idx: u32) -> U; +} + +const X: i8x1 = i8x1(42); + +const fn extract_wrong_ret() -> i16 { + unsafe { simd_extract(X, 0_u32) } +} + +const A: i16 = extract_wrong_ret(); + +fn main() {} diff --git a/src/test/ui/consts/const-eval/simd/extract-fail0.stderr b/src/test/ui/consts/const-eval/simd/extract-fail0.stderr new file mode 100644 index 0000000000000..51518481941df --- /dev/null +++ b/src/test/ui/consts/const-eval/simd/extract-fail0.stderr @@ -0,0 +1,15 @@ +thread 'rustc' panicked at 'assertion failed: `(left == right)` + left: `i8`, + right: `i16`: Return type `i16` must match vector element type `i8`', src/librustc_mir/interpret/intrinsics.rs:281:17 +note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace. + +error: internal compiler error: unexpected panic + +note: the compiler unexpectedly panicked. this is a bug. + +note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports + +note: rustc 1.39.0-dev running on x86_64-apple-darwin + +note: compiler flags: -Z threads=1 -Z ui-testing -Z unstable-options -C prefer-dynamic -C rpath -C debuginfo=0 + diff --git a/src/test/ui/consts/const-eval/simd/extract-fail1.rs b/src/test/ui/consts/const-eval/simd/extract-fail1.rs new file mode 100644 index 0000000000000..ddff608181e93 --- /dev/null +++ b/src/test/ui/consts/const-eval/simd/extract-fail1.rs @@ -0,0 +1,22 @@ +// failure-status: 101 +// rustc-env:RUST_BACKTRACE=0 +#![feature(const_fn)] +#![feature(repr_simd)] +#![feature(platform_intrinsics)] +#![allow(non_camel_case_types)] + +#[repr(simd)] struct i8x1(i8); + +extern "platform-intrinsic" { + fn simd_extract(x: T, idx: u32) -> U; +} + +const X: i8x1 = i8x1(42); + +const fn extract_wrong_vec() -> i8 { + unsafe { simd_extract(42_i8, 0_u32) } +} + +const B: i8 = extract_wrong_vec(); + +fn main() {} diff --git a/src/test/ui/consts/const-eval/simd/extract-fail1.stderr b/src/test/ui/consts/const-eval/simd/extract-fail1.stderr new file mode 100644 index 0000000000000..a00d98bf7fd9b --- /dev/null +++ b/src/test/ui/consts/const-eval/simd/extract-fail1.stderr @@ -0,0 +1,15 @@ +error: internal compiler error: src/librustc_mir/interpret/operand.rs:346: Type `i8` is not a SIMD vector type + +thread 'rustc' panicked at 'Box', src/librustc_errors/lib.rs:643:9 +note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace. + +note: the compiler unexpectedly panicked. this is a bug. + +note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports + +note: rustc 1.39.0-dev running on x86_64-apple-darwin + +note: compiler flags: -Z threads=1 -Z ui-testing -Z unstable-options -C prefer-dynamic -C rpath -C debuginfo=0 + +error: aborting due to previous error + diff --git a/src/test/ui/consts/const-eval/simd/extract-fail2.rs b/src/test/ui/consts/const-eval/simd/extract-fail2.rs new file mode 100644 index 0000000000000..e2eb449f977ce --- /dev/null +++ b/src/test/ui/consts/const-eval/simd/extract-fail2.rs @@ -0,0 +1,22 @@ +// failure-status: 101 +// rustc-env:RUST_BACKTRACE=0 +#![feature(const_fn)] +#![feature(repr_simd)] +#![feature(platform_intrinsics)] +#![allow(non_camel_case_types)] + +#[repr(simd)] struct i8x1(i8); + +extern "platform-intrinsic" { + fn simd_extract(x: T, idx: u32) -> U; +} + +const X: i8x1 = i8x1(42); + +const fn extract_wrong_idx() -> i8 { + unsafe { simd_extract(X, 1_u32) } +} + +const C: i8 = extract_wrong_idx(); + +fn main() {} diff --git a/src/test/ui/consts/const-eval/simd/extract-fail2.stderr b/src/test/ui/consts/const-eval/simd/extract-fail2.stderr new file mode 100644 index 0000000000000..5d74e115ef87f --- /dev/null +++ b/src/test/ui/consts/const-eval/simd/extract-fail2.stderr @@ -0,0 +1,13 @@ +thread 'rustc' panicked at 'index `1` is out-of-bounds of vector type `i8` with length `1`', src/librustc_mir/interpret/intrinsics.rs:276:17 +note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace. + +error: internal compiler error: unexpected panic + +note: the compiler unexpectedly panicked. this is a bug. + +note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports + +note: rustc 1.39.0-dev running on x86_64-apple-darwin + +note: compiler flags: -Z threads=1 -Z ui-testing -Z unstable-options -C prefer-dynamic -C rpath -C debuginfo=0 + diff --git a/src/test/ui/consts/const-eval/simd/insert-fail0.rs b/src/test/ui/consts/const-eval/simd/insert-fail0.rs new file mode 100644 index 0000000000000..dca58fb2555a8 --- /dev/null +++ b/src/test/ui/consts/const-eval/simd/insert-fail0.rs @@ -0,0 +1,22 @@ +// failure-status: 101 +// rustc-env:RUST_BACKTRACE=0 +#![feature(const_fn)] +#![feature(repr_simd)] +#![feature(platform_intrinsics)] +#![allow(non_camel_case_types)] + +#[repr(simd)] struct i8x1(i8); + +extern "platform-intrinsic" { + fn simd_insert(x: T, idx: u32, val: U) -> T; +} + +const X: i8x1 = i8x1(42); + +const fn insert_wrong_scalar() -> i8x1 { + unsafe { simd_insert(X, 0_u32, 42_i16) } +} + +const D: i8x1 = insert_wrong_scalar(); + +fn main() {} diff --git a/src/test/ui/consts/const-eval/simd/insert-fail0.stderr b/src/test/ui/consts/const-eval/simd/insert-fail0.stderr new file mode 100644 index 0000000000000..1ea31ec8deb6a --- /dev/null +++ b/src/test/ui/consts/const-eval/simd/insert-fail0.stderr @@ -0,0 +1,15 @@ +thread 'rustc' panicked at 'assertion failed: `(left == right)` + left: `i16`, + right: `i8`: Scalar type `i16` must match vector element type `i8`', src/librustc_mir/interpret/intrinsics.rs:257:17 +note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace. + +error: internal compiler error: unexpected panic + +note: the compiler unexpectedly panicked. this is a bug. + +note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports + +note: rustc 1.39.0-dev running on x86_64-apple-darwin + +note: compiler flags: -Z threads=1 -Z ui-testing -Z unstable-options -C prefer-dynamic -C rpath -C debuginfo=0 + diff --git a/src/test/ui/consts/const-eval/simd/insert-fail1.rs b/src/test/ui/consts/const-eval/simd/insert-fail1.rs new file mode 100644 index 0000000000000..2a3d79b76c306 --- /dev/null +++ b/src/test/ui/consts/const-eval/simd/insert-fail1.rs @@ -0,0 +1,22 @@ +// failure-status: 101 +// rustc-env:RUST_BACKTRACE=0 +#![feature(const_fn)] +#![feature(repr_simd)] +#![feature(platform_intrinsics)] +#![allow(non_camel_case_types)] + +#[repr(simd)] struct i8x1(i8); + +extern "platform-intrinsic" { + fn simd_insert(x: T, idx: u32, val: U) -> T; +} + +const X: i8x1 = i8x1(42); + +const fn insert_wrong_idx() -> i8x1 { + unsafe { simd_insert(X, 1_u32, 42_i8) } +} + +const E: i8x1 = insert_wrong_idx(); + +fn main() {} diff --git a/src/test/ui/consts/const-eval/simd/insert-fail1.stderr b/src/test/ui/consts/const-eval/simd/insert-fail1.stderr new file mode 100644 index 0000000000000..38d3782263010 --- /dev/null +++ b/src/test/ui/consts/const-eval/simd/insert-fail1.stderr @@ -0,0 +1,13 @@ +thread 'rustc' panicked at 'Index `1` must be in bounds of vector type `i8`: `[0, 1)`', src/librustc_mir/interpret/intrinsics.rs:247:17 +note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace. + +error: internal compiler error: unexpected panic + +note: the compiler unexpectedly panicked. this is a bug. + +note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports + +note: rustc 1.39.0-dev running on x86_64-apple-darwin + +note: compiler flags: -Z threads=1 -Z ui-testing -Z unstable-options -C prefer-dynamic -C rpath -C debuginfo=0 + diff --git a/src/test/ui/consts/const-eval/simd/insert_extract-fail.rs b/src/test/ui/consts/const-eval/simd/insert_extract-fail.rs deleted file mode 100644 index 1d1df8d25a406..0000000000000 --- a/src/test/ui/consts/const-eval/simd/insert_extract-fail.rs +++ /dev/null @@ -1,27 +0,0 @@ -#![feature(const_fn)] -#![feature(repr_simd)] -#![feature(platform_intrinsics)] -#![allow(non_camel_case_types)] - -#[repr(simd)] struct i8x1(i8); - -extern "platform-intrinsic" { - fn simd_insert(x: T, idx: u32, val: U) -> T; - fn simd_extract(x: T, idx: u32) -> U; -} - -const fn foo(x: i8x1) -> i8 { - // 42 is a i16 that does not fit in a i8 - unsafe { simd_insert(x, 0_u32, 42_i16) }.0 //~ ERROR -} - -const fn bar(x: i8x1) -> i16 { - // the i8 is not a i16: - unsafe { simd_extract(x, 0_u32) } //~ ERROR -} - -fn main() { - const V: i8x1 = i8x1(13); - const X: i8 = foo(V); - const Y: i16 = bar(V); -} diff --git a/src/test/ui/consts/const-eval/simd/insert_extract-fail.stderr b/src/test/ui/consts/const-eval/simd/insert_extract-fail.stderr deleted file mode 100644 index cf4e6887f16d5..0000000000000 --- a/src/test/ui/consts/const-eval/simd/insert_extract-fail.stderr +++ /dev/null @@ -1,16 +0,0 @@ -error: any use of this value will cause an error - --> $DIR/insert_extract-fail.rs:14:14 - | -LL | unsafe { simd_insert(x, 0_u32, 42_i16) }.0 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | - | Inserting `i16` with size `2` to a vector element place of size `1` - | inside call to `foo` at $DIR/insert_extract-fail.rs:19:19 -... -LL | const X: i8 = foo(V); - | --------------------- - | - = note: `#[deny(const_err)]` on by default - -error: aborting due to previous error - diff --git a/src/test/ui/consts/const-eval/simd/read_fail.rs b/src/test/ui/consts/const-eval/simd/read_fail.rs deleted file mode 100644 index c5109c16e4c6d..0000000000000 --- a/src/test/ui/consts/const-eval/simd/read_fail.rs +++ /dev/null @@ -1,17 +0,0 @@ -#![feature(const_fn)] -#![feature(platform_intrinsics)] -#![allow(non_camel_case_types)] - -extern "platform-intrinsic" { - fn simd_extract(x: T, idx: u32) -> U; -} - -const fn foo(x: i8) -> i8 { - // i8 is not a vector type: - unsafe { simd_extract(x, 0_u32) } //~ ERROR -} - -fn main() { - const V: i8 = 13; - const X: i8 = foo(V); -} From e1cf0a1d677a6f583baf96b14dccf61ec5e4cfeb Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Wed, 25 Sep 2019 13:39:28 +0200 Subject: [PATCH 10/12] Format --- src/librustc_mir/interpret/operand.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/librustc_mir/interpret/operand.rs b/src/librustc_mir/interpret/operand.rs index c5771e4f34378..afaf9d7ed9d67 100644 --- a/src/librustc_mir/interpret/operand.rs +++ b/src/librustc_mir/interpret/operand.rs @@ -338,8 +338,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { /// Read vector length and element type pub fn read_vector_ty( &self, op: OpTy<'tcx, M::PointerTag> - ) - -> (u64, &rustc::ty::TyS<'tcx>) { + ) -> (u64, &rustc::ty::TyS<'tcx>) { if let layout::Abi::Vector { .. } = op.layout.abi { (op.layout.ty.simd_size(*self.tcx) as _, op.layout.ty.simd_type(*self.tcx)) } else { From 02bfbf96c7c241146957a75128ad63276fa0b671 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Wed, 25 Sep 2019 14:05:39 +0200 Subject: [PATCH 11/12] Clean tests --- src/test/ui/consts/const-eval/simd/extract-fail0.rs | 4 ++++ src/test/ui/consts/const-eval/simd/extract-fail0.stderr | 4 ++-- src/test/ui/consts/const-eval/simd/extract-fail1.rs | 4 ++++ src/test/ui/consts/const-eval/simd/extract-fail1.stderr | 6 +++--- src/test/ui/consts/const-eval/simd/extract-fail2.rs | 4 ++++ src/test/ui/consts/const-eval/simd/extract-fail2.stderr | 4 ++-- src/test/ui/consts/const-eval/simd/insert-fail0.rs | 4 ++++ src/test/ui/consts/const-eval/simd/insert-fail0.stderr | 4 ++-- src/test/ui/consts/const-eval/simd/insert-fail1.rs | 4 ++++ src/test/ui/consts/const-eval/simd/insert-fail1.stderr | 4 ++-- 10 files changed, 31 insertions(+), 11 deletions(-) diff --git a/src/test/ui/consts/const-eval/simd/extract-fail0.rs b/src/test/ui/consts/const-eval/simd/extract-fail0.rs index d2c313ddd0cd4..4a046e424c528 100644 --- a/src/test/ui/consts/const-eval/simd/extract-fail0.rs +++ b/src/test/ui/consts/const-eval/simd/extract-fail0.rs @@ -1,5 +1,9 @@ // failure-status: 101 // rustc-env:RUST_BACKTRACE=0 +// normalize-stderr-test "note: rustc 1.* running on .*" -> "note: rustc VERSION running on TARGET" +// normalize-stderr-test "note: compiler flags: .*" -> "note: compiler flags: FLAGS" +// normalize-stderr-test "interpret/intern.rs:[0-9]*:[0-9]*" -> "interpret/intern.rs:LL:CC" + #![feature(const_fn)] #![feature(repr_simd)] #![feature(platform_intrinsics)] diff --git a/src/test/ui/consts/const-eval/simd/extract-fail0.stderr b/src/test/ui/consts/const-eval/simd/extract-fail0.stderr index 51518481941df..be2c2607002e0 100644 --- a/src/test/ui/consts/const-eval/simd/extract-fail0.stderr +++ b/src/test/ui/consts/const-eval/simd/extract-fail0.stderr @@ -9,7 +9,7 @@ note: the compiler unexpectedly panicked. this is a bug. note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports -note: rustc 1.39.0-dev running on x86_64-apple-darwin +note: rustc VERSION running on TARGET -note: compiler flags: -Z threads=1 -Z ui-testing -Z unstable-options -C prefer-dynamic -C rpath -C debuginfo=0 +note: compiler flags: FLAGS diff --git a/src/test/ui/consts/const-eval/simd/extract-fail1.rs b/src/test/ui/consts/const-eval/simd/extract-fail1.rs index ddff608181e93..ec281a19b17d0 100644 --- a/src/test/ui/consts/const-eval/simd/extract-fail1.rs +++ b/src/test/ui/consts/const-eval/simd/extract-fail1.rs @@ -1,5 +1,9 @@ // failure-status: 101 // rustc-env:RUST_BACKTRACE=0 +// normalize-stderr-test "note: rustc 1.* running on .*" -> "note: rustc VERSION running on TARGET" +// normalize-stderr-test "note: compiler flags: .*" -> "note: compiler flags: FLAGS" +// normalize-stderr-test "interpret/intern.rs:[0-9]*:[0-9]*" -> "interpret/intern.rs:LL:CC" + #![feature(const_fn)] #![feature(repr_simd)] #![feature(platform_intrinsics)] diff --git a/src/test/ui/consts/const-eval/simd/extract-fail1.stderr b/src/test/ui/consts/const-eval/simd/extract-fail1.stderr index a00d98bf7fd9b..8c53ee874c466 100644 --- a/src/test/ui/consts/const-eval/simd/extract-fail1.stderr +++ b/src/test/ui/consts/const-eval/simd/extract-fail1.stderr @@ -1,4 +1,4 @@ -error: internal compiler error: src/librustc_mir/interpret/operand.rs:346: Type `i8` is not a SIMD vector type +error: internal compiler error: src/librustc_mir/interpret/operand.rs:345: Type `i8` is not a SIMD vector type thread 'rustc' panicked at 'Box', src/librustc_errors/lib.rs:643:9 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace. @@ -7,9 +7,9 @@ note: the compiler unexpectedly panicked. this is a bug. note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports -note: rustc 1.39.0-dev running on x86_64-apple-darwin +note: rustc VERSION running on TARGET -note: compiler flags: -Z threads=1 -Z ui-testing -Z unstable-options -C prefer-dynamic -C rpath -C debuginfo=0 +note: compiler flags: FLAGS error: aborting due to previous error diff --git a/src/test/ui/consts/const-eval/simd/extract-fail2.rs b/src/test/ui/consts/const-eval/simd/extract-fail2.rs index e2eb449f977ce..d1970877574f8 100644 --- a/src/test/ui/consts/const-eval/simd/extract-fail2.rs +++ b/src/test/ui/consts/const-eval/simd/extract-fail2.rs @@ -1,5 +1,9 @@ // failure-status: 101 // rustc-env:RUST_BACKTRACE=0 +// normalize-stderr-test "note: rustc 1.* running on .*" -> "note: rustc VERSION running on TARGET" +// normalize-stderr-test "note: compiler flags: .*" -> "note: compiler flags: FLAGS" +// normalize-stderr-test "interpret/intern.rs:[0-9]*:[0-9]*" -> "interpret/intern.rs:LL:CC" + #![feature(const_fn)] #![feature(repr_simd)] #![feature(platform_intrinsics)] diff --git a/src/test/ui/consts/const-eval/simd/extract-fail2.stderr b/src/test/ui/consts/const-eval/simd/extract-fail2.stderr index 5d74e115ef87f..1885c930e9a2b 100644 --- a/src/test/ui/consts/const-eval/simd/extract-fail2.stderr +++ b/src/test/ui/consts/const-eval/simd/extract-fail2.stderr @@ -7,7 +7,7 @@ note: the compiler unexpectedly panicked. this is a bug. note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports -note: rustc 1.39.0-dev running on x86_64-apple-darwin +note: rustc VERSION running on TARGET -note: compiler flags: -Z threads=1 -Z ui-testing -Z unstable-options -C prefer-dynamic -C rpath -C debuginfo=0 +note: compiler flags: FLAGS diff --git a/src/test/ui/consts/const-eval/simd/insert-fail0.rs b/src/test/ui/consts/const-eval/simd/insert-fail0.rs index dca58fb2555a8..2ee0fdfc1ec6b 100644 --- a/src/test/ui/consts/const-eval/simd/insert-fail0.rs +++ b/src/test/ui/consts/const-eval/simd/insert-fail0.rs @@ -1,5 +1,9 @@ // failure-status: 101 // rustc-env:RUST_BACKTRACE=0 +// normalize-stderr-test "note: rustc 1.* running on .*" -> "note: rustc VERSION running on TARGET" +// normalize-stderr-test "note: compiler flags: .*" -> "note: compiler flags: FLAGS" +// normalize-stderr-test "interpret/intern.rs:[0-9]*:[0-9]*" -> "interpret/intern.rs:LL:CC" + #![feature(const_fn)] #![feature(repr_simd)] #![feature(platform_intrinsics)] diff --git a/src/test/ui/consts/const-eval/simd/insert-fail0.stderr b/src/test/ui/consts/const-eval/simd/insert-fail0.stderr index 1ea31ec8deb6a..1d0173ed33272 100644 --- a/src/test/ui/consts/const-eval/simd/insert-fail0.stderr +++ b/src/test/ui/consts/const-eval/simd/insert-fail0.stderr @@ -9,7 +9,7 @@ note: the compiler unexpectedly panicked. this is a bug. note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports -note: rustc 1.39.0-dev running on x86_64-apple-darwin +note: rustc VERSION running on TARGET -note: compiler flags: -Z threads=1 -Z ui-testing -Z unstable-options -C prefer-dynamic -C rpath -C debuginfo=0 +note: compiler flags: FLAGS diff --git a/src/test/ui/consts/const-eval/simd/insert-fail1.rs b/src/test/ui/consts/const-eval/simd/insert-fail1.rs index 2a3d79b76c306..146b8ce6a130a 100644 --- a/src/test/ui/consts/const-eval/simd/insert-fail1.rs +++ b/src/test/ui/consts/const-eval/simd/insert-fail1.rs @@ -1,5 +1,9 @@ // failure-status: 101 // rustc-env:RUST_BACKTRACE=0 +// normalize-stderr-test "note: rustc 1.* running on .*" -> "note: rustc VERSION running on TARGET" +// normalize-stderr-test "note: compiler flags: .*" -> "note: compiler flags: FLAGS" +// normalize-stderr-test "interpret/intern.rs:[0-9]*:[0-9]*" -> "interpret/intern.rs:LL:CC" + #![feature(const_fn)] #![feature(repr_simd)] #![feature(platform_intrinsics)] diff --git a/src/test/ui/consts/const-eval/simd/insert-fail1.stderr b/src/test/ui/consts/const-eval/simd/insert-fail1.stderr index 38d3782263010..6223f308c2f35 100644 --- a/src/test/ui/consts/const-eval/simd/insert-fail1.stderr +++ b/src/test/ui/consts/const-eval/simd/insert-fail1.stderr @@ -7,7 +7,7 @@ note: the compiler unexpectedly panicked. this is a bug. note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports -note: rustc 1.39.0-dev running on x86_64-apple-darwin +note: rustc VERSION running on TARGET -note: compiler flags: -Z threads=1 -Z ui-testing -Z unstable-options -C prefer-dynamic -C rpath -C debuginfo=0 +note: compiler flags: FLAGS From 5ecb7eb161e75ab33ca015e7f717424f32af3d59 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Wed, 25 Sep 2019 14:32:57 +0200 Subject: [PATCH 12/12] Remove fail tests --- .../consts/const-eval/simd/extract-fail0.rs | 26 ------------------- .../const-eval/simd/extract-fail0.stderr | 15 ----------- .../consts/const-eval/simd/extract-fail1.rs | 26 ------------------- .../const-eval/simd/extract-fail1.stderr | 15 ----------- .../consts/const-eval/simd/extract-fail2.rs | 26 ------------------- .../const-eval/simd/extract-fail2.stderr | 13 ---------- .../ui/consts/const-eval/simd/insert-fail0.rs | 26 ------------------- .../const-eval/simd/insert-fail0.stderr | 15 ----------- .../ui/consts/const-eval/simd/insert-fail1.rs | 26 ------------------- .../const-eval/simd/insert-fail1.stderr | 13 ---------- 10 files changed, 201 deletions(-) delete mode 100644 src/test/ui/consts/const-eval/simd/extract-fail0.rs delete mode 100644 src/test/ui/consts/const-eval/simd/extract-fail0.stderr delete mode 100644 src/test/ui/consts/const-eval/simd/extract-fail1.rs delete mode 100644 src/test/ui/consts/const-eval/simd/extract-fail1.stderr delete mode 100644 src/test/ui/consts/const-eval/simd/extract-fail2.rs delete mode 100644 src/test/ui/consts/const-eval/simd/extract-fail2.stderr delete mode 100644 src/test/ui/consts/const-eval/simd/insert-fail0.rs delete mode 100644 src/test/ui/consts/const-eval/simd/insert-fail0.stderr delete mode 100644 src/test/ui/consts/const-eval/simd/insert-fail1.rs delete mode 100644 src/test/ui/consts/const-eval/simd/insert-fail1.stderr diff --git a/src/test/ui/consts/const-eval/simd/extract-fail0.rs b/src/test/ui/consts/const-eval/simd/extract-fail0.rs deleted file mode 100644 index 4a046e424c528..0000000000000 --- a/src/test/ui/consts/const-eval/simd/extract-fail0.rs +++ /dev/null @@ -1,26 +0,0 @@ -// failure-status: 101 -// rustc-env:RUST_BACKTRACE=0 -// normalize-stderr-test "note: rustc 1.* running on .*" -> "note: rustc VERSION running on TARGET" -// normalize-stderr-test "note: compiler flags: .*" -> "note: compiler flags: FLAGS" -// normalize-stderr-test "interpret/intern.rs:[0-9]*:[0-9]*" -> "interpret/intern.rs:LL:CC" - -#![feature(const_fn)] -#![feature(repr_simd)] -#![feature(platform_intrinsics)] -#![allow(non_camel_case_types)] - -#[repr(simd)] struct i8x1(i8); - -extern "platform-intrinsic" { - fn simd_extract(x: T, idx: u32) -> U; -} - -const X: i8x1 = i8x1(42); - -const fn extract_wrong_ret() -> i16 { - unsafe { simd_extract(X, 0_u32) } -} - -const A: i16 = extract_wrong_ret(); - -fn main() {} diff --git a/src/test/ui/consts/const-eval/simd/extract-fail0.stderr b/src/test/ui/consts/const-eval/simd/extract-fail0.stderr deleted file mode 100644 index be2c2607002e0..0000000000000 --- a/src/test/ui/consts/const-eval/simd/extract-fail0.stderr +++ /dev/null @@ -1,15 +0,0 @@ -thread 'rustc' panicked at 'assertion failed: `(left == right)` - left: `i8`, - right: `i16`: Return type `i16` must match vector element type `i8`', src/librustc_mir/interpret/intrinsics.rs:281:17 -note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace. - -error: internal compiler error: unexpected panic - -note: the compiler unexpectedly panicked. this is a bug. - -note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports - -note: rustc VERSION running on TARGET - -note: compiler flags: FLAGS - diff --git a/src/test/ui/consts/const-eval/simd/extract-fail1.rs b/src/test/ui/consts/const-eval/simd/extract-fail1.rs deleted file mode 100644 index ec281a19b17d0..0000000000000 --- a/src/test/ui/consts/const-eval/simd/extract-fail1.rs +++ /dev/null @@ -1,26 +0,0 @@ -// failure-status: 101 -// rustc-env:RUST_BACKTRACE=0 -// normalize-stderr-test "note: rustc 1.* running on .*" -> "note: rustc VERSION running on TARGET" -// normalize-stderr-test "note: compiler flags: .*" -> "note: compiler flags: FLAGS" -// normalize-stderr-test "interpret/intern.rs:[0-9]*:[0-9]*" -> "interpret/intern.rs:LL:CC" - -#![feature(const_fn)] -#![feature(repr_simd)] -#![feature(platform_intrinsics)] -#![allow(non_camel_case_types)] - -#[repr(simd)] struct i8x1(i8); - -extern "platform-intrinsic" { - fn simd_extract(x: T, idx: u32) -> U; -} - -const X: i8x1 = i8x1(42); - -const fn extract_wrong_vec() -> i8 { - unsafe { simd_extract(42_i8, 0_u32) } -} - -const B: i8 = extract_wrong_vec(); - -fn main() {} diff --git a/src/test/ui/consts/const-eval/simd/extract-fail1.stderr b/src/test/ui/consts/const-eval/simd/extract-fail1.stderr deleted file mode 100644 index 8c53ee874c466..0000000000000 --- a/src/test/ui/consts/const-eval/simd/extract-fail1.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error: internal compiler error: src/librustc_mir/interpret/operand.rs:345: Type `i8` is not a SIMD vector type - -thread 'rustc' panicked at 'Box', src/librustc_errors/lib.rs:643:9 -note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace. - -note: the compiler unexpectedly panicked. this is a bug. - -note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports - -note: rustc VERSION running on TARGET - -note: compiler flags: FLAGS - -error: aborting due to previous error - diff --git a/src/test/ui/consts/const-eval/simd/extract-fail2.rs b/src/test/ui/consts/const-eval/simd/extract-fail2.rs deleted file mode 100644 index d1970877574f8..0000000000000 --- a/src/test/ui/consts/const-eval/simd/extract-fail2.rs +++ /dev/null @@ -1,26 +0,0 @@ -// failure-status: 101 -// rustc-env:RUST_BACKTRACE=0 -// normalize-stderr-test "note: rustc 1.* running on .*" -> "note: rustc VERSION running on TARGET" -// normalize-stderr-test "note: compiler flags: .*" -> "note: compiler flags: FLAGS" -// normalize-stderr-test "interpret/intern.rs:[0-9]*:[0-9]*" -> "interpret/intern.rs:LL:CC" - -#![feature(const_fn)] -#![feature(repr_simd)] -#![feature(platform_intrinsics)] -#![allow(non_camel_case_types)] - -#[repr(simd)] struct i8x1(i8); - -extern "platform-intrinsic" { - fn simd_extract(x: T, idx: u32) -> U; -} - -const X: i8x1 = i8x1(42); - -const fn extract_wrong_idx() -> i8 { - unsafe { simd_extract(X, 1_u32) } -} - -const C: i8 = extract_wrong_idx(); - -fn main() {} diff --git a/src/test/ui/consts/const-eval/simd/extract-fail2.stderr b/src/test/ui/consts/const-eval/simd/extract-fail2.stderr deleted file mode 100644 index 1885c930e9a2b..0000000000000 --- a/src/test/ui/consts/const-eval/simd/extract-fail2.stderr +++ /dev/null @@ -1,13 +0,0 @@ -thread 'rustc' panicked at 'index `1` is out-of-bounds of vector type `i8` with length `1`', src/librustc_mir/interpret/intrinsics.rs:276:17 -note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace. - -error: internal compiler error: unexpected panic - -note: the compiler unexpectedly panicked. this is a bug. - -note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports - -note: rustc VERSION running on TARGET - -note: compiler flags: FLAGS - diff --git a/src/test/ui/consts/const-eval/simd/insert-fail0.rs b/src/test/ui/consts/const-eval/simd/insert-fail0.rs deleted file mode 100644 index 2ee0fdfc1ec6b..0000000000000 --- a/src/test/ui/consts/const-eval/simd/insert-fail0.rs +++ /dev/null @@ -1,26 +0,0 @@ -// failure-status: 101 -// rustc-env:RUST_BACKTRACE=0 -// normalize-stderr-test "note: rustc 1.* running on .*" -> "note: rustc VERSION running on TARGET" -// normalize-stderr-test "note: compiler flags: .*" -> "note: compiler flags: FLAGS" -// normalize-stderr-test "interpret/intern.rs:[0-9]*:[0-9]*" -> "interpret/intern.rs:LL:CC" - -#![feature(const_fn)] -#![feature(repr_simd)] -#![feature(platform_intrinsics)] -#![allow(non_camel_case_types)] - -#[repr(simd)] struct i8x1(i8); - -extern "platform-intrinsic" { - fn simd_insert(x: T, idx: u32, val: U) -> T; -} - -const X: i8x1 = i8x1(42); - -const fn insert_wrong_scalar() -> i8x1 { - unsafe { simd_insert(X, 0_u32, 42_i16) } -} - -const D: i8x1 = insert_wrong_scalar(); - -fn main() {} diff --git a/src/test/ui/consts/const-eval/simd/insert-fail0.stderr b/src/test/ui/consts/const-eval/simd/insert-fail0.stderr deleted file mode 100644 index 1d0173ed33272..0000000000000 --- a/src/test/ui/consts/const-eval/simd/insert-fail0.stderr +++ /dev/null @@ -1,15 +0,0 @@ -thread 'rustc' panicked at 'assertion failed: `(left == right)` - left: `i16`, - right: `i8`: Scalar type `i16` must match vector element type `i8`', src/librustc_mir/interpret/intrinsics.rs:257:17 -note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace. - -error: internal compiler error: unexpected panic - -note: the compiler unexpectedly panicked. this is a bug. - -note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports - -note: rustc VERSION running on TARGET - -note: compiler flags: FLAGS - diff --git a/src/test/ui/consts/const-eval/simd/insert-fail1.rs b/src/test/ui/consts/const-eval/simd/insert-fail1.rs deleted file mode 100644 index 146b8ce6a130a..0000000000000 --- a/src/test/ui/consts/const-eval/simd/insert-fail1.rs +++ /dev/null @@ -1,26 +0,0 @@ -// failure-status: 101 -// rustc-env:RUST_BACKTRACE=0 -// normalize-stderr-test "note: rustc 1.* running on .*" -> "note: rustc VERSION running on TARGET" -// normalize-stderr-test "note: compiler flags: .*" -> "note: compiler flags: FLAGS" -// normalize-stderr-test "interpret/intern.rs:[0-9]*:[0-9]*" -> "interpret/intern.rs:LL:CC" - -#![feature(const_fn)] -#![feature(repr_simd)] -#![feature(platform_intrinsics)] -#![allow(non_camel_case_types)] - -#[repr(simd)] struct i8x1(i8); - -extern "platform-intrinsic" { - fn simd_insert(x: T, idx: u32, val: U) -> T; -} - -const X: i8x1 = i8x1(42); - -const fn insert_wrong_idx() -> i8x1 { - unsafe { simd_insert(X, 1_u32, 42_i8) } -} - -const E: i8x1 = insert_wrong_idx(); - -fn main() {} diff --git a/src/test/ui/consts/const-eval/simd/insert-fail1.stderr b/src/test/ui/consts/const-eval/simd/insert-fail1.stderr deleted file mode 100644 index 6223f308c2f35..0000000000000 --- a/src/test/ui/consts/const-eval/simd/insert-fail1.stderr +++ /dev/null @@ -1,13 +0,0 @@ -thread 'rustc' panicked at 'Index `1` must be in bounds of vector type `i8`: `[0, 1)`', src/librustc_mir/interpret/intrinsics.rs:247:17 -note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace. - -error: internal compiler error: unexpected panic - -note: the compiler unexpectedly panicked. this is a bug. - -note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports - -note: rustc VERSION running on TARGET - -note: compiler flags: FLAGS -