Diagnostics: Nested higher-ranked lifetimes are incorrectly printed #111365
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
A-higher-ranked
Area: Higher-ranked things (e.g., lifetimes, types, trait bounds aka HRTBs)
A-lifetimes
Area: Lifetimes / regions
A-pretty
Area: Pretty printing (including `-Z unpretty`)
D-incorrect
Diagnostics: A diagnostic that is giving misleading or incorrect information.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
For
the output is
Here the type
for<'o> fn(for<'o, 'a> fn(&'a (), &'o ()))
shown after “expected fn pointer” containsfor<'o, 'a>
which doesn't make sense. The binder contains the lifetime bound in the outer binder.The inner binder should just be
for<'a>
just like in the type shown in the label.Note that this doesn't happen when
-Zverbose
is passed 1.Further, if we change the definition of
Two
to betype Two = for<'a> fn(HelperTwo<'a>);
('o
=>'a
),then the pretty-printer does not try to avoid shadowing through renaming of one of the lifetimes or
through other means. Output:
Ideally it should look something like
Here is a playground for a smaller reproducer of the last issue. In this case, the compiler could either
perform renaming or it could omit the inner binder entirely since the lifetime it binds is not referenced
in the inner type.
I've looked through all relevant A-diagnostics A-lifetimes issues and through some others and couldn't find anything that matches 100% what I was looking for (out of those maybe kinda #29061, #56423, #73457, #92281 but not really).
@rustbot label T-compiler A-diagnostics A-lifetimes D-incorrect
Footnotes
It's
for<Region(BrNamed(DefId(0:7 ~ repro[8603]::Two::'o), 'o))> fn(for<Region(BrNamed(DefId(0:10 ~ repro[8603]::HelperTwo::'a), 'a))> fn(..., ...))
. ↩The text was updated successfully, but these errors were encountered: