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

Try to evaluate in try unify and postpone resolution of constants that contain inference variables #95179

Merged
merged 7 commits into from
Mar 25, 2022

Conversation

b-naber
Copy link
Contributor

@b-naber b-naber commented Mar 21, 2022

We want code like that in ui/const-generics/generic_const_exprs/eval-try-unify.rs to compile. To do that we need to try to evaluate constants in try_unify_abstract_consts, this requires us to be more careful about what constants we try to resolve, specifically we cannot try to resolve constants that still contain inference variables.

r? @lcnr

@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Mar 21, 2022
@rust-highfive
Copy link
Collaborator

Some changes occured to the CTFE / Miri engine

cc @rust-lang/miri

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Mar 21, 2022
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.

a few general nits, apart from that r=me

compiler/rustc_middle/src/mir/interpret/queries.rs Outdated Show resolved Hide resolved
src/test/ui/const-generics/issues/issue-83765.rs Outdated Show resolved Hide resolved
@rust-log-analyzer

This comment has been minimized.

@b-naber b-naber force-pushed the eval-in-try-unify branch 2 times, most recently from eb3a01f to 7d708fb Compare March 22, 2022 09:58
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@b-naber
Copy link
Contributor Author

b-naber commented Mar 22, 2022

Well ok this seems to behave badly with incremental. Only tested ui locally.

@@ -567,14 +569,27 @@ pub(super) fn thir_abstract_const<'tcx>(
}
}

/// Tries to unify two abstract constants using structural equality.
#[instrument(skip(tcx), level = "debug")]
pub(super) fn try_unify<'tcx>(
Copy link
Contributor

Choose a reason for hiding this comment

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

why do we need this to be pub(super) here? additionally, why the try_unify_inner split, can't we use ContextUnifyCtxt::new(tcx, param_env).try_unify(a, b) everywhere instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought this was the better abstraction, since always creating a ConstUnifyCtxt prior to that call didn't seem ideal at first. But we're calling try_unify only twice (besides the recursive calls) anyway and only in this file, so I got rid of the inner method.

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.

yeah, might have to guard against the infer vars in the param env as well.

Instead of canonicalization you should probably erase_regions which 1) improves caching 2) gets rid of region infer variables

@lcnr
Copy link
Contributor

lcnr commented Mar 22, 2022

also generally: please mark review comments as resolved after they are no longer relevant

Github sadly removes the context from review comments after a force push (I think), so I can't easily tell whether specific comments are still relevant. While you're still working on it, its also preferable to only push new commits if possible.

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.

some last nits 😅 after that r=me

compiler/rustc_infer/src/infer/mod.rs Outdated Show resolved Hide resolved
compiler/rustc_middle/src/mir/interpret/queries.rs Outdated Show resolved Hide resolved
@lcnr
Copy link
Contributor

lcnr commented Mar 24, 2022

@bors r+

@bors
Copy link
Contributor

bors commented Mar 24, 2022

📌 Commit 11a70db has been approved by lcnr

@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 Mar 24, 2022
@bors
Copy link
Contributor

bors commented Mar 24, 2022

⌛ Testing commit 11a70db with merge d3d54c547b90b9e2fbd58a0f4c803d94749d9e38...

@rust-log-analyzer
Copy link
Collaborator

A job failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)

Dylan-DPC added a commit to Dylan-DPC/rust that referenced this pull request Mar 24, 2022
Try to evaluate in try unify and postpone resolution of constants that contain inference variables

We want code like that in [`ui/const-generics/generic_const_exprs/eval-try-unify.rs`](https://github.com/rust-lang/rust/compare/master...b-naber:eval-in-try-unify?expand=1#diff-8027038201cf07a6c96abf3cbf0b0f4fdd8a64ce6292435f01c8ed995b87fe9b) to compile. To do that we need to try to evaluate constants in `try_unify_abstract_consts`, this requires us to be more careful about what constants we try to resolve, specifically we cannot try to resolve constants that still contain inference variables.

r? `@lcnr`
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this pull request Mar 24, 2022
Try to evaluate in try unify and postpone resolution of constants that contain inference variables

We want code like that in [`ui/const-generics/generic_const_exprs/eval-try-unify.rs`](https://github.com/rust-lang/rust/compare/master...b-naber:eval-in-try-unify?expand=1#diff-8027038201cf07a6c96abf3cbf0b0f4fdd8a64ce6292435f01c8ed995b87fe9b) to compile. To do that we need to try to evaluate constants in `try_unify_abstract_consts`, this requires us to be more careful about what constants we try to resolve, specifically we cannot try to resolve constants that still contain inference variables.

r? ``@lcnr``
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this pull request Mar 24, 2022
Try to evaluate in try unify and postpone resolution of constants that contain inference variables

We want code like that in [`ui/const-generics/generic_const_exprs/eval-try-unify.rs`](https://github.com/rust-lang/rust/compare/master...b-naber:eval-in-try-unify?expand=1#diff-8027038201cf07a6c96abf3cbf0b0f4fdd8a64ce6292435f01c8ed995b87fe9b) to compile. To do that we need to try to evaluate constants in `try_unify_abstract_consts`, this requires us to be more careful about what constants we try to resolve, specifically we cannot try to resolve constants that still contain inference variables.

r? ```@lcnr```
@Dylan-DPC
Copy link
Member

@bors r-

@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 Mar 24, 2022
@Dylan-DPC
Copy link
Member

uhm seems spurious

@bors r=lcnr

@bors
Copy link
Contributor

bors commented Mar 24, 2022

📌 Commit 11a70db has been approved by lcnr

@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 Mar 24, 2022
bors added a commit to rust-lang-ci/rust that referenced this pull request Mar 25, 2022
Rollup of 5 pull requests

Successful merges:

 - rust-lang#94391 (Fix ice when error reporting recursion errors)
 - rust-lang#94655 (Clarify which kinds of MIR are allowed during which phases.)
 - rust-lang#95179 (Try to evaluate in try unify and postpone resolution of constants that contain inference variables)
 - rust-lang#95270 (debuginfo: Fix debuginfo for Box<T> where T is unsized.)
 - rust-lang#95276 (add diagnostic items for clippy's `trim_split_whitespace`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 1fcb8fc into rust-lang:master Mar 25, 2022
@rustbot rustbot added this to the 1.61.0 milestone Mar 25, 2022
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants