1
Fork 0

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.
This commit is contained in:
Scott McMurray 2022-03-05 23:51:10 -08:00
parent b5a54d8777
commit 54408f0963
11 changed files with 18 additions and 2 deletions

View file

@ -704,7 +704,7 @@ impl<'tcx> Ty<'tcx> {
tcx_at: TyCtxtAt<'tcx>, tcx_at: TyCtxtAt<'tcx>,
param_env: ty::ParamEnv<'tcx>, param_env: ty::ParamEnv<'tcx>,
) -> bool { ) -> 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 /// Checks whether values of this type `T` have a size known at

View file

@ -13,6 +13,7 @@
pub trait Sized {} pub trait Sized {}
#[lang = "copy"] #[lang = "copy"]
pub trait Copy {} pub trait Copy {}
impl Copy for f32 {}
#[repr(C)] #[repr(C)]
pub struct Franta { pub struct Franta {

View file

@ -23,6 +23,7 @@
trait Sized {} trait Sized {}
#[lang = "copy"] #[lang = "copy"]
trait Copy {} trait Copy {}
impl Copy for u32 {}
// Use of these requires target features to be enabled // Use of these requires target features to be enabled
extern "unadjusted" { extern "unadjusted" {

View file

@ -13,6 +13,7 @@
trait Sized {} trait Sized {}
#[lang = "copy"] #[lang = "copy"]
trait Copy {} trait Copy {}
impl Copy for i64 {}
// CHECK: define x86_64_sysvcc i64 @has_sysv64_abi // CHECK: define x86_64_sysvcc i64 @has_sysv64_abi
#[no_mangle] #[no_mangle]

View file

@ -13,6 +13,7 @@
trait Sized {} trait Sized {}
#[lang = "copy"] #[lang = "copy"]
trait Copy {} trait Copy {}
impl Copy for i64 {}
// CHECK: define x86_intrcc i64 @has_x86_interrupt_abi // CHECK: define x86_intrcc i64 @has_x86_interrupt_abi
#[no_mangle] #[no_mangle]

View file

@ -17,7 +17,7 @@
trait Sized { } trait Sized { }
#[lang="copy"] #[lang="copy"]
trait Copy { } trait Copy { }
impl Copy for u32 {}
// CHECK: define i32 @peach{{.*}}[[PEACH_ATTRS:\#[0-9]+]] { // CHECK: define i32 @peach{{.*}}[[PEACH_ATTRS:\#[0-9]+]] {

View file

@ -10,6 +10,14 @@
trait Sized {} trait Sized {}
#[lang = "copy"] #[lang = "copy"]
trait 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() // CHECK: define void @f_void()
#[no_mangle] #[no_mangle]

View file

@ -7,6 +7,7 @@
pub trait Sized { } pub trait Sized { }
#[lang="copy"] #[lang="copy"]
pub trait Copy { } pub trait Copy { }
impl Copy for u32 {}
extern "rust-intrinsic" { extern "rust-intrinsic" {
pub fn transmute<T, U>(e: T) -> U; pub fn transmute<T, U>(e: T) -> U;

View file

@ -7,6 +7,7 @@
pub trait Sized { } pub trait Sized { }
#[lang="copy"] #[lang="copy"]
pub trait Copy { } pub trait Copy { }
impl Copy for u32 {}
extern "rust-intrinsic" { extern "rust-intrinsic" {
pub fn transmute<T, U>(e: T) -> U; pub fn transmute<T, U>(e: T) -> U;

View file

@ -7,6 +7,7 @@
trait Sized { } trait Sized { }
#[lang="copy"] #[lang="copy"]
trait Copy { } trait Copy { }
impl Copy for u32 {}
#[no_mangle] #[no_mangle]
#[cmse_nonsecure_entry] #[cmse_nonsecure_entry]

View file

@ -7,6 +7,7 @@
trait Sized { } trait Sized { }
#[lang="copy"] #[lang="copy"]
trait Copy { } trait Copy { }
impl Copy for u32 {}
#[no_mangle] #[no_mangle]
#[cmse_nonsecure_entry] #[cmse_nonsecure_entry]