]> git.lizzy.rs Git - rust.git/blobdiff - clippy_lints/src/await_holding_invalid.rs
ast/hir: Rename field-related structures
[rust.git] / clippy_lints / src / await_holding_invalid.rs
index 58892024ce2439cebfde97b587939df93c8bf406..14b6a156c621e9963dc24a5abfe8d2a5237d06e1 100644 (file)
@@ -18,7 +18,7 @@
     /// other solution is to ensure the mutex is unlocked before calling await,
     /// either by introducing a scope or an explicit call to Drop::drop.
     ///
-    /// **Known problems:** None.
+    /// **Known problems:** Will report false positive for explicitly dropped guards ([#6446](https://github.com/rust-lang/rust-clippy/issues/6446)).
     ///
     /// **Example:**
     ///
@@ -57,7 +57,7 @@
     /// at runtime. Holding onto a `RefCell` ref across an `await` suspension point
     /// risks panics from a mutable ref shared while other refs are outstanding.
     ///
-    /// **Known problems:** None.
+    /// **Known problems:** Will report false positive for explicitly dropped refs ([#6353](https://github.com/rust-lang/rust-clippy/issues/6353)).
     ///
     /// **Example:**
     ///
@@ -97,9 +97,12 @@ fn check_body(&mut self, cx: &LateContext<'_>, body: &'_ 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);
-            check_interior_types(cx, &typeck_results.generator_interior_types, body.value.span);
+            let typeck_results = cx.tcx.typeck_body(body_id);
+            check_interior_types(
+                cx,
+                &typeck_results.generator_interior_types.as_ref().skip_binder(),
+                body.value.span,
+            );
         }
     }
 }
@@ -112,20 +115,20 @@ fn check_interior_types(cx: &LateContext<'_>, ty_causes: &[GeneratorInteriorType
                     cx,
                     AWAIT_HOLDING_LOCK,
                     ty_cause.span,
-                    "this MutexGuard is held across an 'await' point. Consider using an async-aware Mutex type or ensuring the MutexGuard is dropped before calling await.",
+                    "this MutexGuard is held across an 'await' point. Consider using an async-aware Mutex type or ensuring the MutexGuard is dropped before calling await",
                     ty_cause.scope_span.or(Some(span)),
                     "these are all the await points this lock is held through",
                 );
             }
             if is_refcell_ref(cx, adt.did) {
                 span_lint_and_note(
-                        cx,
-                        AWAIT_HOLDING_REFCELL_REF,
-                        ty_cause.span,
-                        "this RefCell Ref is held across an 'await' point. Consider ensuring the Ref is dropped before calling await.",
-                        ty_cause.scope_span.or(Some(span)),
-                        "these are all the await points this ref is held through",
-                    );
+                    cx,
+                    AWAIT_HOLDING_REFCELL_REF,
+                    ty_cause.span,
+                    "this RefCell Ref is held across an 'await' point. Consider ensuring the Ref is dropped before calling await",
+                    ty_cause.scope_span.or(Some(span)),
+                    "these are all the await points this ref is held through",
+                );
             }
         }
     }