Skip to content

Commit

Permalink
Remove scalable simd check from is_trivially_pure_clone_copy
Browse files Browse the repository at this point in the history
  • Loading branch information
JamieCunliffe committed Jul 24, 2024
1 parent f18804e commit 63f9d37
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 8 deletions.
4 changes: 0 additions & 4 deletions compiler/rustc_middle/src/ty/sty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_mir_build/src/build/misc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 3 additions & 1 deletion tests/ui/simd/scalable/disallow-union.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ pub struct ScalableSimdFloat {
}

pub union Invalid {
x: ScalableSimdFloat, //~ ERROR E0800
x: ScalableSimdFloat,
//~^ ERROR E0740
//~^^ ERROR E0800
other: i32,
}

Expand Down
17 changes: 15 additions & 2 deletions tests/ui/simd/scalable/disallow-union.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -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<ScalableSimdFloat>,
| +++++++++++++++++++++++ +

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`.

0 comments on commit 63f9d37

Please sign in to comment.