Pick one possible lifetime in case there are multiple choices#89327
Pick one possible lifetime in case there are multiple choices#89327bors merged 1 commit intorust-lang:masterfrom
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 |
| | ^^^^^^^^^^^^^^^^^^ | ||
| | | ||
| = 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.
(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.
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.
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
aandbcreating 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
'aand'binstead of just'b.