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