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

Implement some candidates for the new solver (redux) #107004

Merged
merged 7 commits into from
Jan 19, 2023

Conversation

compiler-errors
Copy link
Member

Based on #106718, so the diff is hard to read without it. See here for an easier view until that one lands.

Of note:

  • 44af916020fb43c12070125c45b6dee4ec303bbc fixes a bug where we need to make the query response inside of a probe, or else we make no inference progress (I think)
  • 50daad5acd2f163d03e7ffab942534f09bc36e2e implements consider_assumption for traits and predicates. I'm not sure if using sup here is necessary or if eq is fine.
  • We decided that all of the instantiate_constituent_tys_for_* functions are verbose but ok, since they need to be exhaustive and the logic between each of them is not similar enough, right?

r? @lcnr

@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 Jan 17, 2023
@rustbot
Copy link
Collaborator

rustbot commented Jan 17, 2023

Some changes occurred to the core trait solver

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

@compiler-errors
Copy link
Member Author

compiler-errors commented Jan 17, 2023

This doesn't completely duplicate the logic in #106384, but I'm going to go a bit slower to avoid doing too much work and then having it accidentally obsoleted by refactors 😅

I am pretty happy with the structure of the new assembly, though.

@bors
Copy link
Contributor

bors commented Jan 18, 2023

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

Copy link
Contributor

@lcnr lcnr left a comment

Choose a reason for hiding this comment

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

would it make sense to take the

probe {
    instantiate_constituent_tys_for_X
    evaluate_goal_for_constituent_tys_and_make_canonical_response
}

pattern and make that a function taking a closure/function for instantiate_constituent_tys_for_X, removing the separate function for
evaluate_goal_for_constituent_tys_and_make_canonical_response?

I think it would also be nice to maybe move all impls of instantiate_constituent_tys_for_X into a submodule as their concrete impl is fairly unimportant when trying to understand the solver.

Apart from these nits r=me 👍

compiler/rustc_trait_selection/src/solve/infcx_ext.rs Outdated Show resolved Hide resolved
compiler/rustc_trait_selection/src/solve/project_goals.rs Outdated Show resolved Hide resolved
compiler/rustc_trait_selection/src/solve/trait_goals.rs Outdated Show resolved Hide resolved
compiler/rustc_trait_selection/src/solve/assembly.rs Outdated Show resolved Hide resolved
compiler/rustc_trait_selection/src/solve/project_goals.rs Outdated Show resolved Hide resolved
compiler/rustc_trait_selection/src/solve/trait_goals.rs Outdated Show resolved Hide resolved
@compiler-errors compiler-errors force-pushed the new-solver-new-candidates-2 branch 2 times, most recently from e776e88 to 53f15c5 Compare January 18, 2023 14:58
Comment on lines +339 to +348
for assumption in
elaborate_predicates(tcx, bounds.iter().map(|bound| bound.with_self_ty(tcx, self_ty)))
{
match G::consider_assumption(self, goal, assumption.predicate) {
Ok(result) => {
candidates.push(Candidate { source: CandidateSource::BuiltinImpl, result })
}
Err(NoSolution) => (),
}
}
Copy link
Contributor

@lcnr lcnr Jan 18, 2023

Choose a reason for hiding this comment

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

got reminded of #57893 again :<

@lcnr
Copy link
Contributor

lcnr commented Jan 18, 2023

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Jan 18, 2023

📌 Commit f672436 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 Jan 18, 2023
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Jan 18, 2023
…didates-2, r=lcnr

Implement some candidates for the new solver (redux)

Based on rust-lang#106718, so the diff is hard to read without it. See [here](rust-lang/rust@98700cf...compiler-errors:rust:new-solver-new-candidates-2) for an easier view until that one lands.

Of note:
* 44af916020fb43c12070125c45b6dee4ec303bbc fixes a bug where we need to make the query response *inside* of a probe, or else we make no inference progress (I think)
* 50daad5acd2f163d03e7ffab942534f09bc36e2e implements `consider_assumption` for traits and predicates. I'm not sure if using `sup` here is necessary or if `eq` is fine.
* We decided that all of the `instantiate_constituent_tys_for_*` functions are verbose but ok, since they need to be exhaustive and the logic between each of them is not similar enough, right?

r? `@lcnr`
bors added a commit to rust-lang-ci/rust that referenced this pull request Jan 19, 2023
…mpiler-errors

Rollup of 8 pull requests

Successful merges:

 - rust-lang#105796 (rustdoc: simplify JS search routine by not messing with lev distance)
 - rust-lang#106753 (Make sure that RPITITs are not considered suggestable)
 - rust-lang#106917 (Encode const mir for closures if they're const)
 - rust-lang#107004 (Implement some candidates for the new solver (redux))
 - rust-lang#107023 (Stop using `BREAK` & `CONTINUE` in compiler)
 - rust-lang#107030 (Correct typo)
 - rust-lang#107042 (rustdoc: fix corner cases with "?" JS keyboard command)
 - rust-lang#107045 (rustdoc: remove redundant CSS rule `#settings .setting-line`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit cf5068b into rust-lang:master Jan 19, 2023
@rustbot rustbot added this to the 1.68.0 milestone Jan 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

4 participants