diff options
| author | Scott McMurray <scottmcm@users.noreply.github.com> | 2025-01-10 19:27:47 -0800 |
|---|---|---|
| committer | Scott McMurray <scottmcm@users.noreply.github.com> | 2025-01-11 15:56:58 -0800 |
| commit | 7396ec3edb8f1d3300bdcf0a2bf076264ba61bfc (patch) | |
| tree | 18cef906a1bfde8d7beb27b77eba142f466f2600 /compiler/rustc_mir_transform/src | |
| parent | 6e34369ef6ec53f571565298b0d0de489f343acc (diff) | |
| download | rust-7396ec3edb8f1d3300bdcf0a2bf076264ba61bfc.tar.gz rust-7396ec3edb8f1d3300bdcf0a2bf076264ba61bfc.zip | |
Address PR feedback
Diffstat (limited to 'compiler/rustc_mir_transform/src')
| -rw-r--r-- | compiler/rustc_mir_transform/src/remove_zsts.rs | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/compiler/rustc_mir_transform/src/remove_zsts.rs b/compiler/rustc_mir_transform/src/remove_zsts.rs index e37ead3674b..55e5701bd0a 100644 --- a/compiler/rustc_mir_transform/src/remove_zsts.rs +++ b/compiler/rustc_mir_transform/src/remove_zsts.rs @@ -46,15 +46,17 @@ fn trivially_zst<'tcx>(ty: Ty<'tcx>, tcx: TyCtxt<'tcx>) -> Option<bool> { ty::FnDef(..) | ty::Never => 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), - // maybe ZST (could be more precise) - ty::Adt(..) - | ty::Array(..) - | ty::Closure(..) - | ty::CoroutineClosure(..) - | ty::Tuple(..) - | ty::Alias(ty::Opaque, ..) => None, - // unreachable or can't be ZST - _ => Some(false), + // clearly not ZST + ty::Bool + | ty::Char + | ty::Int(..) + | ty::Uint(..) + | ty::Float(..) + | ty::RawPtr(..) + | ty::Ref(..) + | ty::FnPtr(..) => Some(false), + // check `layout_of` to see (including unreachable things we won't actually see) + _ => None, } } |
