-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Pick one possible lifetime in case there are multiple choices #89327
Conversation
r? @wesleywiser (rust-highfive has picked a reviewer for you, use r? to override) |
@nikomatsakis I think this was precisely the kind of example I was thinking of during the discussion of #89056 |
I think that would be ideal but I'm also happy to merge this and put an issue in to improve it later. |
@bors r=wesleywiser I'll open an issue |
📌 Commit 87a4a79 has been approved by |
@@ -4,7 +4,11 @@ error[E0700]: hidden type for `impl Trait` captures lifetime that does not appea | |||
LL | fn upper_bounds<'a, 'b, 'c, 'd, 'e>(a: Ordinary<'a>, b: Ordinary<'b>) -> impl Trait<'d, 'e> | |||
| ^^^^^^^^^^^^^^^^^^ | |||
| | |||
= note: hidden type `Ordinary<'_>` captures lifetime '_#9r | |||
note: hidden type `Ordinary<'b>` captures the lifetime `'b` as defined on the function body at 16:21 |
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.
(This is pre-existing)
This message mentions Ordinary<'b>
here as a "hidden type", shouldn't this be "hidden type for impl Trait
" instead, or am I misunderstanding this diagnostic ?
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.
You are completely right.
We should completely rewrite the diagnostics around TAIT in general... they are all not too helpful. I'll open an issue to track the various ways in which it is not great
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.
It's maybe even impl Trait
diagnostics in general, as there's no TAIT here, for example.
…arth Rollup of 7 pull requests Successful merges: - rust-lang#88838 (Do not suggest importing inaccessible items) - rust-lang#89251 (Detect when negative literal indices are used and suggest appropriate code) - rust-lang#89321 (Rebase resume argument projections during state transform) - rust-lang#89327 (Pick one possible lifetime in case there are multiple choices) - rust-lang#89344 (Cleanup lower_generics_mut and make span be the bound itself) - rust-lang#89397 (Update `llvm` submodule to fix function name mangling on x86 Windows) - rust-lang#89412 (Add regression test for issues rust-lang#88969 and rust-lang#89119 ) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
In case a lifetime variable is created, but doesn't have an obvious lifetime in the list of named lifetimes that it should be inferred to, just pick the first one for the diagnostic.
This happens e.g. in
where we get a lifetime variable that combines the lifetimes of
a
andb
creating a lifetime that is the intersection of both. Right now the type system cannot express this and thus we get an error, but that error also can't express this.I can also create an entirely new diagnostic that mentions all involved lifetimes, so it would actually mention
'a
and'b
instead of just'b
.