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 {
44
44
_: Span ,
45
45
_: HirId ,
46
46
) {
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
47
49
if let FnKind :: Closure = fn_kind {
48
50
return ;
49
51
}
52
+
50
53
let FnRetTy :: Return ( return_ty_hir) = & decl. output else { return } ;
54
+
55
+ // this is safe, since we're not in a body
51
56
let return_ty = hir_ty_to_ty ( cx. tcx , return_ty_hir) ;
52
57
53
58
if !return_ty. is_box ( ) {
@@ -57,6 +62,7 @@ impl LateLintPass<'_> for UnusedBox {
57
62
let boxed_ty = return_ty. boxed_ty ( ) ;
58
63
let Some ( sized_trait) = cx. tcx . lang_items ( ) . sized_trait ( ) else { return } ;
59
64
65
+ // it's sometimes useful to return Box<T> if T is unsized, so don't lint those
60
66
if implements_trait ( cx, boxed_ty, sized_trait, & [ ] ) {
61
67
span_lint_and_sugg (
62
68
cx,
You can’t perform that action at this time.
0 commit comments