redundant_allocation: fix 7487

This commit is contained in:
lengyijun 2021-08-22 15:22:28 +08:00
parent 1fc1aee7be
commit 641be558fc
3 changed files with 37 additions and 2 deletions

View file

@ -54,7 +54,13 @@ pub(super) fn check(cx: &LateContext<'_>, hir_ty: &hir::Ty<'_>, qpath: &QPath<'_
_ => return false,
};
let inner_span = match get_qpath_generic_tys(inner_qpath).next() {
Some(ty) => ty.span,
Some(ty) => {
// Box<Box<dyn T>> is smaller than Box<dyn T> because of wide pointers
if matches!(ty.kind, TyKind::TraitObject(..)) {
return false;
}
ty.span
},
None => return false,
};
if inner_sym == outer_sym {