Skip to content

Commit

Permalink
Incorporate review comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
ahicks92 committed Dec 16, 2016
1 parent 79c35bb commit f22a22b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
16 changes: 7 additions & 9 deletions src/librustc/ty/layout.rs
Expand Up @@ -557,8 +557,6 @@ impl<'a, 'gcx, 'tcx> Struct {
min_size: Size::from_bytes(0),
};

if fields.len() == 0 {return Ok(ret)};

// Anything with ReprExtern or ReprPacked doesn't optimize.
// Neither do 1-member and 2-member structs.
// In addition, code in trans assume that 2-element structs can become pairs.
Expand Down Expand Up @@ -590,9 +588,9 @@ impl<'a, 'gcx, 'tcx> Struct {
let mut inverse_memory_index: Vec<u32> = (0..fields.len() as u32).collect();

if optimize {
let start = if let StructKind::EnumVariant = kind {1} else {0};
let start = if let StructKind::EnumVariant = kind { 1 } else { 0 };
let end = if let StructKind::MaybeUnsizedUnivariant = kind {
fields.len()-1
fields.len() - 1
} else {
fields.len()
};
Expand Down Expand Up @@ -717,12 +715,12 @@ impl<'a, 'gcx, 'tcx> Struct {

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

/// Find the path leading to a non-zero leaf field, starting from
/// the given set of fields and recursing through aggregates.
// / Returns Some((path, source_path)) on success.
/// Returns Some((path, source_path)) on success.
/// `path` is translated to memory order. `source_path` is not.
fn non_zero_field_paths<I>(infcx: &InferCtxt<'a, 'gcx, 'tcx>,
fields: I,
Expand Down Expand Up @@ -1363,7 +1361,7 @@ impl<'a, 'gcx, 'tcx> Layout {
for i in variant.offsets.iter_mut() {
// The first field is the discrimminant, at offset 0.
// These aren't in order, and we need to skip it.
if *i <= old_ity_size && *i > Size::from_bytes(0){
if *i <= old_ity_size && *i > Size::from_bytes(0) {
*i = new_ity_size;
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/librustc_trans/debuginfo/metadata.rs
Expand Up @@ -1309,7 +1309,7 @@ impl<'tcx> EnumMemberDescriptionFactory<'tcx> {
// Creates MemberDescriptions for the fields of a single enum variant.
struct VariantMemberDescriptionFactory<'tcx> {
// Cloned from the layout::Struct describing the variant.
offsets: Vec<layout::Size>,
offsets: &'tcx [layout::Size],
args: Vec<(String, Ty<'tcx>)>,
discriminant_type_metadata: Option<DIType>,
span: Span,
Expand Down Expand Up @@ -1346,7 +1346,7 @@ enum EnumDiscriminantInfo {
// full RecursiveTypeDescription.
fn describe_enum_variant<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
enum_type: Ty<'tcx>,
struct_def: &layout::Struct,
struct_def: &'tcx layout::Struct,
variant: &'tcx ty::VariantDef,
discriminant_info: EnumDiscriminantInfo,
containing_scope: DIScope,
Expand Down Expand Up @@ -1430,7 +1430,7 @@ fn describe_enum_variant<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,

let member_description_factory =
VariantMDF(VariantMemberDescriptionFactory {
offsets: struct_def.offsets.clone(),
offsets: &struct_def.offsets[..],
args: args,
discriminant_type_metadata: match discriminant_info {
RegularDiscriminant(discriminant_type_metadata) => {
Expand Down

0 comments on commit f22a22b

Please sign in to comment.