Warn about unused expressions with closure or generator type. This follows
existing precedence of must use annotations present on `FnOnce`, `FnMut`, `Fn`
traits, which already indirectly apply to closures in some cases, e.g.,:
```rust
fn f() -> impl FnOnce() {
|| {}
}
fn main() {
// an existing warning: unused implementer of `std::ops::FnOnce` that must be used:
f();
// a new warning: unused closure that must be used:
|| {};
}
```
7 lines
136 B
Rust
7 lines
136 B
Rust
// run-pass
|
|
|
|
// pretty-expanded FIXME #23616
|
|
|
|
pub fn main() {
|
|
{|i: u32| if 1 == i { }}; //~ WARN unused closure that must be used
|
|
}
|