Skip to content

Commit 8f87565

Browse files
committed
---
yaml --- r: 144621 b: refs/heads/try2 c: c70486f h: refs/heads/master i: 144619: efffd4f v: v3
1 parent 3508ed5 commit 8f87565

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

118 files changed

+1473
-1319
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 30fc2c8df2fc565b20d8df3a202cb0c7d089afd0
8+
refs/heads/try2: c70486fffe4d1eb682233749779cf0053cf83b01
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/doc/tutorial-container.md

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,14 +105,18 @@ impl Iterator<int> for ZeroStream {
105105
}
106106
~~~
107107
108+
In general, you cannot rely on the behavior of the `next()` method after it has
109+
returned `None`. Some iterators may return `None` forever. Others may behave
110+
differently.
111+
108112
## Container iterators
109113
110114
Containers implement iteration over the contained elements by returning an
111115
iterator object. For example, vector slices several iterators available:
112116
113117
* `iter()` and `rev_iter()`, for immutable references to the elements
114118
* `mut_iter()` and `mut_rev_iter()`, for mutable references to the elements
115-
* `move_iter()` and `move_rev_iter`, to move the elements out by-value
119+
* `move_iter()` and `move_rev_iter()`, to move the elements out by-value
116120
117121
A typical mutable container will implement at least `iter()`, `mut_iter()` and
118122
`move_iter()` along with the reverse variants if it maintains an order.
@@ -149,7 +153,7 @@ let result = xs.iter().fold(0, |accumulator, item| accumulator - *item);
149153
assert_eq!(result, -41);
150154
~~~
151155
152-
Some adaptors return an adaptor object implementing the `Iterator` trait itself:
156+
Most adaptors return an adaptor object implementing the `Iterator` trait itself:
153157
154158
~~~
155159
let xs = [1, 9, 2, 3, 14, 12];
@@ -158,6 +162,35 @@ let sum = xs.iter().chain(ys.iter()).fold(0, |a, b| a + *b);
158162
assert_eq!(sum, 57);
159163
~~~
160164
165+
Some iterator adaptors may return `None` before exhausting the underlying
166+
iterator. Additionally, if these iterator adaptors are called again after
167+
returning `None`, they may call their underlying iterator again even if the
168+
adaptor will continue to return `None` forever. This may not be desired if the
169+
underlying iterator has side-effects.
170+
171+
In order to provide a guarantee about behavior once `None` has been returned, an
172+
iterator adaptor named `fuse()` is provided. This returns an iterator that will
173+
never call its underlying iterator again once `None` has been returned:
174+
175+
~~~
176+
let xs = [1,2,3,4,5];
177+
let mut calls = 0;
178+
let it = xs.iter().scan((), |_, x| {
179+
calls += 1;
180+
if *x < 3 { Some(x) } else { None }});
181+
// the iterator will only yield 1 and 2 before returning None
182+
// If we were to call it 5 times, calls would end up as 5, despite only 2 values
183+
// being yielded (and therefore 3 unique calls being made). The fuse() adaptor
184+
// can fix this.
185+
let mut it = it.fuse();
186+
it.next();
187+
it.next();
188+
it.next();
189+
it.next();
190+
it.next();
191+
assert_eq!(calls, 3);
192+
~~~
193+
161194
## For loops
162195
163196
The function `range` (or `range_inclusive`) allows to simply iterate through a given range:

branches/try2/src/librustc/back/arm.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,46 +13,46 @@ use driver::session::sess_os_to_meta_os;
1313
use driver::session;
1414
use metadata::loader::meta_section_name;
1515

16-
pub fn get_target_strs(target_triple: ~str, target_os: session::os) -> target_strs::t {
16+
pub fn get_target_strs(target_triple: ~str, target_os: session::Os) -> target_strs::t {
1717
return target_strs::t {
1818
module_asm: ~"",
1919

20-
meta_sect_name: meta_section_name(sess_os_to_meta_os(target_os)),
20+
meta_sect_name: meta_section_name(sess_os_to_meta_os(target_os)).to_owned(),
2121

2222
data_layout: match target_os {
23-
session::os_macos => {
23+
session::OsMacos => {
2424
~"e-p:32:32:32" +
2525
"-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64" +
2626
"-f32:32:32-f64:64:64" +
2727
"-v64:64:64-v128:64:128" +
2828
"-a0:0:64-n32"
2929
}
3030

31-
session::os_win32 => {
31+
session::OsWin32 => {
3232
~"e-p:32:32:32" +
3333
"-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64" +
3434
"-f32:32:32-f64:64:64" +
3535
"-v64:64:64-v128:64:128" +
3636
"-a0:0:64-n32"
3737
}
3838

39-
session::os_linux => {
39+
session::OsLinux => {
4040
~"e-p:32:32:32" +
4141
"-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64" +
4242
"-f32:32:32-f64:64:64" +
4343
"-v64:64:64-v128:64:128" +
4444
"-a0:0:64-n32"
4545
}
4646

47-
session::os_android => {
47+
session::OsAndroid => {
4848
~"e-p:32:32:32" +
4949
"-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64" +
5050
"-f32:32:32-f64:64:64" +
5151
"-v64:64:64-v128:64:128" +
5252
"-a0:0:64-n32"
5353
}
5454

55-
session::os_freebsd => {
55+
session::OsFreebsd => {
5656
~"e-p:32:32:32" +
5757
"-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64" +
5858
"-f32:32:32-f64:64:64" +

branches/try2/src/librustc/back/link.rs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -814,13 +814,13 @@ pub fn mangle_internal_name_by_seq(_ccx: &mut CrateContext, flav: &str) -> ~str
814814
}
815815

816816

817-
pub fn output_dll_filename(os: session::os, lm: LinkMeta) -> ~str {
817+
pub fn output_dll_filename(os: session::Os, lm: LinkMeta) -> ~str {
818818
let (dll_prefix, dll_suffix) = match os {
819-
session::os_win32 => (win32::DLL_PREFIX, win32::DLL_SUFFIX),
820-
session::os_macos => (macos::DLL_PREFIX, macos::DLL_SUFFIX),
821-
session::os_linux => (linux::DLL_PREFIX, linux::DLL_SUFFIX),
822-
session::os_android => (android::DLL_PREFIX, android::DLL_SUFFIX),
823-
session::os_freebsd => (freebsd::DLL_PREFIX, freebsd::DLL_SUFFIX),
819+
session::OsWin32 => (win32::DLL_PREFIX, win32::DLL_SUFFIX),
820+
session::OsMacos => (macos::DLL_PREFIX, macos::DLL_SUFFIX),
821+
session::OsLinux => (linux::DLL_PREFIX, linux::DLL_SUFFIX),
822+
session::OsAndroid => (android::DLL_PREFIX, android::DLL_SUFFIX),
823+
session::OsFreebsd => (freebsd::DLL_PREFIX, freebsd::DLL_SUFFIX),
824824
};
825825
fmt!("%s%s-%s-%s%s", dll_prefix, lm.name, lm.extras_hash, lm.vers, dll_suffix)
826826
}
@@ -835,7 +835,7 @@ pub fn get_cc_prog(sess: Session) -> ~str {
835835
match sess.opts.linker {
836836
Some(ref linker) => linker.to_str(),
837837
None => match sess.targ_cfg.os {
838-
session::os_android =>
838+
session::OsAndroid =>
839839
match &sess.opts.android_cross_path {
840840
&Some(ref path) => {
841841
fmt!("%s/bin/arm-linux-androideabi-gcc", *path)
@@ -845,7 +845,7 @@ pub fn get_cc_prog(sess: Session) -> ~str {
845845
(--android-cross-path)")
846846
}
847847
},
848-
session::os_win32 => ~"g++",
848+
session::OsWin32 => ~"g++",
849849
_ => ~"cc"
850850
}
851851
}
@@ -892,7 +892,7 @@ pub fn link_binary(sess: Session,
892892
}
893893

894894
// Clean up on Darwin
895-
if sess.targ_cfg.os == session::os_macos {
895+
if sess.targ_cfg.os == session::OsMacos {
896896
run::process_status("dsymutil", [output.to_str()]);
897897
}
898898

@@ -913,7 +913,7 @@ pub fn link_args(sess: Session,
913913
// Converts a library file-stem into a cc -l argument
914914
fn unlib(config: @session::config, stem: ~str) -> ~str {
915915
if stem.starts_with("lib") &&
916-
config.os != session::os_win32 {
916+
config.os != session::OsWin32 {
917917
stem.slice(3, stem.len()).to_owned()
918918
} else {
919919
stem
@@ -939,7 +939,7 @@ pub fn link_args(sess: Session,
939939
obj_filename.to_str()]);
940940

941941
let lib_cmd = match sess.targ_cfg.os {
942-
session::os_macos => ~"-dynamiclib",
942+
session::OsMacos => ~"-dynamiclib",
943943
_ => ~"-shared"
944944
};
945945

@@ -995,28 +995,28 @@ pub fn link_args(sess: Session,
995995

996996
// On mac we need to tell the linker to let this library
997997
// be rpathed
998-
if sess.targ_cfg.os == session::os_macos {
998+
if sess.targ_cfg.os == session::OsMacos {
999999
args.push(~"-Wl,-install_name,@rpath/"
10001000
+ output.filename().unwrap());
10011001
}
10021002
}
10031003
10041004
// On linux librt and libdl are an indirect dependencies via rustrt,
10051005
// and binutils 2.22+ won't add them automatically
1006-
if sess.targ_cfg.os == session::os_linux {
1006+
if sess.targ_cfg.os == session::OsLinux {
10071007
args.push_all([~"-lrt", ~"-ldl"]);
10081008

10091009
// LLVM implements the `frem` instruction as a call to `fmod`,
10101010
// which lives in libm. Similar to above, on some linuxes we
10111011
// have to be explicit about linking to it. See #2510
10121012
args.push(~"-lm");
10131013
}
1014-
else if sess.targ_cfg.os == session::os_android {
1014+
else if sess.targ_cfg.os == session::OsAndroid {
10151015
args.push_all([~"-ldl", ~"-llog", ~"-lsupc++", ~"-lgnustl_shared"]);
10161016
args.push(~"-lm");
10171017
}
10181018

1019-
if sess.targ_cfg.os == session::os_freebsd {
1019+
if sess.targ_cfg.os == session::OsFreebsd {
10201020
args.push_all([~"-pthread", ~"-lrt",
10211021
~"-L/usr/local/lib", ~"-lexecinfo",
10221022
~"-L/usr/local/lib/gcc46",
@@ -1030,7 +1030,7 @@ pub fn link_args(sess: Session,
10301030
// linker from the dwarf unwind info. Unfortunately, it does not seem to
10311031
// understand how to unwind our __morestack frame, so we have to turn it
10321032
// off. This has impacted some other projects like GHC.
1033-
if sess.targ_cfg.os == session::os_macos {
1033+
if sess.targ_cfg.os == session::OsMacos {
10341034
args.push(~"-Wl,-no_compact_unwind");
10351035
}
10361036

branches/try2/src/librustc/back/mips.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,46 +13,46 @@ use driver::session;
1313
use driver::session::sess_os_to_meta_os;
1414
use metadata::loader::meta_section_name;
1515

16-
pub fn get_target_strs(target_triple: ~str, target_os: session::os) -> target_strs::t {
16+
pub fn get_target_strs(target_triple: ~str, target_os: session::Os) -> target_strs::t {
1717
return target_strs::t {
1818
module_asm: ~"",
1919

20-
meta_sect_name: meta_section_name(sess_os_to_meta_os(target_os)),
20+
meta_sect_name: meta_section_name(sess_os_to_meta_os(target_os)).to_owned(),
2121

2222
data_layout: match target_os {
23-
session::os_macos => {
23+
session::OsMacos => {
2424
~"e-p:32:32:32" +
2525
"-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64" +
2626
"-f32:32:32-f64:64:64" +
2727
"-v64:64:64-v128:64:128" +
2828
"-a0:0:64-n32"
2929
}
3030

31-
session::os_win32 => {
31+
session::OsWin32 => {
3232
~"e-p:32:32:32" +
3333
"-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64" +
3434
"-f32:32:32-f64:64:64" +
3535
"-v64:64:64-v128:64:128" +
3636
"-a0:0:64-n32"
3737
}
3838

39-
session::os_linux => {
39+
session::OsLinux => {
4040
~"e-p:32:32:32" +
4141
"-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64" +
4242
"-f32:32:32-f64:64:64" +
4343
"-v64:64:64-v128:64:128" +
4444
"-a0:0:64-n32"
4545
}
4646

47-
session::os_android => {
47+
session::OsAndroid => {
4848
~"e-p:32:32:32" +
4949
"-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64" +
5050
"-f32:32:32-f64:64:64" +
5151
"-v64:64:64-v128:64:128" +
5252
"-a0:0:64-n32"
5353
}
5454

55-
session::os_freebsd => {
55+
session::OsFreebsd => {
5656
~"e-p:32:32:32" +
5757
"-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64" +
5858
"-f32:32:32-f64:64:64" +

branches/try2/src/librustc/back/rpath.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,16 @@ use metadata::filesearch;
1616
use std::hashmap::HashSet;
1717
use std::{os, util, vec};
1818

19-
fn not_win32(os: session::os) -> bool {
20-
os != session::os_win32
19+
fn not_win32(os: session::Os) -> bool {
20+
os != session::OsWin32
2121
}
2222

2323
pub fn get_rpath_flags(sess: session::Session, out_filename: &Path)
2424
-> ~[~str] {
2525
let os = sess.targ_cfg.os;
2626

2727
// No rpath on windows
28-
if os == session::os_win32 {
28+
if os == session::OsWin32 {
2929
return ~[];
3030
}
3131

@@ -52,7 +52,7 @@ pub fn rpaths_to_flags(rpaths: &[Path]) -> ~[~str] {
5252
rpaths.iter().map(|rpath| fmt!("-Wl,-rpath,%s",rpath.to_str())).collect()
5353
}
5454

55-
fn get_rpaths(os: session::os,
55+
fn get_rpaths(os: session::Os,
5656
sysroot: &Path,
5757
output: &Path,
5858
libs: &[Path],
@@ -97,13 +97,13 @@ fn get_rpaths(os: session::os,
9797
return rpaths;
9898
}
9999

100-
fn get_rpaths_relative_to_output(os: session::os,
100+
fn get_rpaths_relative_to_output(os: session::Os,
101101
output: &Path,
102102
libs: &[Path]) -> ~[Path] {
103103
libs.iter().map(|a| get_rpath_relative_to_output(os, output, a)).collect()
104104
}
105105

106-
pub fn get_rpath_relative_to_output(os: session::os,
106+
pub fn get_rpath_relative_to_output(os: session::Os,
107107
output: &Path,
108108
lib: &Path)
109109
-> Path {
@@ -113,10 +113,10 @@ pub fn get_rpath_relative_to_output(os: session::os,
113113

114114
// Mac doesn't appear to support $ORIGIN
115115
let prefix = match os {
116-
session::os_android | session::os_linux | session::os_freebsd
116+
session::OsAndroid | session::OsLinux | session::OsFreebsd
117117
=> "$ORIGIN",
118-
session::os_macos => "@executable_path",
119-
session::os_win32 => util::unreachable()
118+
session::OsMacos => "@executable_path",
119+
session::OsWin32 => util::unreachable()
120120
};
121121

122122
Path(prefix).push_rel(&os::make_absolute(output).get_relative_to(&os::make_absolute(lib)))
@@ -205,7 +205,7 @@ mod test {
205205
#[cfg(target_os = "linux")]
206206
#[cfg(target_os = "android")]
207207
fn test_rpath_relative() {
208-
let o = session::os_linux;
208+
let o = session::OsLinux;
209209
let res = get_rpath_relative_to_output(o,
210210
&Path("bin/rustc"), &Path("lib/libstd.so"));
211211
assert_eq!(res.to_str(), ~"$ORIGIN/../lib");
@@ -214,7 +214,7 @@ mod test {
214214
#[test]
215215
#[cfg(target_os = "freebsd")]
216216
fn test_rpath_relative() {
217-
let o = session::os_freebsd;
217+
let o = session::OsFreebsd;
218218
let res = get_rpath_relative_to_output(o,
219219
&Path("bin/rustc"), &Path("lib/libstd.so"));
220220
assert_eq!(res.to_str(), ~"$ORIGIN/../lib");
@@ -223,7 +223,7 @@ mod test {
223223
#[test]
224224
#[cfg(target_os = "macos")]
225225
fn test_rpath_relative() {
226-
let o = session::os_macos;
226+
let o = session::OsMacos;
227227
let res = get_rpath_relative_to_output(o,
228228
&Path("bin/rustc"),
229229
&Path("lib/libstd.so"));

0 commit comments

Comments
 (0)