about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEric Holk <ericholk@microsoft.com>2022-05-23 12:50:55 -0700
committerEric Holk <ericholk@microsoft.com>2022-07-29 15:59:26 -0700
commit89d35060b900f0aa441ca16b1bde2cdebcb46263 (patch)
tree4c7f509dc49a256794a037480eecf7dd8fefe0a9
parentbdfc68855861ecea26844a66c38c53f496386b7d (diff)
downloadrust-89d35060b900f0aa441ca16b1bde2cdebcb46263.tar.gz
rust-89d35060b900f0aa441ca16b1bde2cdebcb46263.zip
Update must_not_suspend lint to traverse references
-rw-r--r--compiler/rustc_typeck/src/check/generator_interior.rs6
-rw-r--r--src/test/ui/lint/must_not_suspend/ref.stderr12
2 files changed, 12 insertions, 6 deletions
diff --git a/compiler/rustc_typeck/src/check/generator_interior.rs b/compiler/rustc_typeck/src/check/generator_interior.rs
index d4f8001493c..b897d137f74 100644
--- a/compiler/rustc_typeck/src/check/generator_interior.rs
+++ b/compiler/rustc_typeck/src/check/generator_interior.rs
@@ -489,6 +489,8 @@ pub fn check_must_not_suspend_ty<'tcx>(
 
     let plural_suffix = pluralize!(data.plural_len);
 
+    debug!("Checking must_not_suspend for {}", ty);
+
     match *ty.kind() {
         ty::Adt(..) if ty.is_box() => {
             let boxed_ty = ty.boxed_ty();
@@ -580,6 +582,10 @@ pub fn check_must_not_suspend_ty<'tcx>(
                 },
             )
         }
+        ty::Ref(_region, ty, _mutability) => {
+            let descr_pre = &format!("{}reference{} to ", data.descr_pre, plural_suffix);
+            check_must_not_suspend_ty(fcx, ty, hir_id, SuspendCheckData { descr_pre, ..data })
+        }
         _ => false,
     }
 }
diff --git a/src/test/ui/lint/must_not_suspend/ref.stderr b/src/test/ui/lint/must_not_suspend/ref.stderr
index 5f000014c7d..8fbf3e71649 100644
--- a/src/test/ui/lint/must_not_suspend/ref.stderr
+++ b/src/test/ui/lint/must_not_suspend/ref.stderr
@@ -1,5 +1,5 @@
-error: `Umm` held across a suspend point, but should not be
-  --> $DIR/ref.rs:18:26
+error: reference to `Umm` held across a suspend point, but should not be
+  --> $DIR/ref.rs:18:13
    |
 LL |         let guard = &mut self.u;
    |                          ^^^^^^
@@ -13,15 +13,15 @@ note: the lint level is defined here
 LL | #![deny(must_not_suspend)]
    |         ^^^^^^^^^^^^^^^^
 note: You gotta use Umm's, ya know?
-  --> $DIR/ref.rs:18:26
+  --> $DIR/ref.rs:18:13
    |
 LL |         let guard = &mut self.u;
-   |                          ^^^^^^
+   |             ^^^^^
 help: consider using a block (`{ ... }`) to shrink the value's scope, ending before the suspend point
-  --> $DIR/ref.rs:18:26
+  --> $DIR/ref.rs:18:13
    |
 LL |         let guard = &mut self.u;
-   |                          ^^^^^^
+   |             ^^^^^
 
 error: aborting due to previous error