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 support for inherent projections in new solver #113336

Merged
merged 2 commits into from
Jul 17, 2023

Conversation

compiler-errors
Copy link
Member

Not hard to support these, and it cuts out a really big chunk of failing UI tests with --compare-mode=next-solver

r? @lcnr (feel free to reassign, anyone can review this)

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver) labels Jul 4, 2023
@rustbot
Copy link
Collaborator

rustbot commented Jul 4, 2023

Some changes occurred to the core trait solver

cc @rust-lang/initiative-trait-system-refactor

tcx.type_of(impl_def_id).subst(tcx, impl_substs),
)?;
self.add_goals(
tcx.predicates_of(impl_def_id)
Copy link
Member Author

Choose a reason for hiding this comment

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

Here, just like the normal projection code,

let where_clause_bounds = tcx
.predicates_of(impl_def_id)
.instantiate(tcx, impl_substs)
.predicates
.into_iter()
.map(|pred| goal.with(tcx, pred));
ecx.add_goals(where_clause_bounds);
we only register the impl's where clauses. the GAT's own where clauses are guaranteed by well-formedness.

Not exactly sure if we should be registering both. Maybe it affects inference?? 🤷

Copy link
Contributor

@lcnr lcnr Jul 7, 2023

Choose a reason for hiding this comment

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

please also check GAT where clauses for this, ordinary trait impl candidates and object candidates, and weak alias types rust-lang/trait-system-refactor-initiative#44

@@ -122,6 +123,14 @@ impl<'tcx> assembly::GoalKind<'tcx> for ProjectionPredicate<'tcx> {
)?;
ecx.eq(goal.param_env, goal.predicate.term, assumption_projection_pred.term)
.expect("expected goal term to be fully unconstrained");

// Add GAT where clauses from the trait's definition
Copy link
Member Author

Choose a reason for hiding this comment

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

I found it easier to check the GAT WC here in probe_and_match_goal_against_assumption rather than just doing it for object candidates. This also makes sure we check them correctly for alias bounds, and for most other built-in bounds which end up flowing through this method.

Let me know what you think about this.

Copy link
Contributor

Choose a reason for hiding this comment

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

hm... I don't feel too happy about this but don't really know. It feels potentially unnecessary and might cause issues. But I guess we cna always move it out and check it in less places.

Copy link
Member Author

Choose a reason for hiding this comment

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

I mean, especially moving towards coinduction, I'm not certain if I understand how this isn't going to be necessary. Builtin candidates should be checking their GAT WCs for them to be sound, right?

@bors
Copy link
Contributor

bors commented Jul 13, 2023

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

@lcnr
Copy link
Contributor

lcnr commented Jul 14, 2023

r=me after rebase

@compiler-errors
Copy link
Member Author

@bors r=lcnr

@bors
Copy link
Contributor

bors commented Jul 14, 2023

📌 Commit 7c3d5fffbb844c9ec34e4e55d9af02fc53c0cfb3 has been approved by lcnr

It is now in the queue for this repository.

@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 14, 2023
@bors
Copy link
Contributor

bors commented Jul 14, 2023

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

@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 Jul 14, 2023
@bors
Copy link
Contributor

bors commented Jul 15, 2023

🔒 Merge conflict

This pull request and the master branch diverged in a way that cannot be automatically merged. Please rebase on top of the latest master branch, and let the reviewer approve again.

How do I rebase?

Assuming self is your fork and upstream is this repository, you can resolve the conflict following these steps:

  1. git checkout new-solver-iat (switch to your branch)
  2. git fetch upstream master (retrieve the latest master)
  3. git rebase upstream/master -p (rebase on top of it)
  4. Follow the on-screen instruction to resolve conflicts (check git status if you got lost).
  5. git push self new-solver-iat --force-with-lease (update this PR)

You may also read Git Rebasing to Resolve Conflicts by Drew Blessing for a short tutorial.

Please avoid the "Resolve conflicts" button on GitHub. It uses git merge instead of git rebase which makes the PR commit history more difficult to read.

Sometimes step 4 will complete without asking for resolution. This is usually due to difference between how Cargo.lock conflict is handled during merge and rebase. This is normal, and you should still perform step 5 to update this PR.

Error message
Auto-merging compiler/rustc_trait_selection/src/traits/project.rs
CONFLICT (content): Merge conflict in compiler/rustc_trait_selection/src/traits/project.rs
Auto-merging compiler/rustc_trait_selection/src/solve/weak_types.rs
Auto-merging compiler/rustc_trait_selection/src/solve/project_goals.rs
Auto-merging compiler/rustc_trait_selection/src/solve/mod.rs
Auto-merging compiler/rustc_middle/src/ty/sty.rs
CONFLICT (content): Merge conflict in compiler/rustc_middle/src/ty/sty.rs
Automatic merge failed; fix conflicts and then commit the result.

@compiler-errors
Copy link
Member Author

rebased to rename substs to args

@bors r=lcnr

@bors
Copy link
Contributor

bors commented Jul 16, 2023

📌 Commit c9ce51b has been approved by lcnr

It is now in the queue for this repository.

@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 Jul 16, 2023
@bors
Copy link
Contributor

bors commented Jul 17, 2023

⌛ Testing commit c9ce51b with merge 4c7af42...

@bors
Copy link
Contributor

bors commented Jul 17, 2023

☀️ Test successful - checks-actions
Approved by: lcnr
Pushing 4c7af42 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Jul 17, 2023
@bors bors merged commit 4c7af42 into rust-lang:master Jul 17, 2023
@rustbot rustbot added this to the 1.73.0 milestone Jul 17, 2023
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (4c7af42): comparison URL.

Overall result: ❌ regressions - no action needed

@rustbot label: -perf-regression

Instruction count

This is a highly reliable metric that was used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
0.8% [0.6%, 1.0%] 3
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Max RSS (memory usage)

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-2.0% [-2.0%, -2.0%] 1
All ❌✅ (primary) - - 0

Cycles

This benchmark run did not return any relevant results for this metric.

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 657.855s -> 656.194s (-0.25%)

@compiler-errors compiler-errors deleted the new-solver-iat branch August 11, 2023 20:09
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. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants