File tree Expand file tree Collapse file tree 1 file changed +6
-0
lines changed Expand file tree Collapse file tree 1 file changed +6
-0
lines changed Original file line number Diff line number Diff line change @@ -44,10 +44,15 @@ impl LateLintPass<'_> for UnusedBox {
4444 _: Span ,
4545 _: HirId ,
4646 ) {
47+ // it's unclear what part of a closure you would span, so for now it's ignored
48+ // if this is changed, please also make sure not to call `hir_ty_to_ty` below
4749 if let FnKind :: Closure = fn_kind {
4850 return ;
4951 }
52+
5053 let FnRetTy :: Return ( return_ty_hir) = & decl. output else { return } ;
54+
55+ // this is safe, since we're not in a body
5156 let return_ty = hir_ty_to_ty ( cx. tcx , return_ty_hir) ;
5257
5358 if !return_ty. is_box ( ) {
@@ -57,6 +62,7 @@ impl LateLintPass<'_> for UnusedBox {
5762 let boxed_ty = return_ty. boxed_ty ( ) ;
5863 let Some ( sized_trait) = cx. tcx . lang_items ( ) . sized_trait ( ) else { return } ;
5964
65+ // it's sometimes useful to return Box<T> if T is unsized, so don't lint those
6066 if implements_trait ( cx, boxed_ty, sized_trait, & [ ] ) {
6167 span_lint_and_sugg (
6268 cx,
You can’t perform that action at this time.
0 commit comments