about summary refs log tree commit diff
diff options
context:
space:
mode:
authorScott McMurray <scottmcm@users.noreply.github.com>2022-03-05 23:51:10 -0800
committerScott McMurray <scottmcm@users.noreply.github.com>2022-03-10 01:19:02 -0800
commit54408f096377190a7faf67cb7ef4eda6e1ed4700 (patch)
tree7677ca8c72b99562057f8b1f18b8e83d1c48667e
parentb5a54d8777f00141954527a118715b1a36981b73 (diff)
downloadrust-54408f096377190a7faf67cb7ef4eda6e1ed4700.tar.gz
rust-54408f096377190a7faf67cb7ef4eda6e1ed4700.zip
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.
-rw-r--r--compiler/rustc_middle/src/ty/util.rs2
-rw-r--r--src/test/assembly/sparc-struct-abi.rs1
-rw-r--r--src/test/assembly/target-feature-multiple.rs1
-rw-r--r--src/test/codegen/abi-sysv64.rs1
-rw-r--r--src/test/codegen/abi-x86-interrupt.rs1
-rw-r--r--src/test/codegen/frame-pointer.rs2
-rw-r--r--src/test/codegen/riscv-abi/riscv64-lp64-lp64f-lp64d-abi.rs8
-rw-r--r--src/test/ui/cmse-nonsecure/cmse-nonsecure-call/params-on-registers.rs1
-rw-r--r--src/test/ui/cmse-nonsecure/cmse-nonsecure-call/params-on-stack.rs1
-rw-r--r--src/test/ui/cmse-nonsecure/cmse-nonsecure-entry/params-on-registers.rs1
-rw-r--r--src/test/ui/cmse-nonsecure/cmse-nonsecure-entry/params-on-stack.rs1
11 files changed, 18 insertions, 2 deletions
diff --git a/compiler/rustc_middle/src/ty/util.rs b/compiler/rustc_middle/src/ty/util.rs
index 04e766d16cc..eb16d305d0a 100644
--- a/compiler/rustc_middle/src/ty/util.rs
+++ b/compiler/rustc_middle/src/ty/util.rs
@@ -704,7 +704,7 @@ impl<'tcx> Ty<'tcx> {
         tcx_at: TyCtxtAt<'tcx>,
         param_env: ty::ParamEnv<'tcx>,
     ) -> bool {
-        tcx_at.is_copy_raw(param_env.and(self))
+        self.is_trivially_pure_clone_copy() || tcx_at.is_copy_raw(param_env.and(self))
     }
 
     /// Checks whether values of this type `T` have a size known at
diff --git a/src/test/assembly/sparc-struct-abi.rs b/src/test/assembly/sparc-struct-abi.rs
index dd8e6f614df..6a898b2974a 100644
--- a/src/test/assembly/sparc-struct-abi.rs
+++ b/src/test/assembly/sparc-struct-abi.rs
@@ -13,6 +13,7 @@
 pub trait Sized {}
 #[lang = "copy"]
 pub trait Copy {}
