Skip to content

Commit 54408f0

Browse files
committed
short-circuit the easy cases in is_copy_modulo_regions
This change is somewhat extensive, since it affects MIR -- since this is called to determine Copy vs Move -- so any test that's `no_core` needs to actually have the normal `impl`s it uses.
1 parent b5a54d8 commit 54408f0

File tree

11 files changed

+18
-2
lines changed

11 files changed

+18
-2
lines changed

compiler/rustc_middle/src/ty/util.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -704,7 +704,7 @@ impl<'tcx> Ty<'tcx> {
704704
tcx_at: TyCtxtAt<'tcx>,
705705
param_env: ty::ParamEnv<'tcx>,
706706
) -> bool {
707-
tcx_at.is_copy_raw(param_env.and(self))
707+
self.is_trivially_pure_clone_copy() || tcx_at.is_copy_raw(param_env.and(self))
708708
}
709709

710710
/// Checks whether values of this type `T` have a size known at

src/test/assembly/sparc-struct-abi.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
pub trait Sized {}
1414
#[lang = "copy"]
1515
pub trait Copy {}
16+
impl Copy for f32 {}
1617

1718
#[repr(C)]
1819
pub struct Franta {

src/test/assembly/target-feature-multiple.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
trait Sized {}
2424
#[lang = "copy"]
2525
trait Copy {}
26+
impl Copy for u32 {}
2627

2728
// Use of these requires target features to be enabled
2829
extern "unadjusted" {

src/test/codegen/abi-sysv64.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
trait Sized {}
1414
#[lang = "copy"]
1515
trait Copy {}
16+
impl Copy for i64 {}
1617

1718
// CHECK: define x86_64_sysvcc i64 @has_sysv64_abi
1819
#[no_mangle]

src/test/codegen/abi-x86-interrupt.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
trait Sized {}
1414
#[lang = "copy"]
1515
trait Copy {}
16+
impl Copy for i64 {}
1617

1718
// CHECK: define x86_intrcc i64 @has_x86_interrupt_abi
1819
#[no_mangle]

src/test/codegen/frame-pointer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
trait Sized { }
1818
#[lang="copy"]
1919
trait Copy { }
20-
20+
impl Copy for u32 {}
2121

2222

2323
// CHECK: define i32 @peach{{.*}}[[PEACH_ATTRS:\#[0-9]+]] {

src/test/codegen/riscv-abi/riscv64-lp64-lp64f-lp64d-abi.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@
1010
trait Sized {}
1111
#[lang = "copy"]
1212
trait Copy {}
13+
impl Copy for bool {}
14+
impl Copy for i8 {}
15+
impl Copy for u8 {}
16+
impl Copy for i32 {}
17+
impl Copy for i64 {}
18+
impl Copy for u64 {}
19+
impl Copy for f32 {}
20+
impl Copy for f64 {}
1321

1422
// CHECK: define void @f_void()
1523
#[no_mangle]

src/test/ui/cmse-nonsecure/cmse-nonsecure-call/params-on-registers.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
pub trait Sized { }
88
#[lang="copy"]
99
pub trait Copy { }
10+
impl Copy for u32 {}
1011

1112
extern "rust-intrinsic" {
1213
pub fn transmute<T, U>(e: T) -> U;

src/test/ui/cmse-nonsecure/cmse-nonsecure-call/params-on-stack.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
pub trait Sized { }
88
#[lang="copy"]
99
pub trait Copy { }
10+
impl Copy for u32 {}
1011

1112
extern "rust-intrinsic" {
1213
pub fn transmute<T, U>(e: T) -> U;

src/test/ui/cmse-nonsecure/cmse-nonsecure-entry/params-on-registers.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
trait Sized { }
88
#[lang="copy"]
99
trait Copy { }
10+
impl Copy for u32 {}
1011

1112
#[no_mangle]
1213
#[cmse_nonsecure_entry]

src/test/ui/cmse-nonsecure/cmse-nonsecure-entry/params-on-stack.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
trait Sized { }
88
#[lang="copy"]
99
trait Copy { }
10+
impl Copy for u32 {}
1011

1112
#[no_mangle]
1213
#[cmse_nonsecure_entry]

0 commit comments

Comments
 (0)