Skip to content

Commit 63f9d37

Browse files
committed
Remove scalable simd check from is_trivially_pure_clone_copy
1 parent f18804e commit 63f9d37

File tree

4 files changed

+19
-8
lines changed

4 files changed

+19
-8
lines changed

compiler/rustc_middle/src/ty/sty.rs

-4
Original file line numberDiff line numberDiff line change
@@ -1851,10 +1851,6 @@ impl<'tcx> Ty<'tcx> {
18511851
/// This is mostly useful for optimizations, as these are the types
18521852
/// on which we can replace cloning with dereferencing.
18531853
pub fn is_trivially_pure_clone_copy(self) -> bool {
1854-
if self.is_scalable_simd() {
1855-
return true;
1856-
}
1857-
18581854
match self.kind() {
18591855
ty::Bool | ty::Char | ty::Never => true,
18601856

compiler/rustc_mir_build/src/build/misc.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
6161
pub(crate) fn consume_by_copy_or_move(&self, place: Place<'tcx>) -> Operand<'tcx> {
6262
let tcx = self.tcx;
6363
let ty = place.ty(&self.local_decls, tcx).ty;
64-
if !self.infcx.type_is_copy_modulo_regions(self.param_env, ty) {
64+
if !self.infcx.type_is_copy_modulo_regions(self.param_env, ty) && !ty.is_scalable_simd() {
6565
Operand::Move(place)
6666
} else {
6767
Operand::Copy(place)

tests/ui/simd/scalable/disallow-union.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ pub struct ScalableSimdFloat {
66
}
77

88
pub union Invalid {
9-
x: ScalableSimdFloat, //~ ERROR E0800
9+
x: ScalableSimdFloat,
10+
//~^ ERROR E0740
11+
//~^^ ERROR E0800
1012
other: i32,
1113
}
1214

tests/ui/simd/scalable/disallow-union.stderr

+15-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,19 @@ error[E0800]: Scalable simd types cannot exist within a union
44
LL | x: ScalableSimdFloat,
55
| ^^^^^^^^^^^^^^^^^
66

7-
error: aborting due to 1 previous error
7+
error[E0740]: field must implement `Copy` or be wrapped in `ManuallyDrop<...>` to be used in a union
8+
--> $DIR/disallow-union.rs:9:5
9+
|
10+
LL | x: ScalableSimdFloat,
11+
| ^^^^^^^^^^^^^^^^^^^^
12+
|
13+
= note: union fields must not have drop side-effects, which is currently enforced via either `Copy` or `ManuallyDrop<...>`
14+
help: wrap the field type in `ManuallyDrop<...>`
15+
|
16+
LL | x: std::mem::ManuallyDrop<ScalableSimdFloat>,
17+
| +++++++++++++++++++++++ +
18+
19+
error: aborting due to 2 previous errors
820

9-
For more information about this error, try `rustc --explain E0800`.
21+
Some errors have detailed explanations: E0740, E0800.
22+
For more information about an error, try `rustc --explain E0740`.

0 commit comments

Comments
 (0)