-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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::Bubble
from MIR validation
#116803
Conversation
Some changes occurred to the CTFE / Miri engine cc @rust-lang/miri Some changes occurred to MIR optimizations cc @rust-lang/wg-mir-opt |
if util::relate_types( | ||
tcx, | ||
param_env, | ||
DefiningAnchor::Error, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CTFE is always performed with a Reveal::All
param-env (or it should, as far as I'm aware?) so it makes sense to use DefiningAnchor::Error
here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My justification is wrong here. We're not using a Reveal::All
param-env, but we have passed this body through the RevealAll
mir-pass.
Not totally clear if that's sufficient, but if it isn't, then we don't have a test for it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can also approximate the defining anchor from the current stack frame. See newest commit for approach.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My justification is wrong here. We're not using a
Reveal::All
param-env, but we have passed this body through theRevealAll
mir-pass.Not totally clear if that's sufficient, but if it isn't, then we don't have a test for it.
This is a bit of a mess. We re-use the result from running with Reveal::UserFacing
when running with Reveal::All
in CTFE. However, afaik there is (and well... should be) no call site actually using Reveal::UserFacing
. I think we should switch to always use Reveal::All
:
- using
Reveal::UserFacing
after revealing opaque types can result in weird errors and failures, as we end up trying to relate an opaque and its revealed (but normally hidden) type - when people call a
const
-function returningimpl Iterator<Item = u32>
they actually want to be able to use the returned value as an iterator. The check that we only treat the type opaquely happened in typeck but during codegen this behavior is undesirable. I haven't thought about specialization and default associated types yet, but also, idc. cc Stop usingReveal::All
before borrowck #101478 where I tried to change const generics CTFE to useReveal::UserFacing
.
if anchor != DefiningAnchor::Error { | ||
// With `Reveal::All`, opaque types get normalized away, with `Reveal::UserFacing` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The relationship between what the if
is checking (DefiningAnchor
, whatever that is) and what the comment talks about (Reveal::UserFacing
/Reveal::All
) is completely unclear.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well I didn't touch that comment, but I'll rework it I guess.
Is there any explanation anywhere on what a |
Always use RevealAll for const eval queries implements what is described in rust-lang#116803 (comment)
i dont have time to continue with this |
Always use RevealAll for const eval queries implements what is described in rust-lang#116803 (comment) Using `UserFacing` for const eval does not make sense anymore, unless we significantly change things like avoiding revealing opaque types. New tests are copied from rust-lang#101478
Always use RevealAll for const eval queries implements what is described in rust-lang/rust#116803 (comment) Using `UserFacing` for const eval does not make sense anymore, unless we significantly change things like avoiding revealing opaque types. New tests are copied from rust-lang/rust#101478
Always use RevealAll for const eval queries implements what is described in rust-lang/rust#116803 (comment) Using `UserFacing` for const eval does not make sense anymore, unless we significantly change things like avoiding revealing opaque types. New tests are copied from rust-lang/rust#101478
Always use RevealAll for const eval queries implements what is described in rust-lang/rust#116803 (comment) Using `UserFacing` for const eval does not make sense anymore, unless we significantly change things like avoiding revealing opaque types. New tests are copied from rust-lang/rust#101478
If we're in the MIR validator, our body is local, and our reveal mode is
Reveal::UserFacing
, then useDefiningAnchor::Bind
-- otherwise, we should never be constraining opaques, so useDefiningAnchor::Error
like codegen does.r? oli-obk