From 7396ec3edb8f1d3300bdcf0a2bf076264ba61bfc Mon Sep 17 00:00:00 2001 From: Scott McMurray Date: Fri, 10 Jan 2025 19:27:47 -0800 Subject: Address PR feedback --- compiler/rustc_mir_transform/src/remove_zsts.rs | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'compiler/rustc_mir_transform/src') 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 { 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, } } -- cgit 1.4.1-3-g733a5