rust/src/test/ui/generator/yield-in-initializer.stderr
Tomasz Miąsko 821d50aa0c Make closures and generators a must use types
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:
    || {};
}
```
2020-07-28 00:00:00 +00:00

18 lines
502 B
Plaintext

warning: unused generator that must be used
--> $DIR/yield-in-initializer.rs:6:5
|
LL | / static || {
LL | | loop {
LL | | // Test that `opt` is not live across the yield, even when borrowed in a loop
LL | | // See https://github.com/rust-lang/rust/issues/52792
... |
LL | | }
LL | | };
| |______^
|
= note: `#[warn(unused_must_use)]` on by default
= note: generators are lazy and do nothing unless resumed
warning: 1 warning emitted