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

Remove DefiningAnchor from InferCtxt #108389

Closed
wants to merge 23 commits into from

Conversation

oli-obk
Copy link
Contributor

@oli-obk oli-obk commented Feb 23, 2023

This PR removes the InferCtxt::defining_use_anchor field and instead bubbles it through the appropriate types and functions that already need to know about their body owner (e.g. hir typeck or mir borrowck/typeck).

follow-up to #108311

r? @lcnr

@rustbot
Copy link
Collaborator

rustbot commented Feb 23, 2023

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @lcnr (or someone else) soon.

Please see the contribution instructions for more information.

@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 labels Feb 23, 2023
@rustbot
Copy link
Collaborator

rustbot commented Feb 23, 2023

Some changes occurred in engine.rs, potentially modifying the public API of ObligationCtxt.

cc @lcnr, @compiler-errors

Some changes occurred to the core trait solver

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

@oli-obk
Copy link
Contributor Author

oli-obk commented Feb 23, 2023

@bors try @rust-timer queue

need to crater this, too

@rust-timer

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Feb 23, 2023
@bors
Copy link
Contributor

bors commented Feb 23, 2023

⌛ Trying commit c6f51440db29e048884073c7767841e88a8c9275 with merge f8af1895d636b112468fb6304c316e2cce25a8d6...

@bors
Copy link
Contributor

bors commented Feb 23, 2023

💔 Test failed - checks-actions

@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-review Status: Awaiting review from the assignee but also interested parties. labels Feb 23, 2023
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

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.

I really like this change.

I personally think it would be good to stop using DefiningAnchor::Error as the default and always require the user to explicitly provide the anchor.

E.g. by changing infcx.at(param_env, cause).define_opaque_types(anchor) to infcx.at(param_env, cause, anchor).

Same for ObligationCtxt and probably a few other places.

having looked through all changes yet, but I am really happy about what I've seen so far and the general direction of this PR.

compiler/rustc_hir_typeck/src/fn_ctxt/mod.rs Outdated Show resolved Hide resolved
compiler/rustc_infer/src/infer/canonical/query_response.rs Outdated Show resolved Hide resolved
@oli-obk
Copy link
Contributor Author

oli-obk commented Feb 23, 2023

I personally would really like to stop using DefiningAnchor::Error as the default and always require the user to explicitly provide the anchor.

yea, but doing that at the same time as this PR would've been increadibly hard to review properly

@oli-obk
Copy link
Contributor Author

oli-obk commented Feb 23, 2023

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@bors
Copy link
Contributor

bors commented Feb 23, 2023

⌛ Trying commit 557cf7bf1aea5ccdaa663a66cc254fe6d5c5d405 with merge 9edc8987ad42f7a9d21d57465015000ae3578c17...

@bors
Copy link
Contributor

bors commented Feb 23, 2023

☀️ Try build successful - checks-actions
Build commit: 9edc8987ad42f7a9d21d57465015000ae3578c17 (9edc8987ad42f7a9d21d57465015000ae3578c17)

@rust-timer

This comment has been minimized.

@rustbot
Copy link
Collaborator

rustbot commented Feb 23, 2023

Some changes occurred in const_evaluatable.rs

cc @BoxyUwU

Some changes occurred in src/tools/clippy

cc @rust-lang/clippy

@oli-obk
Copy link
Contributor Author

oli-obk commented Feb 23, 2023

@craterbot check

@craterbot
Copy link
Collaborator

👌 Experiment pr-108389 created and queued.
🤖 Automatically detected try build 9edc8987ad42f7a9d21d57465015000ae3578c17
⚠️ Try build based on commit 557cf7bf1aea5ccdaa663a66cc254fe6d5c5d405, but latest commit is 4d36170c6d09c01e3a14d1ab2509e41966c68039. Did you forget to make a new try build?
🔍 You can check out the queue and this experiment's details.

ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

@craterbot craterbot removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Feb 23, 2023
It was only used in error paths or places already using `DefiningAchor::Error` already
They were already `Error` at all use sites
@rust-log-analyzer
Copy link
Collaborator

The job x86_64-gnu-tools failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
Prepare all required actions
Getting action download info
Download action repository 'actions/checkout@v3' (SHA:ac593985615ec2ede58e132d2e21d2b1cbd6127c)
Download action repository 'rust-lang/simpleinfra@master' (SHA:0fdabd83e1d3faaa8e9cfd7c00031e3a92997344)
Complete job name: PR (x86_64-gnu-tools, false, ubuntu-20.04-xl)
git config --global core.autocrlf false
shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
env:
  CI_JOB_NAME: x86_64-gnu-tools
---
   Compiling rustc_data_structures v0.0.0 (/checkout/compiler/rustc_data_structures)
error[E0284]: type annotations needed
   --> compiler/rustc_data_structures/src/obligation_forest/mod.rs:352:63
    |
352 |                     None => self.obligation_tree_id_generator.next().unwrap(),
    |
    |
    = note: cannot satisfy `<_ as Iterator>::Item == ObligationTreeId`
    |
    |
352 |                     None => <Self as Iterator>::next(self.obligation_tree_id_generator).unwrap(),

For more information about this error, try `rustc --explain E0284`.
error: could not compile `rustc_data_structures` due to previous error
Build completed unsuccessfully in 0:05:06

@bors
Copy link
Contributor

bors commented Mar 3, 2023

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

@oli-obk
Copy link
Contributor Author

oli-obk commented Mar 15, 2023

@lcnr is working on doing something similar to this PR in smaller steps.

@oli-obk oli-obk closed this Mar 15, 2023
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Mar 15, 2023
… r=oli-obk

make `define_opaque_types` fully explicit

based on the idea of rust-lang#108389. Moved `define_opaque_types` into the actual operations, e.g. `eq`, instead of `infcx.at` because normalization doesn't use `define_opaque_types` and even creates it's own `At` with a different `define_opaque_types` internally.

Somewhat surprisingly, coherence actually relies on `DefineOpaqueTypes::Yes` for soundness which was revealed because I've incorrectly used `DefineOpaqueTypes::No` in `equate_impl_headers`. It feels concerning that even though this is the case, we still sometimes use `DefineOpaqueTypes::No` in coherence. I did not look into this as part of this PR as it is purely changing the structure of the code without changing behavior in any way.

r? `@oli-obk`
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Mar 16, 2023
… r=oli-obk

make `define_opaque_types` fully explicit

based on the idea of rust-lang#108389. Moved `define_opaque_types` into the actual operations, e.g. `eq`, instead of `infcx.at` because normalization doesn't use `define_opaque_types` and even creates it's own `At` with a different `define_opaque_types` internally.

Somewhat surprisingly, coherence actually relies on `DefineOpaqueTypes::Yes` for soundness which was revealed because I've incorrectly used `DefineOpaqueTypes::No` in `equate_impl_headers`. It feels concerning that even though this is the case, we still sometimes use `DefineOpaqueTypes::No` in coherence. I did not look into this as part of this PR as it is purely changing the structure of the code without changing behavior in any way.

r? ``@oli-obk``
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Mar 16, 2023
… r=oli-obk

make `define_opaque_types` fully explicit

based on the idea of rust-lang#108389. Moved `define_opaque_types` into the actual operations, e.g. `eq`, instead of `infcx.at` because normalization doesn't use `define_opaque_types` and even creates it's own `At` with a different `define_opaque_types` internally.

Somewhat surprisingly, coherence actually relies on `DefineOpaqueTypes::Yes` for soundness which was revealed because I've incorrectly used `DefineOpaqueTypes::No` in `equate_impl_headers`. It feels concerning that even though this is the case, we still sometimes use `DefineOpaqueTypes::No` in coherence. I did not look into this as part of this PR as it is purely changing the structure of the code without changing behavior in any way.

r? ```@oli-obk```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. 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.

7 participants