Skip to content

Commit 71f5d76

Browse files
committed
Revert "Use a more straight-forward size check"
This reverts commit 2c642b5.
1 parent aacf1cb commit 71f5d76

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

clippy_lints/src/unnecessary_box_returns.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use clippy_utils::diagnostics::span_lint_and_then;
1+
use clippy_utils::{diagnostics::span_lint_and_then, ty::implements_trait};
22
use rustc_errors::Applicability;
33
use rustc_hir::{def_id::LocalDefId, FnDecl, FnRetTy, ImplItemKind, Item, ItemKind, Node, TraitItem, TraitItemKind};
44
use rustc_hir_analysis::hir_ty_to_ty;
@@ -63,9 +63,10 @@ impl UnnecessaryBoxReturns {
6363
}
6464

6565
let boxed_ty = return_ty.boxed_ty();
66+
let Some(sized_trait) = cx.tcx.lang_items().sized_trait() else { return };
6667

6768
// it's sometimes useful to return Box<T> if T is unsized, so don't lint those
68-
if boxed_ty.is_sized(cx.tcx, cx.param_env) {
69+
if implements_trait(cx, boxed_ty, sized_trait, &[]) {
6970
span_lint_and_then(
7071
cx,
7172
UNNECESSARY_BOX_RETURNS,

0 commit comments

Comments
 (0)