Skip to content

Commit fefadec

Browse files
Bhargav Voletinikomatsakis
authored andcommitted
Address feedback. Remove capability to apply lint to functions.
1 parent 622501c commit fefadec

File tree

1 file changed

+2
-35
lines changed

1 file changed

+2
-35
lines changed

text/0000-must-not-suspend-lint.md

Lines changed: 2 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ This will be a best effort lint to signal the user about unintended side-effects
6363
# Reference-level explanation
6464
[reference-level-explanation]: #reference-level-explanation
6565

66-
The `must_not_suspend` attribute is used to issue a diagnostic warning when a value is not "used". It can be applied to user-defined composite types (structs, enums and unions), functions and traits.
66+
The `must_not_suspend` attribute is used to issue a diagnostic warning when a value is not "used". It can be applied to user-defined composite types (structs, enums and unions), traits.
6767

6868
The `must_not_suspend` attribute may include a message by using the [`MetaNameValueStr`] syntax such as `#[must_not_suspend = "example message"]`. The message will be given alongside the warning.
6969

@@ -81,19 +81,6 @@ async fn foo() {
8181
}
8282
```
8383

84-
When used on a function, if the value returned by a function is held across an await point, this lint is violated.
85-
86-
```rust
87-
#[must_not_suspend]
88-
fn foo() -> i32 { 5i32 }
89-
90-
async fn foo() {
91-
let bar = foo();
92-
my_async_op.await;
93-
println!("{:?}", bar);
94-
}
95-
```
96-
9784
When used on a [trait declaration], if the value implementing that trait is held across an await point, the lint is violated.
9885

9986
```rust
@@ -114,26 +101,6 @@ async fn foo() {
114101
}
115102
```
116103

117-
When used on a function in a trait declaration, then the behavior also applies when the call expression is a function from the implementation of the trait.
118-
119-
```rust
120-
trait Trait {
121-
#[must_not_suspend]
122-
fn foo(&self) -> i32;
123-
}
124-
125-
impl Trait for i32 {
126-
fn foo(&self) -> i32 { 0i32 }
127-
}
128-
129-
async fn foo() {
130-
let bar = 5i32.foo();
131-
my_async_op.await;
132-
println!("{:?}", bar);
133-
}
134-
```
135-
136-
137104
When used on a function in a trait implementation, the attribute does nothing.
138105

139106
[`MetaNameValueStr`]: https://doc.rust-lang.org/reference/attributes.html#meta-item-attribute-syntax
@@ -149,7 +116,7 @@ When used on a function in a trait implementation, the attribute does nothing.
149116
# Rationale and alternatives
150117
[rationale-and-alternatives]: #rationale-and-alternatives
151118

152-
Going through the prior are we see two systems currently which provide simailar/semantically similar behavior:
119+
Going through the prior art we see two systems currently which provide similar/semantically similar behavior:
153120

154121
## Clippy `await_holding_lock` lint
155122
This lint goes through all types in `generator_interior_types` looking for `MutexGuard`, `RwLockReadGuard` and `RwLockWriteGuard`. While this is a first great step, we think that this can be further extended to handle not only the hardcoded lock guards, but any type which is should not be held across an await point. By marking a type as `#[must_not_suspend]` we can warn when any arbitrary type is being held across an await boundary. An additional benefit to this approach is that this behaviour can be extended to any type which holds a `#[must_not_suspend]` type inside of it.

0 commit comments

Comments
 (0)