|
| 1 | +error[E0597]: `mutex` does not live long enough |
| 2 | + --> $DIR/span-semicolon-issue-139049.rs:39:27 |
| 3 | + | |
| 4 | +LL | let mutex = Mutex; |
| 5 | + | ----- binding `mutex` declared here |
| 6 | +LL | write!(Out, "{}", mutex.lock()) |
| 7 | + | ^^^^^------- |
| 8 | + | | |
| 9 | + | borrowed value does not live long enough |
| 10 | + | a temporary with access to the borrow is created here ... |
| 11 | +... |
| 12 | +LL | }; |
| 13 | + | -- ... and the borrow might be used here, when that temporary is dropped and runs the `Drop` code for type `MutexGuard` |
| 14 | + | | |
| 15 | + | `mutex` dropped here while still borrowed |
| 16 | + | |
| 17 | +help: consider adding semicolon after the expression so its temporaries are dropped sooner, before the local variables declared by the block are dropped |
| 18 | + | |
| 19 | +LL | write!(Out, "{}", mutex.lock()); |
| 20 | + | + |
| 21 | + |
| 22 | +error[E0597]: `mutex` does not live long enough |
| 23 | + --> $DIR/span-semicolon-issue-139049.rs:48:41 |
| 24 | + | |
| 25 | +LL | let mutex = Mutex; |
| 26 | + | ----- binding `mutex` declared here |
| 27 | +LL | write!(std::io::stdout(), "{}", mutex.lock()) |
| 28 | + | ^^^^^------- |
| 29 | + | | |
| 30 | + | borrowed value does not live long enough |
| 31 | + | a temporary with access to the borrow is created here ... |
| 32 | +... |
| 33 | +LL | }; |
| 34 | + | -- ... and the borrow might be used here, when that temporary is dropped and runs the `Drop` code for type `MutexGuard` |
| 35 | + | | |
| 36 | + | `mutex` dropped here while still borrowed |
| 37 | + | |
| 38 | + = note: the temporary is part of an expression at the end of a block; |
| 39 | + consider forcing this temporary to be dropped sooner, before the block's local variables are dropped |
| 40 | +help: for example, you could save the expression's value in a new local variable `x` and then make `x` be the expression at the end of the block |
| 41 | + | |
| 42 | +LL | let x = write!(std::io::stdout(), "{}", mutex.lock()); x |
| 43 | + | +++++++ +++ |
| 44 | + |
| 45 | +error: aborting due to 2 previous errors |
| 46 | + |
| 47 | +For more information about this error, try `rustc --explain E0597`. |
0 commit comments