diff options
| author | Cameron Steffen <cam.steffen94@gmail.com> | 2021-03-05 10:13:59 -0600 |
|---|---|---|
| committer | Cameron Steffen <cam.steffen94@gmail.com> | 2021-03-05 10:36:16 -0600 |
| commit | 45454f073894d9e211d086d0c5a0c91fa54f67a9 (patch) | |
| tree | ea64c47267045b29bb441d64082c986a1cae9830 | |
| parent | 9e5453835572784dcdcdf63a4723254507282dc7 (diff) | |
| download | rust-45454f073894d9e211d086d0c5a0c91fa54f67a9.tar.gz rust-45454f073894d9e211d086d0c5a0c91fa54f67a9.zip | |
Avoid mir in implicit_return
| -rw-r--r-- | clippy_lints/src/implicit_return.rs | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/clippy_lints/src/implicit_return.rs b/clippy_lints/src/implicit_return.rs index 109d90ff772..b4f814e1dcc 100644 --- a/clippy_lints/src/implicit_return.rs +++ b/clippy_lints/src/implicit_return.rs @@ -1,4 +1,4 @@ -use crate::utils::{fn_has_unsatisfiable_preds, match_panic_def_id, snippet_opt, span_lint_and_then}; +use crate::utils::{match_panic_def_id, snippet_opt, span_lint_and_then}; use if_chain::if_chain; use rustc_errors::Applicability; use rustc_hir::intravisit::FnKind; @@ -133,19 +133,13 @@ impl<'tcx> LateLintPass<'tcx> for ImplicitReturn { span: Span, _: HirId, ) { - let def_id = cx.tcx.hir().body_owner_def_id(body.id()); - - // Building MIR for `fn`s with unsatisfiable preds results in ICE. - if fn_has_unsatisfiable_preds(cx, def_id.to_def_id()) { + if span.from_expansion() { return; } - - let mir = cx.tcx.optimized_mir(def_id.to_def_id()); - - // checking return type through MIR, HIR is not able to determine inferred closure return types - // make sure it's not a macro - if !mir.return_ty().is_unit() && !span.from_expansion() { - expr_match(cx, &body.value); + let body = cx.tcx.hir().body(body.id()); + if cx.typeck_results().expr_ty(&body.value).is_unit() { + return; } + expr_match(cx, &body.value); } } |
