Skip to content

Commit

Permalink
Brought back is_sized. Removed hir_ty_to_ty
Browse files Browse the repository at this point in the history
  • Loading branch information
botahamec committed Mar 5, 2023
1 parent d7f593e commit 4db1131
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions clippy_lints/src/unnecessary_box_returns.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use clippy_utils::{diagnostics::span_lint_and_then, ty::implements_trait};
use clippy_utils::diagnostics::span_lint_and_then;
use rustc_errors::Applicability;
use rustc_hir::{def_id::LocalDefId, FnDecl, FnRetTy, ImplItemKind, Item, ItemKind, Node, TraitItem, TraitItemKind};
use rustc_hir_analysis::hir_ty_to_ty;
use rustc_lint::{LateContext, LateLintPass};
use rustc_session::{declare_tool_lint, impl_lint_pass};

Expand Down Expand Up @@ -55,18 +54,19 @@ impl UnnecessaryBoxReturns {

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

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

if !return_ty.is_box() {
return;
}

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

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

0 comments on commit 4db1131

Please sign in to comment.