+impl Copy for f32 {}
 
 #[repr(C)]
 pub struct Franta {
diff --git a/src/test/assembly/target-feature-multiple.rs b/src/test/assembly/target-feature-multiple.rs
index 4c2073678b8..18d896e86b2 100644
--- a/src/test/assembly/target-feature-multiple.rs
+++ b/src/test/assembly/target-feature-multiple.rs
@@ -23,6 +23,7 @@
 trait Sized {}
 #[lang = "copy"]
 trait Copy {}
+impl Copy for u32 {}
 
 // Use of these requires target features to be enabled
 extern "unadjusted" {
diff --git a/src/test/codegen/abi-sysv64.rs b/src/test/codegen/abi-sysv64.rs
index bb910d573b3..dfc31227908 100644
--- a/src/test/codegen/abi-sysv64.rs
+++ b/src/test/codegen/abi-sysv64.rs
@@ -13,6 +13,7 @@
 trait Sized {}
 #[lang = "copy"]
 trait Copy {}
+impl Copy for i64 {}
 
 // CHECK: define x86_64_sysvcc i64 @has_sysv64_abi
 #[no_mangle]
diff --git a/src/test/codegen/abi-x86-interrupt.rs b/src/test/codegen/abi-x86-interrupt.rs
index 119004d261d..d612f603e4f 100644
--- a/src/test/codegen/abi-x86-interrupt.rs
+++ b/src/test/codegen/abi-x86-interrupt.rs
@@ -13,6 +13,7 @@
 trait Sized {}
 #[lang = "copy"]
 trait Copy {}
+impl Copy for i64 {}
 
 // CHECK: define x86_intrcc i64 @has_x86_interrupt_abi
 #[no_mangle]
diff --git a/src/test/codegen/frame-pointer.rs b/src/test/codegen/frame-pointer.rs
index 367591dcb96..f7c02d47939 100644
--- a/src/test/codegen/frame-pointer.rs
+++ b/src/test/codegen/frame-pointer.rs
@@ -17,7 +17,7 @@
 trait Sized { }
 #[lang="copy"]
 trait Copy { }
-
+impl Copy for u32 {}
 
 
 // CHECK: define i32 @peach{{.*}}[[PEACH_ATTRS:\#[0-9]+]] {
diff --git a/src/test/codegen/riscv-abi/riscv64-lp64-lp64f-lp64d-abi.rs b/src/test/codegen/riscv-abi/riscv64-lp64-lp64f-lp64d-abi.rs
index faf81b5ae76..7f0f678062a 100644
--- a/src/test/codegen/riscv-abi/riscv64-lp64-lp64f-lp64d-abi.rs
+++ b/src/test/codegen/riscv-abi/riscv64-lp64-lp64f-lp64d-abi.rs
@@ -10,6 +10,14 @@
 trait Sized {}
 #[lang = "copy"]
 trait Copy {}
+impl Copy for bool {}
+impl Copy for i8 {}
+impl Copy for u8 {}
+impl Copy for i32 {}
+impl Copy for i64 {}
+impl Copy for u64 {}
+impl Copy for f32 {}
+impl Copy for f64 {}
 
 // CHECK: define void @f_void()
 #[no_mangle]
diff --git a/src/test/ui/cmse-nonsecure/cmse-nonsecure-call/params-on-registers.rs b/src/test/ui/cmse-nonsecure/cmse-nonsecure-call/params-on-registers.rs
index 9e4521df8c3..bbc039bdf5c 100644
--- a/src/test/ui/cmse-nonsecure/cmse-nonsecure-call/params-on-registers.rs
+++ b/src/test/ui/cmse-nonsecure/cmse-nonsecure-call/params-on-registers.rs
@@ -7,6 +7,7 @@
 pub trait Sized { }
 #[lang="copy"]
 pub trait Copy { }
+impl Copy for u32 {}
 
 extern "rust-intrinsic" {
     pub fn transmute<T, U>(e: T) -> U;
diff --git a/src/test/ui/cmse-nonsecure/cmse-nonsecure-call/params-on-stack.rs b/src/test/ui/cmse-nonsecure/cmse-nonsecure-call/params-on-stack.rs
index d5c67af2b41..b8112b20a54 100644
--- a/src/test/ui/cmse-nonsecure/cmse-nonsecure-call/params-on-stack.rs
+++ b/src/test/ui/cmse-nonsecure/cmse-nonsecure-call/params-on-stack.rs
@@ -7,6 +7,7 @@
 pub trait Sized { }
 #[lang="copy"]
 pub trait Copy { }
+impl Copy for u32 {}
 
 extern "rust-intrinsic" {
     pub fn transmute<T, U>(e: T) -> U;
diff --git a/src/test/ui/cmse-nonsecure/cmse-nonsecure-entry/params-on-registers.rs b/src/test/ui/cmse-nonsecure/cmse-nonsecure-entry/params-on-registers.rs
index 8cde9ba58b9..5591a8a5864 100644
--- a/src/test/ui/cmse-nonsecure/cmse-nonsecure-entry/params-on-registers.rs
+++ b/src/test/ui/cmse-nonsecure/cmse-nonsecure-entry/params-on-registers.rs
@@ -7,6 +7,7 @@
 trait Sized { }
 #[lang="copy"]
 trait Copy { }
+impl Copy for u32 {}
 
 #[no_mangle]
 #[cmse_nonsecure_entry]
diff --git a/src/test/ui/cmse-nonsecure/cmse-nonsecure-entry/params-on-stack.rs b/src/test/ui/cmse-nonsecure/cmse-nonsecure-entry/params-on-stack.rs
index 9a1b0a38d5e..39b41dac41f 100644
--- a/src/test/ui/cmse-nonsecure/cmse-nonsecure-entry/params-on-stack.rs
+++ b/src/test/ui/cmse-nonsecure/cmse-nonsecure-entry/params-on-stack.rs
@@ -7,6 +7,7 @@
 trait Sized { }
 #[lang="copy"]
 trait Copy { }
+impl Copy for u32 {}
 
 #[no_mangle]
 #[cmse_nonsecure_entry]