review fixes
This commit is contained in:
parent
8829ddadc4
commit
cf2f1bb072
@ -622,13 +622,13 @@ impl<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
||||
// and we can then extract the value by evaluating the promoted.
|
||||
mir::Operand::Copy(
|
||||
Place::Base(PlaceBase::Static(
|
||||
box mir::Static {promoted: Some(promoted), ty, ..}
|
||||
))
|
||||
box mir::Static {promoted: Some(promoted), ty, ..}
|
||||
))
|
||||
) |
|
||||
mir::Operand::Move(
|
||||
Place::Base(PlaceBase::Static(
|
||||
box mir::Static {promoted: Some(promoted), ty, ..}
|
||||
))
|
||||
box mir::Static {promoted: Some(promoted), ty, ..}
|
||||
))
|
||||
) => {
|
||||
let param_env = ty::ParamEnv::reveal_all();
|
||||
let cid = mir::interpret::GlobalId {
|
||||
|
@ -455,6 +455,27 @@ impl<'a, 'b, 'gcx, 'tcx> TypeVerifier<'a, 'b, 'gcx, 'tcx> {
|
||||
},
|
||||
Place::Base(PlaceBase::Static(box Static { def_id, ty: sty, promoted })) => {
|
||||
let sty = self.sanitize_type(place, sty);
|
||||
let check_err =
|
||||
|verifier: &mut TypeVerifier<'a, 'b, 'gcx, 'tcx> ,
|
||||
place: &Place<'tcx>,
|
||||
ty,
|
||||
sty| {
|
||||
if let Err(terr) = verifier.cx.eq_types(
|
||||
sty,
|
||||
ty,
|
||||
location.to_locations(),
|
||||
ConstraintCategory::Boring,
|
||||
) {
|
||||
span_mirbug!(
|
||||
verifier,
|
||||
place,
|
||||
"bad promoted type ({:?}: {:?}): {:?}",
|
||||
ty,
|
||||
sty,
|
||||
terr
|
||||
);
|
||||
};
|
||||
};
|
||||
match promoted {
|
||||
Some(pr) => {
|
||||
if !self.errors_reported {
|
||||
@ -462,45 +483,14 @@ impl<'a, 'b, 'gcx, 'tcx> TypeVerifier<'a, 'b, 'gcx, 'tcx> {
|
||||
self.sanitize_promoted(promoted_mir, location);
|
||||
|
||||
let promoted_ty = promoted_mir.return_ty();
|
||||
|
||||
if let Err(terr) = self.cx.eq_types(
|
||||
sty,
|
||||
promoted_ty,
|
||||
location.to_locations(),
|
||||
ConstraintCategory::Boring,
|
||||
) {
|
||||
span_mirbug!(
|
||||
self,
|
||||
place,
|
||||
"bad promoted type ({:?}: {:?}): {:?}",
|
||||
promoted_ty,
|
||||
sty,
|
||||
terr
|
||||
);
|
||||
};
|
||||
check_err(self, place, promoted_ty, sty);
|
||||
}
|
||||
}
|
||||
None => {
|
||||
let ty = self.tcx().type_of(def_id);
|
||||
let ty = self.cx.normalize(ty, location);
|
||||
if let Err(terr) =
|
||||
self.cx
|
||||
.eq_types(
|
||||
ty,
|
||||
sty,
|
||||
location.to_locations(),
|
||||
ConstraintCategory::Boring
|
||||
)
|
||||
{
|
||||
span_mirbug!(
|
||||
self,
|
||||
place,
|
||||
"bad static type ({:?}: {:?}): {:?}",
|
||||
ty,
|
||||
sty,
|
||||
terr
|
||||
);
|
||||
};
|
||||
|
||||
check_err(self, place, ty, sty);
|
||||
}
|
||||
}
|
||||
PlaceTy::Ty { ty: sty }
|
||||
|
@ -283,7 +283,7 @@ impl<'a, 'mir, 'tcx> ConstPropagator<'a, 'mir, 'tcx> {
|
||||
// an `Index` projection would throw us off-track.
|
||||
_ => None,
|
||||
},
|
||||
Place::Base(PlaceBase::Static(box Static {promoted: Some(promoted), ty: _, ..})) => {
|
||||
Place::Base(PlaceBase::Static(box Static {promoted: Some(promoted), ..})) => {
|
||||
let generics = self.tcx.generics_of(self.source.def_id());
|
||||
if generics.requires_monomorphization(self.tcx) {
|
||||
// FIXME: can't handle code with generics
|
||||
|
@ -692,14 +692,9 @@ impl<'a, 'tcx> MutVisitor<'tcx> for Integrator<'a, 'tcx> {
|
||||
// Return pointer; update the place itself
|
||||
*place = self.destination.clone();
|
||||
},
|
||||
Place::Base(PlaceBase::Static(ref mut static_)) => {
|
||||
match static_.promoted {
|
||||
Some(promoted) => {
|
||||
if let Some(p) = self.promoted_map.get(promoted).cloned() {
|
||||
static_.promoted = Some(p);
|
||||
}
|
||||
}
|
||||
None => self.super_place(place, _ctxt, _location)
|
||||
Place::Base(PlaceBase::Static(box Static { promoted: Some(promoted), .. })) => {
|
||||
if let Some(p) = self.promoted_map.get(*promoted).cloned() {
|
||||
*promoted = p;
|
||||
}
|
||||
},
|
||||
_ => self.super_place(place, _ctxt, _location)
|
||||
|
@ -153,7 +153,7 @@ struct Promoter<'a, 'tcx: 'a> {
|
||||
/// If true, all nested temps are also kept in the
|
||||
/// source MIR, not moved to the promoted MIR.
|
||||
keep_original: bool,
|
||||
def_id: DefId
|
||||
def_id: DefId,
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> Promoter<'a, 'tcx> {
|
||||
@ -291,17 +291,14 @@ impl<'a, 'tcx> Promoter<'a, 'tcx> {
|
||||
fn promote_candidate(mut self, candidate: Candidate) {
|
||||
use rustc::mir::Static;
|
||||
let mut operand = {
|
||||
let def_id = self.def_id.clone();
|
||||
let def_id = self.def_id;
|
||||
let promoted = &mut self.promoted;
|
||||
let promoted_id = Promoted::new(self.source.promoted.len());
|
||||
let mut promoted_place = |ty, span| {
|
||||
promoted.span = span;
|
||||
promoted.local_decls[RETURN_PLACE] =
|
||||
LocalDecl::new_return_place(ty, span);
|
||||
Place::Base(PlaceBase::Static(
|
||||
Box::new(Static { def_id: def_id, ty, promoted: Some(promoted_id) })
|
||||
)
|
||||
)
|
||||
promoted.local_decls[RETURN_PLACE] = LocalDecl::new_return_place(ty, span);
|
||||
Place::Base(
|
||||
PlaceBase::Static(Box::new(Static { def_id, ty, promoted: Some(promoted_id) })))
|
||||
};
|
||||
let (blocks, local_decls) = self.source.basic_blocks_and_local_decls_mut();
|
||||
match candidate {
|
||||
@ -421,7 +418,7 @@ pub fn promote_candidates<'a, 'tcx>(mir: &mut Mir<'tcx>,
|
||||
source: mir,
|
||||
temps: &mut temps,
|
||||
keep_original: false,
|
||||
def_id
|
||||
def_id,
|
||||
};
|
||||
promoter.promote_candidate(candidate);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user