Skip to content

Normalize bounds fully when checking defaulted types #74670

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 3 commits into from
Jul 26, 2020

Conversation

tmandry
Copy link
Member

@tmandry tmandry commented Jul 23, 2020

When checking that the default type for <T as X>::Y is valid in this example:

trait X { type Y: PartialEq<<Self as X>::Y> }
impl X for T { default type Y = S; }

We will have to prove the bound S: PartialEq<<T as X>::Y>. In this case
we want <T as X>::Y to normalize to S. This is valid because we are
checking the default value specifically here. Add <T as X>::Y = S to the
ParamEnv for normalization of the bound we are checking only.

Fixes #73818.


I noticed that adding this to the env for bounds checking didn't break any tests. Not sure if this is because we can't rely on it to prove anything, or because of missing test coverage.

r? @matthewjasper, @nikomatsakis

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 23, 2020
@tmandry
Copy link
Member Author

tmandry commented Jul 24, 2020

Friendly ping, can I get a review?

@matthewjasper
Copy link
Contributor

Can you try replacing the value of concrete_ty_predicate (line 1277) with predicate.subst(tcx, rebased_substs). Most of the code there is manually normalizing things that should now be normalizable using the additional predicate.

@tmandry
Copy link
Member Author

tmandry commented Jul 25, 2020

That worked!

Note that I now add the predicate unconditionally (removing the branch on is_final()) to avoid regressing an error message for a GAT outlives bound. Details are in the commit history.

@matthewjasper
Copy link
Contributor

@bors r+

@bors
Copy link
Collaborator

bors commented Jul 25, 2020

📌 Commit e35d286 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 Jul 25, 2020
@bors
Copy link
Collaborator

bors commented Jul 25, 2020

⌛ Testing commit e35d286 with merge bb85981...

@bors
Copy link
Collaborator

bors commented Jul 26, 2020

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

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Jul 26, 2020
@bors bors merged commit bb85981 into rust-lang:master Jul 26, 2020
@tmandry tmandry deleted the issue-73818 branch July 26, 2020 03:44
@cuviper cuviper added this to the 1.47.0 milestone May 2, 2024
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.

Regression in associated type checking for default impls
5 participants