Skip to content

Commit 92f2b62

Browse files
committed
Rustup to rustc 1.38.0-nightly (a7f28678b 2019-07-23)
1 parent 8532340 commit 92f2b62

File tree

2 files changed

+72
-60
lines changed

2 files changed

+72
-60
lines changed

src/analyze.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ pub fn analyze<'a, 'tcx: 'a>(fx: &FunctionCx<'a, 'tcx, impl Backend>) -> HashMap
4747
}
4848

4949
fn analyze_non_ssa_place(flag_map: &mut HashMap<Local, Flags>, place: &Place) {
50-
match place {
51-
Place::Base(PlaceBase::Local(local)) => not_ssa(flag_map, local),
50+
match place.base {
51+
PlaceBase::Local(local) => not_ssa(flag_map, local),
5252
_ => {}
5353
}
5454
}

src/base.rs

+70-58
Original file line numberDiff line numberDiff line change
@@ -1148,70 +1148,82 @@ pub fn trans_place<'a, 'tcx: 'a>(
11481148
fx: &mut FunctionCx<'a, 'tcx, impl Backend>,
11491149
place: &Place<'tcx>,
11501150
) -> CPlace<'tcx> {
1151-
match place {
1152-
Place::Base(base) => match base {
1153-
PlaceBase::Local(local) => fx.get_local_place(*local),
1154-
PlaceBase::Static(static_) => match static_.kind {
1155-
StaticKind::Static(def_id) => {
1156-
crate::constant::codegen_static_ref(fx, def_id, static_.ty)
1157-
}
1158-
StaticKind::Promoted(promoted) => {
1159-
crate::constant::trans_promoted(fx, promoted, static_.ty)
1160-
}
1151+
let base = match &place.base {
1152+
PlaceBase::Local(local) => fx.get_local_place(*local),
1153+
PlaceBase::Static(static_) => match static_.kind {
1154+
StaticKind::Static(def_id) => {
1155+
crate::constant::codegen_static_ref(fx, def_id, static_.ty)
1156+
}
1157+
StaticKind::Promoted(promoted) => {
1158+
crate::constant::trans_promoted(fx, promoted, static_.ty)
11611159
}
11621160
}
1163-
Place::Projection(projection) => {
1164-
let base = trans_place(fx, &projection.base);
1165-
match projection.elem {
1166-
ProjectionElem::Deref => base.place_deref(fx),
1167-
ProjectionElem::Field(field, _ty) => base.place_field(fx, field),
1168-
ProjectionElem::Index(local) => {
1169-
let index = fx.get_local_place(local).to_cvalue(fx).load_scalar(fx);
1170-
base.place_index(fx, index)
1171-
}
1172-
ProjectionElem::ConstantIndex {
1173-
offset,
1174-
min_length: _,
1175-
from_end,
1176-
} => {
1177-
let index = if !from_end {
1178-
fx.bcx.ins().iconst(fx.pointer_type, offset as i64)
1179-
} else {
1180-
let len = codegen_array_len(fx, base);
1181-
fx.bcx.ins().iadd_imm(len, -(offset as i64))
1182-
};
1183-
base.place_index(fx, index)
1161+
};
1162+
1163+
trans_place_projection(fx, base, &place.projection)
1164+
}
1165+
1166+
pub fn trans_place_projection<'a, 'tcx: 'a>(
1167+
fx: &mut FunctionCx<'a, 'tcx, impl Backend>,
1168+
base: CPlace<'tcx>,
1169+
projection: &Option<Box<Projection<'tcx>>>,
1170+
) -> CPlace<'tcx> {
1171+
let projection = if let Some(projection) = projection {
1172+
projection
1173+
} else {
1174+
return base;
1175+
};
1176+
1177+
let base = trans_place_projection(fx, base, &projection.base);
1178+
1179+
match projection.elem {
1180+
ProjectionElem::Deref => base.place_deref(fx),
1181+
ProjectionElem::Field(field, _ty) => base.place_field(fx, field),
1182+
ProjectionElem::Index(local) => {
1183+
let index = fx.get_local_place(local).to_cvalue(fx).load_scalar(fx);
1184+
base.place_index(fx, index)
1185+
}
1186+
ProjectionElem::ConstantIndex {
1187+
offset,
1188+
min_length: _,
1189+
from_end,
1190+
} => {
1191+
let index = if !from_end {
1192+
fx.bcx.ins().iconst(fx.pointer_type, offset as i64)
1193+
} else {
1194+
let len = codegen_array_len(fx, base);
1195+
fx.bcx.ins().iadd_imm(len, -(offset as i64))
1196+
};
1197+
base.place_index(fx, index)
1198+
}
1199+
ProjectionElem::Subslice { from, to } => {
1200+
// These indices are generated by slice patterns.
1201+
// slice[from:-to] in Python terms.
1202+
1203+
match base.layout().ty.sty {
1204+
ty::Array(elem_ty, len) => {
1205+
let elem_layout = fx.layout_of(elem_ty);
1206+
let ptr = base.to_addr(fx);
1207+
let len = crate::constant::force_eval_const(fx, len).unwrap_usize(fx.tcx);
1208+
CPlace::for_addr(
1209+
fx.bcx.ins().iadd_imm(ptr, elem_layout.size.bytes() as i64 * from as i64),
1210+
fx.layout_of(fx.tcx.mk_array(elem_ty, len - from as u64 - to as u64)),
1211+
)
11841212
}
1185-
ProjectionElem::Subslice { from, to } => {
1186-
// These indices are generated by slice patterns.
1187-
// slice[from:-to] in Python terms.
1188-
1189-
match base.layout().ty.sty {
1190-
ty::Array(elem_ty, len) => {
1191-
let elem_layout = fx.layout_of(elem_ty);
1192-
let ptr = base.to_addr(fx);
1193-
let len = crate::constant::force_eval_const(fx, len).unwrap_usize(fx.tcx);
1194-
CPlace::for_addr(
1195-
fx.bcx.ins().iadd_imm(ptr, elem_layout.size.bytes() as i64 * from as i64),
1196-
fx.layout_of(fx.tcx.mk_array(elem_ty, len - from as u64 - to as u64)),
1197-
)
1198-
}
1199-
ty::Slice(elem_ty) => {
1200-
let elem_layout = fx.layout_of(elem_ty);
1201-
let (ptr, len) = base.to_addr_maybe_unsized(fx);
1202-
let len = len.unwrap();
1203-
CPlace::for_addr_with_extra(
1204-
fx.bcx.ins().iadd_imm(ptr, elem_layout.size.bytes() as i64 * from as i64),
1205-
fx.bcx.ins().iadd_imm(len, -(from as i64 + to as i64)),
1206-
base.layout(),
1207-
)
1208-
}
1209-
_ => unreachable!(),
1210-
}
1213+
ty::Slice(elem_ty) => {
1214+
let elem_layout = fx.layout_of(elem_ty);
1215+
let (ptr, len) = base.to_addr_maybe_unsized(fx);
1216+
let len = len.unwrap();
1217+
CPlace::for_addr_with_extra(
1218+
fx.bcx.ins().iadd_imm(ptr, elem_layout.size.bytes() as i64 * from as i64),
1219+
fx.bcx.ins().iadd_imm(len, -(from as i64 + to as i64)),
1220+
base.layout(),
1221+
)
12111222
}
1212-
ProjectionElem::Downcast(_adt_def, variant) => base.downcast_variant(fx, variant),
1223+
_ => unreachable!(),
12131224
}
12141225
}
1226+
ProjectionElem::Downcast(_adt_def, variant) => base.downcast_variant(fx, variant),
12151227
}
12161228
}
12171229

0 commit comments

Comments
 (0)