Skip to content

Commit 4db1131

Browse files
committed
Brought back is_sized. Removed hir_ty_to_ty
1 parent d7f593e commit 4db1131

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

clippy_lints/src/unnecessary_box_returns.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
use clippy_utils::{diagnostics::span_lint_and_then, ty::implements_trait};
1+
use clippy_utils::diagnostics::span_lint_and_then;
22
use rustc_errors::Applicability;
33
use rustc_hir::{def_id::LocalDefId, FnDecl, FnRetTy, ImplItemKind, Item, ItemKind, Node, TraitItem, TraitItemKind};
4-
use rustc_hir_analysis::hir_ty_to_ty;
54
use rustc_lint::{LateContext, LateLintPass};
65
use rustc_session::{declare_tool_lint, impl_lint_pass};
76

@@ -55,18 +54,19 @@ impl UnnecessaryBoxReturns {
5554

5655
let FnRetTy::Return(return_ty_hir) = &decl.output else { return };
5756

58-
// this is safe, since we're not in a body
59-
let return_ty = hir_ty_to_ty(cx.tcx, return_ty_hir);
57+
let return_ty = cx
58+
.tcx
59+
.erase_late_bound_regions(cx.tcx.fn_sig(def_id).skip_binder())
60+
.output();
6061

6162
if !return_ty.is_box() {
6263
return;
6364
}
6465

6566
let boxed_ty = return_ty.boxed_ty();
66-
let Some(sized_trait) = cx.tcx.lang_items().sized_trait() else { return };
6767

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

0 commit comments

Comments
 (0)