|
| 1 | +error[E0597]: `mutex` does not live long enough |
| 2 | + --> $DIR/format-args-temporaries-in-write.rs:41:27 |
| 3 | + | |
| 4 | +LL | write!(Out, "{}", mutex.lock()) /* no semicolon */ |
| 5 | + | ^^^^^^^^^^^^ |
| 6 | + | | |
| 7 | + | borrowed value does not live long enough |
| 8 | + | a temporary with access to the borrow is created here ... |
| 9 | +LL | |
| 10 | +LL | }; |
| 11 | + | -- ... and the borrow might be used here, when that temporary is dropped and runs the `Drop` code for type `MutexGuard` |
| 12 | + | | |
| 13 | + | `mutex` dropped here while still borrowed |
| 14 | + | |
| 15 | +help: consider adding semicolon after the expression so its temporaries are dropped sooner, before the local variables declared by the block are dropped |
| 16 | + --> $SRC_DIR/core/src/macros/mod.rs:LL:COL |
| 17 | + | |
| 18 | +LL | $dst.write_fmt($crate::format_args!($($arg)*)); |
| 19 | + | + |
| 20 | + |
| 21 | +error[E0597]: `mutex` does not live long enough |
| 22 | + --> $DIR/format-args-temporaries-in-write.rs:47:29 |
| 23 | + | |
| 24 | +LL | writeln!(Out, "{}", mutex.lock()) /* no semicolon */ |
| 25 | + | ^^^^^^^^^^^^ |
| 26 | + | | |
| 27 | + | borrowed value does not live long enough |
| 28 | + | a temporary with access to the borrow is created here ... |
| 29 | +LL | |
| 30 | +LL | }; |
| 31 | + | -- ... and the borrow might be used here, when that temporary is dropped and runs the `Drop` code for type `MutexGuard` |
| 32 | + | | |
| 33 | + | `mutex` dropped here while still borrowed |
| 34 | + | |
| 35 | +help: consider adding semicolon after the expression so its temporaries are dropped sooner, before the local variables declared by the block are dropped |
| 36 | + --> $SRC_DIR/core/src/macros/mod.rs:LL:COL |
| 37 | + | |
| 38 | +LL | $dst.write_fmt($crate::format_args_nl!($($arg)*)); |
| 39 | + | + |
| 40 | + |
| 41 | +error: aborting due to 2 previous errors |
| 42 | + |
| 43 | +For more information about this error, try `rustc --explain E0597`. |
0 commit comments