From ad7338e5659f5711e08502906147e22b44e41a3e Mon Sep 17 00:00:00 2001 From: Evan Typanski Date: Fri, 13 May 2022 05:55:50 -0400 Subject: [PATCH] Comment why `hir_ty_to_ty` is safe in `check_ty` --- clippy_lints/src/types/redundant_allocation.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/clippy_lints/src/types/redundant_allocation.rs b/clippy_lints/src/types/redundant_allocation.rs index 6c231fa2510..a1312fcda0b 100644 --- a/clippy_lints/src/types/redundant_allocation.rs +++ b/clippy_lints/src/types/redundant_allocation.rs @@ -55,7 +55,9 @@ pub(super) fn check(cx: &LateContext<'_>, hir_ty: &hir::Ty<'_>, qpath: &QPath<'_ }; let inner_span = match qpath_generic_tys(inner_qpath).next() { Some(ty) => { - // Reallocation of a fat pointer causes it to become thin + // Reallocation of a fat pointer causes it to become thin. `hir_ty_to_ty` is safe to use + // here because `mod.rs` guarantees this lint is only run on types outside of bodies and + // is not run on locals. if !hir_ty_to_ty(cx.tcx, ty).is_sized(cx.tcx.at(ty.span), cx.param_env) { return false; }