Skip to content

Commit 60df7e4

Browse files
committed
Added some comments
1 parent 2cdba4a commit 60df7e4

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

clippy_lints/src/unused_box.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff 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,

0 commit comments

Comments
 (0)