Address PR feedback
This commit is contained in:
parent
6e34369ef6
commit
7396ec3edb
5 changed files with 54 additions and 13 deletions
|
@ -46,15 +46,17 @@ fn trivially_zst<'tcx>(ty: Ty<'tcx>, tcx: TyCtxt<'tcx>) -> Option<bool> {
|
||||||
ty::FnDef(..) | ty::Never => Some(true),
|
ty::FnDef(..) | ty::Never => Some(true),
|
||||||
ty::Tuple(fields) if fields.is_empty() => Some(true),
|
ty::Tuple(fields) if fields.is_empty() => Some(true),
|
||||||
ty::Array(_ty, len) if let Some(0) = len.try_to_target_usize(tcx) => Some(true),
|
ty::Array(_ty, len) if let Some(0) = len.try_to_target_usize(tcx) => Some(true),
|
||||||
// maybe ZST (could be more precise)
|
// clearly not ZST
|
||||||
ty::Adt(..)
|
ty::Bool
|
||||||
| ty::Array(..)
|
| ty::Char
|
||||||
| ty::Closure(..)
|
| ty::Int(..)
|
||||||
| ty::CoroutineClosure(..)
|
| ty::Uint(..)
|
||||||
| ty::Tuple(..)
|
| ty::Float(..)
|
||||||
| ty::Alias(ty::Opaque, ..) => None,
|
| ty::RawPtr(..)
|
||||||
// unreachable or can't be ZST
|
| ty::Ref(..)
|
||||||
_ => Some(false),
|
| ty::FnPtr(..) => Some(false),
|
||||||
|
// check `layout_of` to see (including unreachable things we won't actually see)
|
||||||
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,13 +4,25 @@
|
||||||
fn repeat_once_to_aggregate(_1: T) -> [T; 1] {
|
fn repeat_once_to_aggregate(_1: T) -> [T; 1] {
|
||||||
debug x => _1;
|
debug x => _1;
|
||||||
let mut _0: [T; 1];
|
let mut _0: [T; 1];
|
||||||
let mut _2: T;
|
let _2: [T; 1];
|
||||||
|
let mut _3: T;
|
||||||
|
let mut _4: T;
|
||||||
|
scope 1 {
|
||||||
|
debug other => _2;
|
||||||
|
}
|
||||||
|
|
||||||
bb0: {
|
bb0: {
|
||||||
StorageLive(_2);
|
StorageLive(_2);
|
||||||
_2 = copy _1;
|
StorageLive(_3);
|
||||||
- _0 = [move _2; 1];
|
_3 = copy _1;
|
||||||
+ _0 = [move _2];
|
- _2 = [move _3; 1];
|
||||||
|
+ _2 = [move _3];
|
||||||
|
StorageDead(_3);
|
||||||
|
StorageLive(_4);
|
||||||
|
_4 = copy _1;
|
||||||
|
- _0 = [move _4; 1];
|
||||||
|
+ _0 = [move _4];
|
||||||
|
StorageDead(_4);
|
||||||
StorageDead(_2);
|
StorageDead(_2);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,12 +2,19 @@
|
||||||
//@ compile-flags: -C panic=abort
|
//@ compile-flags: -C panic=abort
|
||||||
#![crate_type = "lib"]
|
#![crate_type = "lib"]
|
||||||
|
|
||||||
|
const MYSTERY: usize = 3_usize.pow(2) - 2_usize.pow(3);
|
||||||
|
|
||||||
// EMIT_MIR simplify_repeat.repeat_once_to_aggregate.InstSimplify-after-simplifycfg.diff
|
// EMIT_MIR simplify_repeat.repeat_once_to_aggregate.InstSimplify-after-simplifycfg.diff
|
||||||
pub fn repeat_once_to_aggregate<T: Copy>(x: T) -> [T; 1] {
|
pub fn repeat_once_to_aggregate<T: Copy>(x: T) -> [T; 1] {
|
||||||
// CHECK-LABEL: fn repeat_once_to_aggregate(
|
// CHECK-LABEL: fn repeat_once_to_aggregate(
|
||||||
|
// CHECK: debug other => [[OTHER:_[0-9]+]]
|
||||||
|
// CHECK-NOT: [move {{_[0-9]+}}; 1]
|
||||||
|
// CHECK: [[OTHER]] = [move {{_[0-9]+}}];
|
||||||
// CHECK-NOT: [move {{_[0-9]+}}; 1]
|
// CHECK-NOT: [move {{_[0-9]+}}; 1]
|
||||||
// CHECK: _0 = [move {{_[0-9]+}}];
|
// CHECK: _0 = [move {{_[0-9]+}}];
|
||||||
// CHECK-NOT: [move {{_[0-9]+}}; 1]
|
// CHECK-NOT: [move {{_[0-9]+}}; 1]
|
||||||
|
|
||||||
|
let other = [x; MYSTERY];
|
||||||
|
|
||||||
[x; 1]
|
[x; 1]
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,9 +6,15 @@
|
||||||
let mut _0: ();
|
let mut _0: ();
|
||||||
let _2: [T; 0];
|
let _2: [T; 0];
|
||||||
let mut _3: T;
|
let mut _3: T;
|
||||||
|
let mut _5: T;
|
||||||
scope 1 {
|
scope 1 {
|
||||||
- debug a => _2;
|
- debug a => _2;
|
||||||
+ debug a => const ZeroSized: [T; 0];
|
+ debug a => const ZeroSized: [T; 0];
|
||||||
|
let _4: [T; 0];
|
||||||
|
scope 2 {
|
||||||
|
- debug b => _4;
|
||||||
|
+ debug b => const ZeroSized: [T; 0];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bb0: {
|
bb0: {
|
||||||
|
@ -19,9 +25,18 @@
|
||||||
- _2 = [];
|
- _2 = [];
|
||||||
+ nop;
|
+ nop;
|
||||||
StorageDead(_3);
|
StorageDead(_3);
|
||||||
|
- StorageLive(_4);
|
||||||
|
+ nop;
|
||||||
|
StorageLive(_5);
|
||||||
|
_5 = copy _1;
|
||||||
|
- _4 = [];
|
||||||
|
+ nop;
|
||||||
|
StorageDead(_5);
|
||||||
- _0 = const ();
|
- _0 = const ();
|
||||||
|
- StorageDead(_4);
|
||||||
- StorageDead(_2);
|
- StorageDead(_2);
|
||||||
+ nop;
|
+ nop;
|
||||||
|
+ nop;
|
||||||
+ nop;
|
+ nop;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,12 +12,17 @@ fn get_union() -> Foo {
|
||||||
Foo { x: () }
|
Foo { x: () }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const MYSTERY: usize = 280_usize.isqrt() - 260_usize.isqrt();
|
||||||
|
|
||||||
// EMIT_MIR remove_zsts.remove_generic_array.RemoveZsts.diff
|
// EMIT_MIR remove_zsts.remove_generic_array.RemoveZsts.diff
|
||||||
fn remove_generic_array<T: Copy>(x: T) {
|
fn remove_generic_array<T: Copy>(x: T) {
|
||||||
// CHECK-LABEL: fn remove_generic_array
|
// CHECK-LABEL: fn remove_generic_array
|
||||||
// CHECK: debug a => const ZeroSized: [T; 0];
|
// CHECK: debug a => const ZeroSized: [T; 0];
|
||||||
|
// CHECK: debug b => const ZeroSized: [T; 0];
|
||||||
// CHECK-NOT: = [];
|
// CHECK-NOT: = [];
|
||||||
|
// CHECK-NOT: ; 1]
|
||||||
let a = [x; 0];
|
let a = [x; 0];
|
||||||
|
let b = [x; MYSTERY];
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue