Rollup merge of #52617 - matthewjasper:remove-unused-code, r=nikomatsakis

Don't match on region kinds when reporting NLL errors

First half (by number of tests affected) of the changes to "does not live long enough".

Now that lexical MIR borrowck is gone, region kinds are always ReVar, so matching on them to change errors does nothing.

Changes "borrowed value only lives until here" to "`x` is dropped here while still borrowed".

r? @pnkfelix  cc @nikomatsakis
This commit is contained in:
Mark Rousskov 2018-07-26 09:18:26 -06:00 committed by GitHub
commit 2aeb76500e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
66 changed files with 135 additions and 198 deletions

View File

@ -14,7 +14,7 @@ use rustc::mir::{BindingForm, BorrowKind, ClearCrossCrate, Field, Local};
use rustc::mir::{LocalDecl, LocalKind, Location, Operand, Place};
use rustc::mir::{ProjectionElem, Rvalue, Statement, StatementKind};
use rustc::mir::VarBindingForm;
use rustc::ty::{self, RegionKind};
use rustc::ty;
use rustc_data_structures::indexed_vec::Idx;
use rustc_data_structures::sync::Lrc;
use syntax_pos::Span;
@ -427,34 +427,9 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
self.access_place_error_reported
.insert((root_place.clone(), borrow_span));
match (borrow.region, &self.describe_place(&borrow.borrowed_place)) {
(RegionKind::ReScope(_), Some(name)) => {
self.report_scoped_local_value_does_not_live_long_enough(
context,
name,
&scope_tree,
&borrow,
drop_span,
borrow_span,
proper_span,
);
}
(RegionKind::ReScope(_), None) => {
self.report_scoped_temporary_value_does_not_live_long_enough(
context,
&scope_tree,
&borrow,
drop_span,
borrow_span,
proper_span,
);
}
(RegionKind::ReEarlyBound(_), Some(name))
| (RegionKind::ReFree(_), Some(name))
| (RegionKind::ReStatic, Some(name))
| (RegionKind::ReEmpty, Some(name))
| (RegionKind::ReVar(_), Some(name)) => {
self.report_unscoped_local_value_does_not_live_long_enough(
match &self.describe_place(&borrow.borrowed_place) {
Some(name) => {
self.report_local_value_does_not_live_long_enough(
context,
name,
&scope_tree,
@ -465,12 +440,8 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
kind.map(|k| (k, place_span.0)),
);
}
(RegionKind::ReEarlyBound(_), None)
| (RegionKind::ReFree(_), None)
| (RegionKind::ReStatic, None)
| (RegionKind::ReEmpty, None)
| (RegionKind::ReVar(_), None) => {
self.report_unscoped_temporary_value_does_not_live_long_enough(
None => {
self.report_temporary_value_does_not_live_long_enough(
context,
&scope_tree,
&borrow,
@ -479,65 +450,10 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
proper_span,
);
}
(RegionKind::ReLateBound(_, _), _)
| (RegionKind::ReSkolemized(_, _), _)
| (RegionKind::ReClosureBound(_), _)
| (RegionKind::ReCanonical(_), _)
| (RegionKind::ReErased, _) => {
span_bug!(
drop_span,
"region {:?} does not make sense in this context",
borrow.region
);
}
}
}
fn report_scoped_local_value_does_not_live_long_enough(
&mut self,
context: Context,
name: &String,
_scope_tree: &Lrc<ScopeTree>,
borrow: &BorrowData<'tcx>,
drop_span: Span,
borrow_span: Span,
_proper_span: Span,
) {
let tcx = self.tcx;
let mut err =
tcx.path_does_not_live_long_enough(borrow_span, &format!("`{}`", name), Origin::Mir);
err.span_label(borrow_span, "borrowed value does not live long enough");
err.span_label(
drop_span,
format!("`{}` dropped here while still borrowed", name),
);
self.explain_why_borrow_contains_point(context, borrow, None, &mut err);
err.buffer(&mut self.errors_buffer);
}
fn report_scoped_temporary_value_does_not_live_long_enough(
&mut self,
context: Context,
_scope_tree: &Lrc<ScopeTree>,
borrow: &BorrowData<'tcx>,
drop_span: Span,
_borrow_span: Span,
proper_span: Span,
) {
let tcx = self.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 dropped here while still borrowed",
);
err.note("consider using a `let` binding to increase its lifetime");
self.explain_why_borrow_contains_point(context, borrow, None, &mut err);
err.buffer(&mut self.errors_buffer);
}
fn report_unscoped_local_value_does_not_live_long_enough(
fn report_local_value_does_not_live_long_enough(
&mut self,
context: Context,
name: &String,
@ -549,7 +465,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
kind_place: Option<(WriteKind, &Place<'tcx>)>,
) {
debug!(
"report_unscoped_local_value_does_not_live_long_enough(\
"report_local_value_does_not_live_long_enough(\
{:?}, {:?}, {:?}, {:?}, {:?}, {:?}\
)",
context, name, scope_tree, borrow, drop_span, borrow_span
@ -559,13 +475,16 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
let mut err =
tcx.path_does_not_live_long_enough(borrow_span, &format!("`{}`", name), Origin::Mir);
err.span_label(borrow_span, "borrowed value does not live long enough");
err.span_label(drop_span, "borrowed value only lives until here");
err.span_label(
drop_span,
format!("`{}` dropped here while still borrowed", name),
);
self.explain_why_borrow_contains_point(context, borrow, kind_place, &mut err);
err.buffer(&mut self.errors_buffer);
}
fn report_unscoped_temporary_value_does_not_live_long_enough(
fn report_temporary_value_does_not_live_long_enough(
&mut self,
context: Context,
scope_tree: &Lrc<ScopeTree>,
@ -575,7 +494,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
proper_span: Span,
) {
debug!(
"report_unscoped_temporary_value_does_not_live_long_enough(\
"report_temporary_value_does_not_live_long_enough(\
{:?}, {:?}, {:?}, {:?}, {:?}\
)",
context, scope_tree, borrow, drop_span, proper_span

View File

@ -5,7 +5,7 @@ LL | spawn(|| books.push(4));
| ^^^^^^^^^^^^^^^^ borrowed value does not live long enough
LL | //~^ ERROR E0373
LL | }
| - borrowed value only lives until here
| - `books` dropped here while still borrowed
|
= note: borrowed value must be valid for the static lifetime...

View File

@ -5,7 +5,7 @@ LL | Box::new(|| books.push(4))
| ^^^^^^^^^^^^^^^^ borrowed value does not live long enough
LL | //~^ ERROR E0373
LL | }
| - borrowed value only lives until here
| - `books` dropped here while still borrowed
|
note: borrowed value must be valid for the lifetime 'a as defined on the function body at 19:8...
--> $DIR/borrowck-escaping-closure-error-2.rs:19:8

View File

@ -7,7 +7,7 @@ LL | dt = Dt("dt", &c_shortest);
LL | }
| -
| |
| borrowed value only lives until here
| `c_shortest` dropped here while still borrowed
| borrow later used here, when `dt` is dropped
|
= note: values in a scope are dropped in the opposite order they are defined

View File

@ -7,7 +7,7 @@ LL | dt = Dt("dt", &c_shortest);
LL | }
| -
| |
| borrowed value only lives until here
| `c_shortest` dropped here while still borrowed
| borrow later used here, when `dt` is dropped
|
= note: values in a scope are dropped in the opposite order they are defined

View File

@ -7,7 +7,7 @@ LL | dt = Dt("dt", &c_shortest);
LL | }
| -
| |
| borrowed value only lives until here
| `c_shortest` dropped here while still borrowed
| borrow later used here, when `dt` is dropped
|
= note: values in a scope are dropped in the opposite order they are defined

View File

@ -7,7 +7,7 @@ LL | //~^ `y` does not live long enough [E0597]
LL | }
| -
| |
| borrowed value only lives until here
| `y` dropped here while still borrowed
| borrow later used here, when `x` is dropped
|
= note: values in a scope are dropped in the opposite order they are defined

View File

@ -5,7 +5,7 @@ LL | unsafe { (|| yield &a).resume() }
| ^^^^^^^^^^^^^ borrowed value does not live long enough
LL | //~^ ERROR: `a` does not live long enough
LL | };
| - borrowed value only lives until here
| - `a` dropped here while still borrowed
error[E0597]: `a` does not live long enough
--> $DIR/borrowing.rs:24:9
@ -16,7 +16,7 @@ LL | | //~^ ERROR: `a` does not live long enough
LL | | }
| |_________^ borrowed value does not live long enough
LL | };
| - borrowed value only lives until here
| - `a` dropped here while still borrowed
LL | }
| - borrow later used here, when `_b` is dropped

