-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Lifetime error points to wrong reference in async fn return #75785
Comments
On stable the output is different:
Per bisect-rustc, the commit that changed the output is f781bab - almost definitely #73806. @Aaron1011 is there something that can be done to improve this case? Bisect outputsearched nightlies: from nightly-2020-06-01 to nightly-2020-07-15 bisected with cargo-bisect-rustc v0.5.2Host triple: x86_64-unknown-linux-gnu cargo bisect-rustc --regress success --script ./test.sh --start 2020-06-01 --end 2020-07-15 --preserve |
Here's the output with pub fn async_fn(x: &mut i32) -> (&i32, &i32) {
let y = &*x;
*x += 1;
(&32, y)
}
It looks like we're missing the "let's call the lifetime of this reference" note in the |
The current equivalent of that annotation is the note at the bottom: (see #74072)
I actually ran into this while testing a potential fix for that issue - it would make the output
Which still points at the wrong reference. |
@Aaron1011 Are you still planning to work on this? |
…tmandry Prefer regions with an `external_name` in `approx_universal_upper_bound` Fixes rust-lang#75785 When displaying a MIR borrowcheck error, we may need to find an upper bound for a region, which gives us a region to point to in the error message. However, a region might outlive multiple distinct universal regions, in which case the only upper bound is 'static To try to display a meaningful error message, we compute an 'approximate' upper bound by picking one of the universal regions. Currently, we pick the region with the lowest index - however, this caused us to produce a suboptimal error message in issue rust-lang#75785 This PR `approx_universal_upper_bound` to prefer regions with an `external_name`. This causes us to prefer regions from function arguments/upvars, which seems to lead to a nicer error message in some cases.
Output (playground):
The
'1
lifetime name should be given to the second reference in the tuple.@rustbot modify labels: C-bug A-async-await A-diagnostics A-lifetimes T-compiler
The text was updated successfully, but these errors were encountered: