Skip to content

Commit 45454f0

Browse files
committed
Avoid mir in implicit_return
1 parent 9e54538 commit 45454f0

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

clippy_lints/src/implicit_return.rs

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::utils::{fn_has_unsatisfiable_preds, match_panic_def_id, snippet_opt, span_lint_and_then};
1+
use crate::utils::{match_panic_def_id, snippet_opt, span_lint_and_then};
22
use if_chain::if_chain;
33
use rustc_errors::Applicability;
44
use rustc_hir::intravisit::FnKind;
@@ -133,19 +133,13 @@ impl<'tcx> LateLintPass<'tcx> for ImplicitReturn {
133133
span: Span,
134134
_: HirId,
135135
) {
136-
let def_id = cx.tcx.hir().body_owner_def_id(body.id());
137-
138-
// Building MIR for `fn`s with unsatisfiable preds results in ICE.
139-
if fn_has_unsatisfiable_preds(cx, def_id.to_def_id()) {
136+
if span.from_expansion() {
140137
return;
141138
}
142-
143-
let mir = cx.tcx.optimized_mir(def_id.to_def_id());
144-
145-
// checking return type through MIR, HIR is not able to determine inferred closure return types
146-
// make sure it's not a macro
147-
if !mir.return_ty().is_unit() && !span.from_expansion() {
148-
expr_match(cx, &body.value);
139+
let body = cx.tcx.hir().body(body.id());
140+
if cx.typeck_results().expr_ty(&body.value).is_unit() {
141+
return;
149142
}
143+
expr_match(cx, &body.value);
150144
}
151145
}

0 commit comments

Comments
 (0)