Skip to content

Commit 89d3506

Browse files
committed
Update must_not_suspend lint to traverse references
1 parent bdfc688 commit 89d3506

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

compiler/rustc_typeck/src/check/generator_interior.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,8 @@ pub fn check_must_not_suspend_ty<'tcx>(
489489

490490
let plural_suffix = pluralize!(data.plural_len);
491491

492+
debug!("Checking must_not_suspend for {}", ty);
493+
492494
match *ty.kind() {
493495
ty::Adt(..) if ty.is_box() => {
494496
let boxed_ty = ty.boxed_ty();
@@ -580,6 +582,10 @@ pub fn check_must_not_suspend_ty<'tcx>(
580582
},
581583
)
582584
}
585+
ty::Ref(_region, ty, _mutability) => {
586+
let descr_pre = &format!("{}reference{} to ", data.descr_pre, plural_suffix);
587+
check_must_not_suspend_ty(fcx, ty, hir_id, SuspendCheckData { descr_pre, ..data })
588+
}
583589
_ => false,
584590
}
585591
}
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
error: `Umm` held across a suspend point, but should not be
2-
--> $DIR/ref.rs:18:26
1+
error: reference to `Umm` held across a suspend point, but should not be
2+
--> $DIR/ref.rs:18:13
33
|
44
LL | let guard = &mut self.u;
55
| ^^^^^^
@@ -13,15 +13,15 @@ note: the lint level is defined here
1313
LL | #![deny(must_not_suspend)]
1414
| ^^^^^^^^^^^^^^^^
1515
note: You gotta use Umm's, ya know?
16-
--> $DIR/ref.rs:18:26
16+
--> $DIR/ref.rs:18:13
1717
|
1818
LL | let guard = &mut self.u;
19-
| ^^^^^^
19+
| ^^^^^
2020
help: consider using a block (`{ ... }`) to shrink the value's scope, ending before the suspend point
21-
--> $DIR/ref.rs:18:26
21+
--> $DIR/ref.rs:18:13
2222
|
2323
LL | let guard = &mut self.u;
24-
| ^^^^^^
24+
| ^^^^^
2525

2626
error: aborting due to previous error
2727

0 commit comments

Comments
 (0)