View File

@ -7,7 +7,7 @@ LL | let ref_ = Box::leak(Box::new(Some(cell.borrow_mut())));
LL | }
| -
| |
| borrowed value only lives until here
| `*cell` dropped here while still borrowed
| borrow later used here, when `gen` is dropped
|
= note: values in a scope are dropped in the opposite order they are defined
@ -26,7 +26,7 @@ LL | | };
LL | }
| -
| |
| borrowed value only lives until here
| `ref_` dropped here while still borrowed
| borrow later used here, when `gen` is dropped
|
= note: values in a scope are dropped in the opposite order they are defined

View File

@ -5,7 +5,7 @@ LL | a = &b;
| ^^ borrowed value does not live long enough
LL | //~^ ERROR `b` does not live long enough
LL | };
| - borrowed value only lives until here
| - `b` dropped here while still borrowed
error: aborting due to previous error

View File

@ -5,7 +5,7 @@ LL | let bb: &B = &*b; //~ ERROR does not live long enough
| ^^^ borrowed value does not live long enough
LL | make_a(bb)
LL | }
| - borrowed value only lives until here
| - `*b` dropped here while still borrowed
|
note: borrowed value must be valid for the lifetime 'a as defined on the function body at 36:16...
--> $DIR/issue-12470.rs:36:16

View File

@ -0,0 +1,18 @@
error[E0597]: `rawLines` does not live long enough
--> $DIR/issue-13497-2.rs:13:5
|
LL | rawLines //~ ERROR `rawLines` does not live long enough
| ^^^^^^^^ borrowed value does not live long enough
LL | .iter().map(|l| l.trim()).collect()
LL | }
| - `rawLines` dropped here while still borrowed
|
note: borrowed value must be valid for the lifetime 'a as defined on the function body at 11:24...
--> $DIR/issue-13497-2.rs:11:24
|
LL | fn read_lines_borrowed<'a>() -> Vec<&'a str> {
| ^^
error: aborting due to previous error
For more information about this error, try `rustc --explain E0597`.

View File

@ -5,7 +5,7 @@ LL | let a = &FOO;
| ^^^^ borrowed value does not live long enough
...
LL | }
| - borrowed value only lives until here
| - `FOO` dropped here while still borrowed
|
= note: borrowed value must be valid for the static lifetime...

View File

@ -5,7 +5,7 @@ LL | let a = &FOO;
| ^^^^ borrowed value does not live long enough
...
LL | }
| - borrowed value only lives until here
| - `FOO` dropped here while still borrowed
|
= note: borrowed value must be valid for the static lifetime...

View File

@ -29,5 +29,5 @@ fn main() {
println!("{}", a);
});
}
//[mir]~^ borrowed value only lives until here
//[mir]~^ `FOO` dropped here while still borrowed
//[ast]~^^ temporary value only lives until here

View File

@ -57,7 +57,7 @@ LL | &p //~ ERROR `p` does not live long enough
| ^^ borrowed value does not live long enough
LL | //~^ ERROR let bindings in constants are unstable
LL | };
| - borrowed value only lives until here
| - `p` dropped here while still borrowed
|
= note: borrowed value must be valid for the static lifetime...

View File

@ -5,7 +5,7 @@ LL | &x
| ^^ borrowed value does not live long enough
LL | //~^ ERROR: `x` does not live long enough
LL | }
| - borrowed value only lives until here
| - `x` dropped here while still borrowed
|
note: borrowed value must be valid for the lifetime 'y as defined on the function body at 17:10...
--> $DIR/issue-30438-c.rs:17:10

View File

@ -11,7 +11,7 @@ LL | id(Box::new(|| *v))
| ^^^^^ borrowed value does not live long enough
...
LL | }
| - borrowed value only lives until here
| - `v` dropped here while still borrowed
|
note: borrowed value must be valid for the lifetime 'r as defined on the function body at 15:6...
--> $DIR/issue-4335.rs:15:6

View File

@ -5,7 +5,7 @@ LL | let foo = Foo { x: &a }; //~ ERROR E0597
| ^^ borrowed value does not live long enough
LL | loop { }
LL | }
| - borrowed value only lives until here
| - `a` dropped here while still borrowed
|
= note: borrowed value must be valid for the static lifetime...

View File

@ -20,7 +20,7 @@ LL | | &mut z
LL | | };
| | -
| | |
| |_____borrowed value only lives until here
| |_____`z` dropped here while still borrowed
| borrow later used here
error: aborting due to 2 previous errors

View File

@ -16,7 +16,7 @@ LL | &x
| ^^ borrowed value does not live long enough
...
LL | }
| - borrowed value only lives until here
| - `x` dropped here while still borrowed
|
= note: borrowed value must be valid for the static lifetime...

View File

@ -8,7 +8,7 @@ LL | println!("accumulator before add_assign {:?}", acc.map);
| ------- borrow later used here
...
LL | }
| - borrowed value only lives until here
| - `line` dropped here while still borrowed
error: aborting due to previous error

View File

@ -10,7 +10,7 @@ LL | | //~^ ERROR `v` does not live long enough [E0597]
LL | | });
| |_____-- borrow later used here
| |
| borrowed value only lives until here
| `v` dropped here while still borrowed
error: aborting due to previous error

View File

@ -5,7 +5,7 @@ LL | &v
| ^^ borrowed value does not live long enough
LL | //~^ ERROR `v` does not live long enough [E0597]
LL | }
| - borrowed value only lives until here
| - `v` dropped here while still borrowed
|
note: borrowed value must be valid for the lifetime 'a as defined on the function body at 14:8...
--> $DIR/borrowed-universal-error-2.rs:14:8

View File

@ -5,7 +5,7 @@ LL | y: &y,
| ^^ borrowed value does not live long enough
...
LL | }
| - borrowed value only lives until here
| - `y` dropped here while still borrowed
LL |
LL | deref(p);
| - borrow later used here

View File

@ -30,7 +30,7 @@ LL | closure(&mut p, &y);
| ^^ borrowed value does not live long enough
LL | //~^ ERROR `y` does not live long enough [E0597]
LL | }
| - borrowed value only lives until here
| - `y` dropped here while still borrowed
LL |
LL | deref(p);
| - borrow later used here

View File

@ -57,7 +57,7 @@ LL | | };
| |_________^ borrowed value does not live long enough
...
LL | }
| - borrowed value only lives until here
| - `y` dropped here while still borrowed
LL |
LL | deref(p);
| - borrow later used here

