Skip to content

Commit cf2f1bb

Browse files
author
Saleem Jaffer
committed
review fixes
1 parent 8829dda commit cf2f1bb

File tree

5 files changed

+38
-56
lines changed

5 files changed

+38
-56
lines changed

src/librustc_codegen_ssa/mir/block.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -622,13 +622,13 @@ impl<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
622622
// and we can then extract the value by evaluating the promoted.
623623
mir::Operand::Copy(
624624
Place::Base(PlaceBase::Static(
625-
box mir::Static {promoted: Some(promoted), ty, ..}
626-
))
625+
box mir::Static {promoted: Some(promoted), ty, ..}
626+
))
627627
) |
628628
mir::Operand::Move(
629629
Place::Base(PlaceBase::Static(
630-
box mir::Static {promoted: Some(promoted), ty, ..}
631-
))
630+
box mir::Static {promoted: Some(promoted), ty, ..}
631+
))
632632
) => {
633633
let param_env = ty::ParamEnv::reveal_all();
634634
let cid = mir::interpret::GlobalId {

src/librustc_mir/borrow_check/nll/type_check/mod.rs

Lines changed: 24 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -455,52 +455,42 @@ impl<'a, 'b, 'gcx, 'tcx> TypeVerifier<'a, 'b, 'gcx, 'tcx> {
455455
},
456456
Place::Base(PlaceBase::Static(box Static { def_id, ty: sty, promoted })) => {
457457
let sty = self.sanitize_type(place, sty);
458+
let check_err =
459+
|verifier: &mut TypeVerifier<'a, 'b, 'gcx, 'tcx> ,
460+
place: &Place<'tcx>,
461+
ty,
462+
sty| {
463+
if let Err(terr) = verifier.cx.eq_types(
464+
sty,
465+
ty,
466+
location.to_locations(),
467+
ConstraintCategory::Boring,
468+
) {
469+
span_mirbug!(
470+
verifier,
471+
place,
472+
"bad promoted type ({:?}: {:?}): {:?}",
473+
ty,
474+
sty,
475+
terr
476+
);
477+
};
478+
};
458479
match promoted {
459480
Some(pr) => {
460481
if !self.errors_reported {
461482
let promoted_mir = &self.mir.promoted[pr];
462483
self.sanitize_promoted(promoted_mir, location);
463484

464485
let promoted_ty = promoted_mir.return_ty();
465-
466-
if let Err(terr) = self.cx.eq_types(
467-
sty,
468-
promoted_ty,
469-
location.to_locations(),
470-
ConstraintCategory::Boring,
471-
) {
472-
span_mirbug!(
473-
self,
474-
place,
475-
"bad promoted type ({:?}: {:?}): {:?}",
476-
promoted_ty,
477-
sty,
478-
terr
479-
);
480-
};
486+
check_err(self, place, promoted_ty, sty);
481487
}
482488
}
483489
None => {
484490
let ty = self.tcx().type_of(def_id);
485491
let ty = self.cx.normalize(ty, location);
486-
if let Err(terr) =
487-
self.cx
488-
.eq_types(
489-
ty,
490-
sty,
491-
location.to_locations(),
492-
ConstraintCategory::Boring
493-
)
494-
{
495-
span_mirbug!(
496-
self,
497-
place,
498-
"bad static type ({:?}: {:?}): {:?}",
499-
ty,
500-
sty,
501-
terr
502-
);
503-
};
492+
493+
check_err(self, place, ty, sty);
504494
}
505495
}
506496
PlaceTy::Ty { ty: sty }

src/librustc_mir/transform/const_prop.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ impl<'a, 'mir, 'tcx> ConstPropagator<'a, 'mir, 'tcx> {
283283
// an `Index` projection would throw us off-track.
284284
_ => None,
285285
},
286-
Place::Base(PlaceBase::Static(box Static {promoted: Some(promoted), ty: _, ..})) => {
286+
Place::Base(PlaceBase::Static(box Static {promoted: Some(promoted), ..})) => {
287287
let generics = self.tcx.generics_of(self.source.def_id());
288288
if generics.requires_monomorphization(self.tcx) {
289289
// FIXME: can't handle code with generics

src/librustc_mir/transform/inline.rs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -692,14 +692,9 @@ impl<'a, 'tcx> MutVisitor<'tcx> for Integrator<'a, 'tcx> {
692692
// Return pointer; update the place itself
693693
*place = self.destination.clone();
694694
},
695-
Place::Base(PlaceBase::Static(ref mut static_)) => {
696-
match static_.promoted {
697-
Some(promoted) => {
698-
if let Some(p) = self.promoted_map.get(promoted).cloned() {
699-
static_.promoted = Some(p);
700-
}
701-
}
702-
None => self.super_place(place, _ctxt, _location)
695+
Place::Base(PlaceBase::Static(box Static { promoted: Some(promoted), .. })) => {
696+
if let Some(p) = self.promoted_map.get(*promoted).cloned() {
697+
*promoted = p;
703698
}
704699
},
705700
_ => self.super_place(place, _ctxt, _location)

src/librustc_mir/transform/promote_consts.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ struct Promoter<'a, 'tcx: 'a> {
153153
/// If true, all nested temps are also kept in the
154154
/// source MIR, not moved to the promoted MIR.
155155
keep_original: bool,
156-
def_id: DefId
156+
def_id: DefId,
157157
}
158158

159159
impl<'a, 'tcx> Promoter<'a, 'tcx> {
@@ -291,17 +291,14 @@ impl<'a, 'tcx> Promoter<'a, 'tcx> {
291291
fn promote_candidate(mut self, candidate: Candidate) {
292292
use rustc::mir::Static;
293293
let mut operand = {
294-
let def_id = self.def_id.clone();
294+
let def_id = self.def_id;
295295
let promoted = &mut self.promoted;
296296
let promoted_id = Promoted::new(self.source.promoted.len());
297297
let mut promoted_place = |ty, span| {
298298
promoted.span = span;
299-
promoted.local_decls[RETURN_PLACE] =
300-
LocalDecl::new_return_place(ty, span);
301-
Place::Base(PlaceBase::Static(
302-
Box::new(Static { def_id: def_id, ty, promoted: Some(promoted_id) })
303-
)
304-
)
299+
promoted.local_decls[RETURN_PLACE] = LocalDecl::new_return_place(ty, span);
300+
Place::Base(
301+
PlaceBase::Static(Box::new(Static { def_id, ty, promoted: Some(promoted_id) })))
305302
};
306303
let (blocks, local_decls) = self.source.basic_blocks_and_local_decls_mut();
307304
match candidate {
@@ -421,7 +418,7 @@ pub fn promote_candidates<'a, 'tcx>(mir: &mut Mir<'tcx>,
421418
source: mir,
422419
temps: &mut temps,
423420
keep_original: false,
424-
def_id
421+
def_id,
425422
};
426423
promoter.promote_candidate(candidate);
427424
}

0 commit comments

Comments
 (0)