Rollup merge of #146011 - estebank:lifetime-obligation-span, r=lcnr

Point at fn bound that introduced lifetime obligation

The last note is new
```
error[E0597]: `c` does not live long enough
  --> $DIR/without-precise-captures-we-are-powerless.rs:19:20
   |
LL | fn simple<'a>(x: &'a i32) {
   |           -- lifetime `'a` defined here
...
LL |     let c = async move || { println!("{}", *x); };
   |         - binding `c` declared here
LL |     outlives::<'a>(c());
   |     ---------------^---
   |     |              |
   |     |              borrowed value does not live long enough
   |     argument requires that `c` is borrowed for `'a`
LL |     outlives::<'a>(call_once(c));
LL | }
   | - `c` dropped here while still borrowed
   |
note: requirement that `c` is borrowed for `'a` introduced here
  --> $DIR/without-precise-captures-we-are-powerless.rs:7:33
   |
LL | fn outlives<'a>(_: impl Sized + 'a) {}
   |                                 ^^
```

When encountering a `ConstraintCategory::Predicate` in a funtion call, point at the `Span` for that `Predicate` to explain where the lifetime obligation originates from.

CC rust-lang/rust#55307.
This commit is contained in:
Stuart Cook 2025-09-30 22:25:16 +10:00 committed by GitHub
commit 1aa426b335
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
24 changed files with 258 additions and 32 deletions

View file

@ -426,7 +426,7 @@ impl<'infcx, 'tcx> crate::MirBorrowckCtxt<'_, 'infcx, 'tcx> {
}
pub(crate) fn path_does_not_live_long_enough(&self, span: Span, path: &str) -> Diag<'infcx> {
struct_span_code_err!(self.dcx(), span, E0597, "{} does not live long enough", path,)
struct_span_code_err!(self.dcx(), span, E0597, "{} does not live long enough", path)
}
pub(crate) fn cannot_return_reference_to_local(
@ -480,7 +480,7 @@ impl<'infcx, 'tcx> crate::MirBorrowckCtxt<'_, 'infcx, 'tcx> {
}
pub(crate) fn temporary_value_borrowed_for_too_long(&self, span: Span) -> Diag<'infcx> {
struct_span_code_err!(self.dcx(), span, E0716, "temporary value dropped while borrowed",)
struct_span_code_err!(self.dcx(), span, E0716, "temporary value dropped while borrowed")
}
}

View file

@ -2992,6 +2992,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
self.buffer_error(err);
}
#[tracing::instrument(level = "debug", skip(self, explanation))]
fn report_local_value_does_not_live_long_enough(
&self,
location: Location,
@ -3001,13 +3002,6 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
borrow_spans: UseSpans<'tcx>,
explanation: BorrowExplanation<'tcx>,
) -> Diag<'infcx> {
debug!(
"report_local_value_does_not_live_long_enough(\
{:?}, {:?}, {:?}, {:?}, {:?}\
)",
location, name, borrow, drop_span, borrow_spans
);
let borrow_span = borrow_spans.var_or_use_path_span();
if let BorrowExplanation::MustBeValidFor {
category,

View file

@ -416,6 +416,26 @@ impl<'tcx> BorrowExplanation<'tcx> {
{
self.add_object_lifetime_default_note(tcx, err, unsize_ty);
}
let mut preds = path
.iter()
.filter_map(|constraint| match constraint.category {
ConstraintCategory::Predicate(pred) if !pred.is_dummy() => Some(pred),
_ => None,
})
.collect::<Vec<Span>>();
preds.sort();
preds.dedup();
if !preds.is_empty() {
let s = if preds.len() == 1 { "" } else { "s" };
err.span_note(
preds,
format!(
"requirement{s} that the value outlives `{region_name}` introduced here"
),
);
}
self.add_lifetime_bound_suggestion_to_diagnostic(err, &category, span, region_name);
}
_ => {}

View file

@ -44,4 +44,18 @@ fn through_field_and_ref_move<'a>(x: &S<'a>) {
outlives::<'a>(call_once(c)); //~ ERROR explicit lifetime required in the type of `x`
}
struct T;
impl T {
fn outlives<'a>(&'a self, _: impl Sized + 'a) {}
}
fn through_method<'a>(x: &'a i32) {
let c = async || { println!("{}", *x); }; //~ ERROR `x` does not live long enough
T.outlives::<'a>(c());
T.outlives::<'a>(call_once(c));
let c = async move || { println!("{}", *x); };
T.outlives::<'a>(c()); //~ ERROR `c` does not live long enough
T.outlives::<'a>(call_once(c));
}
fn main() {}

View file

@ -28,6 +28,12 @@ LL | outlives::<'a>(c());
LL | outlives::<'a>(call_once(c));
LL | }
| - `c` dropped here while still borrowed
|
note: requirement that the value outlives `'a` introduced here
--> $DIR/without-precise-captures-we-are-powerless.rs:7:33
|
LL | fn outlives<'a>(_: impl Sized + 'a) {}
| ^^
error[E0597]: `x` does not live long enough
--> $DIR/without-precise-captures-we-are-powerless.rs:26:13
@ -73,6 +79,12 @@ LL | outlives::<'a>(c());
LL | outlives::<'a>(call_once(c));
LL | }
| - `c` dropped here while still borrowed
|
note: requirement that the value outlives `'a` introduced here
--> $DIR/without-precise-captures-we-are-powerless.rs:7:33
|
LL | fn outlives<'a>(_: impl Sized + 'a) {}
| ^^
error[E0505]: cannot move out of `c` because it is borrowed
--> $DIR/without-precise-captures-we-are-powerless.rs:32:30
@ -89,6 +101,12 @@ LL | outlives::<'a>(c());
| argument requires that `c` is borrowed for `'a`
LL | outlives::<'a>(call_once(c));
| ^ move out of `c` occurs here
|
note: requirement that the value outlives `'a` introduced here
--> $DIR/without-precise-captures-we-are-powerless.rs:7:33
|
LL | fn outlives<'a>(_: impl Sized + 'a) {}
| ^^
error[E0597]: `x` does not live long enough
--> $DIR/without-precise-captures-we-are-powerless.rs:36:13
@ -129,6 +147,12 @@ LL | outlives::<'a>(c());
LL | outlives::<'a>(call_once(c));
LL | }
| - `c` dropped here while still borrowed
|
note: requirement that the value outlives `'a` introduced here
--> $DIR/without-precise-captures-we-are-powerless.rs:7:33
|
LL | fn outlives<'a>(_: impl Sized + 'a) {}
| ^^
error[E0621]: explicit lifetime required in the type of `x`
--> $DIR/without-precise-captures-we-are-powerless.rs:44:5
@ -141,7 +165,44 @@ help: add explicit lifetime `'a` to the type of `x`
LL | fn through_field_and_ref_move<'a>(x: &'a S<'a>) {
| ++
error: aborting due to 10 previous errors
error[E0597]: `x` does not live long enough
--> $DIR/without-precise-captures-we-are-powerless.rs:52:13
|
LL | fn through_method<'a>(x: &'a i32) {
| -- lifetime `'a` defined here
LL | let c = async || { println!("{}", *x); };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ borrowed value does not live long enough
LL | T.outlives::<'a>(c());
LL | T.outlives::<'a>(call_once(c));
| ------------------------------ argument requires that `x` is borrowed for `'a`
...
LL | }
| - `x` dropped here while still borrowed
error[E0597]: `c` does not live long enough
--> $DIR/without-precise-captures-we-are-powerless.rs:57:22
|
LL | fn through_method<'a>(x: &'a i32) {
| -- lifetime `'a` defined here
...
LL | let c = async move || { println!("{}", *x); };
| - binding `c` declared here
LL | T.outlives::<'a>(c());
| -----------------^---
| | |
| | borrowed value does not live long enough
| argument requires that `c` is borrowed for `'a`
LL | T.outlives::<'a>(call_once(c));
LL | }
| - `c` dropped here while still borrowed
|
note: requirement that the value outlives `'a` introduced here
--> $DIR/without-precise-captures-we-are-powerless.rs:49:47
|
LL | fn outlives<'a>(&'a self, _: impl Sized + 'a) {}
| ^^
error: aborting due to 12 previous errors
Some errors have detailed explanations: E0505, E0597, E0621.
For more information about an error, try `rustc --explain E0505`.

