Skip to content

Commit 025456e

Browse files
committed
Incorporate review comments
1 parent e9580e2 commit 025456e

File tree

3 files changed

+8
-15
lines changed

3 files changed

+8
-15
lines changed

src/librustc/ty/layout.rs

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -459,11 +459,7 @@ impl Integer {
459459
}
460460
}
461461

462-
let at_least = if let Some(i) = min_from_extern {
463-
i
464-
} else {
465-
min_default
466-
};
462+
let at_least = min_from_extern.unwrap_or(min_default);
467463

468464
// If there are no negative values, we can use the unsigned fit.
469465
if min >= 0 {
@@ -571,13 +567,11 @@ impl<'a, 'gcx, 'tcx> Struct {
571567
if can_optimize {
572568
// This exhaustive match makes new reprs force the adder to modify this function.
573569
// Otherwise, things can silently break.
574-
// Note the inversion, return true to stop matching.
570+
// Note the inversion, return true to stop optimizing.
575571
can_optimize = !reprs.iter().any(|r| {
576572
match *r {
577-
attr::ReprAny => false,
578-
attr::ReprInt(_) => false,
579-
attr::ReprExtern => true,
580-
attr::ReprPacked => true,
573+
attr::ReprAny | attr::ReprInt(_) => false,
574+
attr::ReprExtern | attr::ReprPacked => true,
581575
attr::ReprSimd => bug!("Simd vectors should be represented as layout::Vector")
582576
}
583577
});
@@ -588,7 +582,7 @@ impl<'a, 'gcx, 'tcx> Struct {
588582
StructKind::MaybeUnsizedUnivariant => (can_optimize, false),
589583
StructKind::EnumVariant => {
590584
assert!(fields.len() >= 1, "Enum variants must have discriminants.");
591-
(can_optimize || fields[0].size(dl).bytes() == 1, true)
585+
(can_optimize && fields[0].size(dl).bytes() == 1, true)
592586
}
593587
};
594588

@@ -1189,7 +1183,7 @@ impl<'a, 'gcx, 'tcx> Layout {
11891183
});
11901184
}
11911185

1192-
if !def.is_enum() || def.variants.len() == 1 && hints.len() == 0 {
1186+
if !def.is_enum() || def.variants.len() == 1 && hints.is_empty() {
11931187
// Struct, or union, or univariant enum equivalent to a struct.
11941188
// (Typechecking will reject discriminant-sizing attrs.)
11951189

@@ -1239,7 +1233,7 @@ impl<'a, 'gcx, 'tcx> Layout {
12391233
v.fields.iter().map(|field| field.ty(tcx, substs)).collect::<Vec<_>>()
12401234
}).collect::<Vec<_>>();
12411235

1242-
if variants.len() == 2 && hints.len() == 0 {
1236+
if variants.len() == 2 && hints.is_empty() {
12431237
// Nullable pointer optimization
12441238
for discr in 0..2 {
12451239
let other_fields = variants[1 - discr].iter().map(|ty| {

src/test/run-pass/closure-immediate.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ fn main() {
1919
assert_eq!(c, 3);
2020
};
2121
c(1, 2, 3);
22-
}
22+
}

src/test/run-pass/multiple-reprs.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ enum E2 {
2828
}
2929

3030
// From pr 37429
31-
pub const SIZEOF_QUERY: usize = 21;
3231

3332
#[repr(C,packed)]
3433
pub struct p0f_api_query {

0 commit comments

Comments
 (0)