]> git.lizzy.rs Git - rust.git/blobdiff - clippy_lints/src/implicit_return.rs
Auto merge of #4809 - iankronquist:patch-1, r=flip1995
[rust.git] / clippy_lints / src / implicit_return.rs
index c6cf021af01fd211d33355b1f8b854dc726d617d..b0d80aa0d539d30875d1a18d2e2617d81aa6e2b6 100644 (file)
@@ -4,13 +4,12 @@
     snippet_opt, span_lint_and_then,
 };
 use if_chain::if_chain;
-use rustc::{
-    declare_lint_pass, declare_tool_lint,
-    hir::{intravisit::FnKind, Body, Expr, ExprKind, FnDecl, HirId, MatchSource, StmtKind},
-    lint::{LateContext, LateLintPass, LintArray, LintPass},
-};
 use rustc_errors::Applicability;
-use syntax::source_map::Span;
+use rustc_hir::intravisit::FnKind;
+use rustc_hir::{Body, Expr, ExprKind, FnDecl, HirId, MatchSource, StmtKind};
+use rustc_lint::{LateContext, LateLintPass};
+use rustc_session::{declare_lint_pass, declare_tool_lint};
+use rustc_span::source_map::Span;
 
 declare_clippy_lint! {
     /// **What it does:** Checks for missing return statements at the end of a block.
@@ -49,7 +48,7 @@ fn lint(cx: &LateContext<'_, '_>, outer_span: Span, inner_span: Span, msg: &str)
     let outer_span = outer_span.source_callsite();
     let inner_span = inner_span.source_callsite();
 
-    span_lint_and_then(cx, IMPLICIT_RETURN, outer_span, "missing return statement", |db| {
+    span_lint_and_then(cx, IMPLICIT_RETURN, outer_span, "missing `return` statement", |db| {
         if let Some(snippet) = snippet_opt(cx, inner_span) {
             db.span_suggestion(
                 outer_span,
@@ -61,8 +60,8 @@ fn lint(cx: &LateContext<'_, '_>, outer_span: Span, inner_span: Span, msg: &str)
     });
 }
 
-fn expr_match(cx: &LateContext<'_, '_>, expr: &Expr) {
-    match &expr.kind {
+fn expr_match(cx: &LateContext<'_, '_>, expr: &Expr<'_>) {
+    match expr.kind {
         // loops could be using `break` instead of `return`
         ExprKind::Block(block, ..) | ExprKind::Loop(block, ..) => {
             if let Some(expr) = &block.expr {
@@ -91,7 +90,7 @@ fn expr_match(cx: &LateContext<'_, '_>, expr: &Expr) {
             let check_all_arms = match source {
                 MatchSource::IfLetDesugar {
                     contains_else_clause: has_else,
-                } => *has_else,
+                } => has_else,
                 _ => true,
             };
 
@@ -100,7 +99,7 @@ fn expr_match(cx: &LateContext<'_, '_>, expr: &Expr) {
                     expr_match(cx, &arm.body);
                 }
             } else {
-                expr_match(cx, &arms.first().expect("if let doesn't have a single arm").body);
+                expr_match(cx, &arms.first().expect("`if let` doesn't have a single arm").body);
             }
         },
         // skip if it already has a return statement
@@ -128,8 +127,8 @@ fn check_fn(
         &mut self,
         cx: &LateContext<'a, 'tcx>,
         _: FnKind<'tcx>,
-        _: &'tcx FnDecl,
-        body: &'tcx Body,
+        _: &'tcx FnDecl<'_>,
+        body: &'tcx Body<'_>,
         span: Span,
         _: HirId,
     ) {