store the normalized types of statics in MIR Lvalues
The types of statics, like all other items, are stored in the tcx
unnormalized. This is necessarily so, because
a) Item types other than statics have generics, which can't be
normalized.
b) Eager normalization causes undesirable on-demand dependencies.
Keeping with the principle that MIR lvalues require no normalization in
order to interpret, this patch stores the normalized type of the statics
in the Lvalue and reads it to get the lvalue type.
Fixes #39367.
This commit is contained in:
parent
ca8708273b
commit
34ff9aa83f
8 changed files with 100 additions and 16 deletions
|
|
@ -382,11 +382,11 @@ impl<'a, 'tcx> MirConstContext<'a, 'tcx> {
|
|||
|
||||
let lvalue = match *lvalue {
|
||||
mir::Lvalue::Local(_) => bug!(), // handled above
|
||||
mir::Lvalue::Static(def_id) => {
|
||||
mir::Lvalue::Static(box mir::Static { def_id, ty }) => {
|
||||
ConstLvalue {
|
||||
base: Base::Static(consts::get_static(self.ccx, def_id)),
|
||||
llextra: ptr::null_mut(),
|
||||
ty: lvalue.ty(self.mir, tcx).to_ty(tcx)
|
||||
ty: self.monomorphize(&ty),
|
||||
}
|
||||
}
|
||||
mir::Lvalue::Projection(ref projection) => {
|
||||
|
|
|
|||
|
|
@ -304,10 +304,9 @@ impl<'a, 'tcx> MirContext<'a, 'tcx> {
|
|||
|
||||
let result = match *lvalue {
|
||||
mir::Lvalue::Local(_) => bug!(), // handled above
|
||||
mir::Lvalue::Static(def_id) => {
|
||||
let const_ty = self.monomorphized_lvalue_ty(lvalue);
|
||||
mir::Lvalue::Static(box mir::Static { def_id, ty }) => {
|
||||
LvalueRef::new_sized(consts::get_static(ccx, def_id),
|
||||
LvalueTy::from_ty(const_ty),
|
||||
LvalueTy::from_ty(self.monomorphize(&ty)),
|
||||
Alignment::AbiAligned)
|
||||
},
|
||||
mir::Lvalue::Projection(box mir::Projection {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue