Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #54164 - mikhail-m1:54131, r=pnkfelix
add "temporary value borrowed for too long" error Issue #54131 r? @nikomatsakis
- Loading branch information
Showing
60 changed files
with
852 additions
and
192 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
src/test/ui/borrowck/borrowck-borrow-from-temporary.nll.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
error[E0716]: temporary value dropped while borrowed | ||
--> $DIR/borrowck-borrow-from-temporary.rs:19:24 | ||
| | ||
LL | let &Foo(ref x) = &id(Foo(3)); //~ ERROR borrowed value does not live long enough | ||
| ^^^^^^^^^^ creates a temporary which is freed while still in use | ||
LL | x | ||
LL | } | ||
| - temporary value is freed at the end of this statement | ||
| | ||
note: borrowed value must be valid for the lifetime 'a as defined on the function body at 18:8... | ||
--> $DIR/borrowck-borrow-from-temporary.rs:18:8 | ||
| | ||
LL | fn foo<'a>() -> &'a isize { | ||
| ^^ | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0716`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 16 additions & 16 deletions
32
src/test/ui/borrowck/promote-ref-mut-in-let-issue-46557.nll.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,57 +1,57 @@ | ||
error[E0597]: borrowed value does not live long enough | ||
error[E0716]: temporary value dropped while borrowed | ||
--> $DIR/promote-ref-mut-in-let-issue-46557.rs:15:21 | ||
| | ||
LL | let ref mut x = 1234543; //~ ERROR | ||
| ^^^^^^^ temporary value does not live long enough | ||
| ^^^^^^^ creates a temporary which is freed while still in use | ||
LL | x | ||
LL | } | ||
| - temporary value only lives until here | ||
| - temporary value is freed at the end of this statement | ||
| | ||
= note: borrowed value must be valid for the static lifetime... | ||
|
||
error[E0597]: borrowed value does not live long enough | ||
error[E0716]: temporary value dropped while borrowed | ||
--> $DIR/promote-ref-mut-in-let-issue-46557.rs:20:25 | ||
| | ||
LL | let (ref mut x, ) = (1234543, ); //~ ERROR | ||
| ^^^^^^^^^^^ temporary value does not live long enough | ||
| ^^^^^^^^^^^ creates a temporary which is freed while still in use | ||
LL | x | ||
LL | } | ||
| - temporary value only lives until here | ||
| - temporary value is freed at the end of this statement | ||
| | ||
= note: borrowed value must be valid for the static lifetime... | ||
|
||
error[E0597]: borrowed value does not live long enough | ||
error[E0716]: temporary value dropped while borrowed | ||
--> $DIR/promote-ref-mut-in-let-issue-46557.rs:25:11 | ||
| | ||
LL | match 1234543 { | ||
| ^^^^^^^ temporary value does not live long enough | ||
| ^^^^^^^ creates a temporary which is freed while still in use | ||
... | ||
LL | } | ||
| - temporary value only lives until here | ||
| - temporary value is freed at the end of this statement | ||
| | ||
= note: borrowed value must be valid for the static lifetime... | ||
|
||
error[E0597]: borrowed value does not live long enough | ||
error[E0716]: temporary value dropped while borrowed | ||
--> $DIR/promote-ref-mut-in-let-issue-46557.rs:31:11 | ||
| | ||
LL | match (123443,) { | ||
| ^^^^^^^^^ temporary value does not live long enough | ||
| ^^^^^^^^^ creates a temporary which is freed while still in use | ||
... | ||
LL | } | ||
| - temporary value only lives until here | ||
| - temporary value is freed at the end of this statement | ||
| | ||
= note: borrowed value must be valid for the static lifetime... | ||
|
||
error[E0597]: borrowed value does not live long enough | ||
error[E0716]: temporary value dropped while borrowed | ||
--> $DIR/promote-ref-mut-in-let-issue-46557.rs:37:10 | ||
| | ||
LL | &mut 1234543 //~ ERROR | ||
| ^^^^^^^ temporary value does not live long enough | ||
| ^^^^^^^ creates a temporary which is freed while still in use | ||
LL | } | ||
| - temporary value only lives until here | ||
| - temporary value is freed at the end of this statement | ||
| | ||
= note: borrowed value must be valid for the static lifetime... | ||
|
||
error: aborting due to 5 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0597`. | ||
For more information about this error, try `rustc --explain E0716`. |
43 changes: 43 additions & 0 deletions
43
src/test/ui/consts/const-eval/dont_promote_unstable_const_fn.nll.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
error: `foo` is not yet stable as a const fn | ||
--> $DIR/dont_promote_unstable_const_fn.rs:25:25 | ||
| | ||
LL | const fn bar() -> u32 { foo() } //~ ERROR `foo` is not yet stable as a const fn | ||
| ^^^^^ | ||
| | ||
= help: in Nightly builds, add `#![feature(foo)]` to the crate attributes to enable | ||
|
||
error[E0716]: temporary value dropped while borrowed | ||
--> $DIR/dont_promote_unstable_const_fn.rs:28:28 | ||
| | ||
LL | let _: &'static u32 = &foo(); //~ ERROR does not live long enough | ||
| ^^^^^ creates a temporary which is freed while still in use | ||
LL | } | ||
| - temporary value is freed at the end of this statement | ||
| | ||
= note: borrowed value must be valid for the static lifetime... | ||
|
||
error[E0716]: temporary value dropped while borrowed | ||
--> $DIR/dont_promote_unstable_const_fn.rs:32:28 | ||
| | ||
LL | let _: &'static u32 = &meh(); //~ ERROR does not live long enough | ||
| ^^^^^ creates a temporary which is freed while still in use | ||
... | ||
LL | } | ||
| - temporary value is freed at the end of this statement | ||
| | ||
= note: borrowed value must be valid for the static lifetime... | ||
|
||
error[E0716]: temporary value dropped while borrowed | ||
--> $DIR/dont_promote_unstable_const_fn.rs:33:26 | ||
| | ||
LL | let x: &'static _ = &std::time::Duration::from_millis(42).subsec_millis(); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use | ||
LL | //~^ does not live long enough | ||
LL | } | ||
| - temporary value is freed at the end of this statement | ||
| | ||
= note: borrowed value must be valid for the static lifetime... | ||
|
||
error: aborting due to 4 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0716`. |
24 changes: 24 additions & 0 deletions
24
src/test/ui/consts/const-eval/dont_promote_unstable_const_fn_cross_crate.nll.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
error[E0716]: temporary value dropped while borrowed | ||
--> $DIR/dont_promote_unstable_const_fn_cross_crate.rs:18:28 | ||
| | ||
LL | let _: &'static u32 = &foo(); //~ ERROR does not live long enough | ||
| ^^^^^ creates a temporary which is freed while still in use | ||
LL | let _x: &'static u32 = &foo(); //~ ERROR does not live long enough | ||
LL | } | ||
| - temporary value is freed at the end of this statement | ||
| | ||
= note: borrowed value must be valid for the static lifetime... | ||
|
||
error[E0716]: temporary value dropped while borrowed | ||
--> $DIR/dont_promote_unstable_const_fn_cross_crate.rs:19:29 | ||
| | ||
LL | let _x: &'static u32 = &foo(); //~ ERROR does not live long enough | ||
| ^^^^^ creates a temporary which is freed while still in use | ||
LL | } | ||
| - temporary value is freed at the end of this statement | ||
| | ||
= note: borrowed value must be valid for the static lifetime... | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0716`. |
35 changes: 35 additions & 0 deletions
35
src/test/ui/consts/const-eval/promoted_raw_ptr_ops.nll.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
error[E0716]: temporary value dropped while borrowed | ||
--> $DIR/promoted_raw_ptr_ops.rs:14:29 | ||
| | ||
LL | let x: &'static bool = &(42 as *const i32 == 43 as *const i32); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use | ||
... | ||
LL | } | ||
| - temporary value is freed at the end of this statement | ||
| | ||
= note: borrowed value must be valid for the static lifetime... | ||
|
||
error[E0716]: temporary value dropped while borrowed | ||
--> $DIR/promoted_raw_ptr_ops.rs:16:30 | ||
| | ||
LL | let y: &'static usize = &(&1 as *const i32 as usize + 1); //~ ERROR does not live long enough | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use | ||
LL | let z: &'static i32 = &(unsafe { *(42 as *const i32) }); //~ ERROR does not live long enough | ||
LL | } | ||
| - temporary value is freed at the end of this statement | ||
| | ||
= note: borrowed value must be valid for the static lifetime... | ||
|
||
error[E0716]: temporary value dropped while borrowed | ||
--> $DIR/promoted_raw_ptr_ops.rs:17:28 | ||
| | ||
LL | let z: &'static i32 = &(unsafe { *(42 as *const i32) }); //~ ERROR does not live long enough | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use | ||
LL | } | ||
| - temporary value is freed at the end of this statement | ||
| | ||
= note: borrowed value must be valid for the static lifetime... | ||
|
||
error: aborting due to 3 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0716`. |
14 changes: 14 additions & 0 deletions
14
src/test/ui/consts/const-eval/transmute-const-promotion.nll.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
error[E0716]: temporary value dropped while borrowed | ||
--> $DIR/transmute-const-promotion.rs:16:37 | ||
| | ||
LL | let x: &'static u32 = unsafe { &mem::transmute(3.0f32) }; | ||
| ^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use | ||
LL | //~^ ERROR value does not live long enough | ||
LL | } | ||
| - temporary value is freed at the end of this statement | ||
| | ||
= note: borrowed value must be valid for the static lifetime... | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0716`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
error[E0716]: temporary value dropped while borrowed | ||
--> $DIR/union_promotion.rs:19:29 | ||
| | ||
LL | let x: &'static bool = &unsafe { //~ borrowed value does not live long enough | ||
| _____________________________^ | ||
LL | | Foo { a: &1 }.b == Foo { a: &2 }.b | ||
LL | | }; | ||
| |_____^ creates a temporary which is freed while still in use | ||
LL | } | ||
| - temporary value is freed at the end of this statement | ||
| | ||
= note: borrowed value must be valid for the static lifetime... | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0716`. |
Oops, something went wrong.