forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#89303 - guswynn:std_suspend, r=dtolnay
Add `#[must_not_suspend]` to some types in std I am not sure what else should have it? `Ref`?
- Loading branch information
Showing
7 changed files
with
68 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// edition:2018 | ||
#![deny(must_not_suspend)] | ||
|
||
async fn other() {} | ||
|
||
pub async fn uhoh(m: std::sync::Mutex<()>) { | ||
let _guard = m.lock().unwrap(); //~ ERROR `MutexGuard` held across | ||
other().await; | ||
} | ||
|
||
fn main() { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
error: `MutexGuard` held across a suspend point, but should not be | ||
--> $DIR/mutex.rs:7:9 | ||
| | ||
LL | let _guard = m.lock().unwrap(); | ||
| ^^^^^^ | ||
LL | other().await; | ||
| ------------- the value is held across this suspend point | ||
| | ||
note: the lint level is defined here | ||
--> $DIR/mutex.rs:2:9 | ||
| | ||
LL | #![deny(must_not_suspend)] | ||
| ^^^^^^^^^^^^^^^^ | ||
note: Holding a MutexGuard across suspend points can cause deadlocks, delays, and cause Futures to not implement `Send` | ||
--> $DIR/mutex.rs:7:9 | ||
| | ||
LL | let _guard = m.lock().unwrap(); | ||
| ^^^^^^ | ||
help: consider using a block (`{ ... }`) to shrink the value's scope, ending before the suspend point | ||
--> $DIR/mutex.rs:7:9 | ||
| | ||
LL | let _guard = m.lock().unwrap(); | ||
| ^^^^^^ | ||
|
||
error: aborting due to previous error | ||
|