]> git.lizzy.rs Git - rust.git/blobdiff - clippy_lints/src/async_yields_async.rs
Improve `implicit_return`
[rust.git] / clippy_lints / src / async_yields_async.rs
index ae347fcd3e8e4aa4924e6ed9ea8b7b780ee2cd9e..e6c7c68f91a07a0ce3cb320f67a43aa7a7a5d0e8 100644 (file)
@@ -1,16 +1,16 @@
-use crate::utils::{implements_trait, snippet, span_lint_and_then};
+use clippy_utils::diagnostics::span_lint_and_then;
+use clippy_utils::source::snippet;
+use clippy_utils::ty::implements_trait;
 use rustc_errors::Applicability;
 use rustc_hir::{AsyncGeneratorKind, Body, BodyId, ExprKind, GeneratorKind, QPath};
 use rustc_lint::{LateContext, LateLintPass};
 use rustc_session::{declare_lint_pass, declare_tool_lint};
 
 declare_clippy_lint! {
-    /// **What it does:**
-    /// Checks for async blocks that yield values of types that can themselves
-    /// be awaited.
+    /// **What it does:** Checks for async blocks that yield values of types
+    /// that can themselves be awaited.
     ///
-    /// **Why is this bad?**
-    /// An await is likely missing.
+    /// **Why is this bad?** An await is likely missing.
     ///
     /// **Known problems:** None.
     ///
@@ -52,8 +52,7 @@ fn check_body(&mut self, cx: &LateContext<'tcx>, body: &'tcx Body<'_>) {
                 let body_id = BodyId {
                     hir_id: body.value.hir_id,
                 };
-                let def_id = cx.tcx.hir().body_owner_def_id(body_id);
-                let typeck_results = cx.tcx.typeck(def_id);
+                let typeck_results = cx.tcx.typeck_body(body_id);
                 let expr_ty = typeck_results.expr_ty(&body.value);
 
                 if implements_trait(cx, expr_ty, future_trait_def_id, &[]) {