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

Use fulfillment in next trait solver coherence #121193

Merged
merged 1 commit into from
Feb 17, 2024

Conversation

compiler-errors
Copy link
Member

Use fulfillment in the new trait solver's impl_intersection_has_impossible_obligation routine. This means that inference that falls out of processing other obligations can influence whether we can determine if an obligation is impossible to satisfy. See the committed test.

This should be completely sound, since evaluation and fulfillment both respect intercrate mode equally.

We run the risk of breaking coherence later if we were to change the rules of fulfillment and/or inference during coherence, but this is a problem which affects evaluation, as nested obligations from a trait goal are processed together and can influence each other in the same way.

r? lcnr
cc #114862

Also changed obligationctxt -> fulfillmentctxt because it feels kind of redundant to use an ocx here. I don't really care enough and can change it back if it really matters much.

@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. labels Feb 16, 2024
@compiler-errors
Copy link
Member Author

cc @BoxyUwU who may also care about this

@compiler-errors
Copy link
Member Author

For clarity, lcnr asked for this because it unbreaks some tests that are broken by their generalizer PR. They expressed some concern by coherence becoming more powerful here, but I am personally not worried about this case.

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.

infcx.evaluate_obligation(obligation)
} else {
if infcx.next_trait_solver() {
infcx.probe(|_| {
Copy link
Contributor

Choose a reason for hiding this comment

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

why the probe, i would expect that not using a probe results in better err msg and is desirable. E.g. if we infer _: Trait to Foreign: Trait we should check whether there are any intercrate ambiguity causes for Foreign

@rustbot
Copy link
Collaborator

rustbot commented Feb 16, 2024

Some changes occurred to the core trait solver

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

@rustbot rustbot added the WG-trait-system-refactor The Rustc Trait System Refactor Initiative label Feb 16, 2024
let (_, proof_tree) = self.evaluate_root_goal(goal, GenerateProofTree::Yes);
let proof_tree = proof_tree.unwrap();
visitor.visit_goal(&InspectGoal::new(self, 0, &proof_tree))
self.probe(|_| {
Copy link
Member Author

Choose a reason for hiding this comment

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

Added the probe here in visit_proof_tree so that it has no side effects.

@compiler-errors
Copy link
Member Author

compiler-errors commented Feb 16, 2024

whoops forgor the test

(I'm an idiot whoops misclick)

@lcnr
Copy link
Contributor

lcnr commented Feb 17, 2024

@bors r+ rollup (new solver)

@bors
Copy link
Contributor

bors commented Feb 17, 2024

📌 Commit 228441d 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 Feb 17, 2024
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Feb 17, 2024
…ent, r=lcnr

Use fulfillment in next trait solver coherence

Use fulfillment in the new trait solver's `impl_intersection_has_impossible_obligation` routine. This means that inference that falls out of processing other obligations can influence whether we can determine if an obligation is impossible to satisfy. See the committed test.

This should be completely sound, since evaluation and fulfillment both respect intercrate mode equally.

We run the risk of breaking coherence later if we were to change the rules of fulfillment and/or inference during coherence, but this is a problem which affects evaluation, as nested obligations from a trait goal are processed together and can influence each other in the same way.

r? lcnr
cc rust-lang#114862

Also changed obligationctxt -> fulfillmentctxt because it feels kind of redundant to use an ocx here. I don't really care enough and can change it back if it really matters much.
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Feb 17, 2024
…ent, r=lcnr

Use fulfillment in next trait solver coherence

Use fulfillment in the new trait solver's `impl_intersection_has_impossible_obligation` routine. This means that inference that falls out of processing other obligations can influence whether we can determine if an obligation is impossible to satisfy. See the committed test.

This should be completely sound, since evaluation and fulfillment both respect intercrate mode equally.

We run the risk of breaking coherence later if we were to change the rules of fulfillment and/or inference during coherence, but this is a problem which affects evaluation, as nested obligations from a trait goal are processed together and can influence each other in the same way.

r? lcnr
cc rust-lang#114862

Also changed obligationctxt -> fulfillmentctxt because it feels kind of redundant to use an ocx here. I don't really care enough and can change it back if it really matters much.
bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 17, 2024
…iaskrgr

Rollup of 8 pull requests

Successful merges:

 - rust-lang#120952 (Don't use mem::zeroed in vec::IntoIter)
 - rust-lang#121079 (distribute tool documentations and avoid file conflicts on `x install`)
 - rust-lang#121085 (errors: only eagerly translate subdiagnostics)
 - rust-lang#121091 (use build.rustc config and skip-stage0-validation flag)
 - rust-lang#121193 (Use fulfillment in next trait solver coherence)
 - rust-lang#121209 (Make `CodegenBackend::join_codegen` infallible.)
 - rust-lang#121210 (Fix `cfg(target_abi = "sim")` on `i386-apple-ios`)
 - rust-lang#121228 (create stamp file for clippy)

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 17, 2024
…iaskrgr

Rollup of 9 pull requests

Successful merges:

 - rust-lang#120952 (Don't use mem::zeroed in vec::IntoIter)
 - rust-lang#121085 (errors: only eagerly translate subdiagnostics)
 - rust-lang#121091 (use build.rustc config and skip-stage0-validation flag)
 - rust-lang#121149 (Fix typo in VecDeque::handle_capacity_increase() doc comment.)
 - rust-lang#121193 (Use fulfillment in next trait solver coherence)
 - rust-lang#121209 (Make `CodegenBackend::join_codegen` infallible.)
 - rust-lang#121210 (Fix `cfg(target_abi = "sim")` on `i386-apple-ios`)
 - rust-lang#121228 (create stamp file for clippy)
 - rust-lang#121231 (remove a couple of redundant clones)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit df3712c into rust-lang:master Feb 17, 2024
11 checks passed
@rustbot rustbot added this to the 1.78.0 milestone Feb 17, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Feb 17, 2024
Rollup merge of rust-lang#121193 - compiler-errors:coherence-fulfillment, r=lcnr

Use fulfillment in next trait solver coherence

Use fulfillment in the new trait solver's `impl_intersection_has_impossible_obligation` routine. This means that inference that falls out of processing other obligations can influence whether we can determine if an obligation is impossible to satisfy. See the committed test.

This should be completely sound, since evaluation and fulfillment both respect intercrate mode equally.

We run the risk of breaking coherence later if we were to change the rules of fulfillment and/or inference during coherence, but this is a problem which affects evaluation, as nested obligations from a trait goal are processed together and can influence each other in the same way.

r? lcnr
cc rust-lang#114862

Also changed obligationctxt -> fulfillmentctxt because it feels kind of redundant to use an ocx here. I don't really care enough and can change it back if it really matters much.
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants