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

Fix trait solving ICEs #77720

Merged
merged 2 commits into from
Oct 22, 2020
Merged

Fix trait solving ICEs #77720

merged 2 commits into from
Oct 22, 2020

Conversation

matthewjasper
Copy link
Contributor

  • Selection candidates that are known to be applicable are preferred
    over candidates that are not.
  • Don't ICE if a projection/object candidate is no longer applicable
    (this can happen due to cycles in normalization)
  • Normalize supertraits when finding trait object candidates

Closes #77653
Closes #77656

r? @nikomatsakis

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Oct 8, 2020
@jyn514 jyn514 added A-traits Area: Trait system T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Oct 8, 2020
@tavianator
Copy link
Contributor

I can confirm that this fixes #77656, and https://github.com/tavianator/acap builds successfully now. Thanks!

@bors
Copy link
Contributor

bors commented Oct 13, 2020

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

Note that reviewers usually do not review pull requests until merge conflicts are resolved! Once you resolve the conflicts, you should change the labels applied by bors to indicate that your PR is ready for review. Post this as a comment to change the labels:

@rustbot modify labels: +S-waiting-on-review -S-waiting-on-author

@spastorino
Copy link
Member

spastorino commented Oct 15, 2020

@bors p=1

When this is merged it needs high priority because it fixes 2 P-critical issues.

@lqd
Copy link
Member

lqd commented Oct 15, 2020

If this needs "high priority", over rollups, it needs at least p=6: priorities 1 to 5 can be skipped by rollups

@spastorino
Copy link
Member

If this needs "high priority", over rollups, it needs at least p=6: priorities 1 to 5 can be skipped by rollups

I'm not sure if we have a policy but I'd make this kind of PR higher priority than rollups, yeah.

@lqd
Copy link
Member

lqd commented Oct 15, 2020

I wasn't aware of that policy either before Manish mentioned it to me.

then let's do @bors p=6 for when the PR is reviewed

i > j && !needs_infer
other.evaluation.must_apply_modulo_regions()
&& !needs_infer
&& (i < j || !victim.evaluation.must_apply_modulo_regions())
Copy link
Contributor

@nikomatsakis nikomatsakis Oct 15, 2020

Choose a reason for hiding this comment

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

Hmm I was worried when I read the PR description, but this is relatively narrowly tailored

@nikomatsakis
Copy link
Contributor

So, r=me, but I'd be happy to talk about this more with @matthewjasper -- they seemed to indicate a desire to talk it over. I'm like a little nervous about the changes to prefer one predicate over another but these do seem pretty narrowly tailored, and they avoid inference effects, so I'm not that worried.

@matthewjasper
Copy link
Contributor Author

After trying to find other options here there doesn't seem to be a much better solution without a much larger change here (e.g. making rustc more like chalk). I think that I slightly prefer this change, which simplifies how winnowing works in exchange for evaluating normalization cycles to Recur instead of Unknown. The patch here is against the head of this PR.

@@ -521,12 +521,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
                             result
                         }
                         Ok(Ok(None)) => Ok(EvaluatedToAmbig),
-                        // EvaluatedToRecur might also be acceptable here, but use
-                        // Unknown for now because it means that we won't dismiss a
-                        // selection candidate solely because it has a projection
-                        // cycle. This is closest to the previous behavior of
-                        // immediately erroring.
-                        Ok(Err(project::InProgress)) => Ok(EvaluatedToUnknown),
+                        Ok(Err(project::InProgress)) => Ok(EvaluatedToRecur),
                         Err(_) => Ok(EvaluatedToErr),
                     }
                 }
@@ -1387,9 +1382,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
             | (ObjectCandidate(i), ObjectCandidate(j)) => {
                 // Arbitrarily pick the lower numbered candidate for backwards
                 // compatibility reasons. Don't let this affect inference.
-                other.evaluation.must_apply_modulo_regions()
-                    && !needs_infer
-                    && (i < j || !victim.evaluation.must_apply_modulo_regions())
+                i < j && !needs_infer
             }
             (ObjectCandidate(_), ProjectionCandidate(_))
             | (ProjectionCandidate(_), ObjectCandidate(_)) => {

@nikomatsakis
Copy link
Contributor

@matthewjasper hmm I think I might prefer that patch too. EvaluateToRecur does seem appropriate for a cycle involving normalization.

@matthewjasper
Copy link
Contributor Author

@bors r=nikomatsakis

@bors
Copy link
Contributor

bors commented Oct 19, 2020

📌 Commit 56015a58635d8275f52998c07276adf0aed18cbc has been approved by nikomatsakis

@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 19, 2020
@jonas-schievink
Copy link
Contributor

@bors retry

@jonas-schievink
Copy link
Contributor

@bors retry r-

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Oct 19, 2020
@jonas-schievink
Copy link
Contributor

@bors r=nikomatsakis

@bors
Copy link
Contributor

bors commented Oct 19, 2020

📌 Commit 56015a58635d8275f52998c07276adf0aed18cbc has been approved by nikomatsakis

@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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Oct 19, 2020
@JohnTitor
Copy link
Member

@bors r-
Let me tell bors that this should be tested.

@matthewjasper
Copy link
Contributor Author

seeing if a force-push helps
@bors r=nikomatsakis

@bors
Copy link
Contributor

bors commented Oct 21, 2020

📌 Commit 64520d04b9eaa4899c1686ff02f9e51d0b8db5c4 has been approved by nikomatsakis

@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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Oct 21, 2020
@bors
Copy link
Contributor

bors commented Oct 21, 2020

⌛ Testing commit 64520d04b9eaa4899c1686ff02f9e51d0b8db5c4 with merge 8c26ccaa0b4c073a3d4a129650a486587ce7aac4...

@bors
Copy link
Contributor

bors commented Oct 21, 2020

💔 Test failed - checks-actions

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

@bors r=nikomatsakis

@bors
Copy link
Contributor

bors commented Oct 22, 2020

📌 Commit 50dde2e has been approved by nikomatsakis

@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 22, 2020
@bors
Copy link
Contributor

bors commented Oct 22, 2020

⌛ Testing commit 50dde2e with merge 1dc1166c4fd24c3625904339077abd92217a0c5c...

@bors
Copy link
Contributor

bors commented Oct 22, 2020

☀️ Test successful - checks-actions, checks-azure
Approved by: nikomatsakis
Pushing 1dc1166c4fd24c3625904339077abd92217a0c5c to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Oct 22, 2020
@bors
Copy link
Contributor

bors commented Oct 22, 2020

👀 Test was successful, but fast-forwarding failed: 422 Update is not a fast forward

@matthewjasper
Copy link
Contributor Author

Hmm, merge was against 8f0fa9d but master is at 6b9fbf2 cc @rust-lang/infra

@kennytm
Copy link
Member

kennytm commented Oct 22, 2020

@bors retry

@bors
Copy link
Contributor

bors commented Oct 22, 2020

⌛ Testing commit 50dde2e with merge a9cd294...

@bors
Copy link
Contributor

bors commented Oct 22, 2020

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-traits Area: Trait system 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