Skip to content

Commit ad7338e

Browse files
committed
Comment why hir_ty_to_ty is safe in check_ty
1 parent 0def44a commit ad7338e

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

clippy_lints/src/types/redundant_allocation.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,9 @@ pub(super) fn check(cx: &LateContext<'_>, hir_ty: &hir::Ty<'_>, qpath: &QPath<'_
5555
};
5656
let inner_span = match qpath_generic_tys(inner_qpath).next() {
5757
Some(ty) => {
58-
// Reallocation of a fat pointer causes it to become thin
58+
// Reallocation of a fat pointer causes it to become thin. `hir_ty_to_ty` is safe to use
59+
// here because `mod.rs` guarantees this lint is only run on types outside of bodies and
60+
// is not run on locals.
5961
if !hir_ty_to_ty(cx.tcx, ty).is_sized(cx.tcx.at(ty.span), cx.param_env) {
6062
return false;
6163
}

0 commit comments

Comments
 (0)