diff options
| author | daxpedda <daxpedda@users.noreply.github.com> | 2018-12-05 15:01:19 +0100 |
|---|---|---|
| committer | daxpedda <daxpedda@users.noreply.github.com> | 2018-12-05 15:01:19 +0100 |
| commit | b0f3ed2b808d0696d0a97173d65d368b01c0c9a7 (patch) | |
| tree | cb07e740acb021c98161875d8a2dba4fe847963a | |
| parent | aed2b986e6d596f6ed154625030b8c83a67066fe (diff) | |
| download | rust-b0f3ed2b808d0696d0a97173d65d368b01c0c9a7.tar.gz rust-b0f3ed2b808d0696d0a97173d65d368b01c0c9a7.zip | |
Added additional reasoning to `Why is this bad?`.
Added comment to explain usage of MIR.
| -rw-r--r-- | clippy_lints/src/implicit_return.rs | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/clippy_lints/src/implicit_return.rs b/clippy_lints/src/implicit_return.rs index de783aabefe..664f182c533 100644 --- a/clippy_lints/src/implicit_return.rs +++ b/clippy_lints/src/implicit_return.rs @@ -17,7 +17,10 @@ use crate::utils::{snippet_opt, span_lint_and_then}; /// **What it does:** Checks for missing return statements at the end of a block. /// /// **Why is this bad?** Actually omitting the return keyword is idiomatic Rust code. Programmers -/// coming from other languages might prefer the expressiveness of `return`. +/// coming from other languages might prefer the expressiveness of `return`. It's possible to miss +/// the last returning statement because the only difference is a missing `;`. Especially in bigger +/// code with multiple return paths having a `return` keyword makes it easier to find the +/// corresponding statements. /// /// **Known problems:** None. /// @@ -124,6 +127,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass { let def_id = cx.tcx.hir.body_owner_def_id(body.id()); let mir = cx.tcx.optimized_mir(def_id); + // checking return type through MIR, HIR is not able to determine inferred closure return types if !mir.return_ty().is_unit() { Self::expr_match(cx, &body.value); } |
