-
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
Add information to higher-ranked lifetimes conflicts error messages #57901
Conversation
This comment has been minimized.
This comment has been minimized.
src/test/ui/issues/issue-57362.rs
Outdated
fn f(self); | ||
} | ||
|
||
impl<T> Trait for fn(&T) { |
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.
I'd write this out:
impl<T> Trait for fn(&T) { | |
impl<T> Trait for for<'a> fn(&'a T) { |
to make what's tested clearer.
LL | a.f(); //~ ERROR not general enough | ||
| ^ | ||
| | ||
= note: `Trait` would have to be implemented for the type `fn(&u8)` |
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.
= note: `Trait` would have to be implemented for the type `fn(&u8)` | |
= note: `Trait` must be implemented for the type `fn(&u8)` |
Shorter and more direct :)
(alternatively s/must/needs to/)
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.
I'm not so sure. I find the word "must" more confusing somehow. "would have to be" makes it clearer to me that it is not the case.
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.
In that case: "Trait
isn't, but must be..."; or "Trait
needed to be..." -- I just find the current text wordy, but its not a big deal or anything. :)
src/librustc/infer/error_reporting/nice_region_error/placeholder_error.rs
Show resolved
Hide resolved
if self_ty_has_vid { | ||
err.note(&format!( | ||
"but `{}` is actually implemented for the type `{}`, \ | ||
for the specific lifetime `'{}`", |
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.
Nothing to do about here... but it would have been nice to "switch" on the format in some way since the only difference is the format and not the arguments... I suspect this contributes to duplication in many places...
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.
I guess you mean moving "the specific" and "some" into some string? I'm of mixed minds. I often prefer to read the full text. It's also more friendly to i18n if we ever do that (ha, that's a long way away). But OTOH, it is duplication indeed. No strong opinion.
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.
I guess you mean moving "the specific" and "some" into some string?
Right; I was mainly thinking of switching on the "string literal"; but that doesn't work with format!
afaik so its probably not implementable? (which is why it mostly was a general comment about the future... ^^)
This comment has been minimized.
This comment has been minimized.
Updated to address the review comments here and on Zulip:
|
This comment has been minimized.
This comment has been minimized.
Some errors (e.g placeholder errors) have unresolved type vars so this will allow to use `resolve_type_vars_if_possible` when needed.
…e `sup` region These are happening since the switch to universes, and will now go through the "placeholder error" path, instead of the current fallback of E308 "mismatched types" errors.
These can sometimes be unresolved: some of the rustc UI tests show this.
…closer to the lifetimes When mentioning lifetimes, only invert wording between the expected trait and the self type when the self type has the vid. This way, the lifetimes always stay close to the self type or trait ref that actually contains them.
…ther than "the specific lifetime"
@bors r+ |
📌 Commit c97d135 has been approved by |
@bors p=1 -- fairly severe, if limited, diagnostic regression |
Add information to higher-ranked lifetimes conflicts error messages Make these errors go through the new "placeholder error" code path, to have self tys displayed and make them hopefully less confusing. Should fix #57362. r? @nikomatsakis — so we can iterate on the specific wording you wanted.
☀️ Test successful - checks-travis, status-appveyor |
☀️ Test successful - checks-travis, status-appveyor |
beta nominating so that we discuss at T-compiler meeting. (But to be clear, I personally am skeptical about trying to backport this. We can probably live with a diagnostic regression, even one this severe, in the stable channel for a release cycle.) |
discussed at T-compiler meeting. declining for beta backport. |
Make these errors go through the new "placeholder error" code path, to have self tys displayed and make them hopefully less confusing.
Should fix #57362.
r? @nikomatsakis — so we can iterate on the specific wording you wanted.