Skip to content
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

Merged
merged 16 commits into from
Jan 29, 2019

Conversation

lqd
Copy link
Member

@lqd lqd commented Jan 25, 2019

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.

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jan 25, 2019
@rust-highfive

This comment has been minimized.

fn f(self);
}

impl<T> Trait for fn(&T) {
Copy link
Contributor

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:

Suggested change
impl<T> Trait for fn(&T) {
impl<T> Trait for for<'a> fn(&'a T) {

to make what's tested clearer.

src/test/ui/issues/issue-57362.stderr Outdated Show resolved Hide resolved
src/test/ui/issues/issue-57362.stderr Outdated Show resolved Hide resolved
LL | a.f(); //~ ERROR not general enough
| ^
|
= note: `Trait` would have to be implemented for the type `fn(&u8)`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
= 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/)

Copy link
Contributor

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.

Copy link
Contributor

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. :)

if self_ty_has_vid {
err.note(&format!(
"but `{}` is actually implemented for the type `{}`, \
for the specific lifetime `'{}`",
Copy link
Contributor

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...

Copy link
Contributor

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.

Copy link
Contributor

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... ^^)

@rust-highfive

This comment has been minimized.

@lqd
Copy link
Member Author

lqd commented Jan 26, 2019

Updated to address the review comments here and on Zulip:

  • The code handling all the notes has been extracted to a helper function
  • All the cases needed to correctly print either the trait or the self type where the sub/sup placeholders appear next to these placeholders, and not at opposite ends of the error message, have been added to this helper function.

@bors

This comment has been minimized.

lqd and others added 15 commits January 27, 2019 10:52
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.
@nikomatsakis
Copy link
Contributor

@bors r+

@bors
Copy link
Contributor

bors commented Jan 29, 2019

📌 Commit c97d135 has been approved by nikomatsakis

@bors bors removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jan 29, 2019
@bors bors added the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Jan 29, 2019
@nikomatsakis
Copy link
Contributor

@bors p=1 -- fairly severe, if limited, diagnostic regression

@bors
Copy link
Contributor

bors commented Jan 29, 2019

⌛ Testing commit c97d135 with merge 7425663...

bors added a commit that referenced this pull request Jan 29, 2019
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.
@bors
Copy link
Contributor

bors commented Jan 29, 2019

☀️ Test successful - checks-travis, status-appveyor
Approved by: nikomatsakis
Pushing 7425663 to master...

@bors
Copy link
Contributor

bors commented Jan 29, 2019

☀️ Test successful - checks-travis, status-appveyor
Approved by: nikomatsakis
Pushing 7425663 to master...

@bors bors merged commit c97d135 into rust-lang:master Jan 29, 2019
@lqd lqd deleted the issue_57362 branch January 29, 2019 20:03
@pnkfelix
Copy link
Member

pnkfelix commented Jan 30, 2019

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.)

@pnkfelix pnkfelix added beta-nominated Nominated for backporting to the compiler in the beta channel. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jan 30, 2019
@pnkfelix
Copy link
Member

discussed at T-compiler meeting. declining for beta backport.

@pnkfelix pnkfelix removed the beta-nominated Nominated for backporting to the compiler in the beta channel. label Jan 31, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Confusing error message associated with universe transition: "one type is more general than the other"
6 participants