View file

@ -27,6 +27,12 @@ LL | want(&String::new(), extend_lt);
| | |
| | creates a temporary value which is freed while still in use
| argument requires that borrow lasts for `'static`
|
note: requirement that the value outlives `'static` introduced here
--> $DIR/fn-item-check-type-params.rs:47:33
|
LL | fn want<I, O>(_: I, _: impl Fn(I) -> O) {}
| ^^^^^^^^^^
error[E0716]: temporary value dropped while borrowed
--> $DIR/fn-item-check-type-params.rs:54:26
@ -36,6 +42,12 @@ LL | let val = extend_lt(&String::from("blah blah blah"));
| | |
| | creates a temporary value which is freed while still in use
| argument requires that borrow lasts for `'static`
|
note: requirement that the value outlives `'static` introduced here
--> $DIR/fn-item-check-type-params.rs:22:21
|
LL | (T, Option<U>): Displayable,
| ^^^^^^^^^^^
error: aborting due to 4 previous errors

View file

@ -22,6 +22,12 @@ LL | force_send(async_load(&not_static));
...
LL | }
| - `not_static` dropped here while still borrowed
|
note: requirement that the value outlives `'1` introduced here
--> $DIR/implementation-not-general-enough-ice-133252.rs:16:18
|
LL | fn force_send<T: Send>(_: T) {}
| ^^^^
error: aborting due to 2 previous errors

