Skip to content

Commit 8ed3bfb

Browse files
committed
---
yaml --- r: 188302 b: refs/heads/tmp c: faf3bcd h: refs/heads/master v: v3
1 parent d2b4e33 commit 8ed3bfb

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
@@ -34,5 +34,5 @@ refs/heads/building: 126db549b038c84269a1e4fe46f051b2c15d6970
3434
refs/heads/beta: 522d09dfecbeca1595f25ac58c6d0178bbd21d7d
3535
refs/heads/windistfix: 7608dbad651f02e837ed05eef3d74a6662a6e928
3636
refs/tags/1.0.0-alpha: e42bd6d93a1d3433c486200587f8f9e12590a4d7
37-
refs/heads/tmp: f0404c39f272868c1dedc7cda7b0b6dffcb5713d
37+
refs/heads/tmp: faf3bcd72c85774805ae0e84d0458aa3e67b20e4
3838
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f

branches/tmp/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

branches/tmp/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
}

branches/tmp/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)