Skip to content

Commit aeefbc4

Browse files
committed
More review fixes
1 parent 9f3ad88 commit aeefbc4

File tree

3 files changed

+17
-39
lines changed

3 files changed

+17
-39
lines changed

src/librustc/mir/mod.rs

-7
Original file line numberDiff line numberDiff line change
@@ -1501,13 +1501,6 @@ impl<'tcx> BasicBlockData<'tcx> {
15011501
self.terminator.as_mut().expect("invalid terminator state")
15021502
}
15031503

1504-
pub fn is_unreachable(&self) -> bool {
1505-
match self.terminator().kind {
1506-
TerminatorKind::Unreachable => true,
1507-
_ => false,
1508-
}
1509-
}
1510-
15111504
pub fn retain_statements<F>(&mut self, mut f: F)
15121505
where
15131506
F: FnMut(&mut Statement<'_>) -> bool,

src/librustc/ty/layout.rs

+13-29
Original file line numberDiff line numberDiff line change
@@ -1311,7 +1311,7 @@ impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> {
13111311
) -> Result<&'tcx LayoutDetails, LayoutError<'tcx>> {
13121312
use SavedLocalEligibility::*;
13131313
let tcx = self.tcx;
1314-
let recompute_memory_index = |offsets: &Vec<u32>| -> Vec<u32> {
1314+
let recompute_memory_index = |offsets: &[Size]| -> Vec<u32> {
13151315
debug!("recompute_memory_index({:?})", offsets);
13161316
let mut inverse_index = (0..offsets.len() as u32).collect::<Vec<_>>();
13171317
inverse_index.sort_unstable_by_key(|i| offsets[*i as usize]);
@@ -1349,19 +1349,14 @@ impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> {
13491349
// get included in each variant that requested them in
13501350
// GeneratorLayout.
13511351
debug!("prefix = {:#?}", prefix);
1352-
let (outer_fields, promoted_offsets, promoted_memory_index) = match prefix.fields {
1353-
FieldPlacement::Arbitrary { offsets, memory_index } => {
1354-
let (offsets_a, offsets_b) =
1355-
offsets.split_at(discr_index + 1);
1356-
let (memory_index_a, memory_index_b) =
1357-
memory_index.split_at(discr_index + 1);
1358-
let outer_fields = FieldPlacement::Arbitrary {
1359-
offsets: offsets_a.to_vec(),
1360-
memory_index: recompute_memory_index(&memory_index_a.to_vec())
1361-
};
1362-
(outer_fields,
1363-
offsets_b.to_vec(),
1364-
recompute_memory_index(&memory_index_b.to_vec()))
1352+
let (outer_fields, promoted_offsets) = match prefix.fields {
1353+
FieldPlacement::Arbitrary { mut offsets, .. } => {
1354+
let offsets_b = offsets.split_off(discr_index + 1);
1355+
let offsets_a = offsets;
1356+
1357+
let memory_index = recompute_memory_index(&offsets_a);
1358+
let outer_fields = FieldPlacement::Arbitrary { offsets: offsets_a, memory_index };
1359+
(outer_fields, offsets_b)
13651360
}
13661361
_ => bug!(),
13671362
};
@@ -1391,41 +1386,30 @@ impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> {
13911386
StructKind::Prefixed(prefix_size, prefix_align.abi))?;
13921387
variant.variants = Variants::Single { index };
13931388

1394-
let (offsets, memory_index) = match variant.fields {
1395-
FieldPlacement::Arbitrary { offsets, memory_index } => (offsets, memory_index),
1389+
let offsets = match variant.fields {
1390+
FieldPlacement::Arbitrary { offsets, .. } => offsets,
13961391
_ => bug!(),
13971392
};
13981393

13991394
// Now, stitch the promoted and variant-only fields back together in
14001395
// the order they are mentioned by our GeneratorLayout.
14011396
let mut next_variant_field = 0;
14021397
let mut combined_offsets = Vec::new();
1403-
let mut combined_memory_index = Vec::new();
14041398
for local in variant_fields.iter() {
14051399
match assignments[*local] {
14061400
Unassigned => bug!(),
14071401
Assigned(_) => {
14081402
combined_offsets.push(offsets[next_variant_field]);
1409-
// Shift memory indices by the number of promoted
1410-
// fields, which all come first. We may not use all
1411-
// promoted fields in our variant but that's okay; we'll
1412-
// renumber them below.
1413-
combined_memory_index.push(
1414-
promoted_memory_index.len() as u32 +
1415-
memory_index[next_variant_field]);
14161403
next_variant_field += 1;
14171404
}
14181405
Ineligible(field_idx) => {
14191406
let field_idx = field_idx.unwrap() as usize;
14201407
combined_offsets.push(promoted_offsets[field_idx]);
1421-
combined_memory_index.push(promoted_memory_index[field_idx]);
14221408
}
14231409
}
14241410
}
1425-
variant.fields = FieldPlacement::Arbitrary {
1426-
offsets: combined_offsets,
1427-
memory_index: recompute_memory_index(&combined_memory_index),
1428-
};
1411+
let memory_index = recompute_memory_index(&combined_offsets);
1412+
variant.fields = FieldPlacement::Arbitrary { offsets: combined_offsets, memory_index };
14291413

14301414
size = size.max(variant.size);
14311415
align = align.max(variant.align);

src/librustc_mir/transform/generator.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -660,9 +660,10 @@ impl<'body, 'tcx: 'body, 's> StorageConflictVisitor<'body, 'tcx, 's> {
660660
flow_state: &FlowAtLocation<'tcx, MaybeStorageLive<'body, 'tcx>>,
661661
loc: Location) {
662662
// Ignore unreachable blocks.
663-
if self.body.basic_blocks()[loc.block].is_unreachable() {
664-
return;
665-
}
663+
match self.body.basic_blocks()[loc.block].terminator().kind {
664+
TerminatorKind::Unreachable => return,
665+
_ => (),
666+
};
666667

667668
let mut eligible_storage_live = flow_state.as_dense().clone();
668669
eligible_storage_live.intersect(&self.stored_locals);

0 commit comments

Comments
 (0)