Skip to content

Commit 8b131fd

Browse files
committed
---
yaml --- r: 57314 b: refs/heads/incoming c: 89676d6 h: refs/heads/master v: v3
1 parent 5cf6898 commit 8b131fd

File tree

4 files changed

+52
-17
lines changed

4 files changed

+52
-17
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ refs/heads/try: bf67eb2362b7d0f37012f2d6dac604c3bbacd2c6
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c
9-
refs/heads/incoming: fc26911b493eb151710e1a96578aad55596cfeb7
9+
refs/heads/incoming: 89676d6a5960aa51ee1e6975c423e979819a407c
1010
refs/heads/dist-snap: 00dbbd01c2aee72982b3e0f9511ae1d4428c3ba9
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1212
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/incoming/src/etc/vim/syntax/rust.vim

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,8 @@ syn match rustFloat display "\<[0-9][0-9_]*\.[0-9_]\+\%([eE][+-]\=[0-9
110110
syn match rustLifetime display "\'\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*"
111111
syn match rustCharacter "'\([^'\\]\|\\\(['nrt\\\"]\|x\x\{2}\|u\x\{4}\|U\x\{8}\)\)'"
112112

113-
syn region rustCommentDoc start="/\*\*" end="\*/"
114-
syn region rustCommentDoc start="///" skip="\\$" end="$" keepend
115-
syn match rustComment "/\*\*/"
116-
syn region rustComment start="/\*\([^\*]\|$\)" end="\*/" contains=rustTodo
117-
syn region rustComment start="//\([^/]\|$\)" skip="\\$" end="$" contains=rustTodo keepend
113+
syn region rustComment start="/\*" end="\*/" contains=rustComment,rustTodo
114+
syn region rustComment start="//" skip="\\$" end="$" contains=rustTodo keepend
118115

119116
syn keyword rustTodo contained TODO FIXME XXX NB
120117

@@ -137,7 +134,6 @@ hi def link rustConditional Conditional
137134
hi def link rustIdentifier Identifier
138135
hi def link rustModPath Include
139136
hi def link rustFuncName Function
140-
hi def link rustCommentDoc SpecialComment
141137
hi def link rustComment Comment
142138
hi def link rustMacro Macro
143139
hi def link rustType Type

branches/incoming/src/libcore/num/int-template.rs

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,11 +107,15 @@ pub fn range_step(start: T, stop: T, step: T, it: &fn(T) -> bool) {
107107
} else if step > 0 { // ascending
108108
while i < stop {
109109
if !it(i) { break }
110+
// avoiding overflow. break if i + step > max_value
111+
if i > max_value - step { break; }
110112
i += step;
111113
}
112114
} else { // descending
113115
while i > stop {
114116
if !it(i) { break }
117+
// avoiding underflow. break if i + step < min_value
118+
if i < min_value - step { break; }
115119
i += step;
116120
}
117121
}
@@ -421,10 +425,26 @@ pub fn test_ranges() {
421425
for range_step(36,30,-2) |i| {
422426
l.push(i);
423427
}
424-
assert!(l == ~[0,1,2,
425-
13,12,11,
426-
20,22,24,
427-
36,34,32]);
428+
for range_step(max_value - 2, max_value, 2) |i| {
429+
l.push(i);
430+
}
431+
for range_step(max_value - 3, max_value, 2) |i| {
432+
l.push(i);
433+
}
434+
for range_step(min_value + 2, min_value, -2) |i| {
435+
l.push(i);
436+
}
437+
for range_step(min_value + 3, min_value, -2) |i| {
438+
l.push(i);
439+
}
440+
assert_eq!(l, ~[0,1,2,
441+
13,12,11,
442+
20,22,24,
443+
36,34,32,
444+
max_value-2,
445+
max_value-3,max_value-1,
446+
min_value+2,
447+
min_value+3,min_value+1]);
428448
429449
// None of the `fail`s should execute.
430450
for range(10,0) |_i| {

branches/incoming/src/libcore/num/uint-template.rs

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,15 @@ pub fn range_step(start: T,
7878
if step >= 0 {
7979
while i < stop {
8080
if !it(i) { break }
81+
// avoiding overflow. break if i + step > max_value
82+
if i > max_value - (step as T) { break; }
8183
i += step as T;
8284
}
83-
}
84-
else {
85+
} else {
8586
while i > stop {
8687
if !it(i) { break }
88+
// avoiding underflow. break if i + step < min_value
89+
if i < min_value + ((-step) as T) { break; }
8790
i -= -step as T;
8891
}
8992
}
@@ -371,11 +374,27 @@ pub fn test_ranges() {
371374
for range_step(36,30,-2) |i| {
372375
l.push(i);
373376
}
377+
for range_step(max_value - 2, max_value, 2) |i| {
378+
l.push(i);
379+
}
380+
for range_step(max_value - 3, max_value, 2) |i| {
381+
l.push(i);
382+
}
383+
for range_step(min_value + 2, min_value, -2) |i| {
384+
l.push(i);
385+
}
386+
for range_step(min_value + 3, min_value, -2) |i| {
387+
l.push(i);
388+
}
374389
375-
assert!(l == ~[0,1,2,
376-
13,12,11,
377-
20,22,24,
378-
36,34,32]);
390+
assert_eq!(l, ~[0,1,2,
391+
13,12,11,
392+
20,22,24,
393+
36,34,32,
394+
max_value-2,
395+
max_value-3,max_value-1,
396+
min_value+2,
397+
min_value+3,min_value+1]);
379398
380399
// None of the `fail`s should execute.
381400
for range(0,0) |_i| {

0 commit comments

Comments
 (0)