diff --git a/compiler/rustc_middle/src/ty/sty.rs b/compiler/rustc_middle/src/ty/sty.rs index 46318af02c167..8b4e30b4042d7 100644 --- a/compiler/rustc_middle/src/ty/sty.rs +++ b/compiler/rustc_middle/src/ty/sty.rs @@ -1851,10 +1851,6 @@ impl<'tcx> Ty<'tcx> { /// This is mostly useful for optimizations, as these are the types /// on which we can replace cloning with dereferencing. pub fn is_trivially_pure_clone_copy(self) -> bool { - if self.is_scalable_simd() { - return true; - } - match self.kind() { ty::Bool | ty::Char | ty::Never => true, diff --git a/compiler/rustc_mir_build/src/build/misc.rs b/compiler/rustc_mir_build/src/build/misc.rs index 04e6d24e5a172..74cbd017c4687 100644 --- a/compiler/rustc_mir_build/src/build/misc.rs +++ b/compiler/rustc_mir_build/src/build/misc.rs @@ -61,7 +61,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { pub(crate) fn consume_by_copy_or_move(&self, place: Place<'tcx>) -> Operand<'tcx> { let tcx = self.tcx; let ty = place.ty(&self.local_decls, tcx).ty; - if !self.infcx.type_is_copy_modulo_regions(self.param_env, ty) { + if !self.infcx.type_is_copy_modulo_regions(self.param_env, ty) && !ty.is_scalable_simd() { Operand::Move(place) } else { Operand::Copy(place) diff --git a/tests/ui/simd/scalable/disallow-union.rs b/tests/ui/simd/scalable/disallow-union.rs index f195edb752e1d..180f613f7051d 100644 --- a/tests/ui/simd/scalable/disallow-union.rs +++ b/tests/ui/simd/scalable/disallow-union.rs @@ -6,7 +6,9 @@ pub struct ScalableSimdFloat { } pub union Invalid { - x: ScalableSimdFloat, //~ ERROR E0800 + x: ScalableSimdFloat, + //~^ ERROR E0740 + //~^^ ERROR E0800 other: i32, } diff --git a/tests/ui/simd/scalable/disallow-union.stderr b/tests/ui/simd/scalable/disallow-union.stderr index 5aa02e04c4352..dc2cf4368acf1 100644 --- a/tests/ui/simd/scalable/disallow-union.stderr +++ b/tests/ui/simd/scalable/disallow-union.stderr @@ -4,6 +4,19 @@ error[E0800]: Scalable simd types cannot exist within a union LL | x: ScalableSimdFloat, | ^^^^^^^^^^^^^^^^^ -error: aborting due to 1 previous error +error[E0740]: field must implement `Copy` or be wrapped in `ManuallyDrop<...>` to be used in a union + --> $DIR/disallow-union.rs:9:5 + | +LL | x: ScalableSimdFloat, + | ^^^^^^^^^^^^^^^^^^^^ + | + = note: union fields must not have drop side-effects, which is currently enforced via either `Copy` or `ManuallyDrop<...>` +help: wrap the field type in `ManuallyDrop<...>` + | +LL | x: std::mem::ManuallyDrop, + | +++++++++++++++++++++++ + + +error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0800`. +Some errors have detailed explanations: E0740, E0800. +For more information about an error, try `rustc --explain E0740`.