View File

@ -34,7 +34,7 @@ LL | let mut closure = || p = &y;
| ^^^^^^^^^ borrowed value does not live long enough
...
LL | }
| - borrowed value only lives until here
| - `y` dropped here while still borrowed
LL |
LL | deref(p);
| - borrow later used here

View File

@ -82,7 +82,7 @@ LL | let cell = Cell::new(&a);
| ^^ borrowed value does not live long enough
...
LL | }
| - borrowed value only lives until here
| - `a` dropped here while still borrowed
|
= note: borrowed value must be valid for the static lifetime...

View File

@ -5,7 +5,7 @@ LL | let s_inner: &'a S = &*v.0; //~ ERROR `*v.0` does not live long enough
| ^^^^^ borrowed value does not live long enough
LL | &s_inner.0
LL | }
| - borrowed value only lives until here
| - `*v.0` dropped here while still borrowed
|
note: borrowed value must be valid for the lifetime 'a as defined on the function body at 21:17...
--> $DIR/issue-31567.rs:21:17

View File

@ -4,7 +4,7 @@ error[E0597]: `local` does not live long enough
LL | &local //~ ERROR `local` does not live long enough
| ^^^^^^ borrowed value does not live long enough
LL | }
| - borrowed value only lives until here
| - `local` dropped here while still borrowed
|
note: borrowed value must be valid for the lifetime 'a as defined on the impl at 23:6...
--> $DIR/issue-47470.rs:23:6

View File

