-
Notifications
You must be signed in to change notification settings - Fork 13.8k
Point at fn bound that introduced lifetime obligation #146011
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
``` 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.
| - `c` dropped here while still borrowed | ||
| | ||
note: requirement that `c` is borrowed for `'a` introduced here | ||
note: requirement for `'a` introduced here |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is a requirement for 'a
, I feel like the requirement is for the APIT here, not 'a
. Is it not possible to keep sth like "requirement that outlives " introduced here"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed to "requirement that the value outlives 'a
introduced here".
| 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how come this doesn't actually show the predicate which caused this?
err.span_note( | ||
pred, | ||
format!("requirement that the value outlives `{region_name}` introduced here"), | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if we report this for all preds while always using region_name
it'd be reported twice here, would it?
fn outlives_indir<'a: 'b, 'b, T: 'a>(x: T) {}
fn foo<'b>() {
outlives_indir::<'_, 'b, _>(&mut 1u32);
}
in a sense it would be
- requirement that the value outlives
{other_region}
introduced here - requirement that
{other_region}
outlives{region_name}
introduced here
ahhh. you break. please make this a if let Some(pred_span) = ...
:<
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
r=me after nit
The last note is new
When encountering a
ConstraintCategory::Predicate
in a funtion call, point at theSpan
for thatPredicate
to explain where the lifetime obligation originates from.CC #55307.