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

Point to where clause for GATs to add bound #87478

Merged
merged 1 commit into from
Aug 14, 2021

Conversation

jackh726
Copy link
Member

Fixes #84931

r? @estebank

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 26, 2021
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Contributor

bors commented Aug 12, 2021

☔ The latest upstream changes (presumably #87948) made this pull request unmergeable. Please resolve the merge conflicts.

if !generics.where_clause.predicates.is_empty() { "," } else { " where" },
pred,
);
err.span_suggestion(
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's make the suggestion a bit easier to read, given that it points at a span right in the middle of a larger span:

Suggested change
err.span_suggestion(
err.span_suggestion_verbose(

Copy link
Contributor

Choose a reason for hiding this comment

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

Although that would require rewording the other span label...

Copy link
Contributor

Choose a reason for hiding this comment

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

I leave it to your decision what to do here.

Copy link
Member Author

Choose a reason for hiding this comment

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

So, now that the associated type points to the type itself, not the whole defintion, they don't overlap anymore.

I do think the verbose suggestion would be nice, but I'll leave that as a followup.

@@ -0,0 +1,40 @@
#![feature(generic_associated_types)]
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we mark the tests // run-rustfix?

Copy link
Member Author

Choose a reason for hiding this comment

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

So...no. The suggestion here doesn't actually result in code that compiles, because it causes the where clauses not to match the trait's where clauses. (In fact, in this case, we can't write this where clause in the trait, we would have to use Self)

Unfortunately, that's a whole separate issue with GATs. But applying the current suggestion should help, in the future, to guide the user towards matching the trait's where clauses.

@estebank
Copy link
Contributor

r=me after cleaning up the commented out code.

@jackh726
Copy link
Member Author

@bors r=estebank

@bors
Copy link
Contributor

bors commented Aug 13, 2021

📌 Commit 22fc7d6 has been approved by estebank

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

bors commented Aug 13, 2021

⌛ Testing commit 22fc7d6 with merge d0a10b2...

@bors
Copy link
Contributor

bors commented Aug 14, 2021

☀️ Test successful - checks-actions
Approved by: estebank
Pushing d0a10b2 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Aug 14, 2021
@bors bors merged commit d0a10b2 into rust-lang:master Aug 14, 2021
@rustbot rustbot added this to the 1.56.0 milestone Aug 14, 2021
@jackh726 jackh726 deleted the issue-84931 branch August 14, 2021 01:17
@jackh726 jackh726 restored the issue-84931 branch March 12, 2022 18:30
@jackh726 jackh726 deleted the issue-84931 branch March 12, 2022 18:35
@jackh726 jackh726 restored the issue-84931 branch March 12, 2022 18:42
@jackh726 jackh726 deleted the issue-84931 branch March 12, 2022 18:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

GAT: confusing diagnostic when missing where clause
7 participants