Skip to content

Commit 6ea4cbd

Browse files
committed
Rustup to rustc 1.39.0-nightly (a6946a817 2019-09-13)
1 parent 1558bf9 commit 6ea4cbd

File tree

3 files changed

+70
-74
lines changed

3 files changed

+70
-74
lines changed

src/analyze.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,10 @@ pub fn analyze(fx: &FunctionCx<'_, '_, impl Backend>) -> HashMap<Local, Flags> {
2424
for bb in fx.mir.basic_blocks().iter() {
2525
for stmt in bb.statements.iter() {
2626
match &stmt.kind {
27-
Assign(_, rval) => match &**rval {
28-
Rvalue::Ref(_, _, place) => analyze_non_ssa_place(&mut flag_map, place),
27+
Assign(place_and_rval) => match &place_and_rval.1 {
28+
Rvalue::Ref(_, _, place) => {
29+
analyze_non_ssa_place(&mut flag_map, place);
30+
}
2931
_ => {}
3032
},
3133
_ => {}

src/base.rs

+65-71
Original file line numberDiff line numberDiff line change
@@ -267,10 +267,10 @@ fn trans_stmt<'tcx>(
267267
let place = trans_place(fx, place);
268268
crate::discriminant::codegen_set_discriminant(fx, place, *variant_index);
269269
}
270-
StatementKind::Assign(to_place, rval) => {
271-
let lval = trans_place(fx, to_place);
270+
StatementKind::Assign(to_place_and_rval) => {
271+
let lval = trans_place(fx, &to_place_and_rval.0);
272272
let dest_layout = lval.layout();
273-
match &**rval {
273+
match &to_place_and_rval.1 {
274274
Rvalue::Use(operand) => {
275275
let val = trans_operand(fx, operand);
276276
lval.write_cvalue(fx, val);
@@ -506,7 +506,7 @@ fn trans_stmt<'tcx>(
506506
to.write_cvalue(fx, operand);
507507
}
508508
}
509-
_ => unimpl!("shouldn't exist at trans {:?}", rval),
509+
_ => unimpl!("shouldn't exist at trans {:?}", to_place_and_rval.1),
510510
},
511511
}
512512
}
@@ -606,7 +606,7 @@ pub fn trans_place<'tcx>(
606606
fx: &mut FunctionCx<'_, 'tcx, impl Backend>,
607607
place: &Place<'tcx>,
608608
) -> CPlace<'tcx> {
609-
let base = match &place.base {
609+
let mut cplace = match &place.base {
610610
PlaceBase::Local(local) => fx.get_local_place(*local),
611611
PlaceBase::Static(static_) => match static_.kind {
612612
StaticKind::Static => {
@@ -619,76 +619,70 @@ pub fn trans_place<'tcx>(
619619
},
620620
};
621621

622-
trans_place_projection(fx, base, &place.projection)
623-
}
624-
625-
pub fn trans_place_projection<'tcx>(
626-
fx: &mut FunctionCx<'_, 'tcx, impl Backend>,
627-
base: CPlace<'tcx>,
628-
projection: &Option<Box<Projection<'tcx>>>,
629-
) -> CPlace<'tcx> {
630-
let projection = if let Some(projection) = projection {
631-
projection
632-
} else {
633-
return base;
634-
};
635-
636-
let base = trans_place_projection(fx, base, &projection.base);
637-
638-
match projection.elem {
639-
ProjectionElem::Deref => base.place_deref(fx),
640-
ProjectionElem::Field(field, _ty) => base.place_field(fx, field),
641-
ProjectionElem::Index(local) => {
642-
let index = fx.get_local_place(local).to_cvalue(fx).load_scalar(fx);
643-
base.place_index(fx, index)
644-
}
645-
ProjectionElem::ConstantIndex {
646-
offset,
647-
min_length: _,
648-
from_end,
649-
} => {
650-
let index = if !from_end {
651-
fx.bcx.ins().iconst(fx.pointer_type, offset as i64)
652-
} else {
653-
let len = codegen_array_len(fx, base);
654-
fx.bcx.ins().iadd_imm(len, -(offset as i64))
655-
};
656-
base.place_index(fx, index)
657-
}
658-
ProjectionElem::Subslice { from, to } => {
659-
// These indices are generated by slice patterns.
660-
// slice[from:-to] in Python terms.
661-
662-
match base.layout().ty.sty {
663-
ty::Array(elem_ty, len) => {
664-
let elem_layout = fx.layout_of(elem_ty);
665-
let ptr = base.to_addr(fx);
666-
let len = crate::constant::force_eval_const(fx, len)
667-
.eval_usize(fx.tcx, ParamEnv::reveal_all());
668-
CPlace::for_addr(
669-
fx.bcx
670-
.ins()
671-
.iadd_imm(ptr, elem_layout.size.bytes() as i64 * from as i64),
672-
fx.layout_of(fx.tcx.mk_array(elem_ty, len - from as u64 - to as u64)),
673-
)
674-
}
675-
ty::Slice(elem_ty) => {
676-
let elem_layout = fx.layout_of(elem_ty);
677-
let (ptr, len) = base.to_addr_maybe_unsized(fx);
678-
let len = len.unwrap();
679-
CPlace::for_addr_with_extra(
680-
fx.bcx
681-
.ins()
682-
.iadd_imm(ptr, elem_layout.size.bytes() as i64 * from as i64),
683-
fx.bcx.ins().iadd_imm(len, -(from as i64 + to as i64)),
684-
base.layout(),
685-
)
622+
for elem in &*place.projection {
623+
match *elem {
624+
PlaceElem::Deref => {
625+
cplace = cplace.place_deref(fx);
626+
}
627+
PlaceElem::Field(field, _ty) => {
628+
cplace = cplace.place_field(fx, field);
629+
}
630+
PlaceElem::Index(local) => {
631+
let index = fx.get_local_place(local).to_cvalue(fx).load_scalar(fx);
632+
cplace = cplace.place_index(fx, index);
633+
}
634+
PlaceElem::ConstantIndex {
635+
offset,
636+
min_length: _,
637+
from_end,
638+
} => {
639+
let index = if !from_end {
640+
fx.bcx.ins().iconst(fx.pointer_type, offset as i64)
641+
} else {
642+
let len = codegen_array_len(fx, cplace);
643+
fx.bcx.ins().iadd_imm(len, -(offset as i64))
644+
};
645+
cplace = cplace.place_index(fx, index);
646+
}
647+
PlaceElem::Subslice { from, to } => {
648+
// These indices are generated by slice patterns.
649+
// slice[from:-to] in Python terms.
650+
651+
match cplace.layout().ty.sty {
652+
ty::Array(elem_ty, len) => {
653+
let elem_layout = fx.layout_of(elem_ty);
654+
let ptr = cplace.to_addr(fx);
655+
let len = crate::constant::force_eval_const(fx, len)
656+
.eval_usize(fx.tcx, ParamEnv::reveal_all());
657+
cplace = CPlace::for_addr(
658+
fx.bcx
659+
.ins()
660+
.iadd_imm(ptr, elem_layout.size.bytes() as i64 * from as i64),
661+
fx.layout_of(fx.tcx.mk_array(elem_ty, len - from as u64 - to as u64)),
662+
);
663+
}
664+
ty::Slice(elem_ty) => {
665+
let elem_layout = fx.layout_of(elem_ty);
666+
let (ptr, len) = cplace.to_addr_maybe_unsized(fx);
667+
let len = len.unwrap();
668+
cplace = CPlace::for_addr_with_extra(
669+
fx.bcx
670+
.ins()
671+
.iadd_imm(ptr, elem_layout.size.bytes() as i64 * from as i64),
672+
fx.bcx.ins().iadd_imm(len, -(from as i64 + to as i64)),
673+
cplace.layout(),
674+
);
675+
}
676+
_ => unreachable!(),
686677
}
687-
_ => unreachable!(),
678+
}
679+
PlaceElem::Downcast(_adt_def, variant) => {
680+
cplace = cplace.downcast_variant(fx, variant);
688681
}
689682
}
690-
ProjectionElem::Downcast(_adt_def, variant) => base.downcast_variant(fx, variant),
691683
}
684+
685+
cplace
692686
}
693687

694688
pub fn trans_operand<'tcx>(

src/constant.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,7 @@ pub fn mir_operand_get_const_val<'tcx>(
482482
Operand::Constant(const_) => return Some(force_eval_const(fx, const_.literal)),
483483
};
484484

485-
assert!(place.projection.is_none());
485+
assert!(place.projection.is_empty());
486486
let static_ = match &place.base {
487487
PlaceBase::Static(static_) => static_,
488488
PlaceBase::Local(_) => return None,

0 commit comments

Comments
 (0)