]> git.lizzy.rs Git - rust.git/blobdiff - clippy_lints/src/async_yields_async.rs
add `tcx` to `fn walk`
[rust.git] / clippy_lints / src / async_yields_async.rs
index 88d9d3b5a263d06ee312b6cc0be90f30852e5acf..182736a5a205a6ab3178ef7de4e83af150df74e8 100644 (file)
@@ -1,19 +1,20 @@
-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
+    /// ### 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.
-    ///
-    /// **Known problems:** None.
-    ///
-    /// **Example:**
+    /// ### Why is this bad?
+    /// An await is likely missing.
     ///
+    /// ### Example
     /// ```rust
     /// async fn foo() {}
     ///
@@ -50,8 +51,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, &[]) {