parent
ae366637fe
commit
5fc0b743d7
59 changed files with 848 additions and 188 deletions
|
@ -694,9 +694,9 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
|
|||
|
||||
let tcx = self.infcx.tcx;
|
||||
let mut err =
|
||||
tcx.path_does_not_live_long_enough(proper_span, "borrowed value", Origin::Mir);
|
||||
err.span_label(proper_span, "temporary value does not live long enough");
|
||||
err.span_label(drop_span, "temporary value only lives until here");
|
||||
tcx.temporary_value_borrowed_for_too_long(proper_span, Origin::Mir);
|
||||
err.span_label(proper_span, "creates a temporary which is freed while still in use");
|
||||
err.span_label(drop_span, "temporary value is freed at the end of this statement");
|
||||
|
||||
let explanation = self.explain_why_borrow_contains_point(context, borrow, None);
|
||||
match explanation {
|
||||
|
|
|
@ -2261,7 +2261,92 @@ that after `demo` finishes excuting, something else (such as the
|
|||
destructor!) could access `s.data` after the end of that shorter
|
||||
lifetime, which would again violate the `&mut`-borrow's exclusive
|
||||
access.
|
||||
"##,
|
||||
|
||||
E0714: r##"
|
||||
This error indicates that a temporary value is being dropped
|
||||
while a borrow is still in active use.
|
||||
|
||||
Erroneous code example:
|
||||
|
||||
```compile_fail,E0714
|
||||
# #![feature(nll)]
|
||||
fn foo() -> i32 { 22 }
|
||||
fn bar(x: &i32) -> &i32 { x }
|
||||
let p = bar(&foo());
|
||||
// ------ creates a temporary
|
||||
let q = *p;
|
||||
```
|
||||
|
||||
Here, the expression `&foo()` is borrowing the expression
|
||||
`foo()`. As `foo()` is call to a function, and not the name of
|
||||
a variable, this creates a **temporary** -- that temporary stores
|
||||
the return value from `foo()` so that it can be borrowed.
|
||||
So you might imagine that `let p = bar(&foo())` is equivalent
|
||||
to this:
|
||||
|
||||
```compile_fail,E0597
|
||||
# fn foo() -> i32 { 22 }
|
||||
# fn bar(x: &i32) -> &i32 { x }
|
||||
let p = {
|
||||
let tmp = foo(); // the temporary
|
||||
bar(&tmp)
|
||||
}; // <-- tmp is freed as we exit this block
|
||||
let q = p;
|
||||
```
|
||||
|
||||
Whenever a temporary is created, it is automatically dropped (freed)
|
||||
according to fixed rules. Ordinarily, the temporary is dropped
|
||||
at the end of the enclosing statement -- in this case, after the `let`.
|
||||
This is illustrated in the example above by showing that `tmp` would
|
||||
be freed as we exit the block.
|
||||
|
||||
To fix this problem, you need to create a local variable
|
||||
to store the value in rather than relying on a temporary.
|
||||
For example, you might change the original program to
|
||||
the following:
|
||||
|
||||
```
|
||||
fn foo() -> i32 { 22 }
|
||||
fn bar(x: &i32) -> &i32 { x }
|
||||
let value = foo(); // dropped at the end of the enclosing block
|
||||
let p = bar(&value);
|
||||
let q = *p;
|
||||
```
|
||||
|
||||
By introducing the explicit `let value`, we allocate storage
|
||||
that will last until the end of the enclosing block (when `value`
|
||||
goes out of scope). When we borrow `&value`, we are borrowing a
|
||||
local variable that already exists, and hence no temporary is created.
|
||||
|
||||
Temporaries are not always dropped at the end of the enclosing
|
||||
statement. In simple cases where the `&` expression is immediately
|
||||
stored into a variable, the compiler will automatically extend
|
||||
the lifetime of the temporary until the end of the enclosinb
|
||||
block. Therefore, an alternative way to fix the original
|
||||
program is to write `let tmp = &foo()` and not `let tmp = foo()`:
|
||||
|
||||
```
|
||||
fn foo() -> i32 { 22 }
|
||||
fn bar(x: &i32) -> &i32 { x }
|
||||
let value = &foo();
|
||||
let p = bar(value);
|
||||
let q = *p;
|
||||
```
|
||||
|
||||
Here, we are still borrowing `foo()`, but as the borrow is assigned
|
||||
directly into a variable, the temporary will not be dropped until
|
||||
the end of the enclosing block. Similar rules apply when temporaries
|
||||
are stored into aggregate structures like a tuple or struct:
|
||||
|
||||
```
|
||||
// Here, two temporaries are created, but
|
||||
// as they are stored directly into `value`,
|
||||
// they are not dropped until the end of the
|
||||
// enclosing block.
|
||||
fn foo() -> i32 { 22 }
|
||||
let value = (&foo(), &foo());
|
||||
```
|
||||
"##,
|
||||
|
||||
}
|
||||
|
|
|
@ -730,6 +730,22 @@ pub trait BorrowckErrors<'cx>: Sized + Copy {
|
|||
|
||||
self.cancel_if_wrong_origin(err, o)
|
||||
}
|
||||
|
||||
fn temporary_value_borrowed_for_too_long(
|
||||
self,
|
||||
span: Span,
|
||||
o: Origin,
|
||||
) -> DiagnosticBuilder<'cx> {
|
||||
let err = struct_span_err!(
|
||||
self,
|
||||
span,
|
||||
E0714,
|
||||
"temporary value dropped while borrowed{OGN}",
|
||||
OGN = o
|
||||
);
|
||||
|
||||
self.cancel_if_wrong_origin(err, o)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'cx, 'gcx, 'tcx> BorrowckErrors<'cx> for TyCtxt<'cx, 'gcx, 'tcx> {
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
error[E0714]: 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 E0714`.
|
|
@ -1,10 +1,10 @@
|
|||
error[E0597]: borrowed value does not live long enough
|
||||
error[E0714]: temporary value dropped while borrowed
|
||||
--> $DIR/borrowck-borrowed-uniq-rvalue-2.rs:32:20
|
||||
|
|
||||
LL | let x = defer(&vec!["Goodbye", "world!"]);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ - temporary value only lives until here
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ - temporary value is freed at the end of this statement
|
||||
| |
|
||||
| temporary value does not live long enough
|
||||
| creates a temporary which is freed while still in use
|
||||
LL | x.x[0];
|
||||
| ------ borrow later used here
|
||||
|
|
||||
|
@ -13,4 +13,4 @@ LL | x.x[0];
|
|||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0597`.
|
||||
For more information about this error, try `rustc --explain E0714`.
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
error[E0597]: borrowed value does not live long enough
|
||||
error[E0714]: temporary value dropped while borrowed
|
||||
--> $DIR/borrowck-borrowed-uniq-rvalue.rs:20:28
|
||||
|
|
||||
LL | buggy_map.insert(42, &*Box::new(1)); //~ ERROR borrowed value does not live long enough
|
||||
| ^^^^^^^^^^^ - temporary value only lives until here
|
||||
| ^^^^^^^^^^^ - temporary value is freed at the end of this statement
|
||||
| |
|
||||
| temporary value does not live long enough
|
||||
| creates a temporary which is freed while still in use
|
||||
...
|
||||
LL | buggy_map.insert(43, &*tmp);
|
||||
| --------- borrow later used here
|
||||
|
@ -13,4 +13,4 @@ LL | buggy_map.insert(43, &*tmp);
|
|||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0597`.
|
||||
For more information about this error, try `rustc --explain E0714`.
|
||||
|
|
|
@ -1,57 +1,57 @@
|
|||
error[E0597]: borrowed value does not live long enough
|
||||
error[E0714]: 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[E0714]: 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[E0714]: 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[E0714]: 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[E0714]: 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 E0714`.
|
||||
|
|
|
@ -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[E0714]: 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[E0714]: 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[E0714]: 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 E0714`.
|
|
@ -0,0 +1,24 @@
|
|||
error[E0714]: 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[E0714]: 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 E0714`.
|
|
@ -0,0 +1,35 @@
|
|||
error[E0714]: 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[E0714]: 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[E0714]: 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 E0714`.
|
|
@ -0,0 +1,14 @@
|
|||
error[E0714]: 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 E0714`.
|
16
src/test/ui/consts/const-eval/union_promotion.nll.stderr
Normal file
16
src/test/ui/consts/const-eval/union_promotion.nll.stderr
Normal file
|
@ -0,0 +1,16 @@
|
|||
error[E0714]: 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 E0714`.
|
80
src/test/ui/consts/const-int-conversion.nll.stderr
Normal file
80
src/test/ui/consts/const-int-conversion.nll.stderr
Normal file
|
@ -0,0 +1,80 @@
|
|||
error[E0714]: temporary value dropped while borrowed
|
||||
--> $DIR/const-int-conversion.rs:14:28
|
||||
|
|
||||
LL | let x: &'static i32 = &(5_i32.reverse_bits());
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^ 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[E0714]: temporary value dropped while borrowed
|
||||
--> $DIR/const-int-conversion.rs:16:28
|
||||
|
|
||||
LL | let y: &'static i32 = &(i32::from_be_bytes([0x12, 0x34, 0x56, 0x78]));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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[E0714]: temporary value dropped while borrowed
|
||||
--> $DIR/const-int-conversion.rs:18:28
|
||||
|
|
||||
LL | let z: &'static i32 = &(i32::from_le_bytes([0x12, 0x34, 0x56, 0x78]));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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[E0714]: temporary value dropped while borrowed
|
||||
--> $DIR/const-int-conversion.rs:20:28
|
||||
|
|
||||
LL | let a: &'static i32 = &(i32::from_be(i32::from_ne_bytes([0x80, 0, 0, 0])));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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[E0714]: temporary value dropped while borrowed
|
||||
--> $DIR/const-int-conversion.rs:22:29
|
||||
|
|
||||
LL | let b: &'static [u8] = &(0x12_34_56_78_i32.to_be_bytes());
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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[E0714]: temporary value dropped while borrowed
|
||||
--> $DIR/const-int-conversion.rs:24:29
|
||||
|
|
||||
LL | let c: &'static [u8] = &(0x12_34_56_78_i32.to_le_bytes());
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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[E0714]: temporary value dropped while borrowed
|
||||
--> $DIR/const-int-conversion.rs:26:29
|
||||
|
|
||||
LL | let d: &'static [u8] = &(i32::min_value().to_be().to_ne_bytes());
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use
|
||||
LL | //~^ 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: aborting due to 7 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0714`.
|
35
src/test/ui/consts/const-int-overflowing.nll.stderr
Normal file
35
src/test/ui/consts/const-int-overflowing.nll.stderr
Normal file
|
@ -0,0 +1,35 @@
|
|||
error[E0714]: temporary value dropped while borrowed
|
||||
--> $DIR/const-int-overflowing.rs:12:36
|
||||
|
|
||||
LL | let x: &'static (i32, bool) = &(5_i32.overflowing_add(3)); //~ 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[E0714]: temporary value dropped while borrowed
|
||||
--> $DIR/const-int-overflowing.rs:13:36
|
||||
|
|
||||
LL | let y: &'static (i32, bool) = &(5_i32.overflowing_sub(3)); //~ ERROR does not live long enough
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use
|
||||
LL | let z: &'static (i32, bool) = &(5_i32.overflowing_mul(3)); //~ 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[E0714]: temporary value dropped while borrowed
|
||||
--> $DIR/const-int-overflowing.rs:14:36
|
||||
|
|
||||
LL | let z: &'static (i32, bool) = &(5_i32.overflowing_mul(3)); //~ 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 E0714`.
|
24
src/test/ui/consts/const-int-rotate.nll.stderr
Normal file
24
src/test/ui/consts/const-int-rotate.nll.stderr
Normal file
|
@ -0,0 +1,24 @@
|
|||
error[E0714]: temporary value dropped while borrowed
|
||||
--> $DIR/const-int-rotate.rs:12:28
|
||||
|
|
||||
LL | let x: &'static i32 = &(5_i32.rotate_left(3)); //~ ERROR does not live long enough
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use
|
||||
LL | let y: &'static i32 = &(5_i32.rotate_right(3)); //~ 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[E0714]: temporary value dropped while borrowed
|
||||
--> $DIR/const-int-rotate.rs:13:28
|
||||
|
|
||||
LL | let y: &'static i32 = &(5_i32.rotate_right(3)); //~ 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 E0714`.
|
24
src/test/ui/consts/const-int-sign.nll.stderr
Normal file
24
src/test/ui/consts/const-int-sign.nll.stderr
Normal file
|
@ -0,0 +1,24 @@
|
|||
error[E0714]: temporary value dropped while borrowed
|
||||
--> $DIR/const-int-sign.rs:12:29
|
||||
|
|
||||
LL | let x: &'static bool = &(5_i32.is_negative()); //~ ERROR does not live long enough
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use
|
||||
LL | let y: &'static bool = &(5_i32.is_positive()); //~ 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[E0714]: temporary value dropped while borrowed
|
||||
--> $DIR/const-int-sign.rs:13:29
|
||||
|
|
||||
LL | let y: &'static bool = &(5_i32.is_positive()); //~ 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 E0714`.
|
57
src/test/ui/consts/const-int-wrapping.nll.stderr
Normal file
57
src/test/ui/consts/const-int-wrapping.nll.stderr
Normal file
|
@ -0,0 +1,57 @@
|
|||
error[E0714]: temporary value dropped while borrowed
|
||||
--> $DIR/const-int-wrapping.rs:12:28
|
||||
|
|
||||
LL | let x: &'static i32 = &(5_i32.wrapping_add(3)); //~ 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[E0714]: temporary value dropped while borrowed
|
||||
--> $DIR/const-int-wrapping.rs:13:28
|
||||
|
|
||||
LL | let y: &'static i32 = &(5_i32.wrapping_sub(3)); //~ 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[E0714]: temporary value dropped while borrowed
|
||||
--> $DIR/const-int-wrapping.rs:14:28
|
||||
|
|
||||
LL | let z: &'static i32 = &(5_i32.wrapping_mul(3)); //~ 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[E0714]: temporary value dropped while borrowed
|
||||
--> $DIR/const-int-wrapping.rs:15:28
|
||||
|
|
||||
LL | let a: &'static i32 = &(5_i32.wrapping_shl(3)); //~ ERROR does not live long enough
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use
|
||||
LL | let b: &'static i32 = &(5_i32.wrapping_shr(3)); //~ 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[E0714]: temporary value dropped while borrowed
|
||||
--> $DIR/const-int-wrapping.rs:16:28
|
||||
|
|
||||
LL | let b: &'static i32 = &(5_i32.wrapping_shr(3)); //~ 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 5 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0714`.
|
|
@ -190,13 +190,13 @@ error: trait bounds other than `Sized` on const fn parameters are unstable
|
|||
LL | const fn no_dyn_trait_ret() -> &'static dyn std::fmt::Debug { &() }
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0597]: borrowed value does not live long enough
|
||||
error[E0714]: temporary value dropped while borrowed
|
||||
--> $DIR/min_const_fn.rs:144:64
|
||||
|
|
||||
LL | const fn no_dyn_trait_ret() -> &'static dyn std::fmt::Debug { &() }
|
||||
| ^^ - temporary value only lives until here
|
||||
| ^^ - temporary value is freed at the end of this statement
|
||||
| |
|
||||
| temporary value does not live long enough
|
||||
| creates a temporary which is freed while still in use
|
||||
|
|
||||
= note: borrowed value must be valid for the static lifetime...
|
||||
|
||||
|
@ -220,5 +220,5 @@ LL | const fn no_fn_ptrs2() -> fn() { fn foo() {} foo }
|
|||
|
||||
error: aborting due to 36 previous errors
|
||||
|
||||
Some errors occurred: E0493, E0597.
|
||||
Some errors occurred: E0493, E0714.
|
||||
For more information about an error, try `rustc --explain E0493`.
|
||||
|
|
|
@ -10,16 +10,16 @@ error: trait bounds other than `Sized` on const fn parameters are unstable
|
|||
LL | const fn no_inner_dyn_trait_ret() -> Hide { Hide(HasDyn { field: &0 }) }
|
||||
| ^^
|
||||
|
||||
error[E0597]: borrowed value does not live long enough
|
||||
error[E0714]: temporary value dropped while borrowed
|
||||
--> $DIR/min_const_fn_dyn.rs:24:67
|
||||
|
|
||||
LL | const fn no_inner_dyn_trait_ret() -> Hide { Hide(HasDyn { field: &0 }) }
|
||||
| ^ - temporary value only lives until here
|
||||
| ^ - temporary value is freed at the end of this statement
|
||||
| |
|
||||
| temporary value does not live long enough
|
||||
| creates a temporary which is freed while still in use
|
||||
|
|
||||
= 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 E0597`.
|
||||
For more information about this error, try `rustc --explain E0714`.
|
||||
|
|
18
src/test/ui/issues/issue-11681.nll.stderr
Normal file
18
src/test/ui/issues/issue-11681.nll.stderr
Normal file
|
@ -0,0 +1,18 @@
|
|||
error[E0714]: temporary value dropped while borrowed
|
||||
--> $DIR/issue-11681.rs:22:20
|
||||
|
|
||||
LL | let testValue = &Test; //~ ERROR borrowed value does not live long enough
|
||||
| ^^^^ creates a temporary which is freed while still in use
|
||||
LL | return testValue;
|
||||
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 21:15...
|
||||
--> $DIR/issue-11681.rs:21:15
|
||||
|
|
||||
LL | fn createTest<'a>() -> &'a Test {
|
||||
| ^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0714`.
|
|
@ -1,10 +1,10 @@
|
|||
error[E0597]: borrowed value does not live long enough
|
||||
error[E0714]: temporary value dropped while borrowed
|
||||
--> $DIR/issue-17545.rs:17:10
|
||||
|
|
||||
LL | &id(()), //~ ERROR borrowed value does not live long enough
|
||||
| ^^^^^^ 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 lifetime 'a as defined on the function body at 15:12...
|
||||
--> $DIR/issue-17545.rs:15:12
|
||||
|
@ -14,4 +14,4 @@ LL | pub fn foo<'a, F: Fn(&'a ())>(bar: F) {
|
|||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0597`.
|
||||
For more information about this error, try `rustc --explain E0714`.
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
error[E0714]: temporary value dropped while borrowed
|
||||
--> $DIR/issue-17718-constants-not-static.rs:15:31
|
||||
|
|
||||
LL | fn foo() -> &'static usize { &id(FOO) }
|
||||
| ^^^^^^^ - temporary value is freed at the end of this statement
|
||||
| |
|
||||
| creates a temporary which is freed while still in use
|
||||
|
|
||||
= 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 E0714`.
|
|
@ -1,19 +1,19 @@
|
|||
error[E0597]: borrowed value does not live long enough
|
||||
error[E0714]: temporary value dropped while borrowed
|
||||
--> $DIR/issue-27592.rs:26:27
|
||||
|
|
||||
LL | write(|| format_args!("{}", String::from("Hello world")));
|
||||
| ^^^^ - temporary value only lives until here
|
||||
| ^^^^ - temporary value is freed at the end of this statement
|
||||
| |
|
||||
| temporary value does not live long enough
|
||||
| creates a temporary which is freed while still in use
|
||||
|
||||
error[E0597]: borrowed value does not live long enough
|
||||
error[E0714]: temporary value dropped while borrowed
|
||||
--> $DIR/issue-27592.rs:26:33
|
||||
|
|
||||
LL | write(|| format_args!("{}", String::from("Hello world")));
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^- temporary value only lives until here
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^- temporary value is freed at the end of this statement
|
||||
| |
|
||||
| temporary value does not live long enough
|
||||
| creates a temporary which is freed while still in use
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0597`.
|
||||
For more information about this error, try `rustc --explain E0714`.
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
error[E0597]: borrowed value does not live long enough
|
||||
error[E0714]: temporary value dropped while borrowed
|
||||
--> $DIR/issue-30438-a.rs:22:17
|
||||
|
|
||||
LL | return &Test { s: &self.s};
|
||||
| ^^^^^^^^^^^^^^^^^^- temporary value only lives until here
|
||||
| ^^^^^^^^^^^^^^^^^^- temporary value is freed at the end of this statement
|
||||
| |
|
||||
| temporary value does not live long enough
|
||||
| creates a temporary which is freed while still in use
|
||||
|
|
||||
note: borrowed value must be valid for the anonymous lifetime #1 defined on the method body at 21:5...
|
||||
--> $DIR/issue-30438-a.rs:21:5
|
||||
|
@ -17,4 +17,4 @@ LL | | }
|
|||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0597`.
|
||||
For more information about this error, try `rustc --explain E0714`.
|
||||
|
|
21
src/test/ui/issues/issue-30438-b.nll.stderr
Normal file
21
src/test/ui/issues/issue-30438-b.nll.stderr
Normal file
|
@ -0,0 +1,21 @@
|
|||
error[E0714]: temporary value dropped while borrowed
|
||||
--> $DIR/issue-30438-b.rs:23:10
|
||||
|
|
||||
LL | &Test { s: &self.s}
|
||||
| ^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use
|
||||
LL | //~^ ERROR: borrowed 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 anonymous lifetime #1 defined on the method body at 22:5...
|
||||
--> $DIR/issue-30438-b.rs:22:5
|
||||
|
|
||||
LL | / fn index(&self, _: usize) -> &Self::Output {
|
||||
LL | | &Test { s: &self.s}
|
||||
LL | | //~^ ERROR: borrowed value does not live long enough
|
||||
LL | | }
|
||||
| |_____^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0714`.
|
|
@ -1,10 +1,10 @@
|
|||
error[E0597]: borrowed value does not live long enough
|
||||
error[E0714]: temporary value dropped while borrowed
|
||||
--> $DIR/issue-36082.rs:23:19
|
||||
|
|
||||
LL | let val: &_ = x.borrow().0;
|
||||
| ^^^^^^^^^^ - temporary value only lives until here
|
||||
| ^^^^^^^^^^ - temporary value is freed at the end of this statement
|
||||
| |
|
||||
| temporary value does not live long enough
|
||||
| creates a temporary which is freed while still in use
|
||||
...
|
||||
LL | println!("{}", val);
|
||||
| --- borrow later used here
|
||||
|
@ -13,4 +13,4 @@ LL | println!("{}", val);
|
|||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0597`.
|
||||
For more information about this error, try `rustc --explain E0714`.
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
error[E0597]: borrowed value does not live long enough
|
||||
error[E0714]: temporary value dropped while borrowed
|
||||
--> $DIR/issue-36082.rs:23:19
|
||||
|
|
||||
LL | let val: &_ = x.borrow().0;
|
||||
| ^^^^^^^^^^ - temporary value only lives until here
|
||||
| ^^^^^^^^^^ - temporary value is freed at the end of this statement
|
||||
| |
|
||||
| temporary value does not live long enough
|
||||
| creates a temporary which is freed while still in use
|
||||
...
|
||||
LL | println!("{}", val);
|
||||
| --- borrow later used here
|
||||
|
@ -13,4 +13,4 @@ LL | println!("{}", val);
|
|||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0597`.
|
||||
For more information about this error, try `rustc --explain E0714`.
|
||||
|
|
|
@ -25,9 +25,9 @@ fn main() {
|
|||
//[ast]~| NOTE temporary value dropped here while still borrowed
|
||||
//[ast]~| NOTE temporary value does not live long enough
|
||||
//[ast]~| NOTE consider using a `let` binding to increase its lifetime
|
||||
//[mir]~^^^^^ ERROR borrowed value does not live long enough [E0597]
|
||||
//[mir]~| NOTE temporary value does not live long enough
|
||||
//[mir]~| NOTE temporary value only lives until here
|
||||
//[mir]~^^^^^ ERROR temporary value dropped while borrowed [E0714]
|
||||
//[mir]~| NOTE temporary value is freed at the end of this statement
|
||||
//[mir]~| NOTE creates a temporary which is freed while still in use
|
||||
//[mir]~| NOTE consider using a `let` binding to create a longer lived value
|
||||
println!("{}", val);
|
||||
//[mir]~^ borrow later used here
|
||||
|
|
13
src/test/ui/issues/issue-44373.nll.stderr
Normal file
13
src/test/ui/issues/issue-44373.nll.stderr
Normal file
|
@ -0,0 +1,13 @@
|
|||
error[E0714]: temporary value dropped while borrowed
|
||||
--> $DIR/issue-44373.rs:15:42
|
||||
|
|
||||
LL | let _val: &'static [&'static u32] = &[&FOO]; //~ ERROR borrowed value 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 previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0714`.
|
|
@ -13,7 +13,7 @@
|
|||
fn bar<'a>() -> &'a mut u32 {
|
||||
&mut 4
|
||||
//~^ ERROR borrowed value does not live long enough (Ast) [E0597]
|
||||
//~| ERROR borrowed value does not live long enough (Mir) [E0597]
|
||||
//~| ERROR temporary value dropped while borrowed (Mir) [E0714]
|
||||
}
|
||||
|
||||
fn main() { }
|
||||
|
|
|
@ -13,14 +13,14 @@ note: borrowed value must be valid for the lifetime 'a as defined on the functio
|
|||
LL | fn bar<'a>() -> &'a mut u32 {
|
||||
| ^^
|
||||
|
||||
error[E0597]: borrowed value does not live long enough (Mir)
|
||||
error[E0714]: temporary value dropped while borrowed (Mir)
|
||||
--> $DIR/issue-46472.rs:14:10
|
||||
|
|
||||
LL | &mut 4
|
||||
| ^ 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 lifetime 'a as defined on the function body at 13:8...
|
||||
--> $DIR/issue-46472.rs:13:8
|
||||
|
@ -30,4 +30,5 @@ LL | fn bar<'a>() -> &'a mut u32 {
|
|||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0597`.
|
||||
Some errors occurred: E0597, E0714.
|
||||
For more information about an error, try `rustc --explain E0597`.
|
||||
|
|
|
@ -12,5 +12,5 @@
|
|||
|
||||
fn main() {
|
||||
let _vec: Vec<&'static String> = vec![&String::new()];
|
||||
//~^ ERROR borrowed value does not live long enough [E0597]
|
||||
//~^ ERROR temporary value dropped while borrowed [E0714]
|
||||
}
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
error[E0597]: borrowed value does not live long enough
|
||||
error[E0714]: temporary value dropped while borrowed
|
||||
--> $DIR/issue-47184.rs:14:44
|
||||
|
|
||||
LL | let _vec: Vec<&'static String> = vec![&String::new()];
|
||||
| ^^^^^^^^^^^^^ - temporary value only lives until here
|
||||
| ^^^^^^^^^^^^^ - temporary value is freed at the end of this statement
|
||||
| |
|
||||
| temporary value does not live long enough
|
||||
| creates a temporary which is freed while still in use
|
||||
|
|
||||
= 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 E0597`.
|
||||
For more information about this error, try `rustc --explain E0714`.
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
error[E0597]: borrowed value does not live long enough
|
||||
error[E0714]: temporary value dropped while borrowed
|
||||
--> $DIR/issue-52049.rs:16:10
|
||||
|
|
||||
LL | foo(&unpromotable(5u32));
|
||||
| ^^^^^^^^^^^^^^^^^^ 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 previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0597`.
|
||||
For more information about this error, try `rustc --explain E0714`.
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
error[E0597]: borrowed value does not live long enough
|
||||
error[E0714]: temporary value dropped while borrowed
|
||||
--> $DIR/borrowck-let-suggestion.rs:12:17
|
||||
|
|
||||
LL | let mut x = vec![1].iter();
|
||||
| ^^^^^^^ - temporary value only lives until here
|
||||
| ^^^^^^^ - temporary value is freed at the end of this statement
|
||||
| |
|
||||
| temporary value does not live long enough
|
||||
| creates a temporary which is freed while still in use
|
||||
LL | //~^ ERROR borrowed value does not live long enough
|
||||
LL | x.use_mut();
|
||||
| - borrow later used here
|
||||
|
@ -14,4 +14,4 @@ LL | x.use_mut();
|
|||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0597`.
|
||||
For more information about this error, try `rustc --explain E0714`.
|
||||
|
|
|
@ -18,7 +18,7 @@ fn main() {
|
|||
let x = gimme({
|
||||
let v = 22;
|
||||
&(v,)
|
||||
//~^ ERROR borrowed value does not live long enough [E0597]
|
||||
//~^ ERROR temporary value dropped while borrowed [E0714]
|
||||
});
|
||||
println!("{:?}", x);
|
||||
}
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
error[E0597]: borrowed value does not live long enough
|
||||
error[E0714]: temporary value dropped while borrowed
|
||||
--> $DIR/borrowed-temporary-error.rs:20:10
|
||||
|
|
||||
LL | &(v,)
|
||||
| ^^^^ temporary value does not live long enough
|
||||
LL | //~^ ERROR borrowed value does not live long enough [E0597]
|
||||
| ^^^^ creates a temporary which is freed while still in use
|
||||
LL | //~^ ERROR temporary value dropped while borrowed [E0714]
|
||||
LL | });
|
||||
| - temporary value only lives until here
|
||||
| - temporary value is freed at the end of this statement
|
||||
LL | println!("{:?}", x);
|
||||
| - borrow later used here
|
||||
|
|
||||
|
@ -13,4 +13,4 @@ LL | println!("{:?}", x);
|
|||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0597`.
|
||||
For more information about this error, try `rustc --explain E0714`.
|
||||
|
|
|
@ -18,7 +18,7 @@ fn gimme(x: &(u32,)) -> &u32 {
|
|||
fn foo<'a>(x: &'a (u32,)) -> &'a u32 {
|
||||
let v = 22;
|
||||
gimme(&(v,))
|
||||
//~^ ERROR borrowed value does not live long enough [E0597]
|
||||
//~^ ERROR temporary value dropped while borrowed [E0714]
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
error[E0597]: borrowed value does not live long enough
|
||||
error[E0714]: temporary value dropped while borrowed
|
||||
--> $DIR/borrowed-universal-error.rs:20:12
|
||||
|
|
||||
LL | gimme(&(v,))
|
||||
| ^^^^ temporary value does not live long enough
|
||||
LL | //~^ ERROR borrowed value does not live long enough [E0597]
|
||||
| ^^^^ creates a temporary which is freed while still in use
|
||||
LL | //~^ ERROR temporary value dropped while borrowed [E0714]
|
||||
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 lifetime 'a as defined on the function body at 18:8...
|
||||
--> $DIR/borrowed-universal-error.rs:18:8
|
||||
|
@ -15,4 +15,4 @@ LL | fn foo<'a>(x: &'a (u32,)) -> &'a u32 {
|
|||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0597`.
|
||||
For more information about this error, try `rustc --explain E0714`.
|
||||
|
|
|
@ -52,13 +52,13 @@ LL | }
|
|||
= note: functions cannot return a borrow to data owned within the function's scope, functions can only return borrows to data passed as arguments
|
||||
= note: to learn more, visit <https://doc.rust-lang.org/book/second-edition/ch04-02-references-and-borrowing.html#dangling-references>
|
||||
|
||||
error[E0597]: borrowed value does not live long enough
|
||||
error[E0714]: temporary value dropped while borrowed
|
||||
--> $DIR/issue-52534-1.rs:30:6
|
||||
|
|
||||
LL | &&x
|
||||
| ^^ 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 anonymous lifetime #1 defined on the function body at 28:1...
|
||||
--> $DIR/issue-52534-1.rs:28:1
|
||||
|
@ -137,4 +137,5 @@ LL | }
|
|||
|
||||
error: aborting due to 8 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0597`.
|
||||
Some errors occurred: E0597, E0714.
|
||||
For more information about an error, try `rustc --explain E0597`.
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
#![allow(dead_code)]
|
||||
|
||||
fn gimme_static_mut() -> &'static mut u32 {
|
||||
let ref mut x = 1234543; //~ ERROR borrowed value does not live long enough [E0597]
|
||||
let ref mut x = 1234543; //~ ERROR temporary value dropped while borrowed [E0714]
|
||||
x
|
||||
}
|
||||
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
error[E0597]: borrowed value does not live long enough
|
||||
error[E0714]: temporary value dropped while borrowed
|
||||
--> $DIR/return-ref-mut-issue-46557.rs:17:21
|
||||
|
|
||||
LL | let ref mut x = 1234543; //~ ERROR borrowed value does not live long enough [E0597]
|
||||
| ^^^^^^^ temporary value does not live long enough
|
||||
LL | let ref mut x = 1234543; //~ ERROR temporary value dropped while borrowed [E0714]
|
||||
| ^^^^^^^ 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: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0597`.
|
||||
For more information about this error, try `rustc --explain E0714`.
|
||||
|
|
|
@ -51,13 +51,13 @@ fn underscore_with_initializer() {
|
|||
let _: &'static u32 = &x; //~ ERROR
|
||||
|
||||
let _: Vec<&'static String> = vec![&String::new()];
|
||||
//~^ ERROR borrowed value does not live long enough [E0597]
|
||||
//~^ ERROR temporary value dropped while borrowed [E0714]
|
||||
|
||||
let (_, a): (Vec<&'static String>, _) = (vec![&String::new()], 44);
|
||||
//~^ ERROR borrowed value does not live long enough [E0597]
|
||||
//~^ ERROR temporary value dropped while borrowed [E0714]
|
||||
|
||||
let (_a, b): (Vec<&'static String>, _) = (vec![&String::new()], 44);
|
||||
//~^ ERROR borrowed value does not live long enough [E0597]
|
||||
//~^ ERROR temporary value dropped while borrowed [E0714]
|
||||
}
|
||||
|
||||
fn pair_underscores_with_initializer() {
|
||||
|
|
|
@ -40,33 +40,33 @@ LL | }
|
|||
|
|
||||
= note: borrowed value must be valid for the static lifetime...
|
||||
|
||||
error[E0597]: borrowed value does not live long enough
|
||||
error[E0714]: temporary value dropped while borrowed
|
||||
--> $DIR/patterns.rs:53:41
|
||||
|
|
||||
LL | let _: Vec<&'static String> = vec![&String::new()];
|
||||
| ^^^^^^^^^^^^^ - temporary value only lives until here
|
||||
| ^^^^^^^^^^^^^ - temporary value is freed at the end of this statement
|
||||
| |
|
||||
| temporary value does not live long enough
|
||||
| creates a temporary which is freed while still in use
|
||||
|
|
||||
= note: borrowed value must be valid for the static lifetime...
|
||||
|
||||
error[E0597]: borrowed value does not live long enough
|
||||
error[E0714]: temporary value dropped while borrowed
|
||||
--> $DIR/patterns.rs:56:52
|
||||
|
|
||||
LL | let (_, a): (Vec<&'static String>, _) = (vec![&String::new()], 44);
|
||||
| ^^^^^^^^^^^^^ - temporary value only lives until here
|
||||
| ^^^^^^^^^^^^^ - temporary value is freed at the end of this statement
|
||||
| |
|
||||
| temporary value does not live long enough
|
||||
| creates a temporary which is freed while still in use
|
||||
|
|
||||
= note: borrowed value must be valid for the static lifetime...
|
||||
|
||||
error[E0597]: borrowed value does not live long enough
|
||||
error[E0714]: temporary value dropped while borrowed
|
||||
--> $DIR/patterns.rs:59:53
|
||||
|
|
||||
LL | let (_a, b): (Vec<&'static String>, _) = (vec![&String::new()], 44);
|
||||
| ^^^^^^^^^^^^^ - temporary value only lives until here
|
||||
| ^^^^^^^^^^^^^ - temporary value is freed at the end of this statement
|
||||
| |
|
||||
| temporary value does not live long enough
|
||||
| creates a temporary which is freed while still in use
|
||||
|
|
||||
= note: borrowed value must be valid for the static lifetime...
|
||||
|
||||
|
@ -140,4 +140,5 @@ LL | let (y, _z): (&'static u32, u32) = (x, 44); //~ ERROR
|
|||
|
||||
error: aborting due to 14 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0597`.
|
||||
Some errors occurred: E0597, E0714.
|
||||
For more information about an error, try `rustc --explain E0597`.
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
error[E0597]: borrowed value does not live long enough
|
||||
error[E0714]: temporary value dropped while borrowed
|
||||
--> $DIR/regions-creating-enums.rs:33:17
|
||||
|
|
||||
LL | return &ast::num((*f)(x)); //~ ERROR borrowed value does not live long enough
|
||||
| ^^^^^^^^^^^^^^^^^- temporary value only lives until here
|
||||
| ^^^^^^^^^^^^^^^^^- temporary value is freed at the end of this statement
|
||||
| |
|
||||
| temporary value does not live long enough
|
||||
| creates a temporary which is freed while still in use
|
||||
|
|
||||
note: borrowed value must be valid for the lifetime 'a as defined on the function body at 30:13...
|
||||
--> $DIR/regions-creating-enums.rs:30:13
|
||||
|
@ -12,13 +12,13 @@ note: borrowed value must be valid for the lifetime 'a as defined on the functio
|
|||
LL | fn map_nums<'a,'b, F>(x: &ast, f: &mut F) -> &'a ast<'b> where F: FnMut(usize) -> usize {
|
||||
| ^^
|
||||
|
||||
error[E0597]: borrowed value does not live long enough
|
||||
error[E0714]: temporary value dropped while borrowed
|
||||
--> $DIR/regions-creating-enums.rs:38:17
|
||||
|
|
||||
LL | return &ast::add(m_x, m_y); //~ ERROR borrowed value does not live long enough
|
||||
| ^^^^^^^^^^^^^^^^^^- temporary value only lives until here
|
||||
| ^^^^^^^^^^^^^^^^^^- temporary value is freed at the end of this statement
|
||||
| |
|
||||
| temporary value does not live long enough
|
||||
| creates a temporary which is freed while still in use
|
||||
|
|
||||
note: borrowed value must be valid for the lifetime 'a as defined on the function body at 30:13...
|
||||
--> $DIR/regions-creating-enums.rs:30:13
|
||||
|
@ -28,4 +28,4 @@ LL | fn map_nums<'a,'b, F>(x: &ast, f: &mut F) -> &'a ast<'b> where F: FnMut(usi
|
|||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0597`.
|
||||
For more information about this error, try `rustc --explain E0714`.
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
error[E0597]: borrowed value does not live long enough
|
||||
error[E0714]: temporary value dropped while borrowed
|
||||
--> $DIR/regions-free-region-ordering-caller1.rs:19:27
|
||||
|
|
||||
LL | let z: &'a & usize = &(&y);
|
||||
| ^^^^ 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 lifetime 'a as defined on the function body at 15:10...
|
||||
--> $DIR/regions-free-region-ordering-caller1.rs:15:10
|
||||
|
@ -15,4 +15,4 @@ LL | fn call1<'a>(x: &'a usize) {
|
|||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0597`.
|
||||
For more information about this error, try `rustc --explain E0714`.
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
error[E0714]: temporary value dropped while borrowed
|
||||
--> $DIR/regions-lifetime-of-struct-or-enum-variant.rs:24:20
|
||||
|
|
||||
LL | let testValue = &id(Test);
|
||||
| ^^^^^^^^ 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 lifetime 'a as defined on the function body at 23:19...
|
||||
--> $DIR/regions-lifetime-of-struct-or-enum-variant.rs:23:19
|
||||
|
|
||||
LL | fn structLifetime<'a>() -> &'a Test {
|
||||
| ^^
|
||||
|
||||
error[E0714]: temporary value dropped while borrowed
|
||||
--> $DIR/regions-lifetime-of-struct-or-enum-variant.rs:30:20
|
||||
|
|
||||
LL | let testValue = &id(MyEnum::Variant1);
|
||||
| ^^^^^^^^^^^^^^^^^^^^ 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 lifetime 'a as defined on the function body at 29:20...
|
||||
--> $DIR/regions-lifetime-of-struct-or-enum-variant.rs:29:20
|
||||
|
|
||||
LL | fn variantLifetime<'a>() -> &'a MyEnum {
|
||||
| ^^
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0714`.
|
|
@ -1,22 +1,22 @@
|
|||
error[E0597]: borrowed value does not live long enough
|
||||
error[E0714]: temporary value dropped while borrowed
|
||||
--> $DIR/regions-ref-in-fn-arg.rs:14:13
|
||||
|
|
||||
LL | fn arg_item(box ref x: Box<isize>) -> &'static isize {
|
||||
| ^^^^^^^^^ temporary value does not live long enough
|
||||
| ^^^^^^^^^ creates a temporary which is freed while still in use
|
||||
LL | x //~^ ERROR borrowed value does not live long enough
|
||||
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[E0714]: temporary value dropped while borrowed
|
||||
--> $DIR/regions-ref-in-fn-arg.rs:21:11
|
||||
|
|
||||
LL | with(|box ref x| x) //~ ERROR borrowed value does not live long enough
|
||||
| ^^^^^^^^^ - temporary value only lives until here
|
||||
| ^^^^^^^^^ - temporary value is freed at the end of this statement
|
||||
| |
|
||||
| temporary value does not live long enough
|
||||
| creates a temporary which is freed while still in use
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0597`.
|
||||
For more information about this error, try `rustc --explain E0714`.
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
error[E0597]: borrowed value does not live long enough
|
||||
error[E0714]: temporary value dropped while borrowed
|
||||
--> $DIR/regions-ret.rs:14:13
|
||||
|
|
||||
LL | return &id(3); //~ ERROR borrowed value does not live long enough
|
||||
| ^^^^^- temporary value only lives until here
|
||||
| ^^^^^- temporary value is freed at the end of this statement
|
||||
| |
|
||||
| temporary value does not live long enough
|
||||
| creates a temporary which is freed while still in use
|
||||
|
|
||||
note: borrowed value must be valid for the anonymous lifetime #1 defined on the function body at 13:1...
|
||||
--> $DIR/regions-ret.rs:13:1
|
||||
|
@ -16,4 +16,4 @@ LL | | }
|
|||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0597`.
|
||||
For more information about this error, try `rustc --explain E0714`.
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
error[E0714]: temporary value dropped while borrowed
|
||||
--> $DIR/regions-return-stack-allocated-vec.rs:14:6
|
||||
|
|
||||
LL | &[x] //~ ERROR borrowed value 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 previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0714`.
|
|
@ -1,10 +1,10 @@
|
|||
error[E0597]: borrowed value does not live long enough
|
||||
error[E0714]: temporary value dropped while borrowed
|
||||
--> $DIR/regions-var-type-out-of-scope.rs:19:14
|
||||
|
|
||||
LL | x = &id(3); //~ ERROR borrowed value does not live long enough
|
||||
| ^^^^^- temporary value only lives until here
|
||||
| ^^^^^- temporary value is freed at the end of this statement
|
||||
| |
|
||||
| temporary value does not live long enough
|
||||
| creates a temporary which is freed while still in use
|
||||
LL | assert_eq!(*x, 3);
|
||||
| ------------------ borrow later used here
|
||||
|
|
||||
|
@ -13,4 +13,4 @@ LL | assert_eq!(*x, 3);
|
|||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0597`.
|
||||
For more information about this error, try `rustc --explain E0714`.
|
||||
|
|
|
@ -1,36 +1,36 @@
|
|||
error[E0597]: borrowed value does not live long enough
|
||||
error[E0714]: temporary value dropped while borrowed
|
||||
--> $DIR/borrowck-let-suggestion-suffixes.rs:28:14
|
||||
|
|
||||
LL | v3.push(&id('x')); // statement 6
|
||||
| ^^^^^^^ - temporary value only lives until here
|
||||
| ^^^^^^^ - temporary value is freed at the end of this statement
|
||||
| |
|
||||
| temporary value does not live long enough
|
||||
| creates a temporary which is freed while still in use
|
||||
...
|
||||
LL | (v1, v2, v3, /* v4 is above. */ v5).use_ref();
|
||||
| -- borrow later used here
|
||||
|
|
||||
= note: consider using a `let` binding to create a longer lived value
|
||||
|
||||
error[E0597]: borrowed value does not live long enough
|
||||
error[E0714]: temporary value dropped while borrowed
|
||||
--> $DIR/borrowck-let-suggestion-suffixes.rs:38:18
|
||||
|
|
||||
LL | v4.push(&id('y'));
|
||||
| ^^^^^^^ - temporary value only lives until here
|
||||
| ^^^^^^^ - temporary value is freed at the end of this statement
|
||||
| |
|
||||
| temporary value does not live long enough
|
||||
| creates a temporary which is freed while still in use
|
||||
...
|
||||
LL | v4.use_ref();
|
||||
| -- borrow later used here
|
||||
|
|
||||
= note: consider using a `let` binding to create a longer lived value
|
||||
|
||||
error[E0597]: borrowed value does not live long enough
|
||||
error[E0714]: temporary value dropped while borrowed
|
||||
--> $DIR/borrowck-let-suggestion-suffixes.rs:49:14
|
||||
|
|
||||
LL | v5.push(&id('z'));
|
||||
| ^^^^^^^ - temporary value only lives until here
|
||||
| ^^^^^^^ - temporary value is freed at the end of this statement
|
||||
| |
|
||||
| temporary value does not live long enough
|
||||
| creates a temporary which is freed while still in use
|
||||
...
|
||||
LL | (v1, v2, v3, /* v4 is above. */ v5).use_ref();
|
||||
| -- borrow later used here
|
||||
|
@ -39,4 +39,4 @@ LL | (v1, v2, v3, /* v4 is above. */ v5).use_ref();
|
|||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0597`.
|
||||
For more information about this error, try `rustc --explain E0714`.
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
error[E0597]: borrowed value does not live long enough
|
||||
error[E0714]: temporary value dropped while borrowed
|
||||
--> $DIR/issue-15480.rs:15:10
|
||||
|
|
||||
LL | &id(3)
|
||||
| ^^^^^ 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
|
||||
...
|
||||
LL | for &&x in &v {
|
||||
| -- borrow later used here
|
||||
|
@ -13,4 +13,4 @@ LL | for &&x in &v {
|
|||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0597`.
|
||||
For more information about this error, try `rustc --explain E0714`.
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
error[E0597]: borrowed value does not live long enough
|
||||
error[E0714]: temporary value dropped while borrowed
|
||||
--> $DIR/regions-close-over-borrowed-ref-in-obj.rs:22:27
|
||||
|
|
||||
LL | let ss: &isize = &id(1);
|
||||
| ^^^^^ 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
|
||||
LL | }
|
||||
| - borrow later used here, when `blah` is dropped
|
||||
|
|
||||
|
@ -13,4 +13,4 @@ LL | }
|
|||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0597`.
|
||||
For more information about this error, try `rustc --explain E0714`.
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
error[E0597]: borrowed value does not live long enough
|
||||
error[E0714]: temporary value dropped while borrowed
|
||||
--> $DIR/slice-borrow.rs:16:28
|
||||
|
|
||||
LL | let x: &[isize] = &vec![1, 2, 3, 4, 5];
|
||||
| ^^^^^^^^^^^^^^^^^^^ 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
|
||||
LL | y.use_ref();
|
||||
| - borrow later used here
|
||||
|
|
||||
|
@ -14,4 +14,4 @@ LL | y.use_ref();
|
|||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0597`.
|
||||
For more information about this error, try `rustc --explain E0714`.
|
||||
|
|
60
src/test/ui/static/static-drop-scope.nll.stderr
Normal file
60
src/test/ui/static/static-drop-scope.nll.stderr
Normal file
|
@ -0,0 +1,60 @@
|
|||
error[E0493]: destructors cannot be evaluated at compile-time
|
||||
--> $DIR/static-drop-scope.rs:19:60
|
||||
|
|
||||
LL | static PROMOTION_FAIL_S: Option<&'static WithDtor> = Some(&WithDtor);
|
||||
| ^^^^^^^^ statics cannot evaluate destructors
|
||||
|
||||
error[E0714]: temporary value dropped while borrowed
|
||||
--> $DIR/static-drop-scope.rs:19:60
|
||||
|
|
||||
LL | static PROMOTION_FAIL_S: Option<&'static WithDtor> = Some(&WithDtor);
|
||||
| ^^^^^^^^- temporary value is freed at the end of this statement
|
||||
| |
|
||||
| creates a temporary which is freed while still in use
|
||||
|
|
||||
= note: borrowed value must be valid for the static lifetime...
|
||||
|
||||
error[E0493]: destructors cannot be evaluated at compile-time
|
||||
--> $DIR/static-drop-scope.rs:23:59
|
||||
|
|
||||
LL | const PROMOTION_FAIL_C: Option<&'static WithDtor> = Some(&WithDtor);
|
||||
| ^^^^^^^^ constants cannot evaluate destructors
|
||||
|
||||
error[E0714]: temporary value dropped while borrowed
|
||||
--> $DIR/static-drop-scope.rs:23:59
|
||||
|
|
||||
LL | const PROMOTION_FAIL_C: Option<&'static WithDtor> = Some(&WithDtor);
|
||||
| ^^^^^^^^- temporary value is freed at the end of this statement
|
||||
| |
|
||||
| creates a temporary which is freed while still in use
|
||||
|
|
||||
= note: borrowed value must be valid for the static lifetime...
|
||||
|
||||
error[E0493]: destructors cannot be evaluated at compile-time
|
||||
--> $DIR/static-drop-scope.rs:27:28
|
||||
|
|
||||
LL | static EARLY_DROP_S: i32 = (WithDtor, 0).1;
|
||||
| ^^^^^^^^^^^^^ statics cannot evaluate destructors
|
||||
|
||||
error[E0493]: destructors cannot be evaluated at compile-time
|
||||
--> $DIR/static-drop-scope.rs:30:27
|
||||
|
|
||||
LL | const EARLY_DROP_C: i32 = (WithDtor, 0).1;
|
||||
| ^^^^^^^^^^^^^ constants cannot evaluate destructors
|
||||
|
||||
error[E0493]: destructors cannot be evaluated at compile-time
|
||||
--> $DIR/static-drop-scope.rs:33:24
|
||||
|
|
||||
LL | const fn const_drop<T>(_: T) {}
|
||||
| ^ constant functions cannot evaluate destructors
|
||||
|
||||
error[E0493]: destructors cannot be evaluated at compile-time
|
||||
--> $DIR/static-drop-scope.rs:37:5
|
||||
|
|
||||
LL | (x, ()).1
|
||||
| ^^^^^^^ constant functions cannot evaluate destructors
|
||||
|
||||
error: aborting due to 8 previous errors
|
||||
|
||||
Some errors occurred: E0493, E0714.
|
||||
For more information about an error, try `rustc --explain E0493`.
|
|
@ -1,10 +1,10 @@
|
|||
error[E0597]: borrowed value does not live long enough
|
||||
error[E0714]: temporary value dropped while borrowed
|
||||
--> $DIR/static-reference-to-fn-2.rs:28:22
|
||||
|
|
||||
LL | self_.statefn = &id(state2 as StateMachineFunc);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- temporary value only lives until here
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- temporary value is freed at the end of this statement
|
||||
| |
|
||||
| temporary value does not live long enough
|
||||
| creates a temporary which is freed while still in use
|
||||
|
|
||||
note: borrowed value must be valid for the anonymous lifetime #2 defined on the function body at 27:1...
|
||||
--> $DIR/static-reference-to-fn-2.rs:27:1
|
||||
|
@ -16,13 +16,13 @@ LL | | return Some("state1");
|
|||
LL | | }
|
||||
| |_^
|
||||
|
||||
error[E0597]: borrowed value does not live long enough
|
||||
error[E0714]: temporary value dropped while borrowed
|
||||
--> $DIR/static-reference-to-fn-2.rs:34:22
|
||||
|
|
||||
LL | self_.statefn = &id(state3 as StateMachineFunc);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- temporary value only lives until here
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- temporary value is freed at the end of this statement
|
||||
| |
|
||||
| temporary value does not live long enough
|
||||
| creates a temporary which is freed while still in use
|
||||
|
|
||||
note: borrowed value must be valid for the anonymous lifetime #2 defined on the function body at 33:1...
|
||||
--> $DIR/static-reference-to-fn-2.rs:33:1
|
||||
|
@ -34,13 +34,13 @@ LL | | return Some("state2");
|
|||
LL | | }
|
||||
| |_^
|
||||
|
||||
error[E0597]: borrowed value does not live long enough
|
||||
error[E0714]: temporary value dropped while borrowed
|
||||
--> $DIR/static-reference-to-fn-2.rs:40:22
|
||||
|
|
||||
LL | self_.statefn = &id(finished as StateMachineFunc);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- temporary value only lives until here
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- temporary value is freed at the end of this statement
|
||||
| |
|
||||
| temporary value does not live long enough
|
||||
| creates a temporary which is freed while still in use
|
||||
|
|
||||
note: borrowed value must be valid for the anonymous lifetime #2 defined on the function body at 39:1...
|
||||
--> $DIR/static-reference-to-fn-2.rs:39:1
|
||||
|
@ -52,17 +52,17 @@ LL | | return Some("state3");
|
|||
LL | | }
|
||||
| |_^
|
||||
|
||||
error[E0597]: borrowed value does not live long enough
|
||||
error[E0714]: temporary value dropped while borrowed
|
||||
--> $DIR/static-reference-to-fn-2.rs:51:19
|
||||
|
|
||||
LL | statefn: &id(state1 as StateMachineFunc)
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 4 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0597`.
|
||||
For more information about this error, try `rustc --explain E0714`.
|
||||
|
|
14
src/test/ui/static/static-region-bound.nll.stderr
Normal file
14
src/test/ui/static/static-region-bound.nll.stderr
Normal file
|
@ -0,0 +1,14 @@
|
|||
error[E0714]: temporary value dropped while borrowed
|
||||
--> $DIR/static-region-bound.rs:20:14
|
||||
|
|
||||
LL | let x = &id(3); //~ ERROR borrowed value does not live long enough
|
||||
| ^^^^^ creates a temporary which is freed while still in use
|
||||
LL | f(x);
|
||||
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 E0714`.
|
|
@ -1,10 +1,10 @@
|
|||
error[E0597]: borrowed value does not live long enough
|
||||
error[E0714]: temporary value dropped while borrowed
|
||||
--> $DIR/wf-misc-methods-issue-28609.rs:32:31
|
||||
|
|
||||
LL | s.transmute_inherent(&mut 42) //~ ERROR does not live long enough
|
||||
| ^^ 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 anonymous lifetime #1 defined on the function body at 30:1...
|
||||
--> $DIR/wf-misc-methods-issue-28609.rs:30:1
|
||||
|
@ -55,13 +55,13 @@ LL | | &*s
|
|||
LL | | }
|
||||
| |_^
|
||||
|
||||
error[E0597]: borrowed value does not live long enough
|
||||
error[E0714]: temporary value dropped while borrowed
|
||||
--> $DIR/wf-misc-methods-issue-28609.rs:63:15
|
||||
|
|
||||
LL | s << &mut 3 //~ ERROR does not live long enough
|
||||
| ^ 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 anonymous lifetime #1 defined on the function body at 61:1...
|
||||
--> $DIR/wf-misc-methods-issue-28609.rs:61:1
|
||||
|
@ -72,13 +72,13 @@ LL | | s << &mut 3 //~ ERROR does not live long enough
|
|||
LL | | }
|
||||
| |_^
|
||||
|
||||
error[E0597]: borrowed value does not live long enough
|
||||
error[E0714]: temporary value dropped while borrowed
|
||||
--> $DIR/wf-misc-methods-issue-28609.rs:68:16
|
||||
|
|
||||
LL | s.shl(&mut 3) //~ ERROR does not live long enough
|
||||
| ^ 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 anonymous lifetime #1 defined on the function body at 66:1...
|
||||
--> $DIR/wf-misc-methods-issue-28609.rs:66:1
|
||||
|
@ -89,13 +89,13 @@ LL | | s.shl(&mut 3) //~ ERROR does not live long enough
|
|||
LL | | }
|
||||
| |_^
|
||||
|
||||
error[E0597]: borrowed value does not live long enough
|
||||
error[E0714]: temporary value dropped while borrowed
|
||||
--> $DIR/wf-misc-methods-issue-28609.rs:73:21
|
||||
|
|
||||
LL | S2::shl(s, &mut 3) //~ ERROR does not live long enough
|
||||
| ^ 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 anonymous lifetime #1 defined on the function body at 71:1...
|
||||
--> $DIR/wf-misc-methods-issue-28609.rs:71:1
|
||||
|
@ -108,4 +108,5 @@ LL | | }
|
|||
|
||||
error: aborting due to 6 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0597`.
|
||||
Some errors occurred: E0597, E0714.
|
||||
For more information about an error, try `rustc --explain E0597`.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue