Skip to content

Commit f22a22b

Browse files
committed
Incorporate review comments.
1 parent 79c35bb commit f22a22b

File tree

2 files changed

+10
-12
lines changed

2 files changed

+10
-12
lines changed

src/librustc/ty/layout.rs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -557,8 +557,6 @@ impl<'a, 'gcx, 'tcx> Struct {
557557
min_size: Size::from_bytes(0),
558558
};
559559

560-
if fields.len() == 0 {return Ok(ret)};
561-
562560
// Anything with ReprExtern or ReprPacked doesn't optimize.
563561
// Neither do 1-member and 2-member structs.
564562
// In addition, code in trans assume that 2-element structs can become pairs.
@@ -590,9 +588,9 @@ impl<'a, 'gcx, 'tcx> Struct {
590588
let mut inverse_memory_index: Vec<u32> = (0..fields.len() as u32).collect();
591589

592590
if optimize {
593-
let start = if let StructKind::EnumVariant = kind {1} else {0};
591+
let start = if let StructKind::EnumVariant = kind { 1 } else { 0 };
594592
let end = if let StructKind::MaybeUnsizedUnivariant = kind {
595-
fields.len()-1
593+
fields.len() - 1
596594
} else {
597595
fields.len()
598596
};
@@ -717,12 +715,12 @@ impl<'a, 'gcx, 'tcx> Struct {
717715

718716
/// Find the path leading to a non-zero leaf field, starting from
719717
/// the given type and recursing through aggregates.
720-
/// The tuple is `(path, source_path)1,
718+
/// The tuple is `(path, source_path)`,
721719
/// where `path` is in memory order and `source_path` in source order.
722720
// FIXME(eddyb) track value ranges and traverse already optimized enums.
723721
fn non_zero_field_in_type(infcx: &InferCtxt<'a, 'gcx, 'tcx>,
724-
ty: Ty<'gcx>)
725-
-> Result<Option<(FieldPath, FieldPath)>, LayoutError<'gcx>> {
722+
ty: Ty<'gcx>)
723+
-> Result<Option<(FieldPath, FieldPath)>, LayoutError<'gcx>> {
726724
let tcx = infcx.tcx.global_tcx();
727725
match (ty.layout(infcx)?, &ty.sty) {
728726
(&Scalar { non_zero: true, .. }, _) |
@@ -792,7 +790,7 @@ impl<'a, 'gcx, 'tcx> Struct {
792790

793791
/// Find the path leading to a non-zero leaf field, starting from
794792
/// the given set of fields and recursing through aggregates.
795-
// / Returns Some((path, source_path)) on success.
793+
/// Returns Some((path, source_path)) on success.
796794
/// `path` is translated to memory order. `source_path` is not.
797795
fn non_zero_field_paths<I>(infcx: &InferCtxt<'a, 'gcx, 'tcx>,
798796
fields: I,
@@ -1363,7 +1361,7 @@ impl<'a, 'gcx, 'tcx> Layout {
13631361
for i in variant.offsets.iter_mut() {
13641362
// The first field is the discrimminant, at offset 0.
13651363
// These aren't in order, and we need to skip it.
1366-
if *i <= old_ity_size && *i > Size::from_bytes(0){
1364+
if *i <= old_ity_size && *i > Size::from_bytes(0) {
13671365
*i = new_ity_size;
13681366
}
13691367
}

src/librustc_trans/debuginfo/metadata.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1309,7 +1309,7 @@ impl<'tcx> EnumMemberDescriptionFactory<'tcx> {
13091309
// Creates MemberDescriptions for the fields of a single enum variant.
13101310
struct VariantMemberDescriptionFactory<'tcx> {
13111311
// Cloned from the layout::Struct describing the variant.
1312-
offsets: Vec<layout::Size>,
1312+
offsets: &'tcx [layout::Size],
13131313
args: Vec<(String, Ty<'tcx>)>,
13141314
discriminant_type_metadata: Option<DIType>,
13151315
span: Span,
@@ -1346,7 +1346,7 @@ enum EnumDiscriminantInfo {
13461346
// full RecursiveTypeDescription.
13471347
fn describe_enum_variant<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
13481348
enum_type: Ty<'tcx>,
1349-
struct_def: &layout::Struct,
1349+
struct_def: &'tcx layout::Struct,
13501350
variant: &'tcx ty::VariantDef,
13511351
discriminant_info: EnumDiscriminantInfo,
13521352
containing_scope: DIScope,
@@ -1430,7 +1430,7 @@ fn describe_enum_variant<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
14301430

14311431
let member_description_factory =
14321432
VariantMDF(VariantMemberDescriptionFactory {
1433-
offsets: struct_def.offsets.clone(),
1433+
offsets: &struct_def.offsets[..],
14341434
args: args,
14351435
discriminant_type_metadata: match discriminant_info {
14361436
RegularDiscriminant(discriminant_type_metadata) => {

0 commit comments

Comments
 (0)