-
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
Various const eval cleanups #116835
Various const eval cleanups #116835
Changes from all commits
0fce74e
5784e9e
f85b139
fec0b54
066ec12
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1074,17 +1074,14 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { | |
instance: ty::Instance<'tcx>, | ||
) -> InterpResult<'tcx, MPlaceTy<'tcx, M::Provenance>> { | ||
let gid = GlobalId { instance, promoted: None }; | ||
// For statics we pick `ParamEnv::reveal_all`, because statics don't have generics | ||
// and thus don't care about the parameter environment. While we could just use | ||
// `self.param_env`, that would mean we invoke the query to evaluate the static | ||
// with different parameter environments, thus causing the static to be evaluated | ||
// multiple times. | ||
let param_env = if self.tcx.is_static(gid.instance.def_id()) { | ||
ty::ParamEnv::reveal_all() | ||
let val = if self.tcx.is_static(gid.instance.def_id()) { | ||
let alloc_id = self.tcx.reserve_and_set_static_alloc(gid.instance.def_id()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, clever! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In particular, this doesn't actually add the assertion that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, because that isn't true in this PR yet. |
||
|
||
let ty = instance.ty(self.tcx.tcx, self.param_env); | ||
mir::ConstAlloc { alloc_id, ty } | ||
} else { | ||
self.param_env | ||
self.ctfe_query(|tcx| tcx.eval_to_allocation_raw(self.param_env.and(gid)))? | ||
}; | ||
let val = self.ctfe_query(|tcx| tcx.eval_to_allocation_raw(param_env.and(gid)))?; | ||
self.raw_const_to_mplace(val) | ||
} | ||
|
||
|
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.
This is just outlining, right? These new functions only have a single call site?
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.
yes