Skip to content

Commit b2d62d3

Browse files
committed
---
yaml --- r: 80803 b: refs/heads/try c: 48f61ec h: refs/heads/master i: 80801: 4630f1e 80799: b3610bd v: v3
1 parent 8227ee2 commit b2d62d3

File tree

14 files changed

+87
-692
lines changed

14 files changed

+87
-692
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: 4c6bf4872012c010f84dc7fa2cdfe87522533f89
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: cbd1eefbd350797b783df119fed7956d7e1c74ad
5-
refs/heads/try: ccadbd3b7c936dacab69856cc3963aad477c7f06
5+
refs/heads/try: 48f61ecbf93740359b62ad5326e70759e738d9e6
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c

branches/try/src/libextra/crypto/md5.rs

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use std::uint;
11+
use std::iter::range_step;
1212

1313
use cryptoutil::{write_u32_le, read_u32v_le, FixedBuffer, FixedBuffer64, StandardPadding};
1414
use digest::Digest;
@@ -86,46 +86,42 @@ impl Md5State {
8686
read_u32v_le(data, input);
8787

8888
// round 1
89-
do uint::range_step(0, 16, 4) |i| {
89+
for i in range_step(0u, 16, 4) {
9090
a = op_f(a, b, c, d, data[i] + C1[i], 7);
9191
d = op_f(d, a, b, c, data[i + 1] + C1[i + 1], 12);
9292
c = op_f(c, d, a, b, data[i + 2] + C1[i + 2], 17);
9393
b = op_f(b, c, d, a, data[i + 3] + C1[i + 3], 22);
94-
true
95-
};
94+
}
9695

9796
// round 2
9897
let mut t = 1;
99-
do uint::range_step(0, 16, 4) |i| {
98+
for i in range_step(0u, 16, 4) {
10099
a = op_g(a, b, c, d, data[t & 0x0f] + C2[i], 5);
101100
d = op_g(d, a, b, c, data[(t + 5) & 0x0f] + C2[i + 1], 9);
102101
c = op_g(c, d, a, b, data[(t + 10) & 0x0f] + C2[i + 2], 14);
103102
b = op_g(b, c, d, a, data[(t + 15) & 0x0f] + C2[i + 3], 20);
104103
t += 20;
105-
true
106-
};
104+
}
107105

108106
// round 3
109107
t = 5;
110-
do uint::range_step(0, 16, 4) |i| {
108+
for i in range_step(0u, 16, 4) {
111109
a = op_h(a, b, c, d, data[t & 0x0f] + C3[i], 4);
112110
d = op_h(d, a, b, c, data[(t + 3) & 0x0f] + C3[i + 1], 11);
113111
c = op_h(c, d, a, b, data[(t + 6) & 0x0f] + C3[i + 2], 16);
114112
b = op_h(b, c, d, a, data[(t + 9) & 0x0f] + C3[i + 3], 23);
115113
t += 12;
116-
true
117-
};
114+
}
118115

119116
// round 4
120117
t = 0;
121-
do uint::range_step(0, 16, 4) |i| {
118+
for i in range_step(0u, 16, 4) {
122119
a = op_i(a, b, c, d, data[t & 0x0f] + C4[i], 6);
123120
d = op_i(d, a, b, c, data[(t + 7) & 0x0f] + C4[i + 1], 10);
124121
c = op_i(c, d, a, b, data[(t + 14) & 0x0f] + C4[i + 2], 15);
125122
b = op_i(b, c, d, a, data[(t + 21) & 0x0f] + C4[i + 3], 21);
126123
t += 28;
127-
true
128-
};
124+
}
129125

130126
self.s0 += a;
131127
self.s1 += b;

branches/try/src/libextra/crypto/sha2.rs

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use std::uint;
11+
use std::iter::range_step;
1212

1313
use cryptoutil::{write_u64_be, write_u32_be, read_u64v_be, read_u32v_be, add_bytes_to_bits,
1414
add_bytes_to_bits_tuple, FixedBuffer, FixedBuffer128, FixedBuffer64, StandardPadding};
@@ -111,7 +111,7 @@ impl Engine512State {
111111

112112
// Putting the message schedule inside the same loop as the round calculations allows for
113113
// the compiler to generate better code.
114-
do uint::range_step(0, 64, 8) |t| {
114+
for t in range_step(0u, 64, 8) {
115115
schedule_round!(t + 16);
116116
schedule_round!(t + 17);
117117
schedule_round!(t + 18);
@@ -129,10 +129,9 @@ impl Engine512State {
129129
sha2_round!(d, e, f, g, h, a, b, c, K64, t + 5);
130130
sha2_round!(c, d, e, f, g, h, a, b, K64, t + 6);
131131
sha2_round!(b, c, d, e, f, g, h, a, K64, t + 7);
132-
true
133-
};
132+
}
134133

135-
do uint::range_step(64, 80, 8) |t| {
134+
for t in range_step(64u, 80, 8) {
136135
sha2_round!(a, b, c, d, e, f, g, h, K64, t);
137136
sha2_round!(h, a, b, c, d, e, f, g, K64, t + 1);
138137
sha2_round!(g, h, a, b, c, d, e, f, K64, t + 2);
@@ -141,8 +140,7 @@ impl Engine512State {
141140
sha2_round!(d, e, f, g, h, a, b, c, K64, t + 5);
142141
sha2_round!(c, d, e, f, g, h, a, b, K64, t + 6);
143142
sha2_round!(b, c, d, e, f, g, h, a, K64, t + 7);
144-
true
145-
};
143+
}
146144

147145
self.H0 += a;
148146
self.H1 += b;
@@ -527,7 +525,7 @@ impl Engine256State {
527525

528526
// Putting the message schedule inside the same loop as the round calculations allows for
529527
// the compiler to generate better code.
530-
do uint::range_step(0, 48, 8) |t| {
528+
for t in range_step(0u, 48, 8) {
531529
schedule_round!(t + 16);
532530
schedule_round!(t + 17);
533531
schedule_round!(t + 18);
@@ -545,10 +543,9 @@ impl Engine256State {
545543
sha2_round!(d, e, f, g, h, a, b, c, K32, t + 5);
546544
sha2_round!(c, d, e, f, g, h, a, b, K32, t + 6);
547545
sha2_round!(b, c, d, e, f, g, h, a, K32, t + 7);
548-
true
549-
};
546+
}
550547

551-
do uint::range_step(48, 64, 8) |t| {
548+
for t in range_step(48u, 64, 8) {
552549
sha2_round!(a, b, c, d, e, f, g, h, K32, t);
553550
sha2_round!(h, a, b, c, d, e, f, g, K32, t + 1);
554551
sha2_round!(g, h, a, b, c, d, e, f, K32, t + 2);
@@ -557,8 +554,7 @@ impl Engine256State {
557554
sha2_round!(d, e, f, g, h, a, b, c, K32, t + 5);
558555
sha2_round!(c, d, e, f, g, h, a, b, K32, t + 6);
559556
sha2_round!(b, c, d, e, f, g, h, a, K32, t + 7);
560-
true
561-
};
557+
}
562558

563559
self.H0 += a;
564560
self.H1 += b;

branches/try/src/librustpkg/tests.rs

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1111,55 +1111,6 @@ fn test_extern_mod() {
11111111
assert!(os::path_exists(&exec_file) && is_executable(&exec_file));
11121112
}
11131113

1114-
#[test]
1115-
fn test_extern_mod_simpler() {
1116-
let dir = mkdtemp(&os::tmpdir(), "test_extern_mod_simpler").expect("test_extern_mod_simpler");
1117-
let main_file = dir.push("main.rs");
1118-
let lib_depend_dir = mkdtemp(&os::tmpdir(), "foo").expect("test_extern_mod_simpler");
1119-
let aux_dir = lib_depend_dir.push_many(["src", "rust-awesomeness"]);
1120-
assert!(os::mkdir_recursive(&aux_dir, U_RWX));
1121-
let aux_pkg_file = aux_dir.push("lib.rs");
1122-
1123-
writeFile(&aux_pkg_file, "pub mod bar { pub fn assert_true() { assert!(true); } }\n");
1124-
assert!(os::path_exists(&aux_pkg_file));
1125-
1126-
writeFile(&main_file,
1127-
"extern mod test = \"rust-awesomeness\";\nuse test::bar;\
1128-
fn main() { bar::assert_true(); }\n");
1129-
1130-
command_line_test([~"install", ~"rust-awesomeness"], &lib_depend_dir);
1131-
1132-
let exec_file = dir.push("out");
1133-
// Be sure to extend the existing environment
1134-
let env = Some([(~"RUST_PATH", lib_depend_dir.to_str())] + os::env());
1135-
let rustpkg_exec = rustpkg_exec();
1136-
let rustc = rustpkg_exec.with_filename("rustc");
1137-
debug!("RUST_PATH=%s %s %s \n --sysroot %s -o %s",
1138-
lib_depend_dir.to_str(),
1139-
rustc.to_str(),
1140-
main_file.to_str(),
1141-
test_sysroot().to_str(),
1142-
exec_file.to_str());
1143-
1144-
let mut prog = run::Process::new(rustc.to_str(), [main_file.to_str(),
1145-
~"--sysroot", test_sysroot().to_str(),
1146-
~"-o", exec_file.to_str()],
1147-
run::ProcessOptions {
1148-
env: env,
1149-
dir: Some(&dir),
1150-
in_fd: None,
1151-
out_fd: None,
1152-
err_fd: None
1153-
});
1154-
let outp = prog.finish_with_output();
1155-
if outp.status != 0 {
1156-
fail!("output was %s, error was %s",
1157-
str::from_utf8(outp.output),
1158-
str::from_utf8(outp.error));
1159-
}
1160-
assert!(os::path_exists(&exec_file) && is_executable(&exec_file));
1161-
}
1162-
11631114
#[test]
11641115
fn test_import_rustpkg() {
11651116
let p_id = PkgId::new("foo");

branches/try/src/librustpkg/util.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,8 +268,10 @@ pub fn compile_input(context: &BuildContext,
268268
let link_options =
269269
~[attr::mk_name_value_item_str(@"name", name_to_use),
270270
attr::mk_name_value_item_str(@"vers", pkg_id.version.to_str().to_managed())] +
271-
~[attr::mk_name_value_item_str(@"package_id",
272-
pkg_id.path.to_str().to_managed())];
271+
if pkg_id.is_complex() {
272+
~[attr::mk_name_value_item_str(@"package_id",
273+
pkg_id.path.to_str().to_managed())]
274+
} else { ~[] };
273275

274276
debug!("link options: %?", link_options);
275277
crate = @ast::Crate {

branches/try/src/libstd/char.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
1313
use cast::transmute;
1414
use option::{None, Option, Some};
15-
use i32;
15+
use iter::{Iterator, range_step};
1616
use str::StrSlice;
1717
use unicode::{derived_property, general_category, decompose};
1818
use to_str::ToStr;
@@ -286,15 +286,14 @@ pub fn escape_unicode(c: char, f: &fn(char)) {
286286
(c <= '\uffff') { f('u'); 4 }
287287
_ { f('U'); 8 }
288288
);
289-
do i32::range_step(4 * (pad - 1), -1, -4) |offset| {
289+
for offset in range_step::<i32>(4 * (pad - 1), -1, -4) {
290290
unsafe {
291291
match ((c as i32) >> offset) & 0xf {
292292
i @ 0 .. 9 => { f(transmute('0' as i32 + i)); }
293293
i => { f(transmute('a' as i32 + (i - 10))); }
294294
}
295295
}
296-
true
297-
};
296+
}
298297
}
299298

300299
///

branches/try/src/libstd/iter.rs

Lines changed: 35 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1790,17 +1790,17 @@ pub fn range_inclusive<A: Add<A, A> + Ord + Clone + One>(start: A, stop: A) -> R
17901790
RangeInclusive{range: range(start, stop), done: false}
17911791
}
17921792

1793-
impl<A: Add<A, A> + Ord + Clone> Iterator<A> for RangeInclusive<A> {
1793+
impl<A: Add<A, A> + Eq + Ord + Clone> Iterator<A> for RangeInclusive<A> {
17941794
#[inline]
17951795
fn next(&mut self) -> Option<A> {
17961796
match self.range.next() {
17971797
Some(x) => Some(x),
17981798
None => {
1799-
if self.done {
1800-
None
1801-
} else {
1799+
if !self.done && self.range.state == self.range.stop {
18021800
self.done = true;
18031801
Some(self.range.stop.clone())
1802+
} else {
1803+
None
18041804
}
18051805
}
18061806
}
@@ -1829,11 +1829,11 @@ impl<A: Sub<A, A> + Integer + Ord + Clone> DoubleEndedIterator<A> for RangeInclu
18291829
let result = self.range.stop.clone();
18301830
self.range.stop = self.range.stop - self.range.one;
18311831
Some(result)
1832-
} else if self.done {
1833-
None
1834-
} else {
1832+
} else if !self.done && self.range.state == self.range.stop {
18351833
self.done = true;
18361834
Some(self.range.stop.clone())
1835+
} else {
1836+
None
18371837
}
18381838
}
18391839
}
@@ -1857,7 +1857,7 @@ pub fn range_step<A: CheckedAdd + Ord + Clone + Zero>(start: A, stop: A, step: A
18571857
impl<A: CheckedAdd + Ord + Clone> Iterator<A> for RangeStep<A> {
18581858
#[inline]
18591859
fn next(&mut self) -> Option<A> {
1860-
if (self.rev && self.state > self.stop) || self.state < self.stop {
1860+
if (self.rev && self.state > self.stop) || (!self.rev && self.state < self.stop) {
18611861
let result = self.state.clone();
18621862
match self.state.checked_add(&self.step) {
18631863
Some(x) => self.state = x,
@@ -1891,22 +1891,14 @@ pub fn range_step_inclusive<A: CheckedAdd + Ord + Clone + Zero>(start: A, stop:
18911891
impl<A: CheckedAdd + Ord + Clone + Eq> Iterator<A> for RangeStepInclusive<A> {
18921892
#[inline]
18931893
fn next(&mut self) -> Option<A> {
1894-
if !self.done {
1895-
if (self.rev && self.state > self.stop) || self.state < self.stop {
1896-
let result = self.state.clone();
1897-
match self.state.checked_add(&self.step) {
1898-
Some(x) => self.state = x,
1899-
None => self.done = true
1900-
}
1901-
Some(result)
1902-
} else {
1903-
if self.state == self.stop {
1904-
self.done = true;
1905-
Some(self.state.clone())
1906-
} else {
1907-
None
1908-
}
1894+
if !self.done && ((self.rev && self.state >= self.stop) ||
1895+
(!self.rev && self.state <= self.stop)) {
1896+
let result = self.state.clone();
1897+
match self.state.checked_add(&self.step) {
1898+
Some(x) => self.state = x,
1899+
None => self.done = true
19091900
}
1901+
Some(result)
19101902
} else {
19111903
None
19121904
}
@@ -2716,24 +2708,44 @@ mod tests {
27162708
}
27172709
}
27182710

2711+
#[test]
2712+
fn test_range() {
2713+
assert_eq!(range(0i, 5).collect::<~[int]>(), ~[0i, 1, 2, 3, 4]);
2714+
assert_eq!(range(0i, 5).invert().collect::<~[int]>(), ~[4, 3, 2, 1, 0]);
2715+
assert_eq!(range(200, -5).collect::<~[int]>(), ~[]);
2716+
assert_eq!(range(200, -5).invert().collect::<~[int]>(), ~[]);
2717+
assert_eq!(range(200, 200).collect::<~[int]>(), ~[]);
2718+
assert_eq!(range(200, 200).invert().collect::<~[int]>(), ~[]);
2719+
}
2720+
27192721
#[test]
27202722
fn test_range_inclusive() {
27212723
assert_eq!(range_inclusive(0i, 5).collect::<~[int]>(), ~[0i, 1, 2, 3, 4, 5]);
27222724
assert_eq!(range_inclusive(0i, 5).invert().collect::<~[int]>(), ~[5i, 4, 3, 2, 1, 0]);
2725+
assert_eq!(range_inclusive(200, -5).collect::<~[int]>(), ~[]);
2726+
assert_eq!(range_inclusive(200, -5).invert().collect::<~[int]>(), ~[]);
2727+
assert_eq!(range_inclusive(200, 200).collect::<~[int]>(), ~[200]);
2728+
assert_eq!(range_inclusive(200, 200).invert().collect::<~[int]>(), ~[200]);
27232729
}
27242730

27252731
#[test]
27262732
fn test_range_step() {
27272733
assert_eq!(range_step(0i, 20, 5).collect::<~[int]>(), ~[0, 5, 10, 15]);
27282734
assert_eq!(range_step(20i, 0, -5).collect::<~[int]>(), ~[20, 15, 10, 5]);
2735+
assert_eq!(range_step(20i, 0, -6).collect::<~[int]>(), ~[20, 14, 8, 2]);
27292736
assert_eq!(range_step(200u8, 255, 50).collect::<~[u8]>(), ~[200u8, 250]);
2737+
assert_eq!(range_step(200, -5, 1).collect::<~[int]>(), ~[]);
2738+
assert_eq!(range_step(200, 200, 1).collect::<~[int]>(), ~[]);
27302739
}
27312740

27322741
#[test]
27332742
fn test_range_step_inclusive() {
27342743
assert_eq!(range_step_inclusive(0i, 20, 5).collect::<~[int]>(), ~[0, 5, 10, 15, 20]);
27352744
assert_eq!(range_step_inclusive(20i, 0, -5).collect::<~[int]>(), ~[20, 15, 10, 5, 0]);
2745+
assert_eq!(range_step_inclusive(20i, 0, -6).collect::<~[int]>(), ~[20, 14, 8, 2]);
27362746
assert_eq!(range_step_inclusive(200u8, 255, 50).collect::<~[u8]>(), ~[200u8, 250]);
2747+
assert_eq!(range_step_inclusive(200, -5, 1).collect::<~[int]>(), ~[]);
2748+
assert_eq!(range_step_inclusive(200, 200, 1).collect::<~[int]>(), ~[200]);
27372749
}
27382750

27392751
#[test]

0 commit comments

Comments
 (0)