@ -5,7 +5,7 @@ LL | let f = |t: bool| if t { x } else { y }; // (separate errors for `x
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ borrowed value does not live long enough
...
LL | };
| - borrowed value only lives until here
| - `x` dropped here while still borrowed
error[E0597]: `y` does not live long enough
--> $DIR/region-borrow-params-issue-29793-small.rs:19:17
@ -14,7 +14,7 @@ LL | let f = |t: bool| if t { x } else { y }; // (separate errors for `x
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ borrowed value does not live long enough
...
LL | };
| - borrowed value only lives until here
| - `y` dropped here while still borrowed
error[E0597]: `x` does not live long enough
--> $DIR/region-borrow-params-issue-29793-small.rs:34:17
@ -23,7 +23,7 @@ LL | let f = |t: bool| if t { x } else { y }; // (separate errors for `x
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ borrowed value does not live long enough
...
LL | };
| - borrowed value only lives until here
| - `x` dropped here while still borrowed
error[E0597]: `y` does not live long enough
--> $DIR/region-borrow-params-issue-29793-small.rs:34:17
@ -32,7 +32,7 @@ LL | let f = |t: bool| if t { x } else { y }; // (separate errors for `x
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ borrowed value does not live long enough
...
LL | };
| - borrowed value only lives until here
| - `y` dropped here while still borrowed
error[E0597]: `x` does not live long enough
--> $DIR/region-borrow-params-issue-29793-small.rs:65:17
@ -41,7 +41,7 @@ LL | let f = |t: bool| if t { x } else { y }; // (separate errors for `x
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ borrowed value does not live long enough
...
LL | };
| - borrowed value only lives until here
| - `x` dropped here while still borrowed
|
note: borrowed value must be valid for the lifetime 'a as defined on the function body at 64:10...
--> $DIR/region-borrow-params-issue-29793-small.rs:64:10
@ -56,7 +56,7 @@ LL | let f = |t: bool| if t { x } else { y }; // (separate errors for `x
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ borrowed value does not live long enough
...
LL | };
| - borrowed value only lives until here
| - `y` dropped here while still borrowed
|
note: borrowed value must be valid for the lifetime 'a as defined on the function body at 64:10...
--> $DIR/region-borrow-params-issue-29793-small.rs:64:10
@ -71,7 +71,7 @@ LL | let f = |t: bool| if t { x } else { y }; // (separate errors for `x
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ borrowed value does not live long enough
...
LL | };
| - borrowed value only lives until here
| - `x` dropped here while still borrowed
|
note: borrowed value must be valid for the lifetime 'a as defined on the function body at 75:10...
--> $DIR/region-borrow-params-issue-29793-small.rs:75:10
@ -86,7 +86,7 @@ LL | let f = |t: bool| if t { x } else { y }; // (separate errors for `x
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ borrowed value does not live long enough
...
LL | };
| - borrowed value only lives until here
| - `y` dropped here while still borrowed
|
note: borrowed value must be valid for the lifetime 'a as defined on the function body at 75:10...
--> $DIR/region-borrow-params-issue-29793-small.rs:75:10
@ -101,7 +101,7 @@ LL | let f = |t: bool| if t { x } else { y }; // (separate errors fo
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ borrowed value does not live long enough
...
LL | }
| - borrowed value only lives until here
| - `x` dropped here while still borrowed
|
note: borrowed value must be valid for the lifetime 'a as defined on the method body at 99:14...
--> $DIR/region-borrow-params-issue-29793-small.rs:99:14
@ -116,7 +116,7 @@ LL | let f = |t: bool| if t { x } else { y }; // (separate errors fo
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ borrowed value does not live long enough
...
LL | }
| - borrowed value only lives until here
| - `y` dropped here while still borrowed
|
note: borrowed value must be valid for the lifetime 'a as defined on the method body at 99:14...
--> $DIR/region-borrow-params-issue-29793-small.rs:99:14
@ -131,7 +131,7 @@ LL | let f = |t: bool| if t { x } else { y }; // (separate errors fo
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ borrowed value does not live long enough
...
LL | }
| - borrowed value only lives until here
| - `x` dropped here while still borrowed
|
note: borrowed value must be valid for the lifetime 'a as defined on the method body at 113:14...
--> $DIR/region-borrow-params-issue-29793-small.rs:113:14
@ -146,7 +146,7 @@ LL | let f = |t: bool| if t { x } else { y }; // (separate errors fo
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ borrowed value does not live long enough
...
LL | }
| - borrowed value only lives until here
| - `y` dropped here while still borrowed
|
note: borrowed value must be valid for the lifetime 'a as defined on the method body at 113:14...
--> $DIR/region-borrow-params-issue-29793-small.rs:113:14
@ -161,7 +161,7 @@ LL | let f = |t: bool| if t { x } else { y }; // (separate errors fo
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ borrowed value does not live long enough
...
LL | }
| - borrowed value only lives until here
| - `x` dropped here while still borrowed
|
note: borrowed value must be valid for the lifetime 'a as defined on the method body at 141:14...
--> $DIR/region-borrow-params-issue-29793-small.rs:141:14
@ -176,7 +176,7 @@ LL | let f = |t: bool| if t { x } else { y }; // (separate errors fo
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ borrowed value does not live long enough
...
LL | }
| - borrowed value only lives until here
| - `y` dropped here while still borrowed
|
note: borrowed value must be valid for the lifetime 'a as defined on the method body at 141:14...
--> $DIR/region-borrow-params-issue-29793-small.rs:141:14
@ -191,7 +191,7 @@ LL | let f = |t: bool| if t { x } else { y }; // (separate errors fo
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ borrowed value does not live long enough
...
LL | }
| - borrowed value only lives until here
| - `x` dropped here while still borrowed
|
note: borrowed value must be valid for the lifetime 'a as defined on the method body at 156:14...
--> $DIR/region-borrow-params-issue-29793-small.rs:156:14
@ -206,7 +206,7 @@ LL | let f = |t: bool| if t { x } else { y }; // (separate errors fo
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ borrowed value does not live long enough
...
LL | }
| - borrowed value only lives until here
| - `y` dropped here while still borrowed
|
note: borrowed value must be valid for the lifetime 'a as defined on the method body at 156:14...
--> $DIR/region-borrow-params-issue-29793-small.rs:156:14
@ -221,7 +221,7 @@ LL | let f = |t: bool| if t { x } else { y }; // (separate errors fo
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ borrowed value does not live long enough
...
LL | }
| - borrowed value only lives until here
| - `x` dropped here while still borrowed
|
note: borrowed value must be valid for the lifetime 'a as defined on the method body at 184:14...
--> $DIR/region-borrow-params-issue-29793-small.rs:184:14
@ -236,7 +236,7 @@ LL | let f = |t: bool| if t { x } else { y }; // (separate errors fo
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ borrowed value does not live long enough
...
LL | }
| - borrowed value only lives until here
| - `y` dropped here while still borrowed
|
note: borrowed value must be valid for the lifetime 'a as defined on the method body at 184:14...
--> $DIR/region-borrow-params-issue-29793-small.rs:184:14
@ -251,7 +251,7 @@ LL | let f = |t: bool| if t { x } else { y }; // (separate errors fo
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ borrowed value does not live long enough
...
LL | }
| - borrowed value only lives until here
| - `x` dropped here while still borrowed
|
note: borrowed value must be valid for the lifetime 'a as defined on the method body at 198:14...
--> $DIR/region-borrow-params-issue-29793-small.rs:198:14
@ -266,7 +266,7 @@ LL | let f = |t: bool| if t { x } else { y }; // (separate errors fo
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ borrowed value does not live long enough
...
LL | }
| - borrowed value only lives until here
| - `y` dropped here while still borrowed
|
note: borrowed value must be valid for the lifetime 'a as defined on the method body at 198:14...
--> $DIR/region-borrow-params-issue-29793-small.rs:198:14

View File

@ -7,7 +7,7 @@ LL | | if false { &y } else { z }
LL | | });
| |_________^ borrowed value does not live long enough
LL | }
| - borrowed value only lives until here
| - `y` dropped here while still borrowed
|
= note: borrowed value must be valid for the static lifetime...

View File

@ -4,7 +4,7 @@ error[E0597]: `*a` does not live long enough
LL | *a.borrow() + 1
| ^ borrowed value does not live long enough
LL | }; //~^ ERROR `*a` does not live long enough
| - borrowed value only lives until here
| - `*a` dropped here while still borrowed
error: aborting due to previous error

View File

