Skip to content

Provide structured suggestions when finding structs when expecting a trait #77087

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

Merged
merged 6 commits into from
Oct 11, 2020

Conversation

estebank
Copy link
Contributor

@estebank estebank commented Sep 23, 2020

When finding an ADT in a trait object definition provide some solutions. Fix #45817.
Given <Param as Trait>::Assoc: Ty suggest Param: Trait<Assoc = Ty>. Fix #75829.

@rust-highfive
Copy link
Contributor

r? @matthewjasper

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 23, 2020
@jyn514 jyn514 added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. A-diagnostics Area: Messages for errors, warnings, and lints A-lifetimes Area: Lifetimes / regions labels Sep 23, 2020
@estebank estebank changed the title When finding an ADT in a trait object definition provide some solutions Provide structured suggestion when finding structs when expecting a trait Sep 24, 2020
@estebank estebank changed the title Provide structured suggestion when finding structs when expecting a trait Provide structured suggestions when finding structs when expecting a trait Sep 24, 2020
@estebank
Copy link
Contributor Author

Screen Shot 2020-09-23 at 11 04 20 PM

vs

Screen Shot 2020-09-23 at 11 04 26 PM

and

Screen Shot 2020-09-23 at 11 06 05 PM

vs

Screen Shot 2020-09-23 at 11 05 48 PM

};
if !(matches!(
partial_res.base_res(),
hir::def::Res::Def(hir::def::DefKind::AssocTy, _)
Copy link
Contributor

@matthewjasper matthewjasper Sep 26, 2020

Choose a reason for hiding this comment

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

Why is this needed? This suggestion would also make sense for <&T as Trait>::Assoc: String

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think you might have meant to point at the next matches check, as this one just verifies that we are trying to constrain an associated type. The last commit now accounts for references. I have these checks because I want to avoid incorrect suggestions, as that is more harmful than not providing a suggestion we could have.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For future reference, this will not help for a case like <(T, T) as Trait>::Assoc: String.

@matthewjasper
Copy link
Contributor

@bors r+

@bors
Copy link
Collaborator

bors commented Oct 10, 2020

📌 Commit 4ae8f6e has been approved by matthewjasper

@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 Oct 10, 2020
@bors
Copy link
Collaborator

bors commented Oct 10, 2020

⌛ Testing commit 4ae8f6e with merge 08764ad...

@bors
Copy link
Collaborator

bors commented Oct 11, 2020

☀️ Test successful - checks-actions, checks-azure
Approved by: matthewjasper
Pushing 08764ad to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Oct 11, 2020
@bors bors merged commit 08764ad into rust-lang:master Oct 11, 2020
@rustbot rustbot added this to the 1.49.0 milestone Oct 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-lifetimes Area: Lifetimes / regions 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. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
6 participants