about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEvan Typanski <evantypanski@gmail.com>2022-05-13 05:55:50 -0400
committerEvan Typanski <evantypanski@gmail.com>2022-05-13 05:55:50 -0400
commitad7338e5659f5711e08502906147e22b44e41a3e (patch)
treedd1a7217a7c77b82ba1c2e65586e49c35f54815d
parent0def44a1c15e624a6e51206048895021f5b1ee92 (diff)
downloadrust-ad7338e5659f5711e08502906147e22b44e41a3e.tar.gz
rust-ad7338e5659f5711e08502906147e22b44e41a3e.zip
Comment why `hir_ty_to_ty` is safe in `check_ty`
-rw-r--r--clippy_lints/src/types/redundant_allocation.rs4
1 files changed, 3 insertions, 1 deletions
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;
             }