View file

@ -10,6 +10,9 @@ LL | | ));
| | -- temporary value is freed at the end of this statement
| |______|
| argument requires that borrow lasts for `'a`
|
note: requirement that the value outlives `'a` introduced here
--> $SRC_DIR/core/src/ops/function.rs:LL:COL
error: aborting due to 1 previous error

View file

@ -14,6 +14,11 @@ note: due to a current limitation of the type system, this implies a `'static` l
|
LL | for<'a> I::Item<'a>: Debug,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
note: requirement that the value outlives `'static` introduced here
--> $DIR/hrtb-implied-1.rs:26:26
|
LL | for<'a> I::Item<'a>: Debug,
| ^^^^^
error: aborting due to 1 previous error

View file

@ -32,6 +32,7 @@ fn needs_static() {
//~| NOTE borrowed value does not live long enoug
fn needs_static(_: impl Sized + 'static) {}
//~^ NOTE requirement that the value outlives `'static` introduced here
needs_static(a);
//~^ NOTE argument requires that `x` is borrowed for `'static`
}
@ -79,6 +80,7 @@ fn needs_static_mut() {
//~| NOTE borrowed value does not live long enough
fn needs_static(_: impl Sized + 'static) {}
//~^ NOTE requirement that the value outlives `'static` introduced here
needs_static(a);
//~^ NOTE argument requires that `x` is borrowed for `'static`
}

View file

@ -1,5 +1,5 @@
error[E0597]: `x` does not live long enough
--> $DIR/migration-note.rs:182:17
--> $DIR/migration-note.rs:184:17
|
LL | let x = vec![0];
| - binding `x` declared here
@ -50,6 +50,11 @@ LL |
LL | }
| - `x` dropped here while still borrowed
|
note: requirement that the value outlives `'static` introduced here
--> $DIR/migration-note.rs:34:37
|
LL | fn needs_static(_: impl Sized + 'static) {}
| ^^^^^^^
note: this call may capture more lifetimes than intended, because Rust 2024 has adjusted the `impl Trait` lifetime capture rules
--> $DIR/migration-note.rs:29:13
|
@ -61,7 +66,7 @@ LL | fn display_len<T>(x: &Vec<T>) -> impl Display + use<T> {
| ++++++++
error[E0505]: cannot move out of `x` because it is borrowed
--> $DIR/migration-note.rs:48:8
--> $DIR/migration-note.rs:49:8
|
LL | let x = vec![1];
| - binding `x` declared here
@ -76,7 +81,7 @@ LL | }
| - borrow might be used here, when `a` is dropped and runs the destructor for type `impl std::fmt::Display`
|
note: this call may capture more lifetimes than intended, because Rust 2024 has adjusted the `impl Trait` lifetime capture rules
--> $DIR/migration-note.rs:43:13
--> $DIR/migration-note.rs:44:13
|
LL | let a = display_len(&x);
| ^^^^^^^^^^^^^^^
@ -90,7 +95,7 @@ LL | let a = display_len(&x.clone());
| ++++++++
error[E0499]: cannot borrow `x` as mutable more than once at a time
--> $DIR/migration-note.rs:66:5
--> $DIR/migration-note.rs:67:5
|
LL | let a = display_len_mut(&mut x);
| ------ first mutable borrow occurs here
@ -102,7 +107,7 @@ LL | println!("{a}");
| - first borrow later used here
|
note: this call may capture more lifetimes than intended, because Rust 2024 has adjusted the `impl Trait` lifetime capture rules
--> $DIR/migration-note.rs:63:13
--> $DIR/migration-note.rs:64:13
|
LL | let a = display_len_mut(&mut x);
| ^^^^^^^^^^^^^^^^^^^^^^^
@ -112,7 +117,7 @@ LL | fn display_len_mut<T>(x: &mut Vec<T>) -> impl Display + use<T> {
| ++++++++
error[E0597]: `x` does not live long enough
--> $DIR/migration-note.rs:76:29
--> $DIR/migration-note.rs:77:29
|
LL | let mut x = vec![1];
| ----- binding `x` declared here
@ -126,8 +131,13 @@ LL |
LL | }
| - `x` dropped here while still borrowed
|
note: requirement that the value outlives `'static` introduced here
--> $DIR/migration-note.rs:82:37
|
LL | fn needs_static(_: impl Sized + 'static) {}
| ^^^^^^^
note: this call may capture more lifetimes than intended, because Rust 2024 has adjusted the `impl Trait` lifetime capture rules
--> $DIR/migration-note.rs:76:13
--> $DIR/migration-note.rs:77:13
|
LL | let a = display_len_mut(&mut x);
| ^^^^^^^^^^^^^^^^^^^^^^^
@ -137,7 +147,7 @@ LL | fn display_len_mut<T>(x: &mut Vec<T>) -> impl Display + use<T> {
| ++++++++
error[E0505]: cannot move out of `x` because it is borrowed
--> $DIR/migration-note.rs:95:8
--> $DIR/migration-note.rs:97:8
|
LL | let mut x = vec![1];
| ----- binding `x` declared here
@ -152,7 +162,7 @@ LL | }
| - borrow might be used here, when `a` is dropped and runs the destructor for type `impl std::fmt::Display`
|
note: this call may capture more lifetimes than intended, because Rust 2024 has adjusted the `impl Trait` lifetime capture rules
--> $DIR/migration-note.rs:90:13
--> $DIR/migration-note.rs:92:13
|
LL | let a = display_len_mut(&mut x);
| ^^^^^^^^^^^^^^^^^^^^^^^
@ -166,7 +176,7 @@ LL | let a = display_len_mut(&mut x.clone());
| ++++++++
error[E0506]: cannot assign to `s.f` because it is borrowed
--> $DIR/migration-note.rs:115:5
--> $DIR/migration-note.rs:117:5
|
LL | let a = display_field(&s.f);
| ---- `s.f` is borrowed here
@ -178,7 +188,7 @@ LL | println!("{a}");
| - borrow later used here
|
note: this call may capture more lifetimes than intended, because Rust 2024 has adjusted the `impl Trait` lifetime capture rules
--> $DIR/migration-note.rs:112:13
--> $DIR/migration-note.rs:114:13
|
LL | let a = display_field(&s.f);
| ^^^^^^^^^^^^^^^^^^^
@ -188,7 +198,7 @@ LL | fn display_field<T: Copy + Display>(t: &T) -> impl Display + use<T> {
| ++++++++
error[E0506]: cannot assign to `s.f` because it is borrowed
--> $DIR/migration-note.rs:131:5
--> $DIR/migration-note.rs:133:5
|
LL | let a = display_field(&mut s.f);
| -------- `s.f` is borrowed here
@ -200,7 +210,7 @@ LL | println!("{a}");
| - borrow later used here
|
note: this call may capture more lifetimes than intended, because Rust 2024 has adjusted the `impl Trait` lifetime capture rules
--> $DIR/migration-note.rs:128:13
--> $DIR/migration-note.rs:130:13
|
LL | let a = display_field(&mut s.f);
| ^^^^^^^^^^^^^^^^^^^^^^^
@ -210,7 +220,7 @@ LL | fn display_field<T: Copy + Display>(t: &T) -> impl Display + use<T> {
| ++++++++
error[E0503]: cannot use `s.f` because it was mutably borrowed
--> $DIR/migration-note.rs:143:5
--> $DIR/migration-note.rs:145:5
|
LL | let a = display_field(&mut s.f);
| -------- `s.f` is borrowed here
@ -222,7 +232,7 @@ LL | println!("{a}");
| - borrow later used here
|
note: this call may capture more lifetimes than intended, because Rust 2024 has adjusted the `impl Trait` lifetime capture rules
--> $DIR/migration-note.rs:140:13
--> $DIR/migration-note.rs:142:13
|
LL | let a = display_field(&mut s.f);
| ^^^^^^^^^^^^^^^^^^^^^^^
@ -232,7 +242,7 @@ LL | fn display_field<T: Copy + Display>(t: &T) -> impl Display + use<T> {
| ++++++++
error[E0597]: `z.f` does not live long enough
--> $DIR/migration-note.rs:159:25
--> $DIR/migration-note.rs:161:25
|
LL | let z = Z { f: vec![1] };
| - binding `z` declared here
@ -248,7 +258,7 @@ LL | }
|
= note: values in a scope are dropped in the opposite order they are defined
note: this call may capture more lifetimes than intended, because Rust 2024 has adjusted the `impl Trait` lifetime capture rules
--> $DIR/migration-note.rs:159:13
--> $DIR/migration-note.rs:161:13
|
LL | x = display_len(&z.f);
| ^^^^^^^^^^^^^^^^^
@ -258,7 +268,7 @@ LL | fn display_len<T>(x: &Vec<T>) -> impl Display + use<T> {
| ++++++++
error[E0716]: temporary value dropped while borrowed
--> $DIR/migration-note.rs:170:40
--> $DIR/migration-note.rs:172:40
|
LL | let x = { let x = display_len(&mut vec![0]); x };
| ^^^^^^^ - - borrow later used here
@ -268,7 +278,7 @@ LL | let x = { let x = display_len(&mut vec![0]); x };
|
= note: consider using a `let` binding to create a longer lived value
note: this call may capture more lifetimes than intended, because Rust 2024 has adjusted the `impl Trait` lifetime capture rules
--> $DIR/migration-note.rs:170:23
--> $DIR/migration-note.rs:172:23
|
LL | let x = { let x = display_len(&mut vec![0]); x };
| ^^^^^^^^^^^^^^^^^^^^^^^^^
@ -279,7 +289,7 @@ LL | fn display_len<T>(x: &Vec<T>) -> impl Display + use<T> {
| ++++++++
error[E0505]: cannot move out of `x` because it is borrowed
--> $DIR/migration-note.rs:198:10
--> $DIR/migration-note.rs:200:10
|
LL | let x = String::new();
| - binding `x` declared here
@ -294,12 +304,12 @@ LL | }
| - borrow might be used here, when `y` is dropped and runs the destructor for type `impl Sized`
|
note: this call may capture more lifetimes than intended, because Rust 2024 has adjusted the `impl Trait` lifetime capture rules
--> $DIR/migration-note.rs:195:13
--> $DIR/migration-note.rs:197:13
|
LL | let y = capture_apit(&x);
| ^^^^^^^^^^^^^^^^
note: you could use a `use<...>` bound to explicitly specify captures, but argument-position `impl Trait`s are not nameable
--> $DIR/migration-note.rs:189:21
--> $DIR/migration-note.rs:191:21
|
LL | fn capture_apit(x: &impl Sized) -> impl Sized {}
| ^^^^^^^^^^

View file

@ -69,6 +69,12 @@ LL | cell_x.set(cell_a.get()); // forces 'a: 'x, implies 'a = 'static ->
LL | })
LL | }
| - `a` dropped here while still borrowed
|
note: requirement that the value outlives `'static` introduced here
--> $DIR/propagate-approximated-shorter-to-static-comparing-against-free.rs:13:8
|
LL | F: for<'x> FnOnce(Cell<&'a u32>, Cell<&'x u32>),
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 2 previous errors

View file

@ -13,6 +13,12 @@ LL | z = &local_arr;
...
LL | }
| - `local_arr` dropped here while still borrowed
|
note: requirement that the value outlives `'static` introduced here
--> $DIR/propagate-multiple-requirements.rs:4:21
|
LL | fn once<S, T, U, F: FnOnce(S, T) -> U>(f: F, s: S, t: T) -> U {
| ^^^^^^^^^^^^^^^^^
error: aborting due to 1 previous error

View file

@ -17,6 +17,11 @@ note: due to a current limitation of the type system, this implies a `'static` l
|
LL | fn assert_static_via_hrtb<G>(_: G) where for<'a> G: Outlives<'a> {}
| ^^^^^^^^^^^^^^^^^^^^^^^
note: requirement that the value outlives `'static` introduced here
--> $DIR/local-outlives-static-via-hrtb.rs:15:53
|
LL | fn assert_static_via_hrtb<G>(_: G) where for<'a> G: Outlives<'a> {}
| ^^^^^^^^^^^^
error[E0597]: `local` does not live long enough
--> $DIR/local-outlives-static-via-hrtb.rs:25:45
@ -37,6 +42,11 @@ note: due to a current limitation of the type system, this implies a `'static` l
|
LL | for<'a> &'a T: Reference<AssociatedType = &'a ()>,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: requirement that the value outlives `'static` introduced here
--> $DIR/local-outlives-static-via-hrtb.rs:19:30
|
LL | for<'a> &'a T: Reference<AssociatedType = &'a ()>,
| ^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 2 previous errors

View file

@ -18,6 +18,11 @@ note: due to a current limitation of the type system, this implies a `'static` l
|
LL | fn bad<F: Fn(&()) -> &()>(_: F) {}
| ^^^^^^^^^^^^^^
note: requirement that the value outlives `'static` introduced here
--> $DIR/location-insensitive-scopes-issue-117146.rs:20:22
|
LL | fn bad<F: Fn(&()) -> &()>(_: F) {}
| ^^^
error: implementation of `Fn` is not general enough
--> $DIR/location-insensitive-scopes-issue-117146.rs:13:5

View file

@ -18,6 +18,11 @@ note: due to a current limitation of the type system, this implies a `'static` l
|
LL | fn bad<F: Fn(&()) -> &()>(_: F) {}
| ^^^^^^^^^^^^^^
note: requirement that the value outlives `'static` introduced here
--> $DIR/location-insensitive-scopes-issue-117146.rs:20:22
|
LL | fn bad<F: Fn(&()) -> &()>(_: F) {}
| ^^^
error: implementation of `Fn` is not general enough
--> $DIR/location-insensitive-scopes-issue-117146.rs:13:5

View file

@ -0,0 +1,11 @@
fn outlives_indir<'a: 'b, 'b, T: 'a>(_x: T) {}
//~^ NOTE: requirements that the value outlives `'b` introduced here
fn foo<'b>() { //~ NOTE: lifetime `'b` defined here
outlives_indir::<'_, 'b, _>(&mut 1u32); //~ ERROR: temporary value dropped while borrowed
//~^ NOTE: argument requires that borrow lasts for `'b`
//~| NOTE: creates a temporary value which is freed while still in use
//~| NOTE: temporary value is freed at the end of this statement
}
fn main() {}

View file

@ -0,0 +1,20 @@
error[E0716]: temporary value dropped while borrowed
--> $DIR/multiple-sources-for-outlives-requirement.rs:5:38
|
LL | fn foo<'b>() {
| -- lifetime `'b` defined here
LL | outlives_indir::<'_, 'b, _>(&mut 1u32);
| ---------------------------------^^^^-- temporary value is freed at the end of this statement
| | |
| | creates a temporary value which is freed while still in use
| argument requires that borrow lasts for `'b`
|
note: requirements that the value outlives `'b` introduced here
--> $DIR/multiple-sources-for-outlives-requirement.rs:1:23
|
LL | fn outlives_indir<'a: 'b, 'b, T: 'a>(_x: T) {}
| ^^ ^^
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0716`.

View file

@ -11,6 +11,12 @@ LL | | });
| |______- argument requires that `x` is borrowed for `'static`
LL | }
| - `x` dropped here while still borrowed
|
note: requirement that the value outlives `'static` introduced here
--> $DIR/regions-infer-proc-static-upvar.rs:4:19
|
LL | fn foo<F:FnOnce()+'static>(_p: F) { }
| ^^^^^^^
error: aborting due to 1 previous error

View file

@ -10,6 +10,12 @@ LL | [ word ] => { assert_static(word); }
LL | }
LL | }
| - `line` dropped here while still borrowed
|
note: requirement that the value outlives `'static` introduced here
--> $DIR/regions-pattern-typing-issue-19552.rs:1:21
|
LL | fn assert_static<T: 'static>(_t: T) {}
| ^^^^^^^
error: aborting due to 1 previous error

View file

@ -10,6 +10,12 @@ LL | f(&x);
| argument requires that `x` is borrowed for `'static`
LL | }
| - `x` dropped here while still borrowed
|
note: requirement that the value outlives `'static` introduced here
--> $DIR/static-lifetime-bound.rs:1:10
|
LL | fn f<'a: 'static>(_: &'a i32) {}
| ^^^^^^^
error: aborting due to 1 previous error

View file

@ -7,6 +7,12 @@ LL | f(x);
| ---- argument requires that borrow lasts for `'static`
LL | }
| - temporary value is freed at the end of this statement
|
note: requirement that the value outlives `'static` introduced here
--> $DIR/static-region-bound.rs:3:8
|
LL | fn f<T:'static>(_: T) {}
| ^^^^^^^
error: aborting due to 1 previous error

View file

@ -6,6 +6,12 @@ LL | let s = foo(&String::from("blah blah blah"));
| | |
| | creates a temporary value which is freed while still in use
| argument requires that borrow lasts for `'static`
|
note: requirement that the value outlives `'static` introduced here
--> $DIR/wf-in-where-clause-static.rs:12:17
|
LL | &'static S: Static,
| ^^^^^^
error: aborting due to 1 previous error

View file

@ -6,6 +6,12 @@ LL | let s = foo(&String::from("blah blah blah"));
| | |
| | creates a temporary value which is freed while still in use
| argument requires that borrow lasts for `'static`
|
note: requirement that the value outlives `'static` introduced here
--> $DIR/wf-in-where-clause-static.rs:12:17
|
LL | &'static S: Static,
| ^^^^^^
error: aborting due to 1 previous error