|
| 1 | +error[E0716]: temporary value dropped while borrowed |
| 2 | + --> $DIR/promote-ref-mut-in-let-issue-46557.rs:5:21 |
| 3 | + | |
| 4 | +LL | let ref mut x = 1234543; |
| 5 | + | ^^^^^^^ creates a temporary which is freed while still in use |
| 6 | +LL | x |
| 7 | + | - borrow later used here |
| 8 | +LL | } |
| 9 | + | - temporary value is freed at the end of this statement |
| 10 | + | |
| 11 | + = note: consider using a `let` binding to create a longer lived value |
| 12 | + |
| 13 | +error[E0716]: temporary value dropped while borrowed |
| 14 | + --> $DIR/promote-ref-mut-in-let-issue-46557.rs:10:25 |
| 15 | + | |
| 16 | +LL | let (ref mut x, ) = (1234543, ); |
| 17 | + | ^^^^^^^^^^^ creates a temporary which is freed while still in use |
| 18 | +LL | x |
| 19 | + | - borrow later used here |
| 20 | +LL | } |
| 21 | + | - temporary value is freed at the end of this statement |
| 22 | + | |
| 23 | + = note: consider using a `let` binding to create a longer lived value |
| 24 | + |
| 25 | +error[E0515]: cannot return value referencing temporary value |
| 26 | + --> $DIR/promote-ref-mut-in-let-issue-46557.rs:15:5 |
| 27 | + | |
| 28 | +LL | match 1234543 { |
| 29 | + | ^ ------- temporary value created here |
| 30 | + | _____| |
| 31 | + | | |
| 32 | +LL | | ref mut x => x |
| 33 | +LL | | } |
| 34 | + | |_____^ returns a value referencing data owned by the current function |
| 35 | + |
| 36 | +error[E0515]: cannot return value referencing temporary value |
| 37 | + --> $DIR/promote-ref-mut-in-let-issue-46557.rs:21:5 |
| 38 | + | |
| 39 | +LL | match (123443,) { |
| 40 | + | ^ --------- temporary value created here |
| 41 | + | _____| |
| 42 | + | | |
| 43 | +LL | | (ref mut x,) => x, |
| 44 | +LL | | } |
| 45 | + | |_____^ returns a value referencing data owned by the current function |
| 46 | + |
| 47 | +error[E0515]: cannot return reference to temporary value |
| 48 | + --> $DIR/promote-ref-mut-in-let-issue-46557.rs:27:5 |
| 49 | + | |
| 50 | +LL | &mut 1234543 |
| 51 | + | ^^^^^------- |
| 52 | + | | | |
| 53 | + | | temporary value created here |
| 54 | + | returns a reference to data owned by the current function |
| 55 | + |
| 56 | +error: aborting due to 5 previous errors |
| 57 | + |
| 58 | +Some errors have detailed explanations: E0515, E0716. |
| 59 | +For more information about an error, try `rustc --explain E0515`. |
0 commit comments