@ -7,7 +7,7 @@ LL | assert_eq!(object_invoke1(&*m), (4,5));
LL | }
| -
| |
| borrowed value only lives until here
| `*m` dropped here while still borrowed
| borrow later used here, when `m` is dropped
|
= note: values in a scope are dropped in the opposite order they are defined

View File

@ -7,7 +7,7 @@ LL | b1.a[1].v.set(Some(&b3));
LL | }
| -
| |
| borrowed value only lives until here
| `b3` dropped here while still borrowed
| borrow later used here, when `b1` is dropped
error[E0597]: `b2` does not live long enough
@ -19,7 +19,7 @@ LL | b1.a[0].v.set(Some(&b2));
LL | }
| -
| |
| borrowed value only lives until here
| `b2` dropped here while still borrowed
| borrow later used here, when `b1` is dropped
error[E0597]: `b1` does not live long enough
@ -31,7 +31,7 @@ LL | b3.a[0].v.set(Some(&b1));
LL | }
| -
| |
| borrowed value only lives until here
| `b1` dropped here while still borrowed
| borrow later used here, when `b1` is dropped
error: aborting due to 3 previous errors

View File

@ -7,7 +7,7 @@ LL | d1.p.set(Some(&d2));
LL | }
| -
| |
| borrowed value only lives until here
| `d2` dropped here while still borrowed
| borrow later used here, when `d1` is dropped
|
= note: values in a scope are dropped in the opposite order they are defined
@ -21,7 +21,7 @@ LL | //~^ ERROR `d1` does not live long enough
LL | }
| -
| |
| borrowed value only lives until here
| `d1` dropped here while still borrowed
| borrow later used here, when `d1` is dropped
|
= note: values in a scope are dropped in the opposite order they are defined

View File

@ -6,7 +6,7 @@ LL | _w = Wrap::<&[&str]>(NoisyDrop(&bomb));
LL | }
| -
| |
| borrowed value only lives until here
| `bomb` dropped here while still borrowed
| borrow later used here, when `_w` is dropped
|
= note: values in a scope are dropped in the opposite order they are defined
@ -20,7 +20,7 @@ LL | let u = NoisyDrop(&v);
LL | }
| -
| |
| borrowed value only lives until here
| `v` dropped here while still borrowed
| borrow later used here, when `_w` is dropped
|
= note: values in a scope are dropped in the opposite order they are defined

View File

@ -7,7 +7,7 @@ LL | c1.v[1].v.set(Some(&c3));
LL | }
| -
| |
| borrowed value only lives until here
| `c3` dropped here while still borrowed
| borrow later used here, when `c1` is dropped
error[E0597]: `c2` does not live long enough
@ -19,7 +19,7 @@ LL | c1.v[0].v.set(Some(&c2));
LL | }
| -
| |
| borrowed value only lives until here
| `c2` dropped here while still borrowed
| borrow later used here, when `c1` is dropped
error[E0597]: `c1` does not live long enough
@ -31,7 +31,7 @@ LL | c3.v[0].v.set(Some(&c1));
LL | }
| -
| |
| borrowed value only lives until here
| `c1` dropped here while still borrowed
| borrow later used here, when `c1` is dropped
error: aborting due to 3 previous errors

View File

@ -4,7 +4,7 @@ error[E0597]: `x` does not live long enough
LL | let f = to_fn_once(move|| &x); //~ ERROR does not live long enough
| ^-
| ||
| |borrowed value only lives until here
| |`x` dropped here while still borrowed
| borrowed value does not live long enough
error: aborting due to previous error

View File

@ -4,7 +4,7 @@ error[E0597]: `y` does not live long enough
LL | y.borrow().clone()
| ^ borrowed value does not live long enough
LL | }
| - borrowed value only lives until here
| - `y` dropped here while still borrowed
error[E0597]: `y` does not live long enough
--> $DIR/issue-23338-locals-die-before-temps-of-body.rs:27:9
@ -12,7 +12,7 @@ error[E0597]: `y` does not live long enough
LL | y.borrow().clone()
| ^ borrowed value does not live long enough
LL | };
| - borrowed value only lives until here
| - `y` dropped here while still borrowed
error: aborting due to 2 previous errors

View File

@ -7,7 +7,7 @@ LL | _d = D_Child(&d1);
LL | }
| -
| |
| borrowed value only lives until here
| `d1` dropped here while still borrowed
| borrow later used here, when `_d` is dropped
|
= note: values in a scope are dropped in the opposite order they are defined

View File

@ -6,7 +6,7 @@ LL | _d = D_HasSelfMethod(&d1);
LL | }
| -
| |
| borrowed value only lives until here
| `d1` dropped here while still borrowed
| borrow later used here, when `_d` is dropped
|
= note: values in a scope are dropped in the opposite order they are defined
@ -19,7 +19,7 @@ LL | _d = D_HasMethodWithSelfArg(&d1);
LL | }
| -
| |
| borrowed value only lives until here
| `d1` dropped here while still borrowed
| borrow later used here, when `_d` is dropped
|
= note: values in a scope are dropped in the opposite order they are defined
@ -32,7 +32,7 @@ LL | _d = D_HasType(&d1);
LL | }
| -
| |
| borrowed value only lives until here
| `d1` dropped here while still borrowed
| borrow later used here, when `_d` is dropped
|
= note: values in a scope are dropped in the opposite order they are defined

View File

@ -6,7 +6,7 @@ LL | d2 = D(S(&d1, "inner"), "d2");
LL | }
| -
| |
| borrowed value only lives until here
| `d1` dropped here while still borrowed
| borrow later used here, when `d2` is dropped
|
= note: values in a scope are dropped in the opposite order they are defined

View File

@ -7,7 +7,7 @@ LL | let test = Test{test: &container};
LL | }
| -
| |
| borrowed value only lives until here
| `container` dropped here while still borrowed
| borrow later used here, when `container` is dropped
error: aborting due to previous error

View File

@ -6,7 +6,7 @@ LL | zook.button = B::BigRedButton(&ticking);
LL | }
| -
| |
| borrowed value only lives until here
| `ticking` dropped here while still borrowed
| borrow later used here, when `zook` is dropped
|
= note: values in a scope are dropped in the opposite order they are defined

View File

@ -6,7 +6,7 @@ LL | y = Arc::new(Foo(&x));
LL | }
| -
| |
| borrowed value only lives until here
| `x` dropped here while still borrowed
| borrow later used here, when `y` is dropped
error[E0597]: `x` does not live long enough
@ -17,7 +17,7 @@ LL | y = Rc::new(Foo(&x));
LL | }
| -
| |
| borrowed value only lives until here
| `x` dropped here while still borrowed
| borrow later used here, when `y` is dropped
error: aborting due to 2 previous errors

View File

@ -5,7 +5,7 @@ LL | p = &a;
| ^^^^^^ borrowed value does not live long enough
...
LL | }
| - borrowed value only lives until here
| - `a` dropped here while still borrowed
LL | p.use_ref();
| - borrow later used here

View File

@ -4,7 +4,7 @@ error[E0597]: `foo` does not live long enough
LL | {println!("{:?}", match { let foo = vec![1, 2]; foo.get(1) } { x => x });}
| ------------------------------^^^--------------------
| | | |
| | | borrowed value only lives until here
| | | `foo` dropped here while still borrowed
| | borrowed value does not live long enough
| borrow later used here

View File

@ -7,7 +7,7 @@ LL | foo.data[0].1.set(Some(&foo.data[1]));
LL | }
| -
| |
| borrowed value only lives until here
| `foo.data` dropped here while still borrowed
| borrow later used here, when `foo` is dropped
|
= note: values in a scope are dropped in the opposite order they are defined

View File

@ -7,7 +7,7 @@ LL | foo1 = Foo(1, &first_dropped);
LL | }
| -
| |
| borrowed value only lives until here
| `first_dropped` dropped here while still borrowed
| borrow later used here, when `foo1` is dropped
|
= note: values in a scope are dropped in the opposite order they are defined

View File

@ -7,7 +7,7 @@ LL | foo1 = Foo(1, &first_dropped, Box::new(callback));
LL | }
| -
| |
| borrowed value only lives until here
| `first_dropped` dropped here while still borrowed
| borrow later used here, when `foo1` is dropped
|
= note: values in a scope are dropped in the opposite order they are defined

View File

@ -7,7 +7,7 @@ LL | foo1 = Foo(1, &first_dropped);
LL | }
| -
| |
| borrowed value only lives until here
| `first_dropped` dropped here while still borrowed
| borrow later used here, when `foo1` is dropped
|
= note: values in a scope are dropped in the opposite order they are defined

View File

@ -4,7 +4,7 @@ error[E0597]: `b` does not live long enough
LL | p = &*b;
| ^ borrowed value does not live long enough
LL | }
| - borrowed value only lives until here
| - `b` dropped here while still borrowed
LL | //~^^ ERROR `b` does not live long enough
LL | p.use_ref();
| - borrow later used here

View File

@ -4,7 +4,7 @@ error[E0597]: `b` does not live long enough
LL | &a..&b
| ^^ borrowed value does not live long enough
LL | };
| - borrowed value only lives until here
| - `b` dropped here while still borrowed
...
LL | r.use_ref();
| - borrow later used here
@ -15,7 +15,7 @@ error[E0597]: `a` does not live long enough
LL | &a..&b
| ^^ borrowed value does not live long enough
LL | };
| - borrowed value only lives until here
| - `a` dropped here while still borrowed
...
LL | r.use_ref();
| - borrow later used here

View File

@ -5,7 +5,7 @@ LL | let c_ref = &c;
| ^^ borrowed value does not live long enough
...
LL | }
| - borrowed value only lives until here
| - `c` dropped here while still borrowed
LL | f.use_mut();
| - borrow later used here

View File

@ -10,7 +10,7 @@ LL | | repeater3(tmp1)
LL | | };
| | -
| | |
| |_____borrowed value only lives until here
| |_____`tmp0` dropped here while still borrowed
| borrow later used here
error: aborting due to previous error

View File

@ -6,7 +6,7 @@ LL | let x = 1 + *p;
LL | p = &x;
| ^^ borrowed value does not live long enough
LL | }
| - borrowed value only lives until here
| - `x` dropped here while still borrowed
error: aborting due to previous error

View File

@ -41,7 +41,7 @@ LL | _y.push(&mut z);
| borrow later used here
...
LL | }
| - borrowed value only lives until here
| - `z` dropped here while still borrowed
error: aborting due to 4 previous errors

View File

@ -5,7 +5,7 @@ LL | y = borrow(&*x);
| ^^^ borrowed value does not live long enough
...
LL | }
| - borrowed value only lives until here
| - `*x` dropped here while still borrowed
LL | assert!(*y != 0);
| -- borrow later used here

View File

@ -8,7 +8,7 @@ LL | | //~^ ERROR `y` does not live long enough
LL | | })
| |_________^ borrowed value does not live long enough
LL | };
| - borrowed value only lives until here
| - `y` dropped here while still borrowed
LL |
LL | bad.join();
| --- borrow later used here
@ -20,7 +20,7 @@ LL | let y = &x;
| ^^ borrowed value does not live long enough
...
LL | };
| - borrowed value only lives until here
| - `x` dropped here while still borrowed
LL |
LL | bad.join();
| --- borrow later used here

View File

@ -4,7 +4,7 @@ error[E0597]: `x` does not live long enough
LL | Mutex::new(&x)
| ^^ borrowed value does not live long enough
LL | };
| - borrowed value only lives until here
| - `x` dropped here while still borrowed
...
LL | let _dangling = *lock.lock().unwrap();
| ---- borrow later used here
@ -15,7 +15,7 @@ error[E0597]: `x` does not live long enough
LL | RwLock::new(&x)
| ^^ borrowed value does not live long enough
LL | };
| - borrowed value only lives until here
| - `x` dropped here while still borrowed
LL | //~^^ ERROR `x` does not live long enough
LL | let _dangling = *lock.read().unwrap();
| ---- borrow later used here
@ -30,7 +30,7 @@ LL | let _ = tx.send(&x);
| ^^ borrowed value does not live long enough
LL | (tx, rx)
LL | };
| - borrowed value only lives until here
| - `x` dropped here while still borrowed
error: aborting due to 3 previous errors

View File

@ -15,7 +15,7 @@ error[E0597]: `z` does not live long enough
LL | *lock.lock().unwrap() = &z;
| ^^ borrowed value does not live long enough
LL | }
| - borrowed value only lives until here
| - `z` dropped here while still borrowed
LL | //~^^ ERROR `z` does not live long enough
LL | lock.use_ref(); // (Mutex is #[may_dangle] so its dtor does not use `z` => needs explicit use)
| ---- borrow later used here
@ -37,7 +37,7 @@ error[E0597]: `z` does not live long enough
LL | *lock.write().unwrap() = &z;
| ^^ borrowed value does not live long enough
LL | }
| - borrowed value only lives until here
| - `z` dropped here while still borrowed
LL | //~^^ ERROR `z` does not live long enough
LL | lock.use_ref(); // (RwLock is #[may_dangle] so its dtor does not use `z` => needs explicit use)
| ---- borrow later used here
@ -59,7 +59,7 @@ error[E0597]: `z` does not live long enough
LL | tx.send(&z).unwrap();
| ^^ borrowed value does not live long enough
LL | }
| - borrowed value only lives until here
| - `z` dropped here while still borrowed
...
LL | }
| - borrow later used here, when `tx` is dropped

View File

@ -7,7 +7,7 @@ LL | c1.v[0].v.set(Some(&c2));
LL | }
| -
| |
| borrowed value only lives until here
| `c2` dropped here while still borrowed
| borrow later used here, when `c1` is dropped
error[E0597]: `c1` does not live long enough
@ -19,7 +19,7 @@ LL | //~^ ERROR `c1` does not live long enough
LL | }
| -
| |
| borrowed value only lives until here
| `c1` dropped here while still borrowed
| borrow later used here, when `c1` is dropped
error: aborting due to 2 previous errors

View File

@ -7,7 +7,7 @@ LL | v.push(&y);
LL | }
| -
| |
| borrowed value only lives until here
| `y` dropped here while still borrowed
| borrow later used here, when `v` is dropped
|
= note: values in a scope are dropped in the opposite order they are defined
@ -21,7 +21,7 @@ LL | v.push(&x);
LL | }
| -
| |
| borrowed value only lives until here
| `x` dropped here while still borrowed
| borrow later used here, when `v` is dropped
|
= note: values in a scope are dropped in the opposite order they are defined

View File

@ -4,7 +4,7 @@ error[E0597]: `pointer` does not live long enough
LL | f2.xmute(&pointer)
| ^^^^^^^^ borrowed value does not live long enough
LL | };
| - borrowed value only lives until here
| - `pointer` dropped here while still borrowed
LL | //~^^ ERROR `pointer` does not live long enough
LL | println!("{}", dangling);
| -------- borrow later used here