Skip to content

Explicitly don't normalize param-env in new solver #122403

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

Conversation

compiler-errors
Copy link
Member

Make it clear that we don't normalize param-envs in the new solver, since normalize is a noop. This also skips the ConstNormalizer hack in normalize_param_env_or_error, since we have deferred projection equality.

r? @lcnr @BoxyUwU

@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 Mar 12, 2024
@compiler-errors compiler-errors changed the title Explicitly don't normalize in new solver Explicitly don't normalize param-env in new solver Mar 12, 2024
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.

It feels a bit dangerous that we always have to explicitly elaborate when creating a new ParamEnv. I would like to have a slightly less "boring" name for fn new but can't think of anything too useful. Maybe ParamEnv::from_raw_components or something like that 🤔

r=me no matter what you prefer here

@compiler-errors
Copy link
Member Author

I think from_elaborated_clauses might be a good name

@compiler-errors compiler-errors force-pushed the explicitly-dont-normalize-in-new-solver branch from 1c2154b to eacc881 Compare March 19, 2024 15:29
@rustbot
Copy link
Collaborator

rustbot commented Mar 19, 2024

Some changes occurred in src/tools/clippy

cc @rust-lang/clippy

@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)
GITHUB_ENV=/home/runner/work/_temp/_runner_file_commands/set_env_24321e5c-d75a-4acc-911d-aac9aec8cb46
GITHUB_EVENT_NAME=pull_request
GITHUB_EVENT_PATH=/home/runner/work/_temp/_github_workflow/event.json
GITHUB_GRAPHQL_URL=https://api.github.com/graphql
GITHUB_HEAD_REF=explicitly-dont-normalize-in-new-solver
GITHUB_JOB=pr
GITHUB_PATH=/home/runner/work/_temp/_runner_file_commands/add_path_24321e5c-d75a-4acc-911d-aac9aec8cb46
GITHUB_REF=refs/pull/122403/merge
GITHUB_REF_NAME=122403/merge
GITHUB_REF_PROTECTED=false
---
     |
992  | pub struct ParamEnv<'tcx> {
     | ------------------------- function or associated item `new` not found for this struct
...
1061 |         Self::new(List::empty(), Reveal::UserFacing)
     |               ^^^ function or associated item not found in `ParamEnv<'tcx>`
     |
note: if you're trying to build a new `ParamEnv<'tcx>` consider using one of the following associated functions:
      ParamEnv::<'tcx>::empty
      ParamEnv::<'tcx>::reveal_all
      ParamEnv::<'tcx>::from_elaborated_clauses
     |
1060 |       pub fn empty() -> Self {
     |       ^^^^^^^^^^^^^^^^^^^^^^
...
...
1082 |       pub fn reveal_all() -> Self {
     |       ^^^^^^^^^^^^^^^^^^^^^^^^^^^
...
1088 | /     pub fn from_elaborated_clauses(
1089 | |         caller_bounds: &'tcx List<Clause<'tcx>>,
1090 | |         reveal: Reveal,
     | |_____________^

error[E0599]: no function or associated item named `new` found for struct `ParamEnv` in the current scope
    --> compiler/rustc_middle/src/ty/mod.rs:1083:15
    --> compiler/rustc_middle/src/ty/mod.rs:1083:15
     |
992  | pub struct ParamEnv<'tcx> {
     | ------------------------- function or associated item `new` not found for this struct
...
1083 |         Self::new(List::empty(), Reveal::All)
     |               ^^^ function or associated item not found in `ParamEnv<'tcx>`
     |
note: if you're trying to build a new `ParamEnv<'tcx>` consider using one of the following associated functions:
      ParamEnv::<'tcx>::empty
      ParamEnv::<'tcx>::reveal_all
      ParamEnv::<'tcx>::from_elaborated_clauses
     |
1060 |       pub fn empty() -> Self {
     |       ^^^^^^^^^^^^^^^^^^^^^^
...
...
1082 |       pub fn reveal_all() -> Self {
     |       ^^^^^^^^^^^^^^^^^^^^^^^^^^^
...
1088 | /     pub fn from_elaborated_clauses(
1089 | |         caller_bounds: &'tcx List<Clause<'tcx>>,
1090 | |         reveal: Reveal,
     | |_____________^

error[E0599]: no function or associated item named `new` found for struct `ParamEnv` in the current scope
    --> compiler/rustc_middle/src/ty/mod.rs:1123:15
    --> compiler/rustc_middle/src/ty/mod.rs:1123:15
     |
992  | pub struct ParamEnv<'tcx> {
     | ------------------------- function or associated item `new` not found for this struct
...
1123 |         Self::new(List::empty(), self.reveal())
     |               ^^^ function or associated item not found in `ParamEnv<'tcx>`
     |
note: if you're trying to build a new `ParamEnv<'tcx>` consider using one of the following associated functions:
      ParamEnv::<'tcx>::empty
      ParamEnv::<'tcx>::reveal_all
      ParamEnv::<'tcx>::from_elaborated_clauses
     |
1060 |       pub fn empty() -> Self {
     |       ^^^^^^^^^^^^^^^^^^^^^^
...
...
1082 |       pub fn reveal_all() -> Self {
     |       ^^^^^^^^^^^^^^^^^^^^^^^^^^^
...
1088 | /     pub fn from_elaborated_clauses(
1089 | |         caller_bounds: &'tcx List<Clause<'tcx>>,
1090 | |         reveal: Reveal,
     | |_____________^

For more information about this error, try `rustc --explain E0599`.
error: could not compile `rustc_middle` (lib) due to 3 previous errors

@BoxyUwU
Copy link
Member

BoxyUwU commented Mar 31, 2024

for rust-lang/trait-system-refactor-initiative#90 we might wind up with another step that we do in param env construction which under this PR would be another thing every callsite of ParamEnv::new would have to explicitly remember to do.

Seeing as how normalize_param_env_or_error does more than just normalizing maybe we ought to rename it to something like prepare_manually_constructed_env and have ParamEnv::new_unprepared_from_clauses or something. Then we can continue calling prepare_manually_constructed_env everywhere and do elaboration + filtering in it under new solver and normalization + elaboration under old solver

@lcnr
Copy link
Contributor

lcnr commented Apr 6, 2024

I agree with boxy and think that we may want to add additional assumptions about the input when creating a ParamEnv in the future. At this point we should change the name again, I do quite like fn from_raw_components. I think the current name is good until then however, so r=me after fixing CI.

@bors
Copy link
Collaborator

bors commented Apr 7, 2024

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

@lcnr lcnr 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 Apr 23, 2024
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants