Skip to content

Commit f54080f

Browse files
committed
---
yaml --- r: 188329 b: refs/heads/master c: faf3bcd h: refs/heads/master i: 188327: 68983dc v: v3
1 parent 2442522 commit f54080f

File tree

4 files changed

+8
-6
lines changed

4 files changed

+8
-6
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: f0404c39f272868c1dedc7cda7b0b6dffcb5713d
2+
refs/heads/master: faf3bcd72c85774805ae0e84d0458aa3e67b20e4
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 3a96d6a9818fe2affc98a187fb1065120458cee9
55
refs/heads/try: 649d35e4d830b27806705dc5352c86ab6d6fd1a1

trunk/src/librustc_trans/trans/adt.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -778,7 +778,9 @@ fn load_discr(bcx: Block, ity: IntType, ptr: ValueRef, min: Disr, max: Disr)
778778
assert!(bits <= 64);
779779
let bits = bits as uint;
780780
let mask = (-1u64 >> (64 - bits)) as Disr;
781-
if (max + 1) & mask == min & mask {
781+
// For a (max) discr of -1, max will be `-1 as usize`, which overflows.
782+
// However, that is fine here (it would still represent the full range),
783+
if (max.wrapping_add(1)) & mask == min & mask {
782784
// i.e., if the range is everything. The lo==hi case would be
783785
// rejected by the LLVM verifier (it would mean either an
784786
// empty set, which is impossible, or the entire range of the
@@ -787,7 +789,7 @@ fn load_discr(bcx: Block, ity: IntType, ptr: ValueRef, min: Disr, max: Disr)
787789
} else {
788790
// llvm::ConstantRange can deal with ranges that wrap around,
789791
// so an overflow on (max + 1) is fine.
790-
LoadRangeAssert(bcx, ptr, min, (max+1), /* signed: */ True)
792+
LoadRangeAssert(bcx, ptr, min, (max.wrapping_add(1)), /* signed: */ True)
791793
}
792794
}
793795

trunk/src/librustc_typeck/astconv.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,9 +205,9 @@ pub fn opt_ast_region_to_region<'tcx>(
205205

206206
if len == 2 && i == 0 {
207207
m.push_str(" or ");
208-
} else if i == len - 2 {
208+
} else if i + 2 == len {
209209
m.push_str(", or ");
210-
} else if i != len - 1 {
210+
} else if i + 1 != len {
211211
m.push_str(", ");
212212
}
213213
}

trunk/src/libsyntax/ext/deriving/encodable.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,6 @@ fn encodable_substructure(cx: &mut ExtCtxt, trait_span: Span,
181181
Struct(ref fields) => {
182182
let emit_struct_field = cx.ident_of("emit_struct_field");
183183
let mut stmts = Vec::new();
184-
let last = fields.len() - 1;
185184
for (i, &FieldInfo {
186185
name,
187186
ref self_,
@@ -204,6 +203,7 @@ fn encodable_substructure(cx: &mut ExtCtxt, trait_span: Span,
204203
lambda));
205204

206205
// last call doesn't need a try!
206+
let last = fields.len() - 1;
207207
let call = if i != last {
208208
cx.expr_try(span, call)
209209
} else {

0 commit comments

Comments
 (0)