Auto merge of #21872 - alexcrichton:rollup, r=alexcrichton

This commit is contained in:
bors 2015-02-03 03:44:05 +00:00
commit 7858cb432d
447 changed files with 5806 additions and 3252 deletions

View File

@ -23,12 +23,12 @@ The following third party packages are included, and carry
their own copyright notices and license terms:
* Two header files that are part of the Valgrind
package. These files are found at src/rt/vg/valgrind.h and
src/rt/vg/memcheck.h, within this distribution. These files
package. These files are found at src/rt/valgrind/valgrind.h and
src/rt/valgrind/memcheck.h, within this distribution. These files
are redistributed under the following terms, as noted in
them:
for src/rt/vg/valgrind.h:
for src/rt/valgrind/valgrind.h:
This file is part of Valgrind, a dynamic binary
instrumentation framework.
@ -74,7 +74,7 @@ their own copyright notices and license terms:
USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
for src/rt/vg/memcheck.h:
for src/rt/valgrind/memcheck.h:
This file is part of MemCheck, a heavyweight Valgrind
tool for detecting memory errors.
@ -120,18 +120,6 @@ their own copyright notices and license terms:
USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.
* The auxiliary file src/etc/pkg/modpath.iss contains a
library routine compiled, by Inno Setup, into the Windows
installer binary. This file is licensed under the LGPL,
version 3, but, in our legal interpretation, this does not
affect the aggregate "collected work" license of the Rust
distribution (MIT/ASL2) nor any other components of it. We
believe that the terms governing distribution of the
binary Windows installer built from modpath.iss are
therefore LGPL, but not the terms governing distribution
of any of the files installed by such an installer (such
as the Rust compiler or runtime libraries themselves).
* The src/rt/miniz.c file, carrying an implementation of
RFC1950/RFC1951 DEFLATE, by Rich Geldreich
<richgel99@gmail.com>. All uses of this file are

4
configure vendored
View File

@ -374,6 +374,10 @@ case $CFG_OSTYPE in
CFG_OSTYPE=unknown-dragonfly
;;
OpenBSD)
CFG_OSTYPE=unknown-openbsd
;;
Darwin)
CFG_OSTYPE=apple-darwin
;;

View File

@ -0,0 +1,26 @@
# x86_64-pc-openbsd-elf configuration
CC_x86_64-unknown-openbsd=$(CC)
CXX_x86_64-unknown-openbsd=$(CXX)
CPP_x86_64-unknown-openbsd=$(CPP)
AR_x86_64-unknown-openbsd=$(AR)
CFG_LIB_NAME_x86_64-unknown-openbsd=lib$(1).so
CFG_STATIC_LIB_NAME_x86_64-unknown-openbsd=lib$(1).a
CFG_LIB_GLOB_x86_64-unknown-openbsd=lib$(1)-*.so
CFG_LIB_DSYM_GLOB_x86_64-unknown-openbsd=$(1)-*.dylib.dSYM
CFG_JEMALLOC_CFLAGS_x86_64-unknown-openbsd := -m64 -I/usr/include $(CFLAGS)
CFG_GCCISH_CFLAGS_x86_64-unknown-openbsd := -Wall -Werror -g -fPIC -m64 -I/usr/include $(CFLAGS)
CFG_GCCISH_LINK_FLAGS_x86_64-unknown-openbsd := -shared -fPIC -g -pthread -m64
CFG_GCCISH_DEF_FLAG_x86_64-unknown-openbsd := -Wl,--export-dynamic,--dynamic-list=
CFG_GCCISH_PRE_LIB_FLAGS_x86_64-unknown-openbsd := -Wl,-whole-archive
CFG_GCCISH_POST_LIB_FLAGS_x86_64-unknown-openbsd := -Wl,-no-whole-archive
CFG_DEF_SUFFIX_x86_64-unknown-openbsd := .bsd.def
CFG_LLC_FLAGS_x86_64-unknown-openbsd :=
CFG_INSTALL_NAME_x86_64-unknown-openbsd =
CFG_EXE_SUFFIX_x86_64-unknown-openbsd :=
CFG_WINDOWSY_x86_64-unknown-openbsd :=
CFG_UNIXY_x86_64-unknown-openbsd := 1
CFG_PATH_MUNGE_x86_64-unknown-openbsd :=
CFG_LDPATH_x86_64-unknown-openbsd :=
CFG_RUN_x86_64-unknown-openbsd=$(2)
CFG_RUN_TARG_x86_64-unknown-openbsd=$(call CFG_RUN_x86_64-unknown-openbsd,,$(2))
CFG_GNU_TRIPLE_x86_64-unknown-openbsd := x86_64-unknown-openbsd

View File

@ -22,6 +22,7 @@
#![feature(std_misc)]
#![feature(test)]
#![feature(unicode)]
#![feature(env)]
#![deny(warnings)]
@ -31,7 +32,7 @@ extern crate getopts;
#[macro_use]
extern crate log;
use std::os;
use std::env;
use std::old_io;
use std::old_io::fs;
use std::thunk::Thunk;
@ -48,7 +49,7 @@ pub mod common;
pub mod errors;
pub fn main() {
let args = os::args();
let args = env::args().map(|s| s.into_string().unwrap()).collect();;
let config = parse_config(args);
if config.valgrind_path.is_none() && config.force_valgrind {
@ -224,7 +225,7 @@ pub fn run_tests(config: &Config) {
//arm-linux-androideabi debug-info test uses remote debugger
//so, we test 1 task at once.
// also trying to isolate problems with adb_run_wrapper.sh ilooping
os::setenv("RUST_TEST_TASKS","1");
env::set_var("RUST_TEST_TASKS","1");
}
match config.mode {
@ -232,7 +233,7 @@ pub fn run_tests(config: &Config) {
// Some older versions of LLDB seem to have problems with multiple
// instances running in parallel, so only run one test task at a
// time.
os::setenv("RUST_TEST_TASKS", "1");
env::set_var("RUST_TEST_TASKS", "1");
}
_ => { /* proceed */ }
}
@ -245,7 +246,7 @@ pub fn run_tests(config: &Config) {
old_io::test::raise_fd_limit();
// Prevent issue #21352 UAC blocking .exe containing 'patch' etc. on Windows
// If #11207 is resolved (adding manifest to .exe) this becomes unnecessary
os::setenv("__COMPAT_LAYER", "RunAsInvoker");
env::set_var("__COMPAT_LAYER", "RunAsInvoker");
let res = test::run_tests_console(&opts, tests.into_iter().collect());
match res {
Ok(true) => {}
@ -276,7 +277,7 @@ pub fn make_tests(config: &Config) -> Vec<test::TestDescAndFn> {
config.src_base.display());
let mut tests = Vec::new();
let dirs = fs::readdir(&config.src_base).unwrap();
for file in dirs.iter() {
for file in &dirs {
let file = file.clone();
debug!("inspecting file {:?}", file.display());
if is_test(config, &file) {
@ -304,13 +305,13 @@ pub fn is_test(config: &Config, testfile: &Path) -> bool {
let mut valid = false;
for ext in valid_extensions.iter() {
for ext in &valid_extensions {
if name.ends_with(ext.as_slice()) {
valid = true;
}
}
for pre in invalid_prefixes.iter() {
for pre in &invalid_prefixes {
if name.starts_with(pre.as_slice()) {
valid = false;
}

View File

@ -40,13 +40,13 @@ pub fn run(lib_path: &str,
let mut cmd = Command::new(prog);
cmd.args(args);
add_target_env(&mut cmd, lib_path, aux_path);
for (key, val) in env.into_iter() {
for (key, val) in env {
cmd.env(key, val);
}
match cmd.spawn() {
Ok(mut process) => {
for input in input.iter() {
if let Some(input) = input {
process.stdin.as_mut().unwrap().write_all(input.as_bytes()).unwrap();
}
let ProcessOutput { status, output, error } =
@ -72,13 +72,13 @@ pub fn run_background(lib_path: &str,
let mut cmd = Command::new(prog);
cmd.args(args);
add_target_env(&mut cmd, lib_path, aux_path);
for (key, val) in env.into_iter() {
for (key, val) in env {
cmd.env(key, val);
}
match cmd.spawn() {
Ok(mut process) => {
for input in input.iter() {
if let Some(input) = input {
process.stdin.as_mut().unwrap().write_all(input.as_bytes()).unwrap();
}

View File

@ -31,7 +31,7 @@ use std::old_io::process::ProcessExit;
use std::old_io::process;
use std::old_io::timer;
use std::old_io;
use std::os;
use std::env;
use std::iter::repeat;
use std::str;
use std::string::String;
@ -547,7 +547,7 @@ fn run_debuginfo_gdb_test(config: &Config, props: &TestProps, testfile: &Path) {
exe_file.as_str().unwrap().replace("\\", "\\\\"))[]);
// Add line breakpoints
for line in breakpoint_lines.iter() {
for line in &breakpoint_lines {
script_str.push_str(&format!("break '{}':{}\n",
testfile.filename_display(),
*line)[]);
@ -683,13 +683,13 @@ fn run_debuginfo_lldb_test(config: &Config, props: &TestProps, testfile: &Path)
script_str.push_str("type category enable Rust\n");
// Set breakpoints on every line that contains the string "#break"
for line in breakpoint_lines.iter() {
for line in &breakpoint_lines {
script_str.push_str(format!("breakpoint set --line {}\n",
line).as_slice());
}
// Append the other commands
for line in commands.iter() {
for line in &commands {
script_str.push_str(line.as_slice());
script_str.push_str("\n");
}
@ -847,7 +847,7 @@ fn check_debugger_output(debugger_run_result: &ProcRes, check_lines: &[String])
let mut rest = line.trim();
let mut first = true;
let mut failed = false;
for frag in check_fragments[i].iter() {
for frag in &check_fragments[i] {
let found = if first {
if rest.starts_with(frag.as_slice()) {
Some(0)
@ -915,7 +915,7 @@ fn check_error_patterns(props: &TestProps,
missing_patterns[0]).as_slice(),
proc_res);
} else {
for pattern in missing_patterns.iter() {
for pattern in missing_patterns {
error(format!("error pattern '{}' not found!",
*pattern).as_slice());
}
@ -935,7 +935,7 @@ fn check_no_compiler_crash(proc_res: &ProcRes) {
fn check_forbid_output(props: &TestProps,
output_to_check: &str,
proc_res: &ProcRes) {
for pat in props.forbid_output.iter() {
for pat in &props.forbid_output {
if output_to_check.contains(pat.as_slice()) {
fatal_proc_rec("forbidden pattern found in compiler output", proc_res);
}
@ -1173,7 +1173,7 @@ fn compose_and_run_compiler(
// FIXME (#9639): This needs to handle non-utf8 paths
let extra_link_args = vec!("-L".to_string(), aux_dir.as_str().unwrap().to_string());
for rel_ab in props.aux_builds.iter() {
for rel_ab in &props.aux_builds {
let abs_ab = config.aux_base.join(rel_ab.as_slice());
let aux_props = header::load_props(&abs_ab);
let mut crate_type = if aux_props.no_prefer_dynamic {
@ -1298,9 +1298,9 @@ fn make_lib_name(config: &Config, auxfile: &Path, testfile: &Path) -> Path {
fn make_exe_name(config: &Config, testfile: &Path) -> Path {
let mut f = output_base_name(config, testfile);
if !os::consts::EXE_SUFFIX.is_empty() {
if !env::consts::EXE_SUFFIX.is_empty() {
let mut fname = f.filename().unwrap().to_vec();
fname.extend(os::consts::EXE_SUFFIX.bytes());
fname.extend(env::consts::EXE_SUFFIX.bytes());
f.set_filename(fname);
}
f
@ -1503,14 +1503,14 @@ fn _arm_exec_compiled_test(config: &Config,
// run test via adb_run_wrapper
runargs.push("shell".to_string());
for (key, val) in env.into_iter() {
for (key, val) in env {
runargs.push(format!("{}={}", key, val));
}
runargs.push(format!("{}/adb_run_wrapper.sh", config.adb_test_dir));
runargs.push(format!("{}", config.adb_test_dir));
runargs.push(format!("{}", prog_short));
for tv in args.args.iter() {
for tv in &args.args {
runargs.push(tv.to_string());
}
procsrv::run("",
@ -1591,7 +1591,7 @@ fn _arm_push_aux_shared_library(config: &Config, testfile: &Path) {
let tdir = aux_output_dir_name(config, testfile);
let dirs = fs::readdir(&tdir).unwrap();
for file in dirs.iter() {
for file in &dirs {
if file.extension_str() == Some("so") {
// FIXME (#9639): This needs to handle non-utf8 paths
let copy_result = procsrv::run("",

View File

@ -1,4 +1,4 @@
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
@ -11,7 +11,7 @@
use common::Config;
#[cfg(target_os = "windows")]
use std::os::getenv;
use std::env;
/// Conversion table from triple OS name to Rust SYSNAME
static OS_TABLE: &'static [(&'static str, &'static str)] = &[
@ -23,10 +23,11 @@ static OS_TABLE: &'static [(&'static str, &'static str)] = &[
("linux", "linux"),
("freebsd", "freebsd"),
("dragonfly", "dragonfly"),
("openbsd", "openbsd"),
];
pub fn get_os(triple: &str) -> &'static str {
for &(triple_os, os) in OS_TABLE.iter() {
for &(triple_os, os) in OS_TABLE {
if triple.contains(triple_os) {
return os
}
@ -39,11 +40,11 @@ pub fn make_new_path(path: &str) -> String {
// Windows just uses PATH as the library search path, so we have to
// maintain the current value while adding our own
match getenv(lib_path_env_var()) {
Some(curr) => {
match env::var_string(lib_path_env_var()) {
Ok(curr) => {
format!("{}{}{}", path, path_div(), curr)
}
None => path.to_string()
Err(..) => path.to_string()
}
}

View File

@ -196,8 +196,7 @@ raw_string : '"' raw_string_body '"' | '#' raw_string '#' ;
common_escape : '\x5c'
| 'n' | 'r' | 't' | '0'
| 'x' hex_digit 2
unicode_escape : 'u' hex_digit 4
| 'U' hex_digit 8 ;
unicode_escape : 'u' '{' hex_digit+ 6 '}';
hex_digit : 'a' | 'b' | 'c' | 'd' | 'e' | 'f'
| 'A' | 'B' | 'C' | 'D' | 'E' | 'F'

View File

@ -250,8 +250,7 @@ cases mentioned in [Number literals](#number-literals) below.
##### Unicode escapes
| | Name |
|---|------|
| `\u7FFF` | 16-bit character code (exactly 4 digits) |
| `\U7EEEFFFF` | 32-bit character code (exactly 8 digits) |
| `\u{7FFF}` | 24-bit Unicode character code (up to 6 digits) |
##### Numbers
@ -286,8 +285,8 @@ raw_string : '"' raw_string_body '"' | '#' raw_string '#' ;
common_escape : '\x5c'
| 'n' | 'r' | 't' | '0'
| 'x' hex_digit 2
unicode_escape : 'u' hex_digit 4
| 'U' hex_digit 8 ;
unicode_escape : 'u' '{' hex_digit+ 6 '}';
hex_digit : 'a' | 'b' | 'c' | 'd' | 'e' | 'f'
| 'A' | 'B' | 'C' | 'D' | 'E' | 'F'
@ -320,12 +319,9 @@ following forms:
* An _8-bit codepoint escape_ escape starts with `U+0078` (`x`) and is
followed by exactly two _hex digits_. It denotes the Unicode codepoint
equal to the provided hex value.
* A _16-bit codepoint escape_ starts with `U+0075` (`u`) and is followed
by exactly four _hex digits_. It denotes the Unicode codepoint equal to
the provided hex value.
* A _32-bit codepoint escape_ starts with `U+0055` (`U`) and is followed
by exactly eight _hex digits_. It denotes the Unicode codepoint equal to
the provided hex value.
* A _24-bit codepoint escape_ starts with `U+0075` (`u`) and is followed
by up to six _hex digits_ surrounded by braces `U+007B` (`{`) and `U+007D`
(`}`). It denotes the Unicode codepoint equal to the provided hex value.
* A _whitespace escape_ is one of the characters `U+006E` (`n`), `U+0072`
(`r`), or `U+0074` (`t`), denoting the unicode values `U+000A` (LF),
`U+000D` (CR) or `U+0009` (HT) respectively.
@ -1063,7 +1059,7 @@ mod foo {
extern crate core;
use foo::core::iter; // good: foo is at crate root
// use core::iter; // bad: native is not at the crate root
// use core::iter; // bad: core is not at the crate root
use self::baz::foobaz; // good: self refers to module 'foo'
use foo::bar::foobar; // good: foo is at crate root
@ -2197,7 +2193,8 @@ The following configurations must be defined by the implementation:
`"unix"` or `"windows"`. The value of this configuration option is defined
as a configuration itself, like `unix` or `windows`.
* `target_os = "..."`. Operating system of the target, examples include
`"win32"`, `"macos"`, `"linux"`, `"android"`, `"freebsd"` or `"dragonfly"`.
`"win32"`, `"macos"`, `"linux"`, `"android"`, `"freebsd"`, `"dragonfly"` or
`"openbsd"`.
* `target_word_size = "..."`. Target word size in bits. This is set to `"32"`
for targets with 32-bit pointers, and likewise set to `"64"` for 64-bit
pointers.

View File

@ -43,5 +43,5 @@ When writing doc comments, adding sections for any arguments, return values,
and providing some examples of usage is very, very helpful. Don't worry about
the `&str`, we'll get to it soon.
You can use the [`rustdoc`](../rustdoc.html) tool to generate HTML documentation
You can use the [`rustdoc`](documentation.html) tool to generate HTML documentation
from these doc comments.

View File

@ -36,7 +36,7 @@ s.push_str(", world.");
println!("{}", s);
```
`String`s will coerece into `&str` with an `&`:
`String`s will coerce into `&str` with an `&`:
```
fn takes_slice(slice: &str) {

View File

@ -552,9 +552,7 @@ extern crate test;
# struct X;
# impl X { fn iter<T, F>(&self, _: F) where F: FnMut() -> T {} } let b = X;
b.iter(|| {
let mut n = 1000_u32;
test::black_box(&mut n); // pretend to modify `n`
let n = test::black_box(1000);
range(0, n).fold(0, |a, b| a ^ b)
})
@ -569,7 +567,7 @@ Performing either of the above changes gives the following benchmarking results
```text
running 1 test
test bench_xor_1000_ints ... bench: 1 ns/iter (+/- 0)
test bench_xor_1000_ints ... bench: 131 ns/iter (+/- 3)
test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured
```

View File

@ -1,5 +1,5 @@
#!/bin/sh
# Copyright 2014 The Rust Project Developers. See the COPYRIGHT
# Copyright 2014-2015 The Rust Project Developers. See the COPYRIGHT
# file at the top-level directory of this distribution and at
# http://rust-lang.org/COPYRIGHT.
#
@ -18,7 +18,7 @@ LIB_PREFIX=lib
OS=`uname -s`
case $OS in
("Linux"|"FreeBSD"|"DragonFly")
("Linux"|"FreeBSD"|"DragonFly"|"OpenBSD")
BIN_SUF=
LIB_SUF=.so
;;

View File

@ -87,6 +87,7 @@ def make_win_dist(rust_root, gcc_root, target_triple):
"libsetupapi.a",
"libshell32.a",
"libuser32.a",
"libuserenv.a",
"libuuid.a",
"libwinhttp.a",
"libwinmm.a",

View File

@ -1,4 +1,4 @@
# Copyright 2011-2014 The Rust Project Developers. See the COPYRIGHT
# Copyright 2011-2015 The Rust Project Developers. See the COPYRIGHT
# file at the top-level directory of this distribution and at
# http://rust-lang.org/COPYRIGHT.
#
@ -46,6 +46,7 @@ snapshot_files = {
"winnt": ["bin/rustc.exe"],
"freebsd": ["bin/rustc"],
"dragonfly": ["bin/rustc"],
"openbsd": ["bin/rustc"],
}
winnt_runtime_deps_32 = ["libgcc_s_dw2-1.dll", "libstdc++-6.dll"]
@ -100,6 +101,8 @@ def get_kernel(triple):
return "freebsd"
if os_name == "dragonfly":
return "dragonfly"
if os_name == "openbsd":
return "openbsd"
return "linux"

View File

@ -127,7 +127,7 @@ impl Drop for Arena {
fn drop(&mut self) {
unsafe {
destroy_chunk(&*self.head.borrow());
for chunk in self.chunks.borrow().iter() {
for chunk in &*self.chunks.borrow() {
if !chunk.is_copy.get() {
destroy_chunk(chunk);
}

View File

@ -9332,7 +9332,7 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
;;
# FreeBSD 3 and greater uses gcc -shared to do shared libraries.
freebsd* | dragonfly*)
freebsd* | dragonfly* | openbsd*)
archive_cmds='$CC -shared -o $lib $libobjs $deplibs $compiler_flags'
hardcode_libdir_flag_spec='-R$libdir'
hardcode_direct=yes

View File

@ -73,7 +73,7 @@ pub fn find_rand_n<M, T, I, F>(n: uint,
let mut keys = (0..n).map(|_| rng.gen::<uint>() % n)
.collect::<Vec<_>>();
for k in keys.iter() {
for k in &keys {
insert(map, *k);
}

View File

@ -673,7 +673,7 @@ impl<'a, T> IntoIterator for &'a BinaryHeap<T> where T: Ord {
#[stable(feature = "rust1", since = "1.0.0")]
impl<T: Ord> Extend<T> for BinaryHeap<T> {
fn extend<Iter: Iterator<Item=T>>(&mut self, mut iter: Iter) {
fn extend<Iter: Iterator<Item=T>>(&mut self, iter: Iter) {
let (lower, _) = iter.size_hint();
self.reserve(lower);
@ -696,7 +696,7 @@ mod tests {
let iterout = [9, 5, 3];
let heap = BinaryHeap::from_vec(data);
let mut i = 0;
for el in heap.iter() {
for el in &heap {
assert_eq!(*el, iterout[i]);
i += 1;
}
@ -884,7 +884,7 @@ mod tests {
let mut q: BinaryHeap<uint> = xs.iter().rev().map(|&x| x).collect();
for &x in xs.iter() {
for &x in &xs {
assert_eq!(q.pop().unwrap(), x);
}
}

View File

@ -431,7 +431,7 @@ impl Bitv {
/// ```
#[inline]
pub fn set_all(&mut self) {
for w in self.storage.iter_mut() { *w = !0u32; }
for w in &mut self.storage { *w = !0u32; }
self.fix_last_block();
}
@ -451,7 +451,7 @@ impl Bitv {
/// ```
#[inline]
pub fn negate(&mut self) {
for w in self.storage.iter_mut() { *w = !*w; }
for w in &mut self.storage { *w = !*w; }
self.fix_last_block();
}
@ -912,7 +912,7 @@ impl Bitv {
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
pub fn clear(&mut self) {
for w in self.storage.iter_mut() { *w = 0u32; }
for w in &mut self.storage { *w = 0u32; }
}
}
@ -934,7 +934,7 @@ impl FromIterator<bool> for Bitv {
#[stable(feature = "rust1", since = "1.0.0")]
impl Extend<bool> for Bitv {
#[inline]
fn extend<I: Iterator<Item=bool>>(&mut self, mut iterator: I) {
fn extend<I: Iterator<Item=bool>>(&mut self, iterator: I) {
let (min, _) = iterator.size_hint();
self.reserve(min);
for element in iterator {
@ -976,7 +976,7 @@ impl Ord for Bitv {
#[stable(feature = "rust1", since = "1.0.0")]
impl fmt::Debug for Bitv {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
for bit in self.iter() {
for bit in self {
try!(write!(fmt, "{}", if bit { 1u32 } else { 0u32 }));
}
Ok(())
@ -1141,7 +1141,7 @@ impl FromIterator<uint> for BitvSet {
#[stable(feature = "rust1", since = "1.0.0")]
impl Extend<uint> for BitvSet {
#[inline]
fn extend<I: Iterator<Item=uint>>(&mut self, mut iterator: I) {
fn extend<I: Iterator<Item=uint>>(&mut self, iterator: I) {
for i in iterator {
self.insert(i);
}
@ -1353,7 +1353,7 @@ impl BitvSet {
}
// virtually pad other with 0's for equal lengths
let mut other_words = {
let other_words = {
let (_, result) = match_words(self_bitv, other_bitv);
result
};
@ -1743,7 +1743,7 @@ impl fmt::Debug for BitvSet {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
try!(write!(fmt, "BitvSet {{"));
let mut first = true;
for n in self.iter() {
for n in self {
if !first {
try!(write!(fmt, ", "));
}
@ -1756,7 +1756,7 @@ impl fmt::Debug for BitvSet {
impl<S: hash::Writer + hash::Hasher> hash::Hash<S> for BitvSet {
fn hash(&self, state: &mut S) {
for pos in self.iter() {
for pos in self {
pos.hash(state);
}
}
@ -2600,7 +2600,7 @@ mod bitv_bench {
b.iter(|| {
let mut sum = 0u;
for _ in 0u..10 {
for pres in bitv.iter() {
for pres in &bitv {
sum += pres as uint;
}
}
@ -2613,7 +2613,7 @@ mod bitv_bench {
let bitv = Bitv::from_elem(BENCH_BITS, false);
b.iter(|| {
let mut sum = 0u;
for pres in bitv.iter() {
for pres in &bitv {
sum += pres as uint;
}
sum
@ -2674,8 +2674,8 @@ mod bitv_set_test {
fn test_bitv_set_frombitv_init() {
let bools = [true, false];
let lengths = [10, 64, 100];
for &b in bools.iter() {
for &l in lengths.iter() {
for &b in &bools {
for &l in &lengths {
let bitset = BitvSet::from_bitv(Bitv::from_elem(l, b));
assert_eq!(bitset.contains(&1u), b);
assert_eq!(bitset.contains(&(l-1u)), b);
@ -3062,7 +3062,7 @@ mod bitv_set_bench {
|idx| {idx % 3 == 0}));
b.iter(|| {
let mut sum = 0u;
for idx in bitv.iter() {
for idx in &bitv {
sum += idx as uint;
}
sum

View File

@ -116,13 +116,13 @@ pub struct IntoIter<K, V> {
/// An iterator over a BTreeMap's keys.
#[stable(feature = "rust1", since = "1.0.0")]
pub struct Keys<'a, K: 'a, V: 'a> {
inner: Map<(&'a K, &'a V), &'a K, Iter<'a, K, V>, fn((&'a K, &'a V)) -> &'a K>
inner: Map<Iter<'a, K, V>, fn((&'a K, &'a V)) -> &'a K>
}
/// An iterator over a BTreeMap's values.
#[stable(feature = "rust1", since = "1.0.0")]
pub struct Values<'a, K: 'a, V: 'a> {
inner: Map<(&'a K, &'a V), &'a V, Iter<'a, K, V>, fn((&'a K, &'a V)) -> &'a V>
inner: Map<Iter<'a, K, V>, fn((&'a K, &'a V)) -> &'a V>
}
/// An iterator over a sub-range of BTreeMap's entries.
@ -197,7 +197,7 @@ impl<K: Ord, V> BTreeMap<K, V> {
pub fn clear(&mut self) {
let b = self.b;
// avoid recursive destructors by manually traversing the tree
for _ in mem::replace(self, BTreeMap::with_b(b)).into_iter() {};
for _ in mem::replace(self, BTreeMap::with_b(b)) {};
}
// Searching in a B-Tree is pretty straightforward.
@ -846,7 +846,7 @@ impl<K: Ord, V> FromIterator<(K, V)> for BTreeMap<K, V> {
#[stable(feature = "rust1", since = "1.0.0")]
impl<K: Ord, V> Extend<(K, V)> for BTreeMap<K, V> {
#[inline]
fn extend<T: Iterator<Item=(K, V)>>(&mut self, mut iter: T) {
fn extend<T: Iterator<Item=(K, V)>>(&mut self, iter: T) {
for (k, v) in iter {
self.insert(k, v);
}
@ -856,7 +856,7 @@ impl<K: Ord, V> Extend<(K, V)> for BTreeMap<K, V> {
#[stable(feature = "rust1", since = "1.0.0")]
impl<S: Hasher, K: Hash<S>, V: Hash<S>> Hash<S> for BTreeMap<K, V> {
fn hash(&self, state: &mut S) {
for elt in self.iter() {
for elt in self {
elt.hash(state);
}
}
@ -1946,7 +1946,7 @@ mod bench {
}
b.iter(|| {
for entry in map.iter() {
for entry in &map {
black_box(entry);
}
});

View File

@ -435,13 +435,13 @@ impl<K: Clone, V: Clone> Clone for Node<K, V> {
let mut vals = RawItems::from_parts(ret.vals().as_ptr(), 0);
let mut edges = RawItems::from_parts(ret.edges().as_ptr(), 0);
for key in self.keys().iter() {
for key in self.keys() {
keys.push(key.clone())
}
for val in self.vals().iter() {
for val in self.vals() {
vals.push(val.clone())
}
for edge in self.edges().iter() {
for edge in self.edges() {
edges.push(edge.clone())
}

View File

@ -45,40 +45,40 @@ pub struct Iter<'a, T: 'a> {
/// An owning iterator over a BTreeSet's items.
#[stable(feature = "rust1", since = "1.0.0")]
pub struct IntoIter<T> {
iter: Map<(T, ()), T, ::btree_map::IntoIter<T, ()>, fn((T, ())) -> T>
iter: Map<::btree_map::IntoIter<T, ()>, fn((T, ())) -> T>
}
/// An iterator over a sub-range of BTreeSet's items.
pub struct Range<'a, T: 'a> {
iter: Map<(&'a T, &'a ()), &'a T, ::btree_map::Range<'a, T, ()>, fn((&'a T, &'a ())) -> &'a T>
iter: Map<::btree_map::Range<'a, T, ()>, fn((&'a T, &'a ())) -> &'a T>
}
/// A lazy iterator producing elements in the set difference (in-order).
#[stable(feature = "rust1", since = "1.0.0")]
pub struct Difference<'a, T:'a> {
a: Peekable<&'a T, Iter<'a, T>>,
b: Peekable<&'a T, Iter<'a, T>>,
a: Peekable<Iter<'a, T>>,
b: Peekable<Iter<'a, T>>,
}
/// A lazy iterator producing elements in the set symmetric difference (in-order).
#[stable(feature = "rust1", since = "1.0.0")]
pub struct SymmetricDifference<'a, T:'a> {
a: Peekable<&'a T, Iter<'a, T>>,
b: Peekable<&'a T, Iter<'a, T>>,
a: Peekable<Iter<'a, T>>,
b: Peekable<Iter<'a, T>>,
}
/// A lazy iterator producing elements in the set intersection (in-order).
#[stable(feature = "rust1", since = "1.0.0")]
pub struct Intersection<'a, T:'a> {
a: Peekable<&'a T, Iter<'a, T>>,
b: Peekable<&'a T, Iter<'a, T>>,
a: Peekable<Iter<'a, T>>,
b: Peekable<Iter<'a, T>>,
}
/// A lazy iterator producing elements in the set union (in-order).
#[stable(feature = "rust1", since = "1.0.0")]
pub struct Union<'a, T:'a> {
a: Peekable<&'a T, Iter<'a, T>>,
b: Peekable<&'a T, Iter<'a, T>>,
a: Peekable<Iter<'a, T>>,
b: Peekable<Iter<'a, T>>,
}
impl<T: Ord> BTreeSet<T> {
@ -499,7 +499,7 @@ impl<'a, T> IntoIterator for &'a BTreeSet<T> {
#[stable(feature = "rust1", since = "1.0.0")]
impl<T: Ord> Extend<T> for BTreeSet<T> {
#[inline]
fn extend<Iter: Iterator<Item=T>>(&mut self, mut iter: Iter) {
fn extend<Iter: Iterator<Item=T>>(&mut self, iter: Iter) {
for elem in iter {
self.insert(elem);
}
@ -791,8 +791,8 @@ mod test {
let mut set_a = BTreeSet::new();
let mut set_b = BTreeSet::new();
for x in a.iter() { assert!(set_a.insert(*x)) }
for y in b.iter() { assert!(set_b.insert(*y)) }
for x in a { assert!(set_a.insert(*x)) }
for y in b { assert!(set_b.insert(*y)) }
let mut i = 0;
f(&set_a, &set_b, Counter { i: &mut i, expected: expected });
@ -894,7 +894,7 @@ mod test {
let set: BTreeSet<int> = xs.iter().map(|&x| x).collect();
for x in xs.iter() {
for x in &xs {
assert!(set.contains(x));
}
}

View File

@ -856,7 +856,7 @@ impl<'a, T> IntoIterator for &'a mut DList<T> {
#[stable(feature = "rust1", since = "1.0.0")]
impl<A> Extend<A> for DList<A> {
fn extend<T: Iterator<Item=A>>(&mut self, mut iterator: T) {
fn extend<T: Iterator<Item=A>>(&mut self, iterator: T) {
for elt in iterator { self.push_back(elt); }
}
}
@ -917,7 +917,7 @@ impl<A: fmt::Debug> fmt::Debug for DList<A> {
impl<S: Writer + Hasher, A: Hash<S>> Hash<S> for DList<A> {
fn hash(&self, state: &mut S) {
self.len().hash(state);
for elt in self.iter() {
for elt in self {
elt.hash(state);
}
}
@ -1061,7 +1061,7 @@ mod tests {
let mut sum = v;
sum.push_all(u.as_slice());
assert_eq!(sum.len(), m.len());
for elt in sum.into_iter() {
for elt in sum {
assert_eq!(m.pop_front(), Some(elt))
}
assert_eq!(n.len(), 0);

View File

@ -36,7 +36,7 @@ impl<E:CLike + fmt::Debug> fmt::Debug for EnumSet<E> {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
try!(write!(fmt, "EnumSet {{"));
let mut first = true;
for e in self.iter() {
for e in self {
if !first {
try!(write!(fmt, ", "));
}
@ -266,7 +266,7 @@ impl<'a, E> IntoIterator for &'a EnumSet<E> where E: CLike {
}
impl<E:CLike> Extend<E> for EnumSet<E> {
fn extend<I: Iterator<Item=E>>(&mut self, mut iterator: I) {
fn extend<I: Iterator<Item=E>>(&mut self, iterator: I) {
for element in iterator {
self.insert(element);
}

View File

@ -22,8 +22,6 @@
html_root_url = "http://doc.rust-lang.org/nightly/",
html_playground_url = "http://play.rust-lang.org/")]
#![cfg_attr(not(stage0), allow(unused_mut))] // NOTE: remove after stage0 snap
#![feature(alloc)]
#![feature(box_syntax)]
#![feature(core)]

View File

@ -1573,7 +1573,7 @@ impl<A: Ord> Ord for RingBuf<A> {
impl<S: Writer + Hasher, A: Hash<S>> Hash<S> for RingBuf<A> {
fn hash(&self, state: &mut S) {
self.len().hash(state);
for elt in self.iter() {
for elt in self {
elt.hash(state);
}
}
@ -1635,7 +1635,7 @@ impl<'a, T> IntoIterator for &'a mut RingBuf<T> {
#[stable(feature = "rust1", since = "1.0.0")]
impl<A> Extend<A> for RingBuf<A> {
fn extend<T: Iterator<Item=A>>(&mut self, mut iterator: T) {
fn extend<T: Iterator<Item=A>>(&mut self, iterator: T) {
for elt in iterator {
self.push_back(elt);
}
@ -1856,7 +1856,7 @@ mod tests {
b.iter(|| {
let mut sum = 0;
for &i in ring.iter() {
for &i in &ring {
sum += i;
}
test::black_box(sum);
@ -1869,7 +1869,7 @@ mod tests {
b.iter(|| {
let mut sum = 0;
for i in ring.iter_mut() {
for i in &mut ring {
sum += *i;
}
test::black_box(sum);

View File

@ -98,9 +98,6 @@ use core::iter::{range_step, MultiplicativeIterator};
use core::marker::Sized;
use core::mem::size_of;
use core::mem;
#[cfg(stage0)]
use core::ops::{FnMut, FullRange};
#[cfg(not(stage0))]
use core::ops::FnMut;
use core::option::Option::{self, Some, None};
use core::ptr::PtrExt;
@ -1121,7 +1118,7 @@ impl<T: Clone, V: AsSlice<T>> SliceConcatExt<T, Vec<T>> for [V] {
fn concat(&self) -> Vec<T> {
let size = self.iter().fold(0u, |acc, v| acc + v.as_slice().len());
let mut result = Vec::with_capacity(size);
for v in self.iter() {
for v in self {
result.push_all(v.as_slice())
}
result
@ -1131,7 +1128,7 @@ impl<T: Clone, V: AsSlice<T>> SliceConcatExt<T, Vec<T>> for [V] {
let size = self.iter().fold(0u, |acc, v| acc + v.as_slice().len());
let mut result = Vec::with_capacity(size + self.len());
let mut first = true;
for v in self.iter() {
for v in self {
if first { first = false } else { result.push(sep.clone()) }
result.push_all(v.as_slice())
}
@ -1231,7 +1228,7 @@ impl Iterator for ElementSwaps {
self.sdir.swap(i, j);
// Swap the direction of each larger SizeDirection
for x in self.sdir.iter_mut() {
for x in &mut self.sdir {
if x.size > sd.size {
x.dir = match x.dir { Pos => Neg, Neg => Pos };
}
@ -1512,9 +1509,6 @@ mod tests {
use core::prelude::{Some, None, range, Clone};
use core::prelude::{Iterator, IteratorExt};
use core::prelude::{AsSlice};
#[cfg(stage0)]
use core::prelude::{Ord, FullRange};
#[cfg(not(stage0))]
use core::prelude::Ord;
use core::default::Default;
use core::mem;
@ -2362,7 +2356,7 @@ mod tests {
#[test]
fn test_mut_iterator() {
let mut xs = [1, 2, 3, 4, 5];
for x in xs.iter_mut() {
for x in &mut xs {
*x += 1;
}
assert!(xs == [2, 3, 4, 5, 6])
@ -2662,7 +2656,7 @@ mod tests {
let left: &[_] = left;
assert!(left[..left.len()] == [1, 2][]);
}
for p in left.iter_mut() {
for p in left {
*p += 1;
}
@ -2670,7 +2664,7 @@ mod tests {
let right: &[_] = right;
assert!(right[..right.len()] == [3, 4, 5][]);
}
for p in right.iter_mut() {
for p in right {
*p += 2;
}
}
@ -2687,25 +2681,25 @@ mod tests {
assert_eq!(v.len(), 3);
let mut cnt = 0u;
for f in v.iter() {
for f in &v {
assert!(*f == Foo);
cnt += 1;
}
assert_eq!(cnt, 3);
for f in v[1..3].iter() {
for f in &v[1..3] {
assert!(*f == Foo);
cnt += 1;
}
assert_eq!(cnt, 5);
for f in v.iter_mut() {
for f in &mut v {
assert!(*f == Foo);
cnt += 1;
}
assert_eq!(cnt, 8);
for f in v.into_iter() {
for f in v {
assert!(f == Foo);
cnt += 1;
}
@ -2713,7 +2707,7 @@ mod tests {
let xs: [Foo; 3] = [Foo, Foo, Foo];
cnt = 0;
for f in xs.iter() {
for f in &xs {
assert!(*f == Foo);
cnt += 1;
}
@ -2802,7 +2796,7 @@ mod tests {
let mut v = [0u8, 1, 2, 3, 4, 5, 6];
assert_eq!(v.chunks_mut(2).len(), 4);
for (i, chunk) in v.chunks_mut(3).enumerate() {
for x in chunk.iter_mut() {
for x in chunk {
*x = i as u8;
}
}
@ -2814,7 +2808,7 @@ mod tests {
fn test_mut_chunks_rev() {
let mut v = [0u8, 1, 2, 3, 4, 5, 6];
for (i, chunk) in v.chunks_mut(3).rev().enumerate() {
for x in chunk.iter_mut() {
for x in chunk {
*x = i as u8;
}
}
@ -2864,7 +2858,7 @@ mod bench {
b.iter(|| {
let mut sum = 0;
for x in v.iter() {
for x in &v {
sum += *x;
}
// sum == 11806, to stop dead code elimination.
@ -2878,7 +2872,7 @@ mod bench {
b.iter(|| {
let mut i = 0;
for x in v.iter_mut() {
for x in &mut v {
*x = i;
i += 1;
}
@ -3012,7 +3006,7 @@ mod bench {
unsafe {
v.set_len(1024);
}
for x in v.iter_mut() {
for x in &mut v {
*x = 0;
}
v

View File

@ -61,11 +61,6 @@ use core::clone::Clone;
use core::iter::AdditiveIterator;
use core::iter::{Iterator, IteratorExt};
use core::ops::Index;
#[cfg(stage0)]
use core::ops::FullRange as RangeFull;
#[cfg(stage0)]
use core::ops::FullRange;
#[cfg(not(stage0))]
use core::ops::RangeFull;
use core::option::Option::{self, Some, None};
use core::result::Result;
@ -104,7 +99,7 @@ impl<S: Str> SliceConcatExt<str, String> for [S] {
let len = s.iter().map(|s| s.as_slice().len()).sum();
let mut result = String::with_capacity(len);
for s in s.iter() {
for s in s {
result.push_str(s.as_slice())
}
@ -130,7 +125,7 @@ impl<S: Str> SliceConcatExt<str, String> for [S] {
let mut result = String::with_capacity(len);
let mut first = true;
for s in s.iter() {
for s in s {
if first {
first = false;
} else {
@ -2010,7 +2005,7 @@ mod tests {
let s = "ศไทย中华Việt Nam";
let v = vec!['ศ','ไ','ท','ย','中','华','V','i','ệ','t',' ','N','a','m'];
let mut pos = 0;
for ch in v.iter() {
for ch in &v {
assert!(s.char_at(pos) == *ch);
pos += ch.to_string().len();
}
@ -2708,7 +2703,7 @@ mod tests {
&["\u{378}\u{308}\u{903}"], &["\u{378}\u{308}", "\u{903}"]),
];
for &(s, g) in test_same.iter() {
for &(s, g) in &test_same[] {
// test forward iterator
assert!(order::equals(s.graphemes(true), g.iter().map(|&x| x)));
assert!(order::equals(s.graphemes(false), g.iter().map(|&x| x)));
@ -2718,7 +2713,7 @@ mod tests {
assert!(order::equals(s.graphemes(false).rev(), g.iter().rev().map(|&x| x)));
}
for &(s, gt, gf) in test_diff.iter() {
for &(s, gt, gf) in &test_diff {
// test forward iterator
assert!(order::equals(s.graphemes(true), gt.iter().map(|&x| x)));
assert!(order::equals(s.graphemes(false), gf.iter().map(|&x| x)));

View File

@ -729,7 +729,7 @@ impl<'a> FromIterator<&'a str> for String {
#[unstable(feature = "collections",
reason = "waiting on Extend stabilization")]
impl Extend<char> for String {
fn extend<I:Iterator<Item=char>>(&mut self, mut iterator: I) {
fn extend<I:Iterator<Item=char>>(&mut self, iterator: I) {
let (lower_bound, _) = iterator.size_hint();
self.reserve(lower_bound);
for ch in iterator {
@ -741,7 +741,7 @@ impl Extend<char> for String {
#[unstable(feature = "collections",
reason = "waiting on Extend stabilization")]
impl<'a> Extend<&'a str> for String {
fn extend<I: Iterator<Item=&'a str>>(&mut self, mut iterator: I) {
fn extend<I: Iterator<Item=&'a str>>(&mut self, iterator: I) {
// A guess that at least one byte per iterator element will be needed.
let (lower_bound, _) = iterator.size_hint();
self.reserve(lower_bound);
@ -877,16 +877,6 @@ impl ops::Index<ops::RangeFrom<uint>> for String {
&self[][*index]
}
}
#[cfg(stage0)]
#[stable(feature = "rust1", since = "1.0.0")]
impl ops::Index<ops::FullRange> for String {
type Output = str;
#[inline]
fn index(&self, _index: &ops::FullRange) -> &str {
unsafe { mem::transmute(self.vec.as_slice()) }
}
}
#[cfg(not(stage0))]
#[stable(feature = "rust1", since = "1.0.0")]
impl ops::Index<ops::RangeFull> for String {
type Output = str;
@ -1011,8 +1001,6 @@ mod tests {
use str::Utf8Error;
use core::iter::repeat;
use super::{as_string, CowString};
#[cfg(stage0)]
use core::ops::FullRange;
#[test]
fn test_as_string() {
@ -1130,7 +1118,7 @@ mod tests {
(String::from_str("\u{20000}"),
vec![0xD840, 0xDC00])];
for p in pairs.iter() {
for p in &pairs {
let (s, u) = (*p).clone();
let s_as_utf16 = s.utf16_units().collect::<Vec<u16>>();
let u_as_string = String::from_utf16(u.as_slice()).unwrap();

View File

@ -1318,16 +1318,6 @@ impl<T> ops::Index<ops::RangeFrom<uint>> for Vec<T> {
self.as_slice().index(index)
}
}
#[cfg(stage0)]
#[stable(feature = "rust1", since = "1.0.0")]
impl<T> ops::Index<ops::FullRange> for Vec<T> {
type Output = [T];
#[inline]
fn index(&self, _index: &ops::FullRange) -> &[T] {
self.as_slice()
}
}
#[cfg(not(stage0))]
#[stable(feature = "rust1", since = "1.0.0")]
impl<T> ops::Index<ops::RangeFull> for Vec<T> {
type Output = [T];
@ -1361,16 +1351,6 @@ impl<T> ops::IndexMut<ops::RangeFrom<uint>> for Vec<T> {
self.as_mut_slice().index_mut(index)
}
}
#[cfg(stage0)]
#[stable(feature = "rust1", since = "1.0.0")]
impl<T> ops::IndexMut<ops::FullRange> for Vec<T> {
type Output = [T];
#[inline]
fn index_mut(&mut self, _index: &ops::FullRange) -> &mut [T] {
self.as_mut_slice()
}
}
#[cfg(not(stage0))]
#[stable(feature = "rust1", since = "1.0.0")]
impl<T> ops::IndexMut<ops::RangeFull> for Vec<T> {
type Output = [T];
@ -1395,7 +1375,7 @@ impl<T> ops::DerefMut for Vec<T> {
#[stable(feature = "rust1", since = "1.0.0")]
impl<T> FromIterator<T> for Vec<T> {
#[inline]
fn from_iter<I:Iterator<Item=T>>(mut iterator: I) -> Vec<T> {
fn from_iter<I:Iterator<Item=T>>(iterator: I) -> Vec<T> {
let (lower, _) = iterator.size_hint();
let mut vector = Vec::with_capacity(lower);
for element in iterator {
@ -1432,7 +1412,7 @@ impl<'a, T> IntoIterator for &'a mut Vec<T> {
#[unstable(feature = "collections", reason = "waiting on Extend stability")]
impl<T> Extend<T> for Vec<T> {
#[inline]
fn extend<I: Iterator<Item=T>>(&mut self, mut iterator: I) {
fn extend<I: Iterator<Item=T>>(&mut self, iterator: I) {
let (lower, _) = iterator.size_hint();
self.reserve(lower);
for element in iterator {
@ -1567,7 +1547,7 @@ impl<T> Drop for Vec<T> {
// zeroed (when moving out, because of #[unsafe_no_drop_flag]).
if self.cap != 0 {
unsafe {
for x in self.iter() {
for x in &*self {
ptr::read(x);
}
dealloc(*self.ptr, self.cap)
@ -1934,8 +1914,6 @@ mod tests {
use prelude::*;
use core::mem::size_of;
use core::iter::repeat;
#[cfg(stage0)]
use core::ops::FullRange;
use test::Bencher;
use super::as_vec;
@ -2044,7 +2022,7 @@ mod tests {
{
let slice = &mut values[2 ..];
assert!(slice == [3, 4, 5]);
for p in slice.iter_mut() {
for p in slice {
*p += 2;
}
}
@ -2058,7 +2036,7 @@ mod tests {
{
let slice = &mut values[.. 2];
assert!(slice == [1, 2]);
for p in slice.iter_mut() {
for p in slice {
*p += 1;
}
}
@ -2075,7 +2053,7 @@ mod tests {
let left: &[_] = left;
assert!(&left[..left.len()] == &[1, 2][]);
}
for p in left.iter_mut() {
for p in left {
*p += 1;
}
@ -2083,7 +2061,7 @@ mod tests {
let right: &[_] = right;
assert!(&right[..right.len()] == &[3, 4, 5][]);
}
for p in right.iter_mut() {
for p in right {
*p += 2;
}
}
@ -2151,7 +2129,7 @@ mod tests {
v.push(());
assert_eq!(v.iter().count(), 2);
for &() in v.iter() {}
for &() in &v {}
assert_eq!(v.iter_mut().count(), 2);
v.push(());
@ -2159,7 +2137,7 @@ mod tests {
v.push(());
assert_eq!(v.iter_mut().count(), 4);
for &mut () in v.iter_mut() {}
for &mut () in &mut v {}
unsafe { v.set_len(0); }
assert_eq!(v.iter_mut().count(), 0);
}
@ -2355,7 +2333,7 @@ mod tests {
fn test_move_items() {
let vec = vec![1, 2, 3];
let mut vec2 : Vec<i32> = vec![];
for i in vec.into_iter() {
for i in vec {
vec2.push(i);
}
assert!(vec2 == vec![1, 2, 3]);
@ -2375,7 +2353,7 @@ mod tests {
fn test_move_items_zero_sized() {
let vec = vec![(), (), ()];
let mut vec2 : Vec<()> = vec![];
for i in vec.into_iter() {
for i in vec {
vec2.push(i);
}
assert!(vec2 == vec![(), (), ()]);

View File

@ -90,7 +90,7 @@ impl<S: Writer + Hasher, V: Hash<S>> Hash<S> for VecMap<V> {
// In order to not traverse the `VecMap` twice, count the elements
// during iteration.
let mut count: uint = 0;
for elt in self.iter() {
for elt in self {
elt.hash(state);
count += 1;
}
@ -562,7 +562,7 @@ impl<'a, T> IntoIterator for &'a mut VecMap<T> {
#[stable(feature = "rust1", since = "1.0.0")]
impl<V> Extend<(uint, V)> for VecMap<V> {
fn extend<Iter: Iterator<Item=(uint, V)>>(&mut self, mut iter: Iter) {
fn extend<Iter: Iterator<Item=(uint, V)>>(&mut self, iter: Iter) {
for (k, v) in iter {
self.insert(k, v);
}
@ -687,7 +687,7 @@ double_ended_iterator! { impl IterMut -> (uint, &'a mut V), as_mut }
/// An iterator over the keys of a map.
#[stable(feature = "rust1", since = "1.0.0")]
pub struct Keys<'a, V: 'a> {
iter: Map<(uint, &'a V), uint, Iter<'a, V>, fn((uint, &'a V)) -> uint>
iter: Map<Iter<'a, V>, fn((uint, &'a V)) -> uint>
}
// FIXME(#19839) Remove in favor of `#[derive(Clone)]`
@ -702,7 +702,7 @@ impl<'a, V> Clone for Keys<'a, V> {
/// An iterator over the values of a map.
#[stable(feature = "rust1", since = "1.0.0")]
pub struct Values<'a, V: 'a> {
iter: Map<(uint, &'a V), &'a V, Iter<'a, V>, fn((uint, &'a V)) -> &'a V>
iter: Map<Iter<'a, V>, fn((uint, &'a V)) -> &'a V>
}
// FIXME(#19839) Remove in favor of `#[derive(Clone)]`
@ -718,8 +718,6 @@ impl<'a, V> Clone for Values<'a, V> {
#[stable(feature = "rust1", since = "1.0.0")]
pub struct IntoIter<V> {
iter: FilterMap<
(uint, Option<V>),
(uint, V),
Enumerate<vec::IntoIter<Option<V>>>,
fn((uint, Option<V>)) -> Option<(uint, V)>>
}
@ -727,8 +725,6 @@ pub struct IntoIter<V> {
#[unstable(feature = "collections")]
pub struct Drain<'a, V> {
iter: FilterMap<
(uint, Option<V>),
(uint, V),
Enumerate<vec::Drain<'a, Option<V>>>,
fn((uint, Option<V>)) -> Option<(uint, V)>>
}
@ -924,7 +920,7 @@ mod test_map {
assert!(m.insert(6, 10).is_none());
assert!(m.insert(10, 11).is_none());
for (k, v) in m.iter_mut() {
for (k, v) in &mut m {
*v += k as int;
}
@ -984,7 +980,7 @@ mod test_map {
let mut m = VecMap::new();
m.insert(1, box 2);
let mut called = false;
for (k, v) in m.into_iter() {
for (k, v) in m {
assert!(!called);
called = true;
assert_eq!(k, 1);
@ -1112,7 +1108,7 @@ mod test_map {
let map: VecMap<char> = xs.iter().map(|&x| x).collect();
for &(k, v) in xs.iter() {
for &(k, v) in &xs {
assert_eq!(map.get(&k), Some(&v));
}
}

View File

@ -20,9 +20,6 @@ use fmt;
use hash::{Hash, Hasher, self};
use iter::IntoIterator;
use marker::Copy;
#[cfg(stage0)]
use ops::{Deref, FullRange};
#[cfg(not(stage0))]
use ops::Deref;
use option::Option;
use slice::{Iter, IterMut, SliceExt};

View File

@ -415,6 +415,7 @@ impl AtomicIsize {
/// let atomic_forty_two = AtomicIsize::new(42);
/// ```
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
pub fn new(v: isize) -> AtomicIsize {
AtomicIsize {v: UnsafeCell::new(v)}
}
@ -437,6 +438,7 @@ impl AtomicIsize {
/// let value = some_isize.load(Ordering::Relaxed);
/// ```
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
pub fn load(&self, order: Ordering) -> isize {
unsafe { atomic_load(self.v.get(), order) }
}
@ -459,6 +461,7 @@ impl AtomicIsize {
///
/// Panics if `order` is `Acquire` or `AcqRel`.
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
pub fn store(&self, val: isize, order: Ordering) {
unsafe { atomic_store(self.v.get(), val, order); }
}
@ -477,6 +480,7 @@ impl AtomicIsize {
/// let value = some_isize.swap(10, Ordering::Relaxed);
/// ```
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
pub fn swap(&self, val: isize, order: Ordering) -> isize {
unsafe { atomic_swap(self.v.get(), val, order) }
}
@ -498,6 +502,7 @@ impl AtomicIsize {
/// let value = some_isize.compare_and_swap(5, 10, Ordering::Relaxed);
/// ```
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
pub fn compare_and_swap(&self, old: isize, new: isize, order: Ordering) -> isize {
unsafe { atomic_compare_and_swap(self.v.get(), old, new, order) }
}
@ -514,6 +519,7 @@ impl AtomicIsize {
/// assert_eq!(10, foo.load(Ordering::SeqCst));
/// ```
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
pub fn fetch_add(&self, val: isize, order: Ordering) -> isize {
unsafe { atomic_add(self.v.get(), val, order) }
}
@ -530,6 +536,7 @@ impl AtomicIsize {
/// assert_eq!(-10, foo.load(Ordering::SeqCst));
/// ```
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
pub fn fetch_sub(&self, val: isize, order: Ordering) -> isize {
unsafe { atomic_sub(self.v.get(), val, order) }
}
@ -545,6 +552,7 @@ impl AtomicIsize {
/// assert_eq!(0b101101, foo.fetch_and(0b110011, Ordering::SeqCst));
/// assert_eq!(0b100001, foo.load(Ordering::SeqCst));
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
pub fn fetch_and(&self, val: isize, order: Ordering) -> isize {
unsafe { atomic_and(self.v.get(), val, order) }
}
@ -560,6 +568,7 @@ impl AtomicIsize {
/// assert_eq!(0b101101, foo.fetch_or(0b110011, Ordering::SeqCst));
/// assert_eq!(0b111111, foo.load(Ordering::SeqCst));
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
pub fn fetch_or(&self, val: isize, order: Ordering) -> isize {
unsafe { atomic_or(self.v.get(), val, order) }
}
@ -575,6 +584,7 @@ impl AtomicIsize {
/// assert_eq!(0b101101, foo.fetch_xor(0b110011, Ordering::SeqCst));
/// assert_eq!(0b011110, foo.load(Ordering::SeqCst));
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
pub fn fetch_xor(&self, val: isize, order: Ordering) -> isize {
unsafe { atomic_xor(self.v.get(), val, order) }
}
@ -592,6 +602,7 @@ impl AtomicUsize {
/// let atomic_forty_two = AtomicUsize::new(42);
/// ```
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
pub fn new(v: usize) -> AtomicUsize {
AtomicUsize { v: UnsafeCell::new(v) }
}
@ -614,6 +625,7 @@ impl AtomicUsize {
/// let value = some_usize.load(Ordering::Relaxed);
/// ```
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
pub fn load(&self, order: Ordering) -> usize {
unsafe { atomic_load(self.v.get(), order) }
}
@ -636,6 +648,7 @@ impl AtomicUsize {
///
/// Panics if `order` is `Acquire` or `AcqRel`.
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
pub fn store(&self, val: usize, order: Ordering) {
unsafe { atomic_store(self.v.get(), val, order); }
}
@ -654,6 +667,7 @@ impl AtomicUsize {
/// let value = some_usize.swap(10, Ordering::Relaxed);
/// ```
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
pub fn swap(&self, val: usize, order: Ordering) -> usize {
unsafe { atomic_swap(self.v.get(), val, order) }
}
@ -675,6 +689,7 @@ impl AtomicUsize {
/// let value = some_usize.compare_and_swap(5, 10, Ordering::Relaxed);
/// ```
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
pub fn compare_and_swap(&self, old: usize, new: usize, order: Ordering) -> usize {
unsafe { atomic_compare_and_swap(self.v.get(), old, new, order) }
}
@ -691,6 +706,7 @@ impl AtomicUsize {
/// assert_eq!(10, foo.load(Ordering::SeqCst));
/// ```
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
pub fn fetch_add(&self, val: usize, order: Ordering) -> usize {
unsafe { atomic_add(self.v.get(), val, order) }
}
@ -707,6 +723,7 @@ impl AtomicUsize {
/// assert_eq!(0, foo.load(Ordering::SeqCst));
/// ```
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
pub fn fetch_sub(&self, val: usize, order: Ordering) -> usize {
unsafe { atomic_sub(self.v.get(), val, order) }
}
@ -722,6 +739,7 @@ impl AtomicUsize {
/// assert_eq!(0b101101, foo.fetch_and(0b110011, Ordering::SeqCst));
/// assert_eq!(0b100001, foo.load(Ordering::SeqCst));
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
pub fn fetch_and(&self, val: usize, order: Ordering) -> usize {
unsafe { atomic_and(self.v.get(), val, order) }
}
@ -737,6 +755,7 @@ impl AtomicUsize {
/// assert_eq!(0b101101, foo.fetch_or(0b110011, Ordering::SeqCst));
/// assert_eq!(0b111111, foo.load(Ordering::SeqCst));
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
pub fn fetch_or(&self, val: usize, order: Ordering) -> usize {
unsafe { atomic_or(self.v.get(), val, order) }
}
@ -752,6 +771,7 @@ impl AtomicUsize {
/// assert_eq!(0b101101, foo.fetch_xor(0b110011, Ordering::SeqCst));
/// assert_eq!(0b011110, foo.load(Ordering::SeqCst));
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
pub fn fetch_xor(&self, val: usize, order: Ordering) -> usize {
unsafe { atomic_xor(self.v.get(), val, order) }
}

View File

@ -266,6 +266,18 @@ pub struct RefCell<T> {
borrow: Cell<BorrowFlag>,
}
/// An enumeration of values returned from the `state` method on a `RefCell<T>`.
#[derive(Copy, Clone, PartialEq, Debug)]
#[unstable(feature = "std_misc")]
pub enum BorrowState {
/// The cell is currently being read, there is at least one active `borrow`.
Reading,
/// The cell is currently being written to, there is an active `borrow_mut`.
Writing,
/// There are no outstanding borrows on this cell.
Unused,
}
// Values [1, MAX-1] represent the number of `Ref` active
// (will not outgrow its range since `uint` is the size of the address space)
type BorrowFlag = uint;
@ -310,6 +322,19 @@ impl<T> RefCell<T> {
unsafe { self.value.into_inner() }
}
/// Query the current state of this `RefCell`
///
/// The returned value can be dispatched on to determine if a call to
/// `borrow` or `borrow_mut` would succeed.
#[unstable(feature = "std_misc")]
pub fn borrow_state(&self) -> BorrowState {
match self.borrow.get() {
WRITING => BorrowState::Writing,
UNUSED => BorrowState::Unused,
_ => BorrowState::Reading,
}
}
/// Attempts to immutably borrow the wrapped value.
///
/// The borrow lasts until the returned `Ref` exits scope. Multiple
@ -317,6 +342,8 @@ impl<T> RefCell<T> {
///
/// Returns `None` if the value is currently mutably borrowed.
#[unstable(feature = "core", reason = "may be renamed or removed")]
#[deprecated(since = "1.0.0",
reason = "dispatch on `cell.borrow_state()` instead")]
pub fn try_borrow<'a>(&'a self) -> Option<Ref<'a, T>> {
match BorrowRef::new(&self.borrow) {
Some(b) => Some(Ref { _value: unsafe { &*self.value.get() }, _borrow: b }),
@ -326,8 +353,8 @@ impl<T> RefCell<T> {
/// Immutably borrows the wrapped value.
///
/// The borrow lasts until the returned `Ref` exits scope. Multiple immutable borrows can be
/// taken out at the same time.
/// The borrow lasts until the returned `Ref` exits scope. Multiple
/// immutable borrows can be taken out at the same time.
///
/// # Panics
///
@ -361,9 +388,12 @@ impl<T> RefCell<T> {
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
pub fn borrow<'a>(&'a self) -> Ref<'a, T> {
match self.try_borrow() {
Some(ptr) => ptr,
None => panic!("RefCell<T> already mutably borrowed")
match BorrowRef::new(&self.borrow) {
Some(b) => Ref {
_value: unsafe { &*self.value.get() },
_borrow: b,
},
None => panic!("RefCell<T> already mutably borrowed"),
}
}
@ -374,6 +404,8 @@ impl<T> RefCell<T> {
///
/// Returns `None` if the value is currently borrowed.
#[unstable(feature = "core", reason = "may be renamed or removed")]
#[deprecated(since = "1.0.0",
reason = "dispatch on `cell.borrow_state()` instead")]
pub fn try_borrow_mut<'a>(&'a self) -> Option<RefMut<'a, T>> {
match BorrowRefMut::new(&self.borrow) {
Some(b) => Some(RefMut { _value: unsafe { &mut *self.value.get() }, _borrow: b }),
@ -383,8 +415,8 @@ impl<T> RefCell<T> {
/// Mutably borrows the wrapped value.
///
/// The borrow lasts until the returned `RefMut` exits scope. The value cannot be borrowed
/// while this borrow is active.
/// The borrow lasts until the returned `RefMut` exits scope. The value
/// cannot be borrowed while this borrow is active.
///
/// # Panics
///
@ -417,9 +449,12 @@ impl<T> RefCell<T> {
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
pub fn borrow_mut<'a>(&'a self) -> RefMut<'a, T> {
match self.try_borrow_mut() {
Some(ptr) => ptr,
None => panic!("RefCell<T> already borrowed")
match BorrowRefMut::new(&self.borrow) {
Some(b) => RefMut {
_value: unsafe { &mut *self.value.get() },
_borrow: b,
},
None => panic!("RefCell<T> already borrowed"),
}
}

View File

@ -67,7 +67,25 @@ static MAX_THREE_B: u32 = 0x10000u32;
#[stable(feature = "rust1", since = "1.0.0")]
pub const MAX: char = '\u{10ffff}';
/// Converts from `u32` to a `char`
/// Converts a `u32` to an `Option<char>`.
///
/// # Examples
///
/// ```
/// use std::char;
///
/// let c = char::from_u32(10084); // produces `Some(❤)`
/// assert_eq!(c, Some('❤'));
/// ```
///
/// An invalid character:
///
/// ```
/// use std::char;
///
/// let none = char::from_u32(1114112);
/// assert_eq!(none, None);
/// ```
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
pub fn from_u32(i: u32) -> Option<char> {
@ -79,8 +97,7 @@ pub fn from_u32(i: u32) -> Option<char> {
}
}
///
/// Converts a number to the character representing it
/// Converts a number to the character representing it.
///
/// # Return value
///
@ -91,6 +108,15 @@ pub fn from_u32(i: u32) -> Option<char> {
///
/// Panics if given an `radix` > 36.
///
/// # Examples
///
/// ```
/// use std::char;
///
/// let c = char::from_digit(4, 10);
///
/// assert_eq!(c, Some('4'));
/// ```
#[inline]
#[unstable(feature = "core", reason = "pending integer conventions")]
pub fn from_digit(num: uint, radix: uint) -> Option<char> {
@ -126,6 +152,16 @@ pub trait CharExt {
/// # Panics
///
/// Panics if given a radix > 36.
///
/// # Examples
///
/// ```
/// let c = '1';
///
/// assert!(c.is_digit(10));
///
/// assert!('f'.is_digit(16));
/// ```
#[unstable(feature = "core",
reason = "pending integer conventions")]
fn is_digit(self, radix: uint) -> bool;
@ -141,16 +177,53 @@ pub trait CharExt {
/// # Panics
///
/// Panics if given a radix outside the range [0..36].
///
/// # Examples
///
/// ```
/// let c = '1';
///
/// assert_eq!(c.to_digit(10), Some(1));
///
/// assert_eq!('f'.to_digit(16), Some(15));
/// ```
#[unstable(feature = "core",
reason = "pending integer conventions")]
fn to_digit(self, radix: uint) -> Option<uint>;
/// Returns an iterator that yields the hexadecimal Unicode escape
/// of a character, as `char`s.
/// Returns an iterator that yields the hexadecimal Unicode escape of a character, as `char`s.
///
/// All characters are escaped with Rust syntax of the form `\\u{NNNN}`
/// where `NNNN` is the shortest hexadecimal representation of the code
/// point.
/// All characters are escaped with Rust syntax of the form `\\u{NNNN}` where `NNNN` is the
/// shortest hexadecimal representation of the code point.
///
/// # Examples
///
/// ```
/// for i in '❤'.escape_unicode() {
/// println!("{}", i);
/// }
/// ```
///
/// This prints:
///
/// ```text
/// \
/// u
/// {
/// 2
/// 7
/// 6
/// 4
/// }
/// ```
///
/// Collecting into a `String`:
///
/// ```
/// let heart: String = '❤'.escape_unicode().collect();
///
/// assert_eq!(heart, r"\u{2764}");
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
fn escape_unicode(self) -> EscapeUnicode;
@ -166,32 +239,113 @@ pub trait CharExt {
/// escaped.
/// * Any other chars in the range [0x20,0x7e] are not escaped.
/// * Any other chars are given hex Unicode escapes; see `escape_unicode`.
///
/// # Examples
///
/// ```
/// for i in '"'.escape_default() {
/// println!("{}", i);
/// }
/// ```
///
/// This prints:
///
/// ```text
/// \
/// "
/// ```
///
/// Collecting into a `String`:
///
/// ```
/// let quote: String = '"'.escape_default().collect();
///
/// assert_eq!(quote, "\\\"");
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
fn escape_default(self) -> EscapeDefault;
/// Returns the amount of bytes this character would need if encoded in
/// UTF-8.
/// Returns the number of bytes this character would need if encoded in UTF-8.
///
/// # Examples
///
/// ```
/// let n = 'ß'.len_utf8();
///
/// assert_eq!(n, 2);
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
fn len_utf8(self) -> uint;
/// Returns the amount of bytes this character would need if encoded in
/// UTF-16.
/// Returns the number of bytes this character would need if encoded in UTF-16.
///
/// # Examples
///
/// ```
/// let n = 'ß'.len_utf16();
///
/// assert_eq!(n, 1);
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
fn len_utf16(self) -> uint;
/// Encodes this character as UTF-8 into the provided byte buffer,
/// and then returns the number of bytes written.
/// Encodes this character as UTF-8 into the provided byte buffer, and then returns the number
/// of bytes written.
///
/// If the buffer is not large enough, nothing will be written into it
/// and a `None` will be returned.
/// If the buffer is not large enough, nothing will be written into it and a `None` will be
/// returned.
///
/// # Examples
///
/// In both of these examples, 'ß' takes two bytes to encode.
///
/// ```
/// let mut b = [0; 2];
///
/// let result = 'ß'.encode_utf8(&mut b);
///
/// assert_eq!(result, Some(2));
/// ```
///
/// A buffer that's too small:
///
/// ```
/// let mut b = [0; 1];
///
/// let result = 'ß'.encode_utf8(&mut b);
///
/// assert_eq!(result, None);
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
fn encode_utf8(self, dst: &mut [u8]) -> Option<uint>;
/// Encodes this character as UTF-16 into the provided `u16` buffer,
/// and then returns the number of `u16`s written.
/// Encodes this character as UTF-16 into the provided `u16` buffer, and then returns the
/// number of `u16`s written.
///
/// If the buffer is not large enough, nothing will be written into it
/// and a `None` will be returned.
/// If the buffer is not large enough, nothing will be written into it and a `None` will be
/// returned.
///
/// # Examples
///
/// In both of these examples, 'ß' takes one byte to encode.
///
/// ```
/// let mut b = [0; 1];
///
/// let result = 'ß'.encode_utf16(&mut b);
///
/// assert_eq!(result, Some(1));
/// ```
///
/// A buffer that's too small:
///
/// ```
/// let mut b = [0; 0];
///
/// let result = 'ß'.encode_utf8(&mut b);
///
/// assert_eq!(result, None);
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
fn encode_utf16(self, dst: &mut [u16]) -> Option<uint>;
}

View File

@ -13,7 +13,7 @@
#![stable(feature = "rust1", since = "1.0.0")]
use any;
use cell::{Cell, RefCell, Ref, RefMut};
use cell::{Cell, RefCell, Ref, RefMut, BorrowState};
use char::CharExt;
use iter::{Iterator, IteratorExt};
use marker::{Copy, Sized};
@ -38,7 +38,6 @@ mod float;
#[stable(feature = "rust1", since = "1.0.0")]
#[doc(hidden)]
pub mod rt {
#[cfg(stage0)] pub use self::v1::*;
pub mod v1;
}
@ -191,20 +190,6 @@ impl<'a> Arguments<'a> {
}
}
/// When using the format_args!() macro, this function is used to generate the
/// Arguments structure.
#[doc(hidden)] #[inline]
#[cfg(stage0)]
#[stable(feature = "rust1", since = "1.0.0")]
pub fn new(pieces: &'a [&'a str],
args: &'a [ArgumentV1<'a>]) -> Arguments<'a> {
Arguments {
pieces: pieces,
fmt: None,
args: args
}
}
/// This function is used to specify nonstandard formatting parameters.
/// The `pieces` array must be at least as long as `fmt` to construct
/// a valid Arguments structure. Also, any `Count` within `fmt` that is
@ -212,25 +197,6 @@ impl<'a> Arguments<'a> {
/// created with `argumentuint`. However, failing to do so doesn't cause
/// unsafety, but will ignore invalid .
#[doc(hidden)] #[inline]
#[cfg(stage0)]
#[stable(feature = "rust1", since = "1.0.0")]
pub fn with_placeholders(pieces: &'a [&'a str],
fmt: &'a [rt::v1::Argument],
args: &'a [ArgumentV1<'a>]) -> Arguments<'a> {
Arguments {
pieces: pieces,
fmt: Some(fmt),
args: args
}
}
/// This function is used to specify nonstandard formatting parameters.
/// The `pieces` array must be at least as long as `fmt` to construct
/// a valid Arguments structure. Also, any `Count` within `fmt` that is
/// `CountIsParam` or `CountIsNextParam` has to point to an argument
/// created with `argumentuint`. However, failing to do so doesn't cause
/// unsafety, but will ignore invalid .
#[doc(hidden)] #[inline]
#[cfg(not(stage0))]
pub fn new_v1_formatted(pieces: &'a [&'a str],
args: &'a [ArgumentV1<'a>],
fmt: &'a [rt::v1::Argument]) -> Arguments<'a> {
@ -516,7 +482,7 @@ impl<'a> Formatter<'a> {
// Writes the sign if it exists, and then the prefix if it was requested
let write_prefix = |&: f: &mut Formatter| {
for c in sign.into_iter() {
if let Some(c) = sign {
let mut b = [0; 4];
let n = c.encode_utf8(&mut b).unwrap_or(0);
let b = unsafe { str::from_utf8_unchecked(&b[..n]) };
@ -684,25 +650,6 @@ impl Display for Error {
}
}
/// This is a function which calls are emitted to by the compiler itself to
/// create the Argument structures that are passed into the `format` function.
#[doc(hidden)] #[inline]
#[cfg(stage0)]
#[stable(feature = "rust1", since = "1.0.0")]
pub fn argument<'a, T>(f: fn(&T, &mut Formatter) -> Result,
t: &'a T) -> ArgumentV1<'a> {
ArgumentV1::new(t, f)
}
/// When the compiler determines that the type of an argument *must* be a uint
/// (such as for width and precision), then it invokes this method.
#[doc(hidden)] #[inline]
#[cfg(stage0)]
#[stable(feature = "rust1", since = "1.0.0")]
pub fn argumentuint<'a>(s: &'a uint) -> ArgumentV1<'a> {
ArgumentV1::from_uint(s)
}
// Implementations of the core formatting traits
macro_rules! fmt_refs {
@ -941,7 +888,7 @@ impl<T: Debug> Debug for [T] {
try!(write!(f, "["));
}
let mut is_first = true;
for x in self.iter() {
for x in self {
if is_first {
is_first = false;
} else {
@ -973,9 +920,11 @@ impl<T: Copy + Debug> Debug for Cell<T> {
#[stable(feature = "rust1", since = "1.0.0")]
impl<T: Debug> Debug for RefCell<T> {
fn fmt(&self, f: &mut Formatter) -> Result {
match self.try_borrow() {
Some(val) => write!(f, "RefCell {{ value: {:?} }}", val),
None => write!(f, "RefCell {{ <borrowed> }}")
match self.borrow_state() {
BorrowState::Unused | BorrowState::Reading => {
write!(f, "RefCell {{ value: {:?} }}", self.borrow())
}
BorrowState::Writing => write!(f, "RefCell {{ <borrowed> }}"),
}
}
}

View File

@ -16,19 +16,6 @@
#![stable(feature = "rust1", since = "1.0.0")]
#[cfg(stage0)] pub use self::Position::*;
#[cfg(stage0)] pub use self::Alignment::Left as AlignLeft;
#[cfg(stage0)] pub use self::Alignment::Right as AlignRight;
#[cfg(stage0)] pub use self::Alignment::Center as AlignCenter;
#[cfg(stage0)] pub use self::Alignment::Unknown as AlignUnknown;
#[cfg(stage0)] pub use self::Count::Is as CountIs;
#[cfg(stage0)] pub use self::Count::Implied as CountImplied;
#[cfg(stage0)] pub use self::Count::Param as CountIsParam;
#[cfg(stage0)] pub use self::Count::NextParam as CountIsNextParam;
#[cfg(stage0)] pub use self::Position::Next as ArgumentNext;
#[cfg(stage0)] pub use self::Position::At as ArgumentIs;
#[derive(Copy)]
#[stable(feature = "rust1", since = "1.0.0")]
pub struct Argument {

View File

@ -205,7 +205,7 @@ impl<S: Writer + Hasher, T: Hash<S>> Hash<S> for [T] {
#[inline]
fn hash(&self, state: &mut S) {
self.len().hash(state);
for elt in self.iter() {
for elt in self {
elt.hash(state);
}
}

View File

@ -174,7 +174,7 @@ pub trait IteratorExt: Iterator + Sized {
/// ```
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
fn last(mut self) -> Option<Self::Item> {
fn last(self) -> Option<Self::Item> {
let mut last = None;
for x in self { last = Some(x); }
last
@ -239,9 +239,7 @@ pub trait IteratorExt: Iterator + Sized {
/// ```
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
fn zip<B, U>(self, other: U) -> Zip<Self, U> where
U: Iterator<Item=B>,
{
fn zip<U: Iterator>(self, other: U) -> Zip<Self, U> {
Zip{a: self, b: other}
}
@ -259,7 +257,7 @@ pub trait IteratorExt: Iterator + Sized {
/// ```
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
fn map<B, F>(self, f: F) -> Map<Self::Item, B, Self, F> where
fn map<B, F>(self, f: F) -> Map<Self, F> where
F: FnMut(Self::Item) -> B,
{
Map{iter: self, f: f}
@ -279,7 +277,7 @@ pub trait IteratorExt: Iterator + Sized {
/// ```
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
fn filter<P>(self, predicate: P) -> Filter<Self::Item, Self, P> where
fn filter<P>(self, predicate: P) -> Filter<Self, P> where
P: FnMut(&Self::Item) -> bool,
{
Filter{iter: self, predicate: predicate}
@ -299,7 +297,7 @@ pub trait IteratorExt: Iterator + Sized {
/// ```
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
fn filter_map<B, F>(self, f: F) -> FilterMap<Self::Item, B, Self, F> where
fn filter_map<B, F>(self, f: F) -> FilterMap<Self, F> where
F: FnMut(Self::Item) -> Option<B>,
{
FilterMap { iter: self, f: f }
@ -342,7 +340,7 @@ pub trait IteratorExt: Iterator + Sized {
/// ```
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
fn peekable(self) -> Peekable<Self::Item, Self> {
fn peekable(self) -> Peekable<Self> {
Peekable{iter: self, peeked: None}
}
@ -362,7 +360,7 @@ pub trait IteratorExt: Iterator + Sized {
/// ```
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
fn skip_while<P>(self, predicate: P) -> SkipWhile<Self::Item, Self, P> where
fn skip_while<P>(self, predicate: P) -> SkipWhile<Self, P> where
P: FnMut(&Self::Item) -> bool,
{
SkipWhile{iter: self, flag: false, predicate: predicate}
@ -383,7 +381,7 @@ pub trait IteratorExt: Iterator + Sized {
/// ```
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
fn take_while<P>(self, predicate: P) -> TakeWhile<Self::Item, Self, P> where
fn take_while<P>(self, predicate: P) -> TakeWhile<Self, P> where
P: FnMut(&Self::Item) -> bool,
{
TakeWhile{iter: self, flag: false, predicate: predicate}
@ -448,12 +446,8 @@ pub trait IteratorExt: Iterator + Sized {
/// ```
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
fn scan<St, B, F>(
self,
initial_state: St,
f: F,
) -> Scan<Self::Item, B, Self, St, F> where
F: FnMut(&mut St, Self::Item) -> Option<B>,
fn scan<St, B, F>(self, initial_state: St, f: F) -> Scan<Self, St, F>
where F: FnMut(&mut St, Self::Item) -> Option<B>,
{
Scan{iter: self, f: f, state: initial_state}
}
@ -474,9 +468,8 @@ pub trait IteratorExt: Iterator + Sized {
/// ```
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
fn flat_map<B, U, F>(self, f: F) -> FlatMap<Self::Item, B, Self, U, F> where
U: Iterator<Item=B>,
F: FnMut(Self::Item) -> U,
fn flat_map<U, F>(self, f: F) -> FlatMap<Self, U, F>
where U: Iterator, F: FnMut(Self::Item) -> U,
{
FlatMap{iter: self, f: f, frontiter: None, backiter: None }
}
@ -534,7 +527,7 @@ pub trait IteratorExt: Iterator + Sized {
/// ```
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
fn inspect<F>(self, f: F) -> Inspect<Self::Item, Self, F> where
fn inspect<F>(self, f: F) -> Inspect<Self, F> where
F: FnMut(&Self::Item),
{
Inspect{iter: self, f: f}
@ -588,7 +581,7 @@ pub trait IteratorExt: Iterator + Sized {
/// ```
#[unstable(feature = "core",
reason = "recently added as part of collections reform")]
fn partition<B, F>(mut self, mut f: F) -> (B, B) where
fn partition<B, F>(self, mut f: F) -> (B, B) where
B: Default + Extend<Self::Item>,
F: FnMut(&Self::Item) -> bool
{
@ -617,7 +610,7 @@ pub trait IteratorExt: Iterator + Sized {
/// ```
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
fn fold<B, F>(mut self, init: B, mut f: F) -> B where
fn fold<B, F>(self, init: B, mut f: F) -> B where
F: FnMut(B, Self::Item) -> B,
{
let mut accum = init;
@ -638,7 +631,7 @@ pub trait IteratorExt: Iterator + Sized {
/// ```
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
fn all<F>(mut self, mut f: F) -> bool where F: FnMut(Self::Item) -> bool {
fn all<F>(self, mut f: F) -> bool where F: FnMut(Self::Item) -> bool {
for x in self { if !f(x) { return false; } }
true
}
@ -946,7 +939,7 @@ pub trait IteratorExt: Iterator + Sized {
/// assert_eq!([2, 4], right);
/// ```
#[unstable(feature = "core", reason = "recent addition")]
fn unzip<A, B, FromA, FromB>(mut self) -> (FromA, FromB) where
fn unzip<A, B, FromA, FromB>(self) -> (FromA, FromB) where
FromA: Default + Extend<A>,
FromB: Default + Extend<B>,
Self: Iterator<Item=(A, B)>,
@ -1077,16 +1070,14 @@ pub trait ExactSizeIterator: Iterator {
#[stable(feature = "rust1", since = "1.0.0")]
impl<I> ExactSizeIterator for Enumerate<I> where I: ExactSizeIterator {}
#[stable(feature = "rust1", since = "1.0.0")]
impl<A, I, F> ExactSizeIterator for Inspect<A, I, F> where
I: ExactSizeIterator<Item=A>,
F: FnMut(&A),
impl<I: ExactSizeIterator, F> ExactSizeIterator for Inspect<I, F> where
F: FnMut(&I::Item),
{}
#[stable(feature = "rust1", since = "1.0.0")]
impl<I> ExactSizeIterator for Rev<I> where I: ExactSizeIterator + DoubleEndedIterator {}
#[stable(feature = "rust1", since = "1.0.0")]
impl<A, B, I, F> ExactSizeIterator for Map<A, B, I, F> where
I: ExactSizeIterator<Item=A>,
F: FnMut(A) -> B,
impl<B, I: ExactSizeIterator, F> ExactSizeIterator for Map<I, F> where
F: FnMut(I::Item) -> B,
{}
#[stable(feature = "rust1", since = "1.0.0")]
impl<A, B> ExactSizeIterator for Zip<A, B> where A: ExactSizeIterator, B: ExactSizeIterator {}
@ -1561,28 +1552,15 @@ impl<T, U, A, B> RandomAccessIterator for Zip<A, B> where
/// An iterator that maps the values of `iter` with `f`
#[must_use = "iterator adaptors are lazy and do nothing unless consumed"]
#[stable(feature = "rust1", since = "1.0.0")]
pub struct Map<A, B, I: Iterator<Item=A>, F: FnMut(A) -> B> {
#[derive(Clone)]
pub struct Map<I, F> {
iter: I,
f: F,
}
// FIXME(#19839) Remove in favor of `#[derive(Clone)]`
#[stable(feature = "rust1", since = "1.0.0")]
impl<A, B, I, F> Clone for Map<A, B, I, F> where
I: Clone + Iterator<Item=A>,
F: Clone + FnMut(A) -> B,
{
fn clone(&self) -> Map<A, B, I, F> {
Map {
iter: self.iter.clone(),
f: self.f.clone(),
}
}
}
impl<A, B, I, F> Map<A, B, I, F> where I: Iterator<Item=A>, F: FnMut(A) -> B {
impl<I: Iterator, F, B> Map<I, F> where F: FnMut(I::Item) -> B {
#[inline]
fn do_map(&mut self, elt: Option<A>) -> Option<B> {
fn do_map(&mut self, elt: Option<I::Item>) -> Option<B> {
match elt {
Some(a) => Some((self.f)(a)),
_ => None
@ -1591,7 +1569,7 @@ impl<A, B, I, F> Map<A, B, I, F> where I: Iterator<Item=A>, F: FnMut(A) -> B {
}
#[stable(feature = "rust1", since = "1.0.0")]
impl<A, B, I, F> Iterator for Map<A, B, I, F> where I: Iterator<Item=A>, F: FnMut(A) -> B {
impl<B, I: Iterator, F> Iterator for Map<I, F> where F: FnMut(I::Item) -> B {
type Item = B;
#[inline]
@ -1607,9 +1585,8 @@ impl<A, B, I, F> Iterator for Map<A, B, I, F> where I: Iterator<Item=A>, F: FnMu
}
#[stable(feature = "rust1", since = "1.0.0")]
impl<A, B, I, F> DoubleEndedIterator for Map<A, B, I, F> where
I: DoubleEndedIterator<Item=A>,
F: FnMut(A) -> B,
impl<B, I: DoubleEndedIterator, F> DoubleEndedIterator for Map<I, F> where
F: FnMut(I::Item) -> B,
{
#[inline]
fn next_back(&mut self) -> Option<B> {
@ -1619,9 +1596,8 @@ impl<A, B, I, F> DoubleEndedIterator for Map<A, B, I, F> where
}
#[unstable(feature = "core", reason = "trait is experimental")]
impl<A, B, I, F> RandomAccessIterator for Map<A, B, I, F> where
I: RandomAccessIterator<Item=A>,
F: FnMut(A) -> B,
impl<B, I: RandomAccessIterator, F> RandomAccessIterator for Map<I, F> where
F: FnMut(I::Item) -> B,
{
#[inline]
fn indexable(&self) -> usize {
@ -1638,31 +1614,18 @@ impl<A, B, I, F> RandomAccessIterator for Map<A, B, I, F> where
/// An iterator that filters the elements of `iter` with `predicate`
#[must_use = "iterator adaptors are lazy and do nothing unless consumed"]
#[stable(feature = "rust1", since = "1.0.0")]
pub struct Filter<A, I, P> where I: Iterator<Item=A>, P: FnMut(&A) -> bool {
#[derive(Clone)]
pub struct Filter<I, P> {
iter: I,
predicate: P,
}
// FIXME(#19839) Remove in favor of `#[derive(Clone)]`
#[stable(feature = "rust1", since = "1.0.0")]
impl<A, I, P> Clone for Filter<A, I, P> where
I: Clone + Iterator<Item=A>,
P: Clone + FnMut(&A) -> bool,
{
fn clone(&self) -> Filter<A, I, P> {
Filter {
iter: self.iter.clone(),
predicate: self.predicate.clone(),
}
}
}
#[stable(feature = "rust1", since = "1.0.0")]
impl<A, I, P> Iterator for Filter<A, I, P> where I: Iterator<Item=A>, P: FnMut(&A) -> bool {
type Item = A;
impl<I: Iterator, P> Iterator for Filter<I, P> where P: FnMut(&I::Item) -> bool {
type Item = I::Item;
#[inline]
fn next(&mut self) -> Option<A> {
fn next(&mut self) -> Option<I::Item> {
for x in self.iter.by_ref() {
if (self.predicate)(&x) {
return Some(x);
@ -1681,12 +1644,11 @@ impl<A, I, P> Iterator for Filter<A, I, P> where I: Iterator<Item=A>, P: FnMut(&
}
#[stable(feature = "rust1", since = "1.0.0")]
impl<A, I, P> DoubleEndedIterator for Filter<A, I, P> where
I: DoubleEndedIterator<Item=A>,
P: FnMut(&A) -> bool,
impl<I: DoubleEndedIterator, P> DoubleEndedIterator for Filter<I, P>
where P: FnMut(&I::Item) -> bool,
{
#[inline]
fn next_back(&mut self) -> Option<A> {
fn next_back(&mut self) -> Option<I::Item> {
for x in self.iter.by_ref().rev() {
if (self.predicate)(&x) {
return Some(x);
@ -1699,29 +1661,15 @@ impl<A, I, P> DoubleEndedIterator for Filter<A, I, P> where
/// An iterator that uses `f` to both filter and map elements from `iter`
#[must_use = "iterator adaptors are lazy and do nothing unless consumed"]
#[stable(feature = "rust1", since = "1.0.0")]
pub struct FilterMap<A, B, I, F> where I: Iterator<Item=A>, F: FnMut(A) -> Option<B> {
#[derive(Clone)]
pub struct FilterMap<I, F> {
iter: I,
f: F,
}
// FIXME(#19839) Remove in favor of `#[derive(Clone)]`
#[stable(feature = "rust1", since = "1.0.0")]
impl<A, B, I, F> Clone for FilterMap<A, B, I, F> where
I: Clone + Iterator<Item=A>,
F: Clone + FnMut(A) -> Option<B>,
{
fn clone(&self) -> FilterMap<A, B, I, F> {
FilterMap {
iter: self.iter.clone(),
f: self.f.clone(),
}
}
}
#[stable(feature = "rust1", since = "1.0.0")]
impl<A, B, I, F> Iterator for FilterMap<A, B, I, F> where
I: Iterator<Item=A>,
F: FnMut(A) -> Option<B>,
impl<B, I: Iterator, F> Iterator for FilterMap<I, F>
where F: FnMut(I::Item) -> Option<B>,
{
type Item = B;
@ -1744,9 +1692,8 @@ impl<A, B, I, F> Iterator for FilterMap<A, B, I, F> where
}
#[stable(feature = "rust1", since = "1.0.0")]
impl<A, B, I, F> DoubleEndedIterator for FilterMap<A, B, I, F> where
I: DoubleEndedIterator<Item=A>,
F: FnMut(A) -> Option<B>,
impl<B, I: DoubleEndedIterator, F> DoubleEndedIterator for FilterMap<I, F>
where F: FnMut(I::Item) -> Option<B>,
{
#[inline]
fn next_back(&mut self) -> Option<B> {
@ -1824,20 +1771,28 @@ impl<I> RandomAccessIterator for Enumerate<I> where I: RandomAccessIterator {
}
/// An iterator with a `peek()` that returns an optional reference to the next element.
#[derive(Clone)]
#[must_use = "iterator adaptors are lazy and do nothing unless consumed"]
#[stable(feature = "rust1", since = "1.0.0")]
pub struct Peekable<T, I> where I: Iterator<Item=T> {
pub struct Peekable<I: Iterator> {
iter: I,
peeked: Option<T>,
peeked: Option<I::Item>,
}
impl<I: Iterator + Clone> Clone for Peekable<I> where I::Item: Clone {
fn clone(&self) -> Peekable<I> {
Peekable {
iter: self.iter.clone(),
peeked: self.peeked.clone(),
}
}
}
#[stable(feature = "rust1", since = "1.0.0")]
impl<T, I> Iterator for Peekable<T, I> where I: Iterator<Item=T> {
type Item = T;
impl<I: Iterator> Iterator for Peekable<I> {
type Item = I::Item;
#[inline]
fn next(&mut self) -> Option<T> {
fn next(&mut self) -> Option<I::Item> {
if self.peeked.is_some() { self.peeked.take() }
else { self.iter.next() }
}
@ -1859,14 +1814,14 @@ impl<T, I> Iterator for Peekable<T, I> where I: Iterator<Item=T> {
}
#[stable(feature = "rust1", since = "1.0.0")]
impl<T, I> ExactSizeIterator for Peekable<T, I> where I: ExactSizeIterator<Item = T> {}
impl<I: ExactSizeIterator> ExactSizeIterator for Peekable<I> {}
#[stable(feature = "rust1", since = "1.0.0")]
impl<T, I> Peekable<T, I> where I: Iterator<Item=T> {
/// Return a reference to the next element of the iterator with out advancing it,
/// or None if the iterator is exhausted.
impl<I: Iterator> Peekable<I> {
/// Return a reference to the next element of the iterator with out
/// advancing it, or None if the iterator is exhausted.
#[inline]
pub fn peek(&mut self) -> Option<&T> {
pub fn peek(&mut self) -> Option<&I::Item> {
if self.peeked.is_none() {
self.peeked = self.iter.next();
}
@ -1886,33 +1841,21 @@ impl<T, I> Peekable<T, I> where I: Iterator<Item=T> {
/// An iterator that rejects elements while `predicate` is true
#[must_use = "iterator adaptors are lazy and do nothing unless consumed"]
#[stable(feature = "rust1", since = "1.0.0")]
pub struct SkipWhile<A, I, P> where I: Iterator<Item=A>, P: FnMut(&A) -> bool {
#[derive(Clone)]
pub struct SkipWhile<I, P> {
iter: I,
flag: bool,
predicate: P,
}
// FIXME(#19839) Remove in favor of `#[derive(Clone)]`
#[stable(feature = "rust1", since = "1.0.0")]
impl<A, I, P> Clone for SkipWhile<A, I, P> where
I: Clone + Iterator<Item=A>,
P: Clone + FnMut(&A) -> bool,
impl<I: Iterator, P> Iterator for SkipWhile<I, P>
where P: FnMut(&I::Item) -> bool
{
fn clone(&self) -> SkipWhile<A, I, P> {
SkipWhile {
iter: self.iter.clone(),
flag: self.flag,
predicate: self.predicate.clone(),
}
}
}
#[stable(feature = "rust1", since = "1.0.0")]
impl<A, I, P> Iterator for SkipWhile<A, I, P> where I: Iterator<Item=A>, P: FnMut(&A) -> bool {
type Item = A;
type Item = I::Item;
#[inline]
fn next(&mut self) -> Option<A> {
fn next(&mut self) -> Option<I::Item> {
for x in self.iter.by_ref() {
if self.flag || !(self.predicate)(&x) {
self.flag = true;
@ -1932,33 +1875,21 @@ impl<A, I, P> Iterator for SkipWhile<A, I, P> where I: Iterator<Item=A>, P: FnMu
/// An iterator that only accepts elements while `predicate` is true
#[must_use = "iterator adaptors are lazy and do nothing unless consumed"]
#[stable(feature = "rust1", since = "1.0.0")]
pub struct TakeWhile<A, I, P> where I: Iterator<Item=A>, P: FnMut(&A) -> bool {
#[derive(Clone)]
pub struct TakeWhile<I, P> {
iter: I,
flag: bool,
predicate: P,
}
// FIXME(#19839) Remove in favor of `#[derive(Clone)]`
#[stable(feature = "rust1", since = "1.0.0")]
impl<A, I, P> Clone for TakeWhile<A, I, P> where
I: Clone + Iterator<Item=A>,
P: Clone + FnMut(&A) -> bool,
impl<I: Iterator, P> Iterator for TakeWhile<I, P>
where P: FnMut(&I::Item) -> bool
{
fn clone(&self) -> TakeWhile<A, I, P> {
TakeWhile {
iter: self.iter.clone(),
flag: self.flag,
predicate: self.predicate.clone(),
}
}
}
#[stable(feature = "rust1", since = "1.0.0")]
impl<A, I, P> Iterator for TakeWhile<A, I, P> where I: Iterator<Item=A>, P: FnMut(&A) -> bool {
type Item = A;
type Item = I::Item;
#[inline]
fn next(&mut self) -> Option<A> {
fn next(&mut self) -> Option<I::Item> {
if self.flag {
None
} else {
@ -2118,7 +2049,8 @@ impl<I> ExactSizeIterator for Take<I> where I: ExactSizeIterator {}
/// An iterator to maintain state while iterating another iterator
#[must_use = "iterator adaptors are lazy and do nothing unless consumed"]
#[stable(feature = "rust1", since = "1.0.0")]
pub struct Scan<A, B, I, St, F> where I: Iterator, F: FnMut(&mut St, A) -> Option<B> {
#[derive(Clone)]
pub struct Scan<I, St, F> {
iter: I,
f: F,
@ -2126,26 +2058,9 @@ pub struct Scan<A, B, I, St, F> where I: Iterator, F: FnMut(&mut St, A) -> Optio
pub state: St,
}
// FIXME(#19839) Remove in favor of `#[derive(Clone)]`
#[stable(feature = "rust1", since = "1.0.0")]
impl<A, B, I, St, F> Clone for Scan<A, B, I, St, F> where
I: Clone + Iterator<Item=A>,
St: Clone,
F: Clone + FnMut(&mut St, A) -> Option<B>,
{
fn clone(&self) -> Scan<A, B, I, St, F> {
Scan {
iter: self.iter.clone(),
f: self.f.clone(),
state: self.state.clone(),
}
}
}
#[stable(feature = "rust1", since = "1.0.0")]
impl<A, B, I, St, F> Iterator for Scan<A, B, I, St, F> where
I: Iterator<Item=A>,
F: FnMut(&mut St, A) -> Option<B>,
impl<B, I: Iterator, St, F> Iterator for Scan<I, St, F> where
F: FnMut(&mut St, I::Item) -> Option<B>,
{
type Item = B;
@ -2166,46 +2081,24 @@ impl<A, B, I, St, F> Iterator for Scan<A, B, I, St, F> where
///
#[must_use = "iterator adaptors are lazy and do nothing unless consumed"]
#[stable(feature = "rust1", since = "1.0.0")]
pub struct FlatMap<A, B, I, U, F> where
I: Iterator<Item=A>,
U: Iterator<Item=B>,
F: FnMut(A) -> U,
{
#[derive(Clone)]
pub struct FlatMap<I, U, F> {
iter: I,
f: F,
frontiter: Option<U>,
backiter: Option<U>,
}
// FIXME(#19839) Remove in favor of `#[derive(Clone)]`
#[stable(feature = "rust1", since = "1.0.0")]
impl<A, B, I, U, F> Clone for FlatMap<A, B, I, U, F> where
I: Clone + Iterator<Item=A>,
U: Clone + Iterator<Item=B>,
F: Clone + FnMut(A) -> U,
impl<I: Iterator, U: Iterator, F> Iterator for FlatMap<I, U, F>
where F: FnMut(I::Item) -> U,
{
fn clone(&self) -> FlatMap<A, B, I, U, F> {
FlatMap {
iter: self.iter.clone(),
f: self.f.clone(),
frontiter: self.frontiter.clone(),
backiter: self.backiter.clone(),
}
}
}
#[stable(feature = "rust1", since = "1.0.0")]
impl<A, B, I, U, F> Iterator for FlatMap<A, B, I, U, F> where
I: Iterator<Item=A>,
U: Iterator<Item=B>,
F: FnMut(A) -> U,
{
type Item = B;
type Item = U::Item;
#[inline]
fn next(&mut self) -> Option<B> {
fn next(&mut self) -> Option<U::Item> {
loop {
for inner in self.frontiter.iter_mut() {
if let Some(ref mut inner) = self.frontiter {
for x in inner.by_ref() {
return Some(x)
}
@ -2230,15 +2123,14 @@ impl<A, B, I, U, F> Iterator for FlatMap<A, B, I, U, F> where
}
#[stable(feature = "rust1", since = "1.0.0")]
impl<A, B, I, U, F> DoubleEndedIterator for FlatMap<A, B, I, U, F> where
I: DoubleEndedIterator<Item=A>,
U: DoubleEndedIterator<Item=B>,
F: FnMut(A) -> U,
impl<I: DoubleEndedIterator, U: DoubleEndedIterator, F> DoubleEndedIterator
for FlatMap<I, U, F>
where F: FnMut(I::Item) -> U
{
#[inline]
fn next_back(&mut self) -> Option<B> {
fn next_back(&mut self) -> Option<U::Item> {
loop {
for inner in self.backiter.iter_mut() {
if let Some(ref mut inner) = self.backiter {
match inner.next_back() {
None => (),
y => return y
@ -2340,28 +2232,15 @@ impl<I> Fuse<I> {
/// element before yielding it.
#[must_use = "iterator adaptors are lazy and do nothing unless consumed"]
#[stable(feature = "rust1", since = "1.0.0")]
pub struct Inspect<A, I, F> where I: Iterator<Item=A>, F: FnMut(&A) {
#[derive(Clone)]
pub struct Inspect<I, F> {
iter: I,
f: F,
}
// FIXME(#19839) Remove in favor of `#[derive(Clone)]`
#[stable(feature = "rust1", since = "1.0.0")]
impl<A, I, F> Clone for Inspect<A, I, F> where
I: Clone + Iterator<Item=A>,
F: Clone + FnMut(&A),
{
fn clone(&self) -> Inspect<A, I, F> {
Inspect {
iter: self.iter.clone(),
f: self.f.clone(),
}
}
}
impl<A, I, F> Inspect<A, I, F> where I: Iterator<Item=A>, F: FnMut(&A) {
impl<I: Iterator, F> Inspect<I, F> where F: FnMut(&I::Item) {
#[inline]
fn do_inspect(&mut self, elt: Option<A>) -> Option<A> {
fn do_inspect(&mut self, elt: Option<I::Item>) -> Option<I::Item> {
match elt {
Some(ref a) => (self.f)(a),
None => ()
@ -2372,11 +2251,11 @@ impl<A, I, F> Inspect<A, I, F> where I: Iterator<Item=A>, F: FnMut(&A) {
}
#[stable(feature = "rust1", since = "1.0.0")]
impl<A, I, F> Iterator for Inspect<A, I, F> where I: Iterator<Item=A>, F: FnMut(&A) {
type Item = A;
impl<I: Iterator, F> Iterator for Inspect<I, F> where F: FnMut(&I::Item) {
type Item = I::Item;
#[inline]
fn next(&mut self) -> Option<A> {
fn next(&mut self) -> Option<I::Item> {
let next = self.iter.next();
self.do_inspect(next)
}
@ -2388,21 +2267,19 @@ impl<A, I, F> Iterator for Inspect<A, I, F> where I: Iterator<Item=A>, F: FnMut(
}
#[stable(feature = "rust1", since = "1.0.0")]
impl<A, I, F> DoubleEndedIterator for Inspect<A, I, F> where
I: DoubleEndedIterator<Item=A>,
F: FnMut(&A),
impl<I: DoubleEndedIterator, F> DoubleEndedIterator for Inspect<I, F>
where F: FnMut(&I::Item),
{
#[inline]
fn next_back(&mut self) -> Option<A> {
fn next_back(&mut self) -> Option<I::Item> {
let next = self.iter.next_back();
self.do_inspect(next)
}
}
#[unstable(feature = "core", reason = "trait is experimental")]
impl<A, I, F> RandomAccessIterator for Inspect<A, I, F> where
I: RandomAccessIterator<Item=A>,
F: FnMut(&A),
impl<I: RandomAccessIterator, F> RandomAccessIterator for Inspect<I, F>
where F: FnMut(&I::Item),
{
#[inline]
fn indexable(&self) -> usize {
@ -2410,7 +2287,7 @@ impl<A, I, F> RandomAccessIterator for Inspect<A, I, F> where
}
#[inline]
fn idx(&mut self, index: usize) -> Option<A> {
fn idx(&mut self, index: usize) -> Option<I::Item> {
let element = self.iter.idx(index);
self.do_inspect(element)
}
@ -2426,9 +2303,11 @@ impl<A, I, F> RandomAccessIterator for Inspect<A, I, F> where
/// use std::iter::Unfold;
/// use std::num::Int; // For `.checked_add()`
///
/// // This iterator will yield up to the last Fibonacci number before the max value of `u32`.
/// // You can simply change `u32` to `u64` in this line if you want higher values than that.
/// let mut fibonacci = Unfold::new((Some(0u32), Some(1u32)), |&mut (ref mut x2, ref mut x1)| {
/// // This iterator will yield up to the last Fibonacci number before the max
/// // value of `u32`. You can simply change `u32` to `u64` in this line if
/// // you want higher values than that.
/// let mut fibonacci = Unfold::new((Some(0u32), Some(1u32)),
/// |&mut (ref mut x2, ref mut x1)| {
/// // Attempt to get the next Fibonacci number
/// // `x1` will be `None` if previously overflowed.
/// let next = match (*x2, *x1) {
@ -2449,32 +2328,19 @@ impl<A, I, F> RandomAccessIterator for Inspect<A, I, F> where
/// }
/// ```
#[unstable(feature = "core")]
pub struct Unfold<A, St, F> where F: FnMut(&mut St) -> Option<A> {
#[derive(Clone)]
pub struct Unfold<St, F> {
f: F,
/// Internal state that will be passed to the closure on the next iteration
pub state: St,
}
// FIXME(#19839) Remove in favor of `#[derive(Clone)]`
#[stable(feature = "rust1", since = "1.0.0")]
impl<A, St, F> Clone for Unfold<A, St, F> where
F: Clone + FnMut(&mut St) -> Option<A>,
St: Clone,
{
fn clone(&self) -> Unfold<A, St, F> {
Unfold {
f: self.f.clone(),
state: self.state.clone(),
}
}
}
#[unstable(feature = "core")]
impl<A, St, F> Unfold<A, St, F> where F: FnMut(&mut St) -> Option<A> {
impl<A, St, F> Unfold<St, F> where F: FnMut(&mut St) -> Option<A> {
/// Creates a new iterator with the specified closure as the "iterator
/// function" and an initial state to eventually pass to the closure
#[inline]
pub fn new(initial_state: St, f: F) -> Unfold<A, St, F> {
pub fn new(initial_state: St, f: F) -> Unfold<St, F> {
Unfold {
f: f,
state: initial_state
@ -2483,7 +2349,7 @@ impl<A, St, F> Unfold<A, St, F> where F: FnMut(&mut St) -> Option<A> {
}
#[stable(feature = "rust1", since = "1.0.0")]
impl<A, St, F> Iterator for Unfold<A, St, F> where F: FnMut(&mut St) -> Option<A> {
impl<A, St, F> Iterator for Unfold<St, F> where F: FnMut(&mut St) -> Option<A> {
type Item = A;
#[inline]
@ -2899,7 +2765,7 @@ type IterateState<T, F> = (F, Option<T>, bool);
/// An iterator that repeatedly applies a given function, starting
/// from a given seed value.
#[unstable(feature = "core")]
pub type Iterate<T, F> = Unfold<T, IterateState<T, F>, fn(&mut IterateState<T, F>) -> Option<T>>;
pub type Iterate<T, F> = Unfold<IterateState<T, F>, fn(&mut IterateState<T, F>) -> Option<T>>;
/// Create a new iterator that produces an infinite sequence of
/// repeated applications of the given function `f`.

View File

@ -59,7 +59,6 @@
#![no_std]
#![allow(raw_pointer_derive)]
#![deny(missing_docs)]
#![cfg_attr(not(stage0), allow(unused_mut))] // NOTE: remove after stage0 snap
#![feature(int_uint)]
#![feature(intrinsics, lang_items)]

View File

@ -947,28 +947,11 @@ pub trait IndexMut<Index: ?Sized> {
}
/// An unbounded range.
#[cfg(stage0)]
#[derive(Copy, Clone, PartialEq, Eq)]
#[lang="full_range"]
#[unstable(feature = "core", reason = "may be renamed to RangeFull")]
pub struct FullRange;
/// An unbounded range.
#[cfg(not(stage0))]
#[derive(Copy, Clone, PartialEq, Eq)]
#[lang="range_full"]
#[stable(feature = "rust1", since = "1.0.0")]
pub struct RangeFull;
#[cfg(stage0)]
#[stable(feature = "rust1", since = "1.0.0")]
impl fmt::Debug for FullRange {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
fmt::Debug::fmt("..", fmt)
}
}
#[cfg(not(stage0))]
#[stable(feature = "rust1", since = "1.0.0")]
impl fmt::Debug for RangeFull {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {

View File

@ -26,9 +26,6 @@
// Reexported core operators
pub use marker::{Copy, Send, Sized, Sync};
#[cfg(stage0)]
pub use ops::{Drop, Fn, FnMut, FnOnce, FullRange};
#[cfg(not(stage0))]
pub use ops::{Drop, Fn, FnMut, FnOnce};
// Reexported functions

View File

@ -956,7 +956,7 @@ pub fn fold<T,
E,
F: FnMut(V, T) -> V,
Iter: Iterator<Item=Result<T, E>>>(
mut iterator: Iter,
iterator: Iter,
mut init: V,
mut f: F)
-> Result<V, E> {

View File

@ -43,9 +43,6 @@ use default::Default;
use iter::*;
use num::Int;
use ops::{FnMut, self, Index};
#[cfg(stage0)]
use ops::FullRange as RangeFull;
#[cfg(not(stage0))]
use ops::RangeFull;
use option::Option;
use option::Option::{None, Some};
@ -769,16 +766,6 @@ impl<'a, T> ops::Index<ops::RangeFrom<uint>> for Iter<'a, T> {
}
}
#[cfg(stage0)]
#[unstable(feature = "core")]
impl<'a, T> ops::Index<ops::FullRange> for Iter<'a, T> {
type Output = [T];
#[inline]
fn index(&self, _index: &ops::FullRange) -> &[T] {
self.as_slice()
}
}
#[cfg(not(stage0))]
#[unstable(feature = "core")]
impl<'a, T> ops::Index<RangeFull> for Iter<'a, T> {
type Output = [T];

View File

@ -478,7 +478,7 @@ impl<'a> DoubleEndedIterator for CharIndices<'a> {
/// Created with `StrExt::bytes`
#[stable(feature = "rust1", since = "1.0.0")]
#[derive(Clone)]
pub struct Bytes<'a>(Map<&'a u8, u8, slice::Iter<'a, u8>, BytesDeref>);
pub struct Bytes<'a>(Map<slice::Iter<'a, u8>, BytesDeref>);
delegate_iter!{exact u8 : Bytes<'a>}
/// A temporary fn new type that ensures that the `Bytes` iterator
@ -526,7 +526,7 @@ pub struct Lines<'a> {
/// An iterator over the lines of a string, separated by either `\n` or (`\r\n`).
#[stable(feature = "rust1", since = "1.0.0")]
pub struct LinesAny<'a> {
inner: Map<&'a str, &'a str, Lines<'a>, fn(&str) -> &str>,
inner: Map<Lines<'a>, fn(&str) -> &str>,
}
impl<'a, Sep> CharSplits<'a, Sep> {
@ -1266,16 +1266,6 @@ mod traits {
}
}
#[cfg(stage0)]
#[stable(feature = "rust1", since = "1.0.0")]
impl ops::Index<ops::FullRange> for str {
type Output = str;
#[inline]
fn index(&self, _index: &ops::FullRange) -> &str {
self
}
}
#[cfg(not(stage0))]
#[stable(feature = "rust1", since = "1.0.0")]
impl ops::Index<ops::RangeFull> for str {
type Output = str;

View File

@ -60,6 +60,7 @@ fn no_mut_then_imm_borrow() {
let x = RefCell::new(0);
let _b1 = x.borrow_mut();
assert!(x.try_borrow().is_none());
assert_eq!(x.borrow_state(), BorrowState::Writing);
}
#[test]
@ -67,13 +68,16 @@ fn no_imm_then_borrow_mut() {
let x = RefCell::new(0);
let _b1 = x.borrow();
assert!(x.try_borrow_mut().is_none());
assert_eq!(x.borrow_state(), BorrowState::Reading);
}
#[test]
fn no_double_borrow_mut() {
let x = RefCell::new(0);
assert_eq!(x.borrow_state(), BorrowState::Unused);
let _b1 = x.borrow_mut();
assert!(x.try_borrow_mut().is_none());
assert_eq!(x.borrow_state(), BorrowState::Writing);
}
#[test]

View File

@ -66,11 +66,11 @@ fn test_partial_min() {
(1.0f64, NAN, None)
];
for &(a, b, result) in data_integer.iter() {
for &(a, b, result) in &data_integer {
assert!(partial_min(a, b) == result);
}
for &(a, b, result) in data_float.iter() {
for &(a, b, result) in &data_float {
assert!(partial_min(a, b) == result);
}
}
@ -99,11 +99,11 @@ fn test_partial_max() {
(1.0f64, NAN, None)
];
for &(a, b, result) in data_integer.iter() {
for &(a, b, result) in &data_integer {
assert!(partial_max(a, b) == result);
}
for &(a, b, result) in data_float.iter() {
for &(a, b, result) in &data_float {
assert!(partial_max(a, b) == result);
}
}

View File

@ -25,7 +25,7 @@ impl Default for MyHasher {
impl Writer for MyHasher {
// Most things we'll just add up the bytes.
fn write(&mut self, buf: &[u8]) {
for byte in buf.iter() {
for byte in buf {
self.hash += *byte as u64;
}
}

View File

@ -109,7 +109,7 @@ fn test_siphash() {
fn to_hex_str(r: &[u8; 8]) -> String {
let mut s = String::new();
for b in r.iter() {
for b in r {
s.push_str(format!("{}", fmt::radix(*b, 16)).as_slice());
}
s
@ -130,7 +130,7 @@ fn test_siphash() {
fn result_str(h: u64) -> String {
let r = result_bytes(h);
let mut s = String::new();
for b in r.iter() {
for b in &r {
s.push_str(format!("{}", fmt::radix(*b, 16)).as_slice());
}
s

View File

@ -24,7 +24,6 @@
html_root_url = "http://doc.rust-lang.org/nightly/",
html_playground_url = "http://play.rust-lang.org/")]
#![cfg_attr(stage0, feature(core))]
#![feature(int_uint)]
#![feature(slicing_syntax)]
#![feature(staged_api)]

View File

@ -315,7 +315,7 @@ impl Matches {
/// Returns true if any of several options were matched.
pub fn opts_present(&self, names: &[String]) -> bool {
for nm in names.iter() {
for nm in names {
match find_opt(self.opts.as_slice(), Name::from_str(&nm[])) {
Some(id) if !self.vals[id].is_empty() => return true,
_ => (),
@ -326,7 +326,7 @@ impl Matches {
/// Returns the string argument supplied to one of several matching options or `None`.
pub fn opts_str(&self, names: &[String]) -> Option<String> {
for nm in names.iter() {
for nm in names {
match self.opt_val(&nm[]) {
Some(Val(ref s)) => return Some(s.clone()),
_ => ()
@ -342,7 +342,7 @@ impl Matches {
pub fn opt_strs(&self, nm: &str) -> Vec<String> {
let mut acc: Vec<String> = Vec::new();
let r = self.opt_vals(nm);
for v in r.iter() {
for v in &r {
match *v {
Val(ref s) => acc.push((*s).clone()),
_ => ()
@ -395,7 +395,7 @@ fn find_opt(opts: &[Opt], nm: Name) -> Option<uint> {
}
// Search in aliases.
for candidate in opts.iter() {
for candidate in opts {
if candidate.aliases.iter().position(|opt| opt.name == nm).is_some() {
return opts.iter().position(|opt| opt.name == candidate.name);
}
@ -648,7 +648,7 @@ pub fn getopts(args: &[String], optgrps: &[OptGroup]) -> Result {
}
}
let mut name_pos = 0;
for nm in names.iter() {
for nm in &names {
name_pos += 1;
let optid = match find_opt(opts.as_slice(), (*nm).clone()) {
Some(id) => id,

View File

@ -548,7 +548,7 @@ pub fn render_opts<'a, N:Clone+'a, E:Clone+'a, G:Labeller<'a,N,E>+GraphWalk<'a,N
options: &[RenderOption]) -> old_io::IoResult<()>
{
fn writeln<W:Writer>(w: &mut W, arg: &[&str]) -> old_io::IoResult<()> {
for &s in arg.iter() { try!(w.write_str(s)); }
for &s in arg { try!(w.write_str(s)); }
w.write_char('\n')
}
@ -557,7 +557,7 @@ pub fn render_opts<'a, N:Clone+'a, E:Clone+'a, G:Labeller<'a,N,E>+GraphWalk<'a,N
}
try!(writeln(w, &["digraph ", g.graph_id().as_slice(), " {"]));
for n in g.nodes().iter() {
for n in &*g.nodes() {
try!(indent(w));
let id = g.node_id(n);
if options.contains(&RenderOption::NoNodeLabels) {
@ -569,7 +569,7 @@ pub fn render_opts<'a, N:Clone+'a, E:Clone+'a, G:Labeller<'a,N,E>+GraphWalk<'a,N
}
}
for e in g.edges().iter() {
for e in &*g.edges() {
let escaped_label = g.edge_label(e).escape();
try!(indent(w));
let source = g.source(e);

View File

@ -280,7 +280,8 @@ pub use funcs::bsd43::{shutdown};
#[cfg(any(target_os = "linux",
target_os = "android",
target_os = "freebsd",
target_os = "dragonfly"))]
target_os = "dragonfly",
target_os = "openbsd"))]
pub use consts::os::posix01::{CLOCK_REALTIME, CLOCK_MONOTONIC};
#[cfg(any(target_os = "linux", target_os = "android"))]
@ -290,7 +291,7 @@ pub use types::os::arch::extra::{sockaddr_ll};
#[cfg(any(target_os = "linux", target_os = "android"))]
pub use consts::os::extra::{AF_PACKET};
#[cfg(all(unix, not(target_os = "freebsd")))]
#[cfg(all(unix, not(any(target_os = "freebsd", target_os = "openbsd"))))]
pub use consts::os::extra::{MAP_STACK};
#[cfg(any(target_os = "freebsd", target_os = "dragonfly"))]
@ -1326,6 +1327,233 @@ pub mod types {
}
}
#[cfg(target_os = "openbsd")]
pub mod os {
pub mod common {
pub mod posix01 {
use types::common::c95::{c_void};
use types::os::arch::c95::{c_char, c_int, size_t,
time_t, suseconds_t, c_long};
use types::os::arch::c99::{uintptr_t};
pub type pthread_t = uintptr_t;
#[repr(C)]
#[derive(Copy)] pub struct glob_t {
pub gl_pathc: c_int,
pub __unused1: c_int,
pub gl_offs: c_int,
pub __unused2: c_int,
pub gl_pathv: *mut *mut c_char,
pub __unused3: *mut c_void,
pub __unused4: *mut c_void,
pub __unused5: *mut c_void,
pub __unused6: *mut c_void,
pub __unused7: *mut c_void,
pub __unused8: *mut c_void,
pub __unused9: *mut c_void,
}
#[repr(C)]
#[derive(Copy)] pub struct timeval {
pub tv_sec: time_t,
pub tv_usec: suseconds_t,
}
#[repr(C)]
#[derive(Copy)] pub struct timespec {
pub tv_sec: time_t,
pub tv_nsec: c_long,
}
#[derive(Copy)] pub enum timezone {}
pub type sighandler_t = size_t;
}
pub mod bsd44 {
use types::common::c95::{c_void};
use types::os::arch::c95::{c_char, c_int, c_uint};
pub type socklen_t = u32;
pub type sa_family_t = u8;
pub type in_port_t = u16;
pub type in_addr_t = u32;
#[repr(C)]
#[derive(Copy)] pub struct sockaddr {
pub sa_len: u8,
pub sa_family: sa_family_t,
pub sa_data: [u8; 14],
}
#[repr(C)]
#[derive(Copy)] pub struct sockaddr_storage {
pub ss_len: u8,
pub ss_family: sa_family_t,
pub __ss_pad1: [u8; 6],
pub __ss_pad2: i64,
pub __ss_pad3: [u8; 240],
}
#[repr(C)]
#[derive(Copy)] pub struct sockaddr_in {
pub sin_len: u8,
pub sin_family: sa_family_t,
pub sin_port: in_port_t,
pub sin_addr: in_addr,
pub sin_zero: [u8; 8],
}
#[repr(C)]
#[derive(Copy)] pub struct in_addr {
pub s_addr: in_addr_t,
}
#[repr(C)]
#[derive(Copy)] pub struct sockaddr_in6 {
pub sin6_len: u8,
pub sin6_family: sa_family_t,
pub sin6_port: in_port_t,
pub sin6_flowinfo: u32,
pub sin6_addr: in6_addr,
pub sin6_scope_id: u32,
}
#[repr(C)]
#[derive(Copy)] pub struct in6_addr {
pub s6_addr: [u16; 8]
}
#[repr(C)]
#[derive(Copy)] pub struct ip_mreq {
pub imr_multiaddr: in_addr,
pub imr_interface: in_addr,
}
#[repr(C)]
#[derive(Copy)] pub struct ip6_mreq {
pub ipv6mr_multiaddr: in6_addr,
pub ipv6mr_interface: c_uint,
}
#[repr(C)]
#[derive(Copy)] pub struct addrinfo {
pub ai_flags: c_int,
pub ai_family: c_int,
pub ai_socktype: c_int,
pub ai_protocol: c_int,
pub ai_addrlen: socklen_t,
pub ai_addr: *mut sockaddr,
pub ai_canonname: *mut c_char,
pub ai_next: *mut addrinfo,
}
#[repr(C)]
#[derive(Copy)] pub struct sockaddr_un {
pub sun_len: u8,
pub sun_family: sa_family_t,
pub sun_path: [c_char; 104]
}
#[repr(C)]
#[derive(Copy)] pub struct ifaddrs {
pub ifa_next: *mut ifaddrs,
pub ifa_name: *mut c_char,
pub ifa_flags: c_uint,
pub ifa_addr: *mut sockaddr,
pub ifa_netmask: *mut sockaddr,
pub ifa_dstaddr: *mut sockaddr,
pub ifa_data: *mut c_void
}
}
}
#[cfg(target_arch = "x86_64")]
pub mod arch {
pub mod c95 {
pub type c_char = i8;
pub type c_schar = i8;
pub type c_uchar = u8;
pub type c_short = i16;
pub type c_ushort = u16;
pub type c_int = i32;
pub type c_uint = u32;
pub type c_long = i64;
pub type c_ulong = u64;
pub type c_float = f32;
pub type c_double = f64;
pub type size_t = u64;
pub type ptrdiff_t = i64;
pub type clock_t = i64;
pub type time_t = i64;
pub type suseconds_t = i64;
pub type wchar_t = i32;
}
pub mod c99 {
pub type c_longlong = i64;
pub type c_ulonglong = u64;
pub type intptr_t = i64;
pub type uintptr_t = u64;
pub type intmax_t = i64;
pub type uintmax_t = u64;
}
pub mod posix88 {
pub type off_t = i64;
pub type dev_t = u32;
pub type ino_t = u64;
pub type pid_t = i32;
pub type uid_t = u32;
pub type gid_t = u32;
pub type useconds_t = u32;
pub type mode_t = u32;
pub type ssize_t = i64;
}
pub mod posix01 {
use types::common::c95::{c_void};
use types::common::c99::{uint32_t, uint64_t};
use types::os::arch::c95::{c_long, time_t};
use types::os::arch::posix88::{dev_t, gid_t};
use types::os::arch::posix88::{mode_t, off_t};
use types::os::arch::posix88::{uid_t};
pub type nlink_t = u32;
pub type blksize_t = uint32_t;
pub type ino_t = uint64_t;
pub type blkcnt_t = i64;
pub type fflags_t = u32; // type not declared, but struct stat have u_int32_t
#[repr(C)]
#[derive(Copy)] pub struct stat {
pub st_mode: mode_t,
pub st_dev: dev_t,
pub st_ino: ino_t,
pub st_nlink: nlink_t,
pub st_uid: uid_t,
pub st_gid: gid_t,
pub st_rdev: dev_t,
pub st_atime: time_t,
pub st_atime_nsec: c_long,
pub st_mtime: time_t,
pub st_mtime_nsec: c_long,
pub st_ctime: time_t,
pub st_ctime_nsec: c_long,
pub st_size: off_t,
pub st_blocks: blkcnt_t,
pub st_blksize: blksize_t,
pub st_flags: fflags_t,
pub st_gen: uint32_t,
pub st_birthtime: time_t,
pub st_birthtime_nsec: c_long,
}
#[repr(C)]
#[derive(Copy)] pub struct utimbuf {
pub actime: time_t,
pub modtime: time_t,
}
pub type pthread_attr_t = *mut c_void;
}
pub mod posix08 {
}
pub mod bsd44 {
}
pub mod extra {
}
}
}
#[cfg(target_os = "windows")]
pub mod os {
pub mod common {
@ -3254,7 +3482,8 @@ pub mod consts {
}
}
#[cfg(any(target_os = "freebsd", target_os = "dragonfly"))]
#[cfg(any(target_os = "freebsd",
target_os = "dragonfly"))]
pub mod os {
pub mod c95 {
use types::os::arch::c95::{c_int, c_uint};
@ -3663,6 +3892,401 @@ pub mod consts {
}
}
#[cfg(target_os = "openbsd")]
pub mod os {
pub mod c95 {
use types::os::arch::c95::{c_int, c_uint};
pub const EXIT_FAILURE : c_int = 1;
pub const EXIT_SUCCESS : c_int = 0;
pub const RAND_MAX : c_int = 2147483647;
pub const EOF : c_int = -1;
pub const SEEK_SET : c_int = 0;
pub const SEEK_CUR : c_int = 1;
pub const SEEK_END : c_int = 2;
pub const _IOFBF : c_int = 0;
pub const _IONBF : c_int = 2;
pub const _IOLBF : c_int = 1;
pub const BUFSIZ : c_uint = 1024_u32;
pub const FOPEN_MAX : c_uint = 20_u32;
pub const FILENAME_MAX : c_uint = 1024_u32;
pub const L_tmpnam : c_uint = 1024_u32;
pub const TMP_MAX : c_uint = 308915776_u32;
}
pub mod c99 {
}
pub mod posix88 {
use types::common::c95::c_void;
use types::os::arch::c95::c_int;
use types::os::arch::posix88::mode_t;
pub const O_RDONLY : c_int = 0;
pub const O_WRONLY : c_int = 1;
pub const O_RDWR : c_int = 2;
pub const O_APPEND : c_int = 8;
pub const O_CREAT : c_int = 512;
pub const O_EXCL : c_int = 2048;
pub const O_TRUNC : c_int = 1024;
pub const S_IFIFO : mode_t = 4096;
pub const S_IFCHR : mode_t = 8192;
pub const S_IFBLK : mode_t = 24576;
pub const S_IFDIR : mode_t = 16384;
pub const S_IFREG : mode_t = 32768;
pub const S_IFLNK : mode_t = 40960;
pub const S_IFMT : mode_t = 61440;
pub const S_IEXEC : mode_t = 64;
pub const S_IWRITE : mode_t = 128;
pub const S_IREAD : mode_t = 256;
pub const S_IRWXU : mode_t = 448;
pub const S_IXUSR : mode_t = 64;
pub const S_IWUSR : mode_t = 128;
pub const S_IRUSR : mode_t = 256;
pub const F_OK : c_int = 0;
pub const R_OK : c_int = 4;
pub const W_OK : c_int = 2;
pub const X_OK : c_int = 1;
pub const STDIN_FILENO : c_int = 0;
pub const STDOUT_FILENO : c_int = 1;
pub const STDERR_FILENO : c_int = 2;
pub const F_LOCK : c_int = 1;
pub const F_TEST : c_int = 3;
pub const F_TLOCK : c_int = 2;
pub const F_ULOCK : c_int = 0;
pub const SIGHUP : c_int = 1;
pub const SIGINT : c_int = 2;
pub const SIGQUIT : c_int = 3;
pub const SIGILL : c_int = 4;
pub const SIGABRT : c_int = 6;
pub const SIGFPE : c_int = 8;
pub const SIGKILL : c_int = 9;
pub const SIGSEGV : c_int = 11;
pub const SIGPIPE : c_int = 13;
pub const SIGALRM : c_int = 14;
pub const SIGTERM : c_int = 15;
pub const PROT_NONE : c_int = 0;
pub const PROT_READ : c_int = 1;
pub const PROT_WRITE : c_int = 2;
pub const PROT_EXEC : c_int = 4;
pub const MAP_FILE : c_int = 0x0000;
pub const MAP_SHARED : c_int = 0x0001;
pub const MAP_PRIVATE : c_int = 0x0002;
pub const MAP_FIXED : c_int = 0x0010;
pub const MAP_ANON : c_int = 0x1000;
pub const MAP_FAILED : *mut c_void = -1 as *mut c_void;
pub const MCL_CURRENT : c_int = 0x0001;
pub const MCL_FUTURE : c_int = 0x0002;
pub const MS_SYNC : c_int = 0x0002; // changed
pub const MS_ASYNC : c_int = 0x0001;
pub const MS_INVALIDATE : c_int = 0x0004; // changed
pub const EPERM : c_int = 1; // not checked
pub const ENOENT : c_int = 2;
pub const ESRCH : c_int = 3;
pub const EINTR : c_int = 4;
pub const EIO : c_int = 5;
pub const ENXIO : c_int = 6;
pub const E2BIG : c_int = 7;
pub const ENOEXEC : c_int = 8;
pub const EBADF : c_int = 9;
pub const ECHILD : c_int = 10;
pub const EDEADLK : c_int = 11;
pub const ENOMEM : c_int = 12;
pub const EACCES : c_int = 13;
pub const EFAULT : c_int = 14;
pub const ENOTBLK : c_int = 15;
pub const EBUSY : c_int = 16;
pub const EEXIST : c_int = 17;
pub const EXDEV : c_int = 18;
pub const ENODEV : c_int = 19;
pub const ENOTDIR : c_int = 20;
pub const EISDIR : c_int = 21;
pub const EINVAL : c_int = 22;
pub const ENFILE : c_int = 23;
pub const EMFILE : c_int = 24;
pub const ENOTTY : c_int = 25;
pub const ETXTBSY : c_int = 26;
pub const EFBIG : c_int = 27;
pub const ENOSPC : c_int = 28;
pub const ESPIPE : c_int = 29;
pub const EROFS : c_int = 30;
pub const EMLINK : c_int = 31;
pub const EPIPE : c_int = 32;
pub const EDOM : c_int = 33;
pub const ERANGE : c_int = 34;
pub const EAGAIN : c_int = 35;
pub const EWOULDBLOCK : c_int = 35;
pub const EINPROGRESS : c_int = 36;
pub const EALREADY : c_int = 37;
pub const ENOTSOCK : c_int = 38;
pub const EDESTADDRREQ : c_int = 39;
pub const EMSGSIZE : c_int = 40;
pub const EPROTOTYPE : c_int = 41;
pub const ENOPROTOOPT : c_int = 42;
pub const EPROTONOSUPPORT : c_int = 43;
pub const ESOCKTNOSUPPORT : c_int = 44;
pub const EOPNOTSUPP : c_int = 45;
pub const EPFNOSUPPORT : c_int = 46;
pub const EAFNOSUPPORT : c_int = 47;
pub const EADDRINUSE : c_int = 48;
pub const EADDRNOTAVAIL : c_int = 49;
pub const ENETDOWN : c_int = 50;
pub const ENETUNREACH : c_int = 51;
pub const ENETRESET : c_int = 52;
pub const ECONNABORTED : c_int = 53;
pub const ECONNRESET : c_int = 54;
pub const ENOBUFS : c_int = 55;
pub const EISCONN : c_int = 56;
pub const ENOTCONN : c_int = 57;
pub const ESHUTDOWN : c_int = 58;
pub const ETOOMANYREFS : c_int = 59;
pub const ETIMEDOUT : c_int = 60;
pub const ECONNREFUSED : c_int = 61;
pub const ELOOP : c_int = 62;
pub const ENAMETOOLONG : c_int = 63;
pub const EHOSTDOWN : c_int = 64;
pub const EHOSTUNREACH : c_int = 65;
pub const ENOTEMPTY : c_int = 66;
pub const EPROCLIM : c_int = 67;
pub const EUSERS : c_int = 68;
pub const EDQUOT : c_int = 69;
pub const ESTALE : c_int = 70;
pub const EREMOTE : c_int = 71;
pub const EBADRPC : c_int = 72;
pub const ERPCMISMATCH : c_int = 73;
pub const EPROGUNAVAIL : c_int = 74;
pub const EPROGMISMATCH : c_int = 75;
pub const EPROCUNAVAIL : c_int = 76;
pub const ENOLCK : c_int = 77;
pub const ENOSYS : c_int = 78;
pub const EFTYPE : c_int = 79;
pub const EAUTH : c_int = 80;
pub const ENEEDAUTH : c_int = 81;
pub const EIDRM : c_int = 82;
pub const ENOMSG : c_int = 83;
pub const EOVERFLOW : c_int = 84;
pub const ECANCELED : c_int = 85;
pub const EILSEQ : c_int = 86;
pub const ENOATTR : c_int = 87;
pub const EDOOFUS : c_int = 88;
pub const EBADMSG : c_int = 89;
pub const EMULTIHOP : c_int = 90;
pub const ENOLINK : c_int = 91;
pub const EPROTO : c_int = 92;
pub const ENOMEDIUM : c_int = 93;
pub const EUNUSED94 : c_int = 94;
pub const EUNUSED95 : c_int = 95;
pub const EUNUSED96 : c_int = 96;
pub const EUNUSED97 : c_int = 97;
pub const EUNUSED98 : c_int = 98;
pub const EASYNC : c_int = 99;
pub const ELAST : c_int = 99;
}
pub mod posix01 {
use types::os::arch::c95::{c_int, size_t};
pub const F_DUPFD : c_int = 0;
pub const F_GETFD : c_int = 1;
pub const F_SETFD : c_int = 2;
pub const F_GETFL : c_int = 3;
pub const F_SETFL : c_int = 4;
pub const SIGTRAP : c_int = 5;
pub const SIGPIPE: c_int = 13;
pub const SIG_IGN: size_t = 1;
pub const GLOB_APPEND : c_int = 0x0001;
pub const GLOB_DOOFFS : c_int = 0x0002;
pub const GLOB_ERR : c_int = 0x0004;
pub const GLOB_MARK : c_int = 0x0008;
pub const GLOB_NOCHECK : c_int = 0x0010;
pub const GLOB_NOSORT : c_int = 0x0020;
pub const GLOB_NOESCAPE : c_int = 0x1000; // changed
pub const GLOB_NOSPACE : c_int = -1;
pub const GLOB_ABORTED : c_int = -2;
pub const GLOB_NOMATCH : c_int = -3;
pub const POSIX_MADV_NORMAL : c_int = 0;
pub const POSIX_MADV_RANDOM : c_int = 1;
pub const POSIX_MADV_SEQUENTIAL : c_int = 2;
pub const POSIX_MADV_WILLNEED : c_int = 3;
pub const POSIX_MADV_DONTNEED : c_int = 4;
pub const _SC_IOV_MAX : c_int = 51; // all changed...
pub const _SC_GETGR_R_SIZE_MAX : c_int = 100;
pub const _SC_GETPW_R_SIZE_MAX : c_int = 101;
pub const _SC_LOGIN_NAME_MAX : c_int = 102;
pub const _SC_MQ_PRIO_MAX : c_int = 59;
pub const _SC_THREAD_ATTR_STACKADDR : c_int = 77;
pub const _SC_THREAD_ATTR_STACKSIZE : c_int = 78;
pub const _SC_THREAD_DESTRUCTOR_ITERATIONS : c_int = 80;
pub const _SC_THREAD_KEYS_MAX : c_int = 81;
pub const _SC_THREAD_PRIO_INHERIT : c_int = 82;
pub const _SC_THREAD_PRIO_PROTECT : c_int = 83;
pub const _SC_THREAD_PRIORITY_SCHEDULING : c_int = 84;
pub const _SC_THREAD_PROCESS_SHARED : c_int = 85;
pub const _SC_THREAD_SAFE_FUNCTIONS : c_int = 103;
pub const _SC_THREAD_STACK_MIN : c_int = 89;
pub const _SC_THREAD_THREADS_MAX : c_int = 90;
pub const _SC_THREADS : c_int = 91;
pub const _SC_TTY_NAME_MAX : c_int = 107;
pub const _SC_ATEXIT_MAX : c_int = 46;
pub const _SC_XOPEN_CRYPT : c_int = 117;
pub const _SC_XOPEN_ENH_I18N : c_int = 118;
pub const _SC_XOPEN_LEGACY : c_int = 119;
pub const _SC_XOPEN_REALTIME : c_int = 120;
pub const _SC_XOPEN_REALTIME_THREADS : c_int = 121;
pub const _SC_XOPEN_SHM : c_int = 30;
pub const _SC_XOPEN_UNIX : c_int = 123;
pub const _SC_XOPEN_VERSION : c_int = 125;
//pub const _SC_XOPEN_XCU_VERSION : c_int = ;
pub const PTHREAD_CREATE_JOINABLE: c_int = 0;
pub const PTHREAD_CREATE_DETACHED: c_int = 1;
pub const PTHREAD_STACK_MIN: size_t = 2048;
pub const CLOCK_REALTIME: c_int = 0;
pub const CLOCK_MONOTONIC: c_int = 3;
}
pub mod posix08 {
}
pub mod bsd44 {
use types::os::arch::c95::c_int;
pub const MADV_NORMAL : c_int = 0;
pub const MADV_RANDOM : c_int = 1;
pub const MADV_SEQUENTIAL : c_int = 2;
pub const MADV_WILLNEED : c_int = 3;
pub const MADV_DONTNEED : c_int = 4;
pub const MADV_FREE : c_int = 6; // changed
//pub const MADV_NOSYNC : c_int = ;
//pub const MADV_AUTOSYNC : c_int = ;
//pub const MADV_NOCORE : c_int = ;
//pub const MADV_CORE : c_int = ;
//pub const MADV_PROTECT : c_int = ;
//pub const MINCORE_INCORE : c_int = ;
//pub const MINCORE_REFERENCED : c_int = ;
//pub const MINCORE_MODIFIED : c_int = ;
//pub const MINCORE_REFERENCED_OTHER : c_int = ;
//pub const MINCORE_MODIFIED_OTHER : c_int = ;
//pub const MINCORE_SUPER : c_int = ;
pub const AF_INET: c_int = 2;
pub const AF_INET6: c_int = 24; // changed
pub const AF_UNIX: c_int = 1;
pub const SOCK_STREAM: c_int = 1;
pub const SOCK_DGRAM: c_int = 2;
pub const SOCK_RAW: c_int = 3;
pub const IPPROTO_TCP: c_int = 6;
pub const IPPROTO_IP: c_int = 0;
pub const IPPROTO_IPV6: c_int = 41;
pub const IP_MULTICAST_TTL: c_int = 10;
pub const IP_MULTICAST_LOOP: c_int = 11;
pub const IP_TTL: c_int = 4;
pub const IP_HDRINCL: c_int = 2;
pub const IP_ADD_MEMBERSHIP: c_int = 12;
pub const IP_DROP_MEMBERSHIP: c_int = 13;
// don't exist, keep same as IP_ADD_MEMBERSHIP
pub const IPV6_ADD_MEMBERSHIP: c_int = 12;
// don't exist, keep same as IP_DROP_MEMBERSHIP
pub const IPV6_DROP_MEMBERSHIP: c_int = 13;
pub const TCP_NODELAY: c_int = 1;
//pub const TCP_KEEPIDLE: c_int = ;
pub const SOL_SOCKET: c_int = 0xffff;
pub const SO_KEEPALIVE: c_int = 0x0008;
pub const SO_BROADCAST: c_int = 0x0020;
pub const SO_REUSEADDR: c_int = 0x0004;
pub const SO_ERROR: c_int = 0x1007;
pub const IFF_LOOPBACK: c_int = 0x8;
pub const SHUT_RD: c_int = 0;
pub const SHUT_WR: c_int = 1;
pub const SHUT_RDWR: c_int = 2;
}
pub mod extra {
use types::os::arch::c95::c_int;
pub const O_SYNC : c_int = 128;
pub const O_NONBLOCK : c_int = 4;
pub const CTL_KERN: c_int = 1;
pub const KERN_PROC: c_int = 66;
pub const MAP_COPY : c_int = 0x0002;
pub const MAP_RENAME : c_int = 0x0000; // changed
pub const MAP_NORESERVE : c_int = 0x0000; // changed
pub const MAP_HASSEMAPHORE : c_int = 0x0000; // changed
//pub const MAP_STACK : c_int = ;
//pub const MAP_NOSYNC : c_int = ;
//pub const MAP_NOCORE : c_int = ;
pub const IPPROTO_RAW : c_int = 255;
}
pub mod sysconf {
use types::os::arch::c95::c_int;
pub const _SC_ARG_MAX : c_int = 1;
pub const _SC_CHILD_MAX : c_int = 2;
pub const _SC_CLK_TCK : c_int = 3;
pub const _SC_NGROUPS_MAX : c_int = 4;
pub const _SC_OPEN_MAX : c_int = 5;
pub const _SC_JOB_CONTROL : c_int = 6;
pub const _SC_SAVED_IDS : c_int = 7;
pub const _SC_VERSION : c_int = 8;
pub const _SC_BC_BASE_MAX : c_int = 9;
pub const _SC_BC_DIM_MAX : c_int = 10;
pub const _SC_BC_SCALE_MAX : c_int = 11;
pub const _SC_BC_STRING_MAX : c_int = 12;
pub const _SC_COLL_WEIGHTS_MAX : c_int = 13;
pub const _SC_EXPR_NEST_MAX : c_int = 14;
pub const _SC_LINE_MAX : c_int = 15;
pub const _SC_RE_DUP_MAX : c_int = 16;
pub const _SC_2_VERSION : c_int = 17;
pub const _SC_2_C_BIND : c_int = 18;
pub const _SC_2_C_DEV : c_int = 19;
pub const _SC_2_CHAR_TERM : c_int = 20;
pub const _SC_2_FORT_DEV : c_int = 21;
pub const _SC_2_FORT_RUN : c_int = 22;
pub const _SC_2_LOCALEDEF : c_int = 23;
pub const _SC_2_SW_DEV : c_int = 24;
pub const _SC_2_UPE : c_int = 25;
pub const _SC_STREAM_MAX : c_int = 26;
pub const _SC_TZNAME_MAX : c_int = 27;
pub const _SC_ASYNCHRONOUS_IO : c_int = 45; // changed...
pub const _SC_MAPPED_FILES : c_int = 53;
pub const _SC_MEMLOCK : c_int = 54;
pub const _SC_MEMLOCK_RANGE : c_int = 55;
pub const _SC_MEMORY_PROTECTION : c_int = 56;
pub const _SC_MESSAGE_PASSING : c_int = 57;
pub const _SC_PRIORITIZED_IO : c_int = 60;
pub const _SC_PRIORITY_SCHEDULING : c_int = 61;
pub const _SC_REALTIME_SIGNALS : c_int = 64;
pub const _SC_SEMAPHORES : c_int = 67;
pub const _SC_FSYNC : c_int = 29;
pub const _SC_SHARED_MEMORY_OBJECTS : c_int = 68;
pub const _SC_SYNCHRONIZED_IO : c_int = 75;
pub const _SC_TIMERS : c_int = 94; // ...changed
pub const _SC_AIO_LISTIO_MAX : c_int = 42;
pub const _SC_AIO_MAX : c_int = 43;
pub const _SC_AIO_PRIO_DELTA_MAX : c_int = 44;
pub const _SC_DELAYTIMER_MAX : c_int = 50; // changed...
pub const _SC_MQ_OPEN_MAX : c_int = 58;
pub const _SC_PAGESIZE : c_int = 28;
pub const _SC_RTSIG_MAX : c_int = 66;
pub const _SC_SEM_NSEMS_MAX : c_int = 31;
pub const _SC_SEM_VALUE_MAX : c_int = 32;
pub const _SC_SIGQUEUE_MAX : c_int = 70;
pub const _SC_TIMER_MAX : c_int = 93;
}
}
#[cfg(any(target_os = "macos", target_os = "ios"))]
pub mod os {
pub mod c95 {
@ -4380,7 +5004,8 @@ pub mod funcs {
target_os = "macos",
target_os = "ios",
target_os = "freebsd",
target_os = "dragonfly"))]
target_os = "dragonfly",
target_os = "openbsd"))]
pub mod posix88 {
pub mod stat_ {
use types::os::arch::c95::{c_char, c_int};
@ -4394,6 +5019,7 @@ pub mod funcs {
#[cfg(any(target_os = "linux",
target_os = "freebsd",
target_os = "dragonfly",
target_os = "openbsd",
target_os = "android",
target_os = "ios"))]
pub fn fstat(fildes: c_int, buf: *mut stat) -> c_int;
@ -4408,6 +5034,7 @@ pub mod funcs {
#[cfg(any(target_os = "linux",
target_os = "freebsd",
target_os = "dragonfly",
target_os = "openbsd",
target_os = "android",
target_os = "ios"))]
pub fn stat(path: *const c_char, buf: *mut stat) -> c_int;
@ -4600,7 +5227,8 @@ pub mod funcs {
target_os = "macos",
target_os = "ios",
target_os = "freebsd",
target_os = "dragonfly"))]
target_os = "dragonfly",
target_os = "openbsd"))]
pub mod posix01 {
pub mod stat_ {
use types::os::arch::c95::{c_char, c_int};
@ -4610,6 +5238,7 @@ pub mod funcs {
#[cfg(any(target_os = "linux",
target_os = "freebsd",
target_os = "dragonfly",
target_os = "openbsd",
target_os = "android",
target_os = "ios"))]
pub fn lstat(path: *const c_char, buf: *mut stat) -> c_int;
@ -4717,7 +5346,8 @@ pub mod funcs {
target_os = "macos",
target_os = "ios",
target_os = "freebsd",
target_os = "dragonfly"))]
target_os = "dragonfly",
target_os = "openbsd"))]
pub mod posix08 {
pub mod unistd {
}
@ -4803,7 +5433,8 @@ pub mod funcs {
#[cfg(any(target_os = "macos",
target_os = "ios",
target_os = "freebsd",
target_os = "dragonfly"))]
target_os = "dragonfly",
target_os = "openbsd"))]
pub mod bsd44 {
use types::common::c95::{c_void};
use types::os::arch::c95::{c_char, c_uchar, c_int, c_uint, c_ulong, size_t};
@ -4866,7 +5497,9 @@ pub mod funcs {
}
}
#[cfg(any(target_os = "freebsd", target_os = "dragonfly"))]
#[cfg(any(target_os = "freebsd",
target_os = "dragonfly",
target_os = "openbsd"))]
pub mod extra {
}

View File

@ -173,15 +173,15 @@
#![feature(int_uint)]
#![feature(core)]
#![feature(io)]
#![feature(os)]
#![feature(std_misc)]
#![feature(env)]
use std::cell::RefCell;
use std::fmt;
use std::old_io::LineBufferedWriter;
use std::old_io;
use std::mem;
use std::os;
use std::env;
use std::ptr;
use std::rt;
use std::slice;
@ -397,9 +397,9 @@ fn enabled(level: u32,
/// This is not threadsafe at all, so initialization is performed through a
/// `Once` primitive (and this function is called from that primitive).
fn init() {
let (mut directives, filter) = match os::getenv("RUST_LOG") {
Some(spec) => directive::parse_logging_spec(&spec[]),
None => (Vec::new(), None),
let (mut directives, filter) = match env::var_string("RUST_LOG") {
Ok(spec) => directive::parse_logging_spec(&spec[]),
Err(..) => (Vec::new(), None),
};
// Sort the provided directives by length of their name, this allows a

View File

@ -194,7 +194,7 @@ impl<'a> SeedableRng<&'a [u32]> for ChaChaRng {
impl Rand for ChaChaRng {
fn rand<R: Rng>(other: &mut R) -> ChaChaRng {
let mut key : [u32; KEY_WORDS] = [0; KEY_WORDS];
for word in key.iter_mut() {
for word in &mut key {
*word = other.gen();
}
SeedableRng::from_seed(key.as_slice())

View File

@ -123,7 +123,7 @@ impl<'a, T: Clone> WeightedChoice<'a, T> {
// we convert the list from individual weights to cumulative
// weights so we can binary search. This *could* drop elements
// with weight == 0 as an optimisation.
for item in items.iter_mut() {
for item in &mut *items {
running_total = match running_total.checked_add(item.weight) {
Some(n) => n,
None => panic!("WeightedChoice::new called with a total weight \
@ -305,7 +305,7 @@ mod tests {
let mut rng = CountingRng { i: 0 };
for &val in expected.iter() {
for &val in &expected {
assert_eq!(wc.ind_sample(&mut rng), val)
}
}}

View File

@ -188,7 +188,7 @@ mod tests {
let v: &[($ty, $ty)] = &[(0, 10),
(10, 127),
(Int::min_value(), Int::max_value())];
for &(low, high) in v.iter() {
for &(low, high) in v {
let mut sampler: Range<$ty> = Range::new(low, high);
for _ in 0u..1000 {
let v = sampler.sample(&mut rng);
@ -214,7 +214,7 @@ mod tests {
(-1e35, -1e25),
(1e-35, 1e-25),
(-1e35, 1e35)];
for &(low, high) in v.iter() {
for &(low, high) in v {
let mut sampler: Range<$ty> = Range::new(low, high);
for _ in 0u..1000 {
let v = sampler.sample(&mut rng);

View File

@ -134,7 +134,7 @@ impl IsaacRng {
}
let r = [(0, MIDPOINT), (MIDPOINT, 0)];
for &(mr_offset, m2_offset) in r.iter() {
for &(mr_offset, m2_offset) in &r {
macro_rules! rngstepp {
($j:expr, $shift:expr) => {{
@ -373,7 +373,7 @@ impl Isaac64Rng {
}
}
for &(mr_offset, m2_offset) in MP_VEC.iter() {
for &(mr_offset, m2_offset) in &MP_VEC {
for base in (0..MIDPOINT / 4).map(|i| i * 4) {
macro_rules! rngstepp {

View File

@ -154,7 +154,7 @@ pub trait Rng : Sized {
// optimisations are on.
let mut count = 0;
let mut num = 0;
for byte in dest.iter_mut() {
for byte in dest {
if count == 0 {
// we could micro-optimise here by generating a u32 if
// we only need a few more bytes to fill the vector

View File

@ -225,7 +225,7 @@ mod test {
// To test that `fill_bytes` actually did something, check that the
// average of `v` is not 0.
let mut sum = 0.0;
for &x in v.iter() {
for &x in &v {
sum += x as f64;
}
assert!(sum / v.len() as f64 != 0.0);

View File

@ -23,8 +23,6 @@
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
html_root_url = "http://doc.rust-lang.org/nightly/")]
#![cfg_attr(not(stage0), allow(unused_mut))] // NOTE: remove after stage0 snap
#![feature(box_syntax)]
#![feature(collections)]
#![feature(core)]
@ -32,7 +30,7 @@
#![feature(int_uint)]
#![feature(io)]
#![feature(libc)]
#![feature(os)]
#![feature(env)]
#![feature(path)]
#![feature(quote)]
#![feature(rustc_diagnostic_macros)]

View File

@ -227,7 +227,7 @@ impl LintPass for TypeLimits {
if (negative && v > (min.abs() as u64)) ||
(!negative && v > (max.abs() as u64)) {
cx.span_lint(OVERFLOWING_LITERALS, e.span,
"literal out of range for its type");
&*format!("literal out of range for {:?}", t));
return;
}
}
@ -246,7 +246,7 @@ impl LintPass for TypeLimits {
};
if lit_val < min || lit_val > max {
cx.span_lint(OVERFLOWING_LITERALS, e.span,
"literal out of range for its type");
&*format!("literal out of range for {:?}", t));
}
},
ty::ty_float(t) => {
@ -263,7 +263,7 @@ impl LintPass for TypeLimits {
};
if lit_val < min || lit_val > max {
cx.span_lint(OVERFLOWING_LITERALS, e.span,
"literal out of range for its type");
&*format!("literal out of range for {:?}", t));
}
},
_ => ()
@ -459,7 +459,7 @@ impl LintPass for ImproperCTypes {
}
fn check_foreign_fn(cx: &Context, decl: &ast::FnDecl) {
for input in decl.inputs.iter() {
for input in &decl.inputs {
check_ty(cx, &*input.ty);
}
if let ast::Return(ref ret_ty) = decl.output {
@ -469,7 +469,7 @@ impl LintPass for ImproperCTypes {
match it.node {
ast::ItemForeignMod(ref nmod) if nmod.abi != abi::RustIntrinsic => {
for ni in nmod.items.iter() {
for ni in &nmod.items {
match ni.node {
ast::ForeignItemFn(ref decl, _) => check_foreign_fn(cx, &**decl),
ast::ForeignItemStatic(ref t, _) => check_ty(cx, &**t)
@ -532,7 +532,7 @@ impl LintPass for BoxPointers {
// If it's a struct, we also have to check the fields' types
match it.node {
ast::ItemStruct(ref struct_def, _) => {
for struct_field in struct_def.fields.iter() {
for struct_field in &struct_def.fields {
self.check_heap_type(cx, struct_field.span,
ty::node_id_to_type(cx.tcx, struct_field.node.id));
}
@ -592,7 +592,15 @@ impl LintPass for RawPointerDerive {
return
}
let did = match item.node {
ast::ItemImpl(..) => {
ast::ItemImpl(_, _, _, ref t_ref_opt, _, _) => {
// Deriving the Copy trait does not cause a warning
if let &Some(ref trait_ref) = t_ref_opt {
let def_id = ty::trait_ref_to_def_id(cx.tcx, trait_ref);
if Some(def_id) == cx.tcx.lang_items.copy_trait() {
return
}
}
match ty::node_id_to_type(cx.tcx, item.id).sty {
ty::ty_enum(did, _) => did,
ty::ty_struct(did, _) => did,
@ -683,7 +691,7 @@ impl LintPass for UnusedAttributes {
"no_builtins",
];
for &name in ATTRIBUTE_WHITELIST.iter() {
for &name in ATTRIBUTE_WHITELIST {
if attr.check_name(name) {
break;
}
@ -785,7 +793,7 @@ impl LintPass for UnusedResults {
}
fn check_must_use(cx: &Context, attrs: &[ast::Attribute], sp: Span) -> bool {
for attr in attrs.iter() {
for attr in attrs {
if attr.check_name("must_use") {
let mut msg = "unused result which must be used".to_string();
// check for #[must_use="..."]
@ -869,7 +877,7 @@ impl LintPass for NonCamelCaseTypes {
ast::ItemEnum(ref enum_definition, _) => {
if has_extern_repr { return }
self.check_case(cx, "type", it.ident, it.span);
for variant in enum_definition.variants.iter() {
for variant in &enum_definition.variants {
self.check_case(cx, "variant", variant.node.name, variant.span);
}
}
@ -878,7 +886,7 @@ impl LintPass for NonCamelCaseTypes {
}
fn check_generics(&mut self, cx: &Context, it: &ast::Generics) {
for gen in it.ty_params.iter() {
for gen in &*it.ty_params {
self.check_case(cx, "type parameter", gen.ident, gen.span);
}
}
@ -1048,7 +1056,7 @@ impl LintPass for NonSnakeCase {
fn check_struct_def(&mut self, cx: &Context, s: &ast::StructDef,
_: ast::Ident, _: &ast::Generics, _: ast::NodeId) {
for sf in s.fields.iter() {
for sf in &s.fields {
if let ast::StructField_ { kind: ast::NamedField(ident, _), .. } = sf.node {
self.check_snake_case(cx, "structure field", ident, sf.span);
}
@ -1346,7 +1354,7 @@ impl UnusedMut {
// avoid false warnings in match arms with multiple patterns
let mut mutables = FnvHashMap();
for p in pats.iter() {
for p in pats {
pat_util::pat_bindings(&cx.tcx.def_map, &**p, |mode, id, _, path1| {
let ident = path1.node;
if let ast::BindByValue(ast::MutMutable) = mode {
@ -1361,7 +1369,7 @@ impl UnusedMut {
}
let used_mutables = cx.tcx.used_mut_nodes.borrow();
for (_, v) in mutables.iter() {
for (_, v) in &mutables {
if !v.iter().any(|e| used_mutables.contains(e)) {
cx.span_lint(UNUSED_MUT, cx.tcx.map.span(v[0]),
"variable does not need to be mutable");
@ -1377,7 +1385,7 @@ impl LintPass for UnusedMut {
fn check_expr(&mut self, cx: &Context, e: &ast::Expr) {
if let ast::ExprMatch(_, ref arms, _) = e.node {
for a in arms.iter() {
for a in arms {
self.check_unused_mut_pat(cx, &a.pats[])
}
}
@ -1394,7 +1402,7 @@ impl LintPass for UnusedMut {
fn check_fn(&mut self, cx: &Context,
_: visit::FnKind, decl: &ast::FnDecl,
_: &ast::Block, _: Span, _: ast::NodeId) {
for a in decl.inputs.iter() {
for a in &decl.inputs {
self.check_unused_mut_pat(cx, slice::ref_slice(&a.pat));
}
}
@ -1871,7 +1879,7 @@ impl LintPass for UnconditionalRecursion {
if cx.current_level(UNCONDITIONAL_RECURSION) != Level::Allow {
let sess = cx.sess();
// offer some help to the programmer.
for call in self_call_spans.iter() {
for call in &self_call_spans {
sess.span_note(*call, "recursive call site")
}
sess.span_help(sp, "a `loop` may express intention better if this is on purpose")
@ -2006,7 +2014,7 @@ declare_lint! {
declare_lint! {
pub UNUSED_FEATURES,
Deny,
Warn,
"unused or unknown features found in crate-level #[feature] directives"
}

View File

@ -116,7 +116,7 @@ impl LintStore {
pub fn register_pass(&mut self, sess: Option<&Session>,
from_plugin: bool, pass: LintPassObject) {
for &lint in pass.get_lints().iter() {
for &lint in pass.get_lints() {
self.lints.push((*lint, from_plugin));
let id = LintId::of(*lint);
@ -260,7 +260,7 @@ impl LintStore {
}
pub fn process_command_line(&mut self, sess: &Session) {
for &(ref lint_name, level) in sess.opts.lint_opts.iter() {
for &(ref lint_name, level) in &sess.opts.lint_opts {
match self.find_lint(&lint_name[], sess, None) {
Some(lint_id) => self.set_level(lint_id, (level, CommandLine)),
None => {
@ -329,7 +329,7 @@ macro_rules! run_lints { ($cx:expr, $f:ident, $($args:expr),*) => ({
// Move the vector of passes out of `$cx` so that we can
// iterate over it mutably while passing `$cx` to the methods.
let mut passes = $cx.lints.passes.take().unwrap();
for obj in passes.iter_mut() {
for obj in &mut passes {
obj.$f($cx, $($args),*);
}
$cx.lints.passes = Some(passes);
@ -340,7 +340,7 @@ macro_rules! run_lints { ($cx:expr, $f:ident, $($args:expr),*) => ({
pub fn gather_attrs(attrs: &[ast::Attribute])
-> Vec<Result<(InternedString, Level, Span), Span>> {
let mut out = vec!();
for attr in attrs.iter() {
for attr in attrs {
let level = match Level::from_str(attr.name().get()) {
None => continue,
Some(lvl) => lvl,
@ -357,7 +357,7 @@ pub fn gather_attrs(attrs: &[ast::Attribute])
}
};
for meta in metas.iter() {
for meta in metas {
out.push(match meta.node {
ast::MetaWord(ref lint_name) => Ok((lint_name.clone(), level, meta.span)),
_ => Err(meta.span),
@ -417,11 +417,11 @@ pub fn raw_emit_lint(sess: &Session, lint: &'static Lint,
_ => sess.bug("impossible level in raw_emit_lint"),
}
for note in note.into_iter() {
if let Some(note) = note {
sess.note(&note[]);
}
for span in def.into_iter() {
if let Some(span) = def {
sess.span_note(span, "lint level defined here");
}
}
@ -492,7 +492,7 @@ impl<'a, 'tcx> Context<'a, 'tcx> {
// specified closure
let mut pushed = 0;
for result in gather_attrs(attrs).into_iter() {
for result in gather_attrs(attrs) {
let v = match result {
Err(span) => {
self.tcx.sess.span_err(span, "malformed lint attribute");
@ -519,7 +519,7 @@ impl<'a, 'tcx> Context<'a, 'tcx> {
}
};
for (lint_id, level, span) in v.into_iter() {
for (lint_id, level, span) in v {
let now = self.lints.get_level_source(lint_id).0;
if now == Forbid && level != Forbid {
let lint_name = lint_id.as_str();
@ -727,7 +727,7 @@ impl<'a, 'tcx> IdVisitingOperation for Context<'a, 'tcx> {
match self.tcx.sess.lints.borrow_mut().remove(&id) {
None => {}
Some(lints) => {
for (lint_id, span, msg) in lints.into_iter() {
for (lint_id, span, msg) in lints {
self.span_lint(lint_id.lint, span, &msg[])
}
}
@ -794,8 +794,8 @@ pub fn check_crate(tcx: &ty::ctxt,
// If we missed any lints added to the session, then there's a bug somewhere
// in the iteration code.
for (id, v) in tcx.sess.lints.borrow().iter() {
for &(lint, span, ref msg) in v.iter() {
for (id, v) in &*tcx.sess.lints.borrow() {
for &(lint, span, ref msg) in v {
tcx.sess.span_bug(span,
format!("unprocessed lint {} at {}: {}",
lint.as_str(), tcx.map.node_to_string(*id), *msg).as_slice())

View File

@ -162,7 +162,7 @@ impl<'a> CrateReader<'a> {
dump_crates(&self.sess.cstore);
}
for &(ref name, kind) in self.sess.opts.libs.iter() {
for &(ref name, kind) in &self.sess.opts.libs {
register_native_lib(self.sess, None, name.clone(), kind);
}
}
@ -235,7 +235,7 @@ impl<'a> CrateReader<'a> {
None
})
.collect::<Vec<&ast::Attribute>>();
for m in link_args.iter() {
for m in &link_args {
match m.value_str() {
Some(linkarg) => self.sess.cstore.add_used_link_args(linkarg.get()),
None => { /* fallthrough */ }
@ -250,7 +250,7 @@ impl<'a> CrateReader<'a> {
None
})
.collect::<Vec<&ast::Attribute>>();
for m in link_args.iter() {
for m in &link_args {
match m.meta_item_list() {
Some(items) => {
let kind = items.iter().find(|k| {
@ -330,6 +330,7 @@ impl<'a> CrateReader<'a> {
if found {
ret = Some(cnum);
}
return
}
// Alright, so we've gotten this far which means that `data` has the

View File

@ -382,7 +382,7 @@ pub fn get_stability(cstore: &cstore::CStore,
pub fn is_staged_api(cstore: &cstore::CStore, def: ast::DefId) -> bool {
let cdata = cstore.get_crate_data(def.krate);
let attrs = decoder::get_crate_attributes(cdata.data());
for attr in attrs.iter() {
for attr in &attrs {
if attr.name().get() == "staged_api" {
match attr.node.value.node { ast::MetaWord(_) => return true, _ => (/*pass*/) }
}

View File

@ -113,7 +113,7 @@ impl CStore {
pub fn iter_crate_data<I>(&self, mut i: I) where
I: FnMut(ast::CrateNum, &crate_metadata),
{
for (&k, v) in self.metas.borrow().iter() {
for (&k, v) in &*self.metas.borrow() {
i(k, &**v);
}
}
@ -122,7 +122,7 @@ impl CStore {
pub fn iter_crate_data_origins<I>(&self, mut i: I) where
I: FnMut(ast::CrateNum, &crate_metadata, Option<CrateSource>),
{
for (&k, v) in self.metas.borrow().iter() {
for (&k, v) in &*self.metas.borrow() {
let origin = self.get_used_crate_source(k);
origin.as_ref().map(|cs| { assert!(k == cs.cnum); });
i(k, &**v, origin);
@ -167,12 +167,12 @@ impl CStore {
ordering: &mut Vec<ast::CrateNum>) {
if ordering.contains(&cnum) { return }
let meta = cstore.get_crate_data(cnum);
for (_, &dep) in meta.cnum_map.iter() {
for (_, &dep) in &meta.cnum_map {
visit(cstore, dep, ordering);
}
ordering.push(cnum);
};
for (&num, _) in self.metas.borrow().iter() {
for (&num, _) in &*self.metas.borrow() {
visit(self, num, &mut ordering);
}
ordering.reverse();

View File

@ -1022,7 +1022,7 @@ pub fn get_methods_if_impl(intr: Rc<IdentInterner>,
});
let mut impl_methods = Vec::new();
for impl_method_id in impl_method_ids.iter() {
for impl_method_id in &impl_method_ids {
let impl_method_doc = lookup_item(impl_method_id.node, cdata.data());
let family = item_family(impl_method_doc);
match family {
@ -1189,7 +1189,7 @@ fn list_crate_attributes(md: rbml::Doc, hash: &Svh,
try!(write!(out, "=Crate Attributes ({})=\n", *hash));
let r = get_attributes(md);
for attr in r.iter() {
for attr in &r {
try!(write!(out, "{}\n", pprust::attribute_to_string(attr)));
}
@ -1232,7 +1232,7 @@ pub fn get_crate_deps(data: &[u8]) -> Vec<CrateDep> {
fn list_crate_deps(data: &[u8], out: &mut old_io::Writer) -> old_io::IoResult<()> {
try!(write!(out, "=External Dependencies=\n"));
for dep in get_crate_deps(data).iter() {
for dep in &get_crate_deps(data) {
try!(write!(out, "{} {}-{}\n", dep.cnum, dep.name, dep.hash));
}
try!(write!(out, "\n"));

View File

@ -288,7 +288,7 @@ fn encode_parent_item(rbml_w: &mut Encoder, id: DefId) {
fn encode_struct_fields(rbml_w: &mut Encoder,
fields: &[ty::field_ty],
origin: DefId) {
for f in fields.iter() {
for f in fields {
if f.name == special_idents::unnamed_field.name {
rbml_w.start_tag(tag_item_unnamed_field);
} else {
@ -316,7 +316,7 @@ fn encode_enum_variant_info(ecx: &EncodeContext,
let mut i = 0;
let vi = ty::enum_variants(ecx.tcx,
DefId { krate: ast::LOCAL_CRATE, node: id });
for variant in variants.iter() {
for variant in variants {
let def_id = local_def(variant.node.id);
index.push(entry {
val: variant.node.id as i64,
@ -367,7 +367,7 @@ fn encode_path<PI: Iterator<Item=PathElem>>(rbml_w: &mut Encoder, path: PI) {
let path = path.collect::<Vec<_>>();
rbml_w.start_tag(tag_path);
rbml_w.wr_tagged_u32(tag_path_len, path.len() as u32);
for pe in path.iter() {
for pe in &path {
let tag = match *pe {
ast_map::PathMod(_) => tag_path_elem_mod,
ast_map::PathName(_) => tag_path_elem_name
@ -402,8 +402,8 @@ fn encode_reexported_static_base_methods(ecx: &EncodeContext,
let impl_items = ecx.tcx.impl_items.borrow();
match ecx.tcx.inherent_impls.borrow().get(&exp.def_id) {
Some(implementations) => {
for base_impl_did in implementations.iter() {
for &method_did in (*impl_items)[*base_impl_did].iter() {
for base_impl_did in &**implementations {
for &method_did in &*(*impl_items)[*base_impl_did] {
let impl_item = ty::impl_or_trait_item(
ecx.tcx,
method_did.def_id());
@ -431,7 +431,7 @@ fn encode_reexported_static_trait_methods(ecx: &EncodeContext,
-> bool {
match ecx.tcx.trait_items_cache.borrow().get(&exp.def_id) {
Some(trait_items) => {
for trait_item in trait_items.iter() {
for trait_item in &**trait_items {
if let ty::MethodTraitItem(ref m) = *trait_item {
encode_reexported_static_method(rbml_w,
exp,
@ -517,9 +517,9 @@ fn encode_reexports(ecx: &EncodeContext,
path: PathElems) {
debug!("(encoding info for module) encoding reexports for {}", id);
match ecx.reexports.get(&id) {
Some(ref exports) => {
Some(exports) => {
debug!("(encoding info for module) found reexports for {}", id);
for exp in exports.iter() {
for exp in exports {
debug!("(encoding info for module) reexport '{}' ({}/{}) for \
{}",
exp.name,
@ -559,7 +559,7 @@ fn encode_info_for_mod(ecx: &EncodeContext,
debug!("(encoding info for module) encoding info for module ID {}", id);
// Encode info about all the module children.
for item in md.items.iter() {
for item in &md.items {
rbml_w.start_tag(tag_mod_child);
rbml_w.wr_str(&def_to_string(local_def(item.id))[]);
rbml_w.end_tag();
@ -665,9 +665,9 @@ fn encode_parent_sort(rbml_w: &mut Encoder, sort: char) {
fn encode_provided_source(rbml_w: &mut Encoder,
source_opt: Option<DefId>) {
for source in source_opt.iter() {
if let Some(source) = source_opt {
rbml_w.start_tag(tag_item_method_provided_source);
let s = def_to_string(*source);
let s = def_to_string(source);
rbml_w.writer.write_all(s.as_bytes());
rbml_w.end_tag();
}
@ -684,7 +684,7 @@ fn encode_info_for_struct(ecx: &EncodeContext,
let mut index = Vec::new();
/* We encode both private and public fields -- need to include
private fields to get the offsets right */
for field in fields.iter() {
for field in fields {
let nm = field.name;
let id = field.id.node;
@ -783,7 +783,7 @@ fn encode_generics<'a, 'tcx>(rbml_w: &mut Encoder,
rbml_w.wr_tagged_u64(tag_region_param_def_index,
param.index as u64);
for &bound_region in param.bounds.iter() {
for &bound_region in &param.bounds {
encode_region(ecx, rbml_w, bound_region);
}
@ -911,7 +911,7 @@ fn encode_info_for_associated_type(ecx: &EncodeContext,
fn encode_method_argument_names(rbml_w: &mut Encoder,
decl: &ast::FnDecl) {
rbml_w.start_tag(tag_method_argument_names);
for arg in decl.inputs.iter() {
for arg in &decl.inputs {
rbml_w.start_tag(tag_method_argument_name);
if let ast::PatIdent(_, ref path1, _) = arg.pat.node {
let name = token::get_ident(path1.node);
@ -926,7 +926,7 @@ fn encode_repr_attrs(rbml_w: &mut Encoder,
ecx: &EncodeContext,
attrs: &[ast::Attribute]) {
let mut repr_attrs = Vec::new();
for attr in attrs.iter() {
for attr in attrs {
repr_attrs.extend(attr::find_repr_attrs(ecx.tcx.sess.diagnostic(),
attr).into_iter());
}
@ -962,7 +962,7 @@ fn encode_inherent_implementations(ecx: &EncodeContext,
match ecx.tcx.inherent_impls.borrow().get(&def_id) {
None => {}
Some(implementations) => {
for &impl_def_id in implementations.iter() {
for &impl_def_id in &**implementations {
rbml_w.start_tag(tag_items_data_item_inherent_impl);
encode_def_id(rbml_w, impl_def_id);
rbml_w.end_tag();
@ -978,7 +978,7 @@ fn encode_extension_implementations(ecx: &EncodeContext,
match ecx.tcx.trait_impls.borrow().get(&trait_def_id) {
None => {}
Some(implementations) => {
for &impl_def_id in implementations.borrow().iter() {
for &impl_def_id in &*implementations.borrow() {
rbml_w.start_tag(tag_items_data_item_extension_impl);
encode_def_id(rbml_w, impl_def_id);
rbml_w.end_tag();
@ -1091,7 +1091,7 @@ fn encode_info_for_item(ecx: &EncodeContext,
encode_path(rbml_w, path);
// Encode all the items in this module.
for foreign_item in fm.items.iter() {
for foreign_item in &fm.items {
rbml_w.start_tag(tag_mod_child);
rbml_w.wr_str(&def_to_string(local_def(foreign_item.id))[]);
rbml_w.end_tag();
@ -1123,7 +1123,7 @@ fn encode_info_for_item(ecx: &EncodeContext,
encode_name(rbml_w, item.ident.name);
encode_attributes(rbml_w, &item.attrs[]);
encode_repr_attrs(rbml_w, ecx, &item.attrs[]);
for v in (*enum_definition).variants.iter() {
for v in &enum_definition.variants {
encode_variant_id(rbml_w, local_def(v.node.id));
}
encode_inlined_item(ecx, rbml_w, IIItemRef(item));
@ -1216,7 +1216,7 @@ fn encode_info_for_item(ecx: &EncodeContext,
}
_ => {}
}
for &item_def_id in items.iter() {
for &item_def_id in items {
rbml_w.start_tag(tag_item_impl_item);
match item_def_id {
ty::MethodTraitItemId(item_def_id) => {
@ -1230,7 +1230,7 @@ fn encode_info_for_item(ecx: &EncodeContext,
}
rbml_w.end_tag();
}
for ast_trait_ref in opt_trait.iter() {
if let Some(ref ast_trait_ref) = *opt_trait {
let trait_ref = ty::node_id_to_trait_ref(
tcx, ast_trait_ref.ref_id);
encode_trait_ref(rbml_w, ecx, &*trait_ref, tag_item_trait_ref);
@ -1314,7 +1314,7 @@ fn encode_info_for_item(ecx: &EncodeContext,
encode_attributes(rbml_w, &item.attrs[]);
encode_visibility(rbml_w, vis);
encode_stability(rbml_w, stab);
for &method_def_id in ty::trait_item_def_ids(tcx, def_id).iter() {
for &method_def_id in &*ty::trait_item_def_ids(tcx, def_id) {
rbml_w.start_tag(tag_item_trait_item);
match method_def_id {
ty::MethodTraitItemId(method_def_id) => {
@ -1589,7 +1589,7 @@ fn encode_index<T, F>(rbml_w: &mut Encoder, index: Vec<entry<T>>, mut write_fn:
T: Hash<SipHasher>,
{
let mut buckets: Vec<Vec<entry<T>>> = (0..256u16).map(|_| Vec::new()).collect();
for elt in index.into_iter() {
for elt in index {
let mut s = SipHasher::new();
elt.val.hash(&mut s);
let h = s.finish() as uint;
@ -1599,10 +1599,10 @@ fn encode_index<T, F>(rbml_w: &mut Encoder, index: Vec<entry<T>>, mut write_fn:
rbml_w.start_tag(tag_index);
let mut bucket_locs = Vec::new();
rbml_w.start_tag(tag_index_buckets);
for bucket in buckets.iter() {
for bucket in &buckets {
bucket_locs.push(rbml_w.writer.tell().unwrap());
rbml_w.start_tag(tag_index_buckets_bucket);
for elt in bucket.iter() {
for elt in bucket {
rbml_w.start_tag(tag_index_buckets_bucket_elt);
assert!(elt.pos < 0xffff_ffff);
{
@ -1616,7 +1616,7 @@ fn encode_index<T, F>(rbml_w: &mut Encoder, index: Vec<entry<T>>, mut write_fn:
}
rbml_w.end_tag();
rbml_w.start_tag(tag_index_table);
for pos in bucket_locs.iter() {
for pos in &bucket_locs {
assert!(*pos < 0xffff_ffff);
let wr: &mut SeekableMemWriter = rbml_w.writer;
wr.write_be_u32(*pos as u32);
@ -1660,7 +1660,7 @@ fn encode_meta_item(rbml_w: &mut Encoder, mi: &ast::MetaItem) {
rbml_w.start_tag(tag_meta_item_name);
rbml_w.writer.write_all(name.get().as_bytes());
rbml_w.end_tag();
for inner_item in items.iter() {
for inner_item in items {
encode_meta_item(rbml_w, &**inner_item);
}
rbml_w.end_tag();
@ -1670,7 +1670,7 @@ fn encode_meta_item(rbml_w: &mut Encoder, mi: &ast::MetaItem) {
fn encode_attributes(rbml_w: &mut Encoder, attrs: &[ast::Attribute]) {
rbml_w.start_tag(tag_attributes);
for attr in attrs.iter() {
for attr in attrs {
rbml_w.start_tag(tag_attribute);
rbml_w.wr_tagged_u8(tag_attribute_is_sugared_doc, attr.node.is_sugared_doc as u8);
encode_meta_item(rbml_w, &*attr.node.value);
@ -1694,7 +1694,7 @@ fn encode_paren_sugar(rbml_w: &mut Encoder, paren_sugar: bool) {
fn encode_associated_type_names(rbml_w: &mut Encoder, names: &[ast::Name]) {
rbml_w.start_tag(tag_associated_type_names);
for &name in names.iter() {
for &name in names {
rbml_w.wr_tagged_str(tag_associated_type_name, token::get_name(name).get());
}
rbml_w.end_tag();
@ -1726,7 +1726,7 @@ fn encode_crate_deps(rbml_w: &mut Encoder, cstore: &cstore::CStore) {
// Sanity-check the crate numbers
let mut expected_cnum = 1;
for n in deps.iter() {
for n in &deps {
assert_eq!(n.cnum, expected_cnum);
expected_cnum += 1;
}
@ -1740,7 +1740,7 @@ fn encode_crate_deps(rbml_w: &mut Encoder, cstore: &cstore::CStore) {
// but is enough to get transitive crate dependencies working.
rbml_w.start_tag(tag_crate_deps);
let r = get_ordered_deps(cstore);
for dep in r.iter() {
for dep in &r {
encode_crate_dep(rbml_w, (*dep).clone());
}
rbml_w.end_tag();
@ -1749,8 +1749,8 @@ fn encode_crate_deps(rbml_w: &mut Encoder, cstore: &cstore::CStore) {
fn encode_lang_items(ecx: &EncodeContext, rbml_w: &mut Encoder) {
rbml_w.start_tag(tag_lang_items);
for (i, def_id) in ecx.tcx.lang_items.items() {
for id in def_id.iter() {
for (i, &def_id) in ecx.tcx.lang_items.items() {
if let Some(id) = def_id {
if id.krate == ast::LOCAL_CRATE {
rbml_w.start_tag(tag_lang_items_item);
@ -1773,7 +1773,7 @@ fn encode_lang_items(ecx: &EncodeContext, rbml_w: &mut Encoder) {
}
}
for i in ecx.tcx.lang_items.missing.iter() {
for i in &ecx.tcx.lang_items.missing {
rbml_w.wr_tagged_u32(tag_lang_items_missing, *i as u32);
}
@ -1817,7 +1817,7 @@ fn encode_plugin_registrar_fn(ecx: &EncodeContext, rbml_w: &mut Encoder) {
fn encode_macro_defs(rbml_w: &mut Encoder,
krate: &ast::Crate) {
rbml_w.start_tag(tag_macro_defs);
for def in krate.exported_macros.iter() {
for def in &krate.exported_macros {
rbml_w.start_tag(tag_macro_def);
encode_name(rbml_w, def.ident.name);
@ -1911,7 +1911,7 @@ fn encode_misc_info(ecx: &EncodeContext,
rbml_w: &mut Encoder) {
rbml_w.start_tag(tag_misc_info);
rbml_w.start_tag(tag_misc_info_crate_items);
for item in krate.module.items.iter() {
for item in &krate.module.items {
rbml_w.start_tag(tag_mod_child);
rbml_w.wr_str(&def_to_string(local_def(item.id))[]);
rbml_w.end_tag();
@ -1935,7 +1935,7 @@ fn encode_misc_info(ecx: &EncodeContext,
fn encode_reachable_extern_fns(ecx: &EncodeContext, rbml_w: &mut Encoder) {
rbml_w.start_tag(tag_reachable_extern_fns);
for id in ecx.reachable.iter() {
for id in ecx.reachable {
if let Some(ast_map::NodeItem(i)) = ecx.tcx.map.find(*id) {
if let ast::ItemFn(_, _, abi, ref generics, _) = i.node {
if abi != abi::Rust && !generics.is_type_parameterized() {
@ -2150,7 +2150,7 @@ fn encode_metadata_inner(wr: &mut SeekableMemWriter,
stats.total_bytes = rbml_w.writer.tell().unwrap();
if tcx.sess.meta_stats() {
for e in rbml_w.writer.get_ref().iter() {
for e in rbml_w.writer.get_ref() {
if *e == 0 {
stats.zero_bytes += 1;
}

View File

@ -13,9 +13,9 @@
pub use self::FileMatch::*;
use std::collections::HashSet;
use std::env;
use std::old_io::fs::PathExtensions;
use std::old_io::fs;
use std::os;
use util::fs as myfs;
use session::search_paths::{SearchPaths, PathKind};
@ -66,7 +66,7 @@ impl<'a> FileSearch<'a> {
// Try RUST_PATH
if !found {
let rustpath = rust_path();
for path in rustpath.iter() {
for path in &rustpath {
let tlib_path = make_rustpkg_lib_path(
self.sysroot, path, self.triple);
debug!("is {} in visited_dirs? {}", tlib_path.display(),
@ -194,7 +194,7 @@ pub fn get_or_default_sysroot() -> Path {
})
}
match canonicalize(os::self_exe_name()) {
match canonicalize(env::current_exe().ok()) {
Some(mut p) => { p.pop(); p.pop(); p }
None => panic!("can't determine value for sysroot")
}
@ -207,7 +207,7 @@ static PATH_ENTRY_SEPARATOR: &'static str = ":";
/// Returns RUST_PATH as a string, without default paths added
pub fn get_rust_path() -> Option<String> {
os::getenv("RUST_PATH").map(|x| x.to_string())
env::var_string("RUST_PATH").ok()
}
/// Returns the value of RUST_PATH, as a list
@ -224,7 +224,7 @@ pub fn rust_path() -> Vec<Path> {
}
None => Vec::new()
};
let mut cwd = os::getcwd().unwrap();
let mut cwd = env::current_dir().unwrap();
// now add in default entries
let cwd_dot_rust = cwd.join(".rust");
if !env_rust_path.contains(&cwd_dot_rust) {
@ -243,8 +243,7 @@ pub fn rust_path() -> Vec<Path> {
}
cwd.pop();
}
let h = os::homedir();
for h in h.iter() {
if let Some(h) = env::home_dir() {
let p = h.join(".rust");
if !env_rust_path.contains(&p) && p.exists() {
env_rust_path.push(p);

View File

@ -425,7 +425,7 @@ impl<'a> Context<'a> {
// libraries corresponds to the crate id and hash criteria that this
// search is being performed for.
let mut libraries = Vec::new();
for (_hash, (rlibs, dylibs)) in candidates.into_iter() {
for (_hash, (rlibs, dylibs)) in candidates {
let mut metadata = None;
let rlib = self.extract_one(rlibs, "rlib", &mut metadata);
let dylib = self.extract_one(dylibs, "dylib", &mut metadata);
@ -452,7 +452,7 @@ impl<'a> Context<'a> {
&format!("multiple matching crates for `{}`",
self.crate_name)[]);
self.sess.note("candidates:");
for lib in libraries.iter() {
for lib in &libraries {
match lib.dylib {
Some((ref p, _)) => {
self.sess.note(&format!("path: {}",
@ -501,7 +501,7 @@ impl<'a> Context<'a> {
}
}
for (lib, kind) in m.into_iter() {
for (lib, kind) in m {
info!("{} reading metadata from: {}", flavor, lib.display());
let metadata = match get_metadata_section(self.target.options.is_like_osx,
&lib) {
@ -610,7 +610,7 @@ impl<'a> Context<'a> {
let mut rlibs = HashMap::new();
let mut dylibs = HashMap::new();
{
let mut locs = locs.iter().map(|l| Path::new(&l[])).filter(|loc| {
let locs = locs.iter().map(|l| Path::new(&l[])).filter(|loc| {
if !loc.exists() {
sess.err(&format!("extern location for {} does not exist: {}",
self.crate_name, loc.display())[]);

View File

@ -249,7 +249,7 @@ fn parse_vec_per_param_space<'a, 'tcx, T, F>(st: &mut PState<'a, 'tcx>,
F: FnMut(&mut PState<'a, 'tcx>) -> T,
{
let mut r = VecPerParamSpace::empty();
for &space in subst::ParamSpace::all().iter() {
for &space in &subst::ParamSpace::all() {
assert_eq!(next(st), '[');
while peek(st) != ']' {
r.push(space, f(st));

View File

@ -97,7 +97,7 @@ pub fn enc_ty<'a, 'tcx>(w: &mut SeekableMemWriter, cx: &ctxt<'a, 'tcx>, t: Ty<'t
}
ty::ty_tup(ref ts) => {
mywrite!(w, "T[");
for t in ts.iter() { enc_ty(w, cx, *t); }
for t in ts { enc_ty(w, cx, *t); }
mywrite!(w, "]");
}
ty::ty_uniq(typ) => { mywrite!(w, "~"); enc_ty(w, cx, typ); }
@ -206,9 +206,9 @@ fn enc_vec_per_param_space<'a, 'tcx, T, F>(w: &mut SeekableMemWriter,
mut op: F) where
F: FnMut(&mut SeekableMemWriter, &ctxt<'a, 'tcx>, &T),
{
for &space in subst::ParamSpace::all().iter() {
for &space in &subst::ParamSpace::all() {
mywrite!(w, "[");
for t in v.get_slice(space).iter() {
for t in v.get_slice(space) {
op(w, cx, t);
}
mywrite!(w, "]");
@ -337,7 +337,7 @@ pub fn enc_closure_ty<'a, 'tcx>(w: &mut SeekableMemWriter, cx: &ctxt<'a, 'tcx>,
fn enc_fn_sig<'a, 'tcx>(w: &mut SeekableMemWriter, cx: &ctxt<'a, 'tcx>,
fsig: &ty::PolyFnSig<'tcx>) {
mywrite!(w, "[");
for ty in fsig.0.inputs.iter() {
for ty in &fsig.0.inputs {
enc_ty(w, cx, *ty);
}
mywrite!(w, "]");
@ -357,7 +357,7 @@ fn enc_fn_sig<'a, 'tcx>(w: &mut SeekableMemWriter, cx: &ctxt<'a, 'tcx>,
}
pub fn enc_builtin_bounds(w: &mut SeekableMemWriter, _cx: &ctxt, bs: &ty::BuiltinBounds) {
for bound in bs.iter() {
for bound in bs {
match bound {
ty::BoundSend => mywrite!(w, "S"),
ty::BoundSized => mywrite!(w, "Z"),
@ -383,17 +383,17 @@ pub fn enc_bounds<'a, 'tcx>(w: &mut SeekableMemWriter, cx: &ctxt<'a, 'tcx>,
bs: &ty::ParamBounds<'tcx>) {
enc_builtin_bounds(w, cx, &bs.builtin_bounds);
for &r in bs.region_bounds.iter() {
for &r in &bs.region_bounds {
mywrite!(w, "R");
enc_region(w, cx, r);
}
for tp in bs.trait_bounds.iter() {
for tp in &bs.trait_bounds {
mywrite!(w, "I");
enc_trait_ref(w, cx, &*tp.0);
}
for tp in bs.projection_bounds.iter() {
for tp in &bs.projection_bounds {
mywrite!(w, "P");
enc_projection_predicate(w, cx, &tp.0);
}

View File

@ -766,7 +766,7 @@ fn encode_vec_per_param_space<T, F>(rbml_w: &mut Encoder,
mut f: F) where
F: FnMut(&mut Encoder, &T),
{
for &space in subst::ParamSpace::all().iter() {
for &space in &subst::ParamSpace::all() {
rbml_w.emit_from_vec(v.get_slice(space),
|rbml_w, n| Ok(f(rbml_w, n))).unwrap();
}
@ -1156,14 +1156,14 @@ fn encode_side_tables_for_id(ecx: &e::EncodeContext,
debug!("Encoding side tables for id {}", id);
for def in tcx.def_map.borrow().get(&id).iter() {
if let Some(def) = tcx.def_map.borrow().get(&id) {
rbml_w.tag(c::tag_table_def, |rbml_w| {
rbml_w.id(id);
rbml_w.tag(c::tag_table_val, |rbml_w| (*def).encode(rbml_w).unwrap());
})
}
for &ty in tcx.node_types.borrow().get(&id).iter() {
if let Some(ty) = tcx.node_types.borrow().get(&id) {
rbml_w.tag(c::tag_table_node_type, |rbml_w| {
rbml_w.id(id);
rbml_w.tag(c::tag_table_val, |rbml_w| {
@ -1172,7 +1172,7 @@ fn encode_side_tables_for_id(ecx: &e::EncodeContext,
})
}
for &item_substs in tcx.item_substs.borrow().get(&id).iter() {
if let Some(item_substs) = tcx.item_substs.borrow().get(&id) {
rbml_w.tag(c::tag_table_item_subst, |rbml_w| {
rbml_w.id(id);
rbml_w.tag(c::tag_table_val, |rbml_w| {
@ -1181,7 +1181,7 @@ fn encode_side_tables_for_id(ecx: &e::EncodeContext,
})
}
for &fv in tcx.freevars.borrow().get(&id).iter() {
if let Some(fv) = tcx.freevars.borrow().get(&id) {
rbml_w.tag(c::tag_table_freevars, |rbml_w| {
rbml_w.id(id);
rbml_w.tag(c::tag_table_val, |rbml_w| {
@ -1191,7 +1191,7 @@ fn encode_side_tables_for_id(ecx: &e::EncodeContext,
})
});
for freevar in fv.iter() {
for freevar in fv {
rbml_w.tag(c::tag_table_upvar_capture_map, |rbml_w| {
rbml_w.id(id);
rbml_w.tag(c::tag_table_val, |rbml_w| {
@ -1209,7 +1209,7 @@ fn encode_side_tables_for_id(ecx: &e::EncodeContext,
}
let lid = ast::DefId { krate: ast::LOCAL_CRATE, node: id };
for &type_scheme in tcx.tcache.borrow().get(&lid).iter() {
if let Some(type_scheme) = tcx.tcache.borrow().get(&lid) {
rbml_w.tag(c::tag_table_tcache, |rbml_w| {
rbml_w.id(id);
rbml_w.tag(c::tag_table_val, |rbml_w| {
@ -1218,7 +1218,7 @@ fn encode_side_tables_for_id(ecx: &e::EncodeContext,
})
}
for &type_param_def in tcx.ty_param_defs.borrow().get(&id).iter() {
if let Some(type_param_def) = tcx.ty_param_defs.borrow().get(&id) {
rbml_w.tag(c::tag_table_param_defs, |rbml_w| {
rbml_w.id(id);
rbml_w.tag(c::tag_table_val, |rbml_w| {
@ -1228,7 +1228,7 @@ fn encode_side_tables_for_id(ecx: &e::EncodeContext,
}
let method_call = MethodCall::expr(id);
for &method in tcx.method_map.borrow().get(&method_call).iter() {
if let Some(method) = tcx.method_map.borrow().get(&method_call) {
rbml_w.tag(c::tag_table_method_map, |rbml_w| {
rbml_w.id(id);
rbml_w.tag(c::tag_table_val, |rbml_w| {
@ -1237,7 +1237,7 @@ fn encode_side_tables_for_id(ecx: &e::EncodeContext,
})
}
for &trait_ref in tcx.object_cast_map.borrow().get(&id).iter() {
if let Some(trait_ref) = tcx.object_cast_map.borrow().get(&id) {
rbml_w.tag(c::tag_table_object_cast_map, |rbml_w| {
rbml_w.id(id);
rbml_w.tag(c::tag_table_val, |rbml_w| {
@ -1246,11 +1246,11 @@ fn encode_side_tables_for_id(ecx: &e::EncodeContext,
})
}
for &adjustment in tcx.adjustments.borrow().get(&id).iter() {
if let Some(adjustment) = tcx.adjustments.borrow().get(&id) {
match *adjustment {
_ if ty::adjust_is_object(adjustment) => {
let method_call = MethodCall::autoobject(id);
for &method in tcx.method_map.borrow().get(&method_call).iter() {
if let Some(method) = tcx.method_map.borrow().get(&method_call) {
rbml_w.tag(c::tag_table_method_map, |rbml_w| {
rbml_w.id(id);
rbml_w.tag(c::tag_table_val, |rbml_w| {
@ -1263,7 +1263,7 @@ fn encode_side_tables_for_id(ecx: &e::EncodeContext,
assert!(!ty::adjust_is_object(adjustment));
for autoderef in 0..adj.autoderefs {
let method_call = MethodCall::autoderef(id, autoderef);
for &method in tcx.method_map.borrow().get(&method_call).iter() {
if let Some(method) = tcx.method_map.borrow().get(&method_call) {
rbml_w.tag(c::tag_table_method_map, |rbml_w| {
rbml_w.id(id);
rbml_w.tag(c::tag_table_val, |rbml_w| {
@ -1287,7 +1287,7 @@ fn encode_side_tables_for_id(ecx: &e::EncodeContext,
})
}
for &closure_type in tcx.closure_tys.borrow().get(&ast_util::local_def(id)).iter() {
if let Some(closure_type) = tcx.closure_tys.borrow().get(&ast_util::local_def(id)) {
rbml_w.tag(c::tag_table_closure_tys, |rbml_w| {
rbml_w.id(id);
rbml_w.tag(c::tag_table_val, |rbml_w| {
@ -1296,11 +1296,11 @@ fn encode_side_tables_for_id(ecx: &e::EncodeContext,
})
}
for &&closure_kind in tcx.closure_kinds.borrow().get(&ast_util::local_def(id)).iter() {
if let Some(closure_kind) = tcx.closure_kinds.borrow().get(&ast_util::local_def(id)) {
rbml_w.tag(c::tag_table_closure_kinds, |rbml_w| {
rbml_w.id(id);
rbml_w.tag(c::tag_table_val, |rbml_w| {
encode_closure_kind(rbml_w, closure_kind)
encode_closure_kind(rbml_w, *closure_kind)
})
})
}

View File

@ -68,7 +68,7 @@ fn add_initial_dummy_node(g: &mut CFGGraph) -> CFGIndex {
impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
fn block(&mut self, blk: &ast::Block, pred: CFGIndex) -> CFGIndex {
let mut stmts_exit = pred;
for stmt in blk.stmts.iter() {
for stmt in &blk.stmts {
stmts_exit = self.stmt(&**stmt, stmts_exit);
}
@ -166,7 +166,7 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
self.pat(&*pats[0], pred)
} else {
let collect = self.add_dummy_node(&[]);
for pat in pats.iter() {
for pat in pats {
let pat_exit = self.pat(&**pat, pred);
self.add_contained_edge(pat_exit, collect);
}
@ -325,7 +325,7 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
let expr_exit = self.add_node(expr.id, &[]);
let mut cond_exit = discr_exit;
for arm in arms.iter() {
for arm in arms {
cond_exit = self.add_dummy_node(&[cond_exit]); // 2
let pats_exit = self.pats_any(&arm.pats[],
cond_exit); // 3
@ -522,7 +522,7 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
assert!(!self.exit_map.contains_key(&id));
self.exit_map.insert(id, node);
}
for &pred in preds.iter() {
for &pred in preds {
self.add_contained_edge(pred, node);
}
node
@ -574,7 +574,7 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
Some(_) => {
match self.tcx.def_map.borrow().get(&expr.id) {
Some(&def::DefLabel(loop_id)) => {
for l in self.loop_scopes.iter() {
for l in &self.loop_scopes {
if l.loop_id == loop_id {
return *l;
}

View File

@ -46,7 +46,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for CheckCrateVisitor<'a, 'tcx> {
}
ast::ItemEnum(ref enum_definition, _) => {
self.inside_const(|v| {
for var in enum_definition.variants.iter() {
for var in &enum_definition.variants {
if let Some(ref ex) = var.node.disr_expr {
v.visit_expr(&**ex);
}
@ -137,7 +137,7 @@ fn check_expr(v: &mut CheckCrateVisitor, e: &ast::Expr) {
}
ast::ExprBlock(ref block) => {
// Check all statements in the block
for stmt in block.stmts.iter() {
for stmt in &block.stmts {
let block_span_err = |&: span|
span_err!(v.tcx.sess, span, E0016,
"blocks in constants are limited to items and \

View File

@ -77,7 +77,7 @@ impl<'a> fmt::Debug for Matrix<'a> {
let total_width = column_widths.iter().map(|n| *n).sum() + column_count * 3 + 1;
let br = repeat('+').take(total_width).collect::<String>();
try!(write!(f, "{}\n", br));
for row in pretty_printed_matrix.into_iter() {
for row in pretty_printed_matrix {
try!(write!(f, "+"));
for (column, pat_str) in row.into_iter().enumerate() {
try!(write!(f, " "));
@ -157,7 +157,7 @@ fn check_expr(cx: &mut MatchCheckCtxt, ex: &ast::Expr) {
visit::walk_expr(cx, ex);
match ex.node {
ast::ExprMatch(ref scrut, ref arms, source) => {
for arm in arms.iter() {
for arm in arms {
// First, check legality of move bindings.
check_legality_of_move_bindings(cx,
arm.guard.is_some(),
@ -285,8 +285,8 @@ fn check_arms(cx: &MatchCheckCtxt,
source: ast::MatchSource) {
let mut seen = Matrix(vec![]);
let mut printed_if_let_err = false;
for &(ref pats, guard) in arms.iter() {
for pat in pats.iter() {
for &(ref pats, guard) in arms {
for pat in pats {
let v = vec![&**pat];
match is_useful(cx, &seen, &v[], LeaveOutWitness) {
@ -979,7 +979,7 @@ fn check_fn(cx: &mut MatchCheckCtxt,
visit::walk_fn(cx, kind, decl, body, sp);
for input in decl.inputs.iter() {
for input in &decl.inputs {
is_refutable(cx, &*input.pat, |pat| {
span_err!(cx.tcx.sess, input.pat.span, E0006,
"refutable pattern in function argument: `{}` not covered",
@ -1012,7 +1012,7 @@ fn check_legality_of_move_bindings(cx: &MatchCheckCtxt,
let tcx = cx.tcx;
let def_map = &tcx.def_map;
let mut by_ref_span = None;
for pat in pats.iter() {
for pat in pats {
pat_bindings(def_map, &**pat, |bm, _, span, _path| {
match bm {
ast::BindByRef(_) => {
@ -1039,7 +1039,7 @@ fn check_legality_of_move_bindings(cx: &MatchCheckCtxt,
}
};
for pat in pats.iter() {
for pat in pats {
walk_pat(&**pat, |p| {
if pat_is_binding(def_map, &*p) {
match p.node {

View File

@ -104,7 +104,7 @@ fn lookup_variant_by_id<'a>(tcx: &'a ty::ctxt,
-> Option<&'a Expr> {
fn variant_expr<'a>(variants: &'a [P<ast::Variant>], id: ast::NodeId)
-> Option<&'a Expr> {
for variant in variants.iter() {
for variant in variants {
if variant.node.id == id {
return variant.node.disr_expr.as_ref().map(|e| &**e);
}

View File

@ -399,7 +399,7 @@ impl<'a, 'tcx, O:DataFlowOperator> DataFlowContext<'a, 'tcx, O> {
let mut orig_kills = self.kills[start.. end].to_vec();
let mut changed = false;
for &node_id in edge.data.exiting_scopes.iter() {
for &node_id in &edge.data.exiting_scopes {
let opt_cfg_idx = self.nodeid_to_index.get(&node_id).map(|&i|i);
match opt_cfg_idx {
Some(cfg_idx) => {
@ -501,7 +501,7 @@ impl<'a, 'b, 'tcx, O:DataFlowOperator> PropagationContext<'a, 'b, 'tcx, O> {
fn reset(&mut self, bits: &mut [uint]) {
let e = if self.dfcx.oper.initial_value() {uint::MAX} else {0};
for b in bits.iter_mut() {
for b in bits {
*b = e;
}
}
@ -550,7 +550,7 @@ fn bits_to_string(words: &[uint]) -> String {
// Note: this is a little endian printout of bytes.
for &word in words.iter() {
for &word in words {
let mut v = word;
for _ in 0..uint::BYTES {
result.push(sep);

View File

@ -173,7 +173,7 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {
}
};
let fields = ty::lookup_struct_fields(self.tcx, id);
for pat in pats.iter() {
for pat in pats {
let field_id = fields.iter()
.find(|field| field.name == pat.node.ident.name).unwrap().id;
self.live_symbols.insert(field_id.node);
@ -318,7 +318,7 @@ fn has_allow_dead_code_or_lang_attr(attrs: &[ast::Attribute]) -> bool {
}
let dead_code = lint::builtin::DEAD_CODE.name_lower();
for attr in lint::gather_attrs(attrs).into_iter() {
for attr in lint::gather_attrs(attrs) {
match attr {
Ok((ref name, lint::Allow, _))
if name.get() == dead_code => return true,
@ -356,7 +356,7 @@ impl<'v> Visitor<'v> for LifeSeeder {
self.worklist.extend(enum_def.variants.iter().map(|variant| variant.node.id));
}
ast::ItemImpl(_, _, _, Some(ref _trait_ref), _, ref impl_items) => {
for impl_item in impl_items.iter() {
for impl_item in impl_items {
match *impl_item {
ast::MethodImplItem(ref method) => {
self.worklist.push(method.id);
@ -397,10 +397,10 @@ fn create_and_seed_worklist(tcx: &ty::ctxt,
// depending on whether a crate is built as bin or lib, and we want
// the warning to be consistent, we also seed the worklist with
// exported symbols.
for id in exported_items.iter() {
for id in exported_items {
worklist.push(*id);
}
for id in reachable_symbols.iter() {
for id in reachable_symbols {
worklist.push(*id);
}
@ -499,8 +499,8 @@ impl<'a, 'tcx> DeadVisitor<'a, 'tcx> {
match self.tcx.inherent_impls.borrow().get(&local_def(id)) {
None => (),
Some(impl_list) => {
for impl_did in impl_list.iter() {
for item_did in (*impl_items)[*impl_did].iter() {
for impl_did in &**impl_list {
for item_did in &(*impl_items)[*impl_did] {
if self.live_symbols.contains(&item_did.def_id()
.node) {
return true;
@ -536,7 +536,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for DeadVisitor<'a, 'tcx> {
} else {
match item.node {
ast::ItemEnum(ref enum_def, _) => {
for variant in enum_def.variants.iter() {
for variant in &enum_def.variants {
if self.should_warn_about_variant(&variant.node) {
self.warn_dead_code(variant.node.id, variant.span,
variant.node.name, "variant");

View File

@ -85,7 +85,7 @@ pub type Dependencies = FnvHashMap<config::CrateType, DependencyList>;
pub fn calculate(tcx: &ty::ctxt) {
let mut fmts = tcx.dependency_formats.borrow_mut();
for &ty in tcx.sess.crate_types.borrow().iter() {
for &ty in &*tcx.sess.crate_types.borrow() {
fmts.insert(ty, calculate_type(&tcx.sess, ty));
}
tcx.sess.abort_if_errors();
@ -148,7 +148,7 @@ fn calculate_type(sess: &session::Session,
debug!("adding dylib: {}", data.name);
add_library(sess, cnum, cstore::RequireDynamic, &mut formats);
let deps = csearch::get_dylib_dependency_formats(&sess.cstore, cnum);
for &(depnum, style) in deps.iter() {
for &(depnum, style) in &deps {
debug!("adding {:?}: {}", style,
sess.cstore.get_crate_data(depnum).name.clone());
add_library(sess, depnum, style, &mut formats);

View File

@ -139,7 +139,7 @@ fn configure_main(this: &mut EntryContext) {
but you have one or more functions named 'main' that are not \
defined at the crate level. Either move the definition or \
attach the `#[main]` attribute to override this behavior.");
for &(_, span) in this.non_main_fns.iter() {
for &(_, span) in &this.non_main_fns {
this.session.span_note(span, "here is a function named 'main'");
}
this.session.abort_if_errors();

View File

@ -342,7 +342,7 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
fn walk_arg_patterns(&mut self,
decl: &ast::FnDecl,
body: &ast::Block) {
for arg in decl.inputs.iter() {
for arg in &decl.inputs {
let arg_ty = return_if_err!(self.typer.node_ty(arg.pat.id));
let fn_body_scope = region::CodeExtent::from_node_id(body.id);
@ -372,7 +372,7 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
}
fn consume_exprs(&mut self, exprs: &Vec<P<ast::Expr>>) {
for expr in exprs.iter() {
for expr in exprs {
self.consume_expr(&**expr);
}
}
@ -476,7 +476,7 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
ast::ExprIf(ref cond_expr, ref then_blk, ref opt_else_expr) => {
self.consume_expr(&**cond_expr);
self.walk_block(&**then_blk);
for else_expr in opt_else_expr.iter() {
if let Some(ref else_expr) = *opt_else_expr {
self.consume_expr(&**else_expr);
}
}
@ -490,7 +490,7 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
self.borrow_expr(&**discr, ty::ReEmpty, ty::ImmBorrow, MatchDiscriminant);
// treatment of the discriminant is handled while walking the arms.
for arm in arms.iter() {
for arm in arms {
let mode = self.arm_move_mode(discr_cmt.clone(), arm);
let mode = mode.match_mode();
self.walk_arm(discr_cmt.clone(), arm, mode);
@ -511,11 +511,11 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
}
ast::ExprInlineAsm(ref ia) => {
for &(_, ref input) in ia.inputs.iter() {
for &(_, ref input) in &ia.inputs {
self.consume_expr(&**input);
}
for &(_, ref output, is_rw) in ia.outputs.iter() {
for &(_, ref output, is_rw) in &ia.outputs {
self.mutate_expr(expr, &**output,
if is_rw { WriteAndRead } else { JustWrite });
}
@ -572,7 +572,7 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
}
ast::ExprRet(ref opt_expr) => {
for expr in opt_expr.iter() {
if let Some(ref expr) = *opt_expr {
self.consume_expr(&**expr);
}
}
@ -715,11 +715,11 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
fn walk_block(&mut self, blk: &ast::Block) {
debug!("walk_block(blk.id={})", blk.id);
for stmt in blk.stmts.iter() {
for stmt in &blk.stmts {
self.walk_stmt(&**stmt);
}
for tail_expr in blk.expr.iter() {
if let Some(ref tail_expr) = blk.expr {
self.consume_expr(&**tail_expr);
}
}
@ -729,7 +729,7 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
fields: &Vec<ast::Field>,
opt_with: &Option<P<ast::Expr>>) {
// Consume the expressions supplying values for each field.
for field in fields.iter() {
for field in fields {
self.consume_expr(&*field.expr);
}
@ -762,7 +762,7 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
};
// Consume those fields of the with expression that are needed.
for with_field in with_fields.iter() {
for with_field in &with_fields {
if !contains_field_named(with_field, fields) {
let cmt_field = self.mc.cat_field(&*with_expr,
with_cmt.clone(),
@ -908,7 +908,7 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
match pass_args {
PassArgs::ByValue => {
self.consume_expr(receiver);
for &arg in rhs.iter() {
for &arg in &rhs {
self.consume_expr(arg);
}
@ -926,7 +926,7 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
let r = ty::ReScope(region::CodeExtent::from_node_id(expr.id));
let bk = ty::ImmBorrow;
for &arg in rhs.iter() {
for &arg in &rhs {
self.borrow_expr(arg, r, bk, OverloadedOperator);
}
return true;
@ -934,18 +934,18 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
fn arm_move_mode(&mut self, discr_cmt: mc::cmt<'tcx>, arm: &ast::Arm) -> TrackMatchMode<Span> {
let mut mode = Unknown;
for pat in arm.pats.iter() {
for pat in &arm.pats {
self.determine_pat_move_mode(discr_cmt.clone(), &**pat, &mut mode);
}
mode
}
fn walk_arm(&mut self, discr_cmt: mc::cmt<'tcx>, arm: &ast::Arm, mode: MatchMode) {
for pat in arm.pats.iter() {
for pat in &arm.pats {
self.walk_pat(discr_cmt.clone(), &**pat, mode);
}
for guard in arm.guard.iter() {
if let Some(ref guard) = arm.guard {
self.consume_expr(&**guard);
}
@ -1195,7 +1195,7 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,'tcx,TYPER> {
debug!("walk_captures({})", closure_expr.repr(self.tcx()));
ty::with_freevars(self.tcx(), closure_expr.id, |freevars| {
for freevar in freevars.iter() {
for freevar in freevars {
let id_var = freevar.def.def_id().node;
let upvar_id = ty::UpvarId { var_id: id_var,
closure_expr_id: closure_expr.id };

View File

@ -116,7 +116,7 @@ pub trait Combine<'tcx> : Sized {
{
let mut substs = subst::Substs::empty();
for &space in subst::ParamSpace::all().iter() {
for &space in &subst::ParamSpace::all() {
let a_tps = a_subst.types.get_slice(space);
let b_tps = b_subst.types.get_slice(space);
let tps = try!(self.tps(space, a_tps, b_tps));
@ -129,7 +129,7 @@ pub trait Combine<'tcx> : Sized {
}
(&NonerasedRegions(ref a), &NonerasedRegions(ref b)) => {
for &space in subst::ParamSpace::all().iter() {
for &space in &subst::ParamSpace::all() {
let a_regions = a.get_slice(space);
let b_regions = b.get_slice(space);
@ -139,7 +139,7 @@ pub trait Combine<'tcx> : Sized {
variances.regions.get_slice(space)
}
None => {
for _ in a_regions.iter() {
for _ in a_regions {
invariance.push(ty::Invariant);
}
&invariance[]

View File

@ -170,7 +170,7 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
errors: &Vec<RegionResolutionError<'tcx>>) {
let p_errors = self.process_errors(errors);
let errors = if p_errors.is_empty() { errors } else { &p_errors };
for error in errors.iter() {
for error in errors {
match error.clone() {
ConcreteFailure(origin, sub, sup) => {
self.report_concrete_failure(origin, sub, sup);
@ -222,7 +222,7 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
let mut trace_origins = Vec::new();
let mut same_regions = Vec::new();
let mut processed_errors = Vec::new();
for error in errors.iter() {
for error in errors {
match error.clone() {
ConcreteFailure(origin, sub, sup) => {
debug!("processing ConcreteFailure");
@ -257,7 +257,7 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
}
if !same_regions.is_empty() {
let common_scope_id = same_regions[0].scope_id;
for sr in same_regions.iter() {
for sr in &same_regions {
// Since ProcessedErrors is used to reconstruct the function
// declaration, we want to make sure that they are, in fact,
// from the same scope
@ -335,7 +335,7 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
same_frs: &FreeRegionsFromSameFn) {
let scope_id = same_frs.scope_id;
let (sub_fr, sup_fr) = (same_frs.sub_fr, same_frs.sup_fr);
for sr in same_regions.iter_mut() {
for sr in &mut *same_regions {
if sr.contains(&sup_fr.bound_region)
&& scope_id == sr.scope_id {
sr.push(sub_fr.bound_region);
@ -796,11 +796,11 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
var_origins: &[RegionVariableOrigin],
trace_origins: &[(TypeTrace<'tcx>, ty::type_err<'tcx>)],
same_regions: &[SameRegions]) {
for vo in var_origins.iter() {
for vo in var_origins {
self.report_inference_failure(vo.clone());
}
self.give_suggestion(same_regions);
for &(ref trace, terr) in trace_origins.iter() {
for &(ref trace, terr) in trace_origins {
self.report_type_error(trace.clone(), &terr);
}
}
@ -916,7 +916,7 @@ impl<'a, 'tcx> Rebuilder<'a, 'tcx> {
let mut ty_params = self.generics.ty_params.clone();
let where_clause = self.generics.where_clause.clone();
let mut kept_lifetimes = HashSet::new();
for sr in self.same_regions.iter() {
for sr in self.same_regions {
self.cur_anon.set(0);
self.offset_cur_anon();
let (anon_nums, region_names) =
@ -958,7 +958,7 @@ impl<'a, 'tcx> Rebuilder<'a, 'tcx> {
// vector of string and then sort them. However, it makes the
// choice of lifetime name deterministic and thus easier to test.
let mut names = Vec::new();
for rn in region_names.iter() {
for rn in region_names {
let lt_name = token::get_name(*rn).get().to_string();
names.push(lt_name);
}
@ -973,7 +973,7 @@ impl<'a, 'tcx> Rebuilder<'a, 'tcx> {
-> (HashSet<u32>, HashSet<ast::Name>) {
let mut anon_nums = HashSet::new();
let mut region_names = HashSet::new();
for br in same_regions.regions.iter() {
for br in &same_regions.regions {
match *br {
ty::BrAnon(i) => {
anon_nums.insert(i);
@ -989,8 +989,8 @@ impl<'a, 'tcx> Rebuilder<'a, 'tcx> {
fn extract_all_region_names(&self) -> HashSet<ast::Name> {
let mut all_region_names = HashSet::new();
for sr in self.same_regions.iter() {
for br in sr.regions.iter() {
for sr in self.same_regions {
for br in &sr.regions {
match *br {
ty::BrNamed(_, name) => {
all_region_names.insert(name);
@ -1123,11 +1123,11 @@ impl<'a, 'tcx> Rebuilder<'a, 'tcx> {
where_clause: ast::WhereClause)
-> ast::Generics {
let mut lifetimes = Vec::new();
for lt in add.iter() {
for lt in add {
lifetimes.push(ast::LifetimeDef { lifetime: *lt,
bounds: Vec::new() });
}
for lt in generics.lifetimes.iter() {
for lt in &generics.lifetimes {
if keep.contains(&lt.lifetime.name) ||
!remove.contains(&lt.lifetime.name) {
lifetimes.push((*lt).clone());
@ -1147,7 +1147,7 @@ impl<'a, 'tcx> Rebuilder<'a, 'tcx> {
region_names: &HashSet<ast::Name>)
-> Vec<ast::Arg> {
let mut new_inputs = Vec::new();
for arg in inputs.iter() {
for arg in inputs {
let new_ty = self.rebuild_arg_ty_or_output(&*arg.ty, lifetime,
anon_nums, region_names);
let possibly_new_arg = ast::Arg {
@ -1729,7 +1729,7 @@ struct LifeGiver {
impl LifeGiver {
fn with_taken(taken: &[ast::LifetimeDef]) -> LifeGiver {
let mut taken_ = HashSet::new();
for lt in taken.iter() {
for lt in taken {
let lt_name = token::get_name(lt.lifetime.name).get().to_string();
taken_.insert(lt_name);
}

View File

@ -176,7 +176,7 @@ impl<'tcx,C> HigherRankedRelations<'tcx> for C
// in both A and B. Replace the variable with the "first"
// bound region from A that we find it to be associated
// with.
for (a_br, a_r) in a_map.iter() {
for (a_br, a_r) in a_map {
if tainted.iter().any(|x| x == a_r) {
debug!("generalize_region(r0={:?}): \
replacing with {:?}, tainted={:?}",
@ -258,7 +258,7 @@ impl<'tcx,C> HigherRankedRelations<'tcx> for C
let mut a_r = None;
let mut b_r = None;
let mut only_new_vars = true;
for r in tainted.iter() {
for r in &tainted {
if is_var_in_set(a_vars, *r) {
if a_r.is_some() {
return fresh_bound_variable(infcx, debruijn);
@ -315,7 +315,7 @@ impl<'tcx,C> HigherRankedRelations<'tcx> for C
a_map: &FnvHashMap<ty::BoundRegion, ty::Region>,
r: ty::Region) -> ty::Region
{
for (a_br, a_r) in a_map.iter() {
for (a_br, a_r) in a_map {
if *a_r == r {
return ty::ReLateBound(ty::DebruijnIndex::new(1), *a_br);
}
@ -497,9 +497,9 @@ pub fn leak_check<'a,'tcx>(infcx: &InferCtxt<'a,'tcx>,
skol_map.repr(infcx.tcx));
let new_vars = infcx.region_vars_confined_to_snapshot(snapshot);
for (&skol_br, &skol) in skol_map.iter() {
for (&skol_br, &skol) in skol_map {
let tainted = infcx.tainted_regions(snapshot, skol);
for &tainted_region in tainted.iter() {
for &tainted_region in &tainted {
// Each skolemized should only be relatable to itself
// or new variables:
match tainted_region {

View File

@ -998,8 +998,8 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
mk_msg(resolved_expected.map(|t| self.ty_to_string(t)), actual_ty),
error_str)[]);
for err in err.iter() {
ty::note_and_explain_type_err(self.tcx, *err)
if let Some(err) = err {
ty::note_and_explain_type_err(self.tcx, err)
}
}
}

View File

@ -27,7 +27,7 @@ use util::ppaux::Repr;
use std::collections::hash_map::Entry::Vacant;
use std::old_io::{self, File};
use std::os;
use std::env;
use std::sync::atomic::{AtomicBool, Ordering, ATOMIC_BOOL_INIT};
use syntax::ast;
@ -59,13 +59,13 @@ pub fn maybe_print_constraints_for<'a, 'tcx>(region_vars: &RegionVarBindings<'a,
}
let requested_node : Option<ast::NodeId> =
os::getenv("RUST_REGION_GRAPH_NODE").and_then(|s| s.parse().ok());
env::var_string("RUST_REGION_GRAPH_NODE").ok().and_then(|s| s.parse().ok());
if requested_node.is_some() && requested_node != Some(subject_node) {
return;
}
let requested_output = os::getenv("RUST_REGION_GRAPH");
let requested_output = env::var_string("RUST_REGION_GRAPH").ok();
debug!("requested_output: {:?} requested_node: {:?}",
requested_output, requested_node);

View File

@ -667,7 +667,7 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
a, b);
}
VerifyGenericBound(_, _, a, ref bs) => {
for &b in bs.iter() {
for &b in bs {
consider_adding_bidirectional_edges(
&mut result_set, r,
a, b);
@ -1200,7 +1200,7 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
errors: &mut Vec<RegionResolutionError<'tcx>>)
{
let mut reg_reg_dups = FnvHashSet();
for verify in self.verifys.borrow().iter() {
for verify in &*self.verifys.borrow() {
match *verify {
VerifyRegSubReg(ref origin, sub, sup) => {
if self.is_subregion_of(sub, sup) {
@ -1333,7 +1333,7 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
}
let dummy_idx = graph.add_node(());
for (constraint, _) in constraints.iter() {
for (constraint, _) in &*constraints {
match *constraint {
ConstrainVarSubVar(a_id, b_id) => {
graph.add_edge(NodeIndex(a_id.index as uint),
@ -1393,8 +1393,8 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
lower_bounds.sort_by(|a, b| { free_regions_first(a, b) });
upper_bounds.sort_by(|a, b| { free_regions_first(a, b) });
for lower_bound in lower_bounds.iter() {
for upper_bound in upper_bounds.iter() {
for lower_bound in &lower_bounds {
for upper_bound in &upper_bounds {
if !self.is_subregion_of(lower_bound.region,
upper_bound.region) {
errors.push(SubSupConflict(
@ -1435,8 +1435,8 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
return;
}
for upper_bound_1 in upper_bounds.iter() {
for upper_bound_2 in upper_bounds.iter() {
for upper_bound_1 in &upper_bounds {
for upper_bound_2 in &upper_bounds {
match self.glb_concrete_regions(upper_bound_1.region,
upper_bound_2.region) {
Ok(_) => {}
@ -1554,7 +1554,7 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> {
changed = false;
iteration += 1;
debug!("---- {} Iteration {}{}", "#", tag, iteration);
for (constraint, _) in self.constraints.borrow().iter() {
for (constraint, _) in &*self.constraints.borrow() {
let edge_changed = body(constraint);
if edge_changed {
debug!("Updated due to constraint {}",

View File

@ -105,7 +105,7 @@ impl<'tcx> TypeVariableTable<'tcx> {
already instantiated")
};
for &(dir, vid) in relations.iter() {
for &(dir, vid) in &relations {
stack.push((ty, dir, vid));
}
@ -165,7 +165,7 @@ impl<'tcx> TypeVariableTable<'tcx> {
let mut escaping_types = Vec::new();
let actions_since_snapshot = self.values.actions_since_snapshot(&s.snapshot);
debug!("actions_since_snapshot.len() = {}", actions_since_snapshot.len());
for action in actions_since_snapshot.iter() {
for action in actions_since_snapshot {
match *action {
sv::UndoLog::NewElem(index) => {
// if any new variables were created during the

View File

@ -120,7 +120,7 @@ impl LanguageItems {
(self.fn_once_trait(), ty::FnOnceClosureKind),
];
for &(opt_def_id, kind) in def_id_kinds.iter() {
for &(opt_def_id, kind) in &def_id_kinds {
if Some(id) == opt_def_id {
return Some(kind);
}
@ -217,7 +217,7 @@ impl<'a> LanguageItemCollector<'a> {
}
pub fn extract(attrs: &[ast::Attribute]) -> Option<InternedString> {
for attribute in attrs.iter() {
for attribute in attrs {
match attribute.value_str() {
Some(ref value) if attribute.check_name("lang") => {
return Some(value.clone());

View File

@ -378,7 +378,7 @@ fn visit_fn(ir: &mut IrMaps,
debug!("creating fn_maps: {:?}", &fn_maps as *const IrMaps);
for arg in decl.inputs.iter() {
for arg in &decl.inputs {
pat_util::pat_bindings(&ir.tcx.def_map,
&*arg.pat,
|_bm, arg_id, _x, path1| {
@ -427,7 +427,7 @@ fn visit_local(ir: &mut IrMaps, local: &ast::Local) {
}
fn visit_arm(ir: &mut IrMaps, arm: &ast::Arm) {
for pat in arm.pats.iter() {
for pat in &arm.pats {
pat_util::pat_bindings(&ir.tcx.def_map, &**pat, |bm, p_id, sp, path1| {
debug!("adding local variable {} from match with bm {:?}",
p_id, bm);
@ -464,7 +464,7 @@ fn visit_expr(ir: &mut IrMaps, expr: &Expr) {
// construction site.
let mut call_caps = Vec::new();
ty::with_freevars(ir.tcx, expr.id, |freevars| {
for fv in freevars.iter() {
for fv in freevars {
if let DefLocal(rv) = fv.def {
let fv_ln = ir.add_live_node(FreeVarNode(fv.span));
call_caps.push(CaptureInfo {ln: fv_ln,
@ -1049,7 +1049,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
let ln = self.live_node(expr.id, expr.span);
self.init_empty(ln, succ);
let mut first_merge = true;
for arm in arms.iter() {
for arm in arms {
let body_succ =
self.propagate_through_expr(&*arm.body, succ);
let guard_succ =
@ -1445,12 +1445,12 @@ fn check_expr(this: &mut Liveness, expr: &Expr) {
}
ast::ExprInlineAsm(ref ia) => {
for &(_, ref input) in ia.inputs.iter() {
for &(_, ref input) in &ia.inputs {
this.visit_expr(&**input);
}
// Output operands must be lvalues
for &(_, ref out, _) in ia.outputs.iter() {
for &(_, ref out, _) in &ia.outputs {
this.check_lvalue(&**out);
this.visit_expr(&**out);
}
@ -1590,7 +1590,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
}
fn warn_about_unused_args(&self, decl: &ast::FnDecl, entry_ln: LiveNode) {
for arg in decl.inputs.iter() {
for arg in &decl.inputs {
pat_util::pat_bindings(&self.ir.tcx.def_map,
&*arg.pat,
|_bm, p_id, sp, path1| {
@ -1620,7 +1620,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
-> bool {
if !self.used_on_entry(ln, var) {
let r = self.should_warn(var);
for name in r.iter() {
if let Some(name) = r {
// annoying: for parameters in funcs like `fn(x: int)
// {ret}`, there is only one node, so asking about
@ -1634,10 +1634,10 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
if is_assigned {
self.ir.tcx.sess.add_lint(lint::builtin::UNUSED_VARIABLES, id, sp,
format!("variable `{}` is assigned to, but never used",
*name));
name));
} else {
self.ir.tcx.sess.add_lint(lint::builtin::UNUSED_VARIABLES, id, sp,
format!("unused variable: `{}`", *name));
format!("unused variable: `{}`", name));
}
}
true
@ -1653,9 +1653,9 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
var: Variable) {
if self.live_on_exit(ln, var).is_none() {
let r = self.should_warn(var);
for name in r.iter() {
if let Some(name) = r {
self.ir.tcx.sess.add_lint(lint::builtin::UNUSED_ASSIGNMENTS, id, sp,
format!("value assigned to `{}` is never read", *name));
format!("value assigned to `{}` is never read", name));
}
}
}

View File

@ -1208,7 +1208,7 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> {
}
}
Some(&def::DefConst(..)) => {
for subpat in subpats.iter() {
for subpat in subpats {
try!(self.cat_pattern_(cmt.clone(), &**subpat, op));
}
}
@ -1230,7 +1230,7 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> {
ast::PatStruct(_, ref field_pats, _) => {
// {f1: p1, ..., fN: pN}
for fp in field_pats.iter() {
for fp in field_pats {
let field_ty = try!(self.pat_ty(&*fp.node.pat)); // see (*2)
let cmt_field = self.cat_field(pat, cmt.clone(), fp.node.ident.name, field_ty);
try!(self.cat_pattern_(cmt_field, &*fp.node.pat, op));
@ -1259,15 +1259,15 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> {
ast::PatVec(ref before, ref slice, ref after) => {
let elt_cmt = try!(self.cat_index(pat, try!(self.deref_vec(pat, cmt))));
for before_pat in before.iter() {
for before_pat in before {
try!(self.cat_pattern_(elt_cmt.clone(), &**before_pat, op));
}
for slice_pat in slice.iter() {
if let Some(ref slice_pat) = *slice {
let slice_ty = try!(self.pat_ty(&**slice_pat));
let slice_cmt = self.cat_rvalue_node(pat.id(), pat.span(), slice_ty);
try!(self.cat_pattern_(slice_cmt, &**slice_pat, op));
}
for after_pat in after.iter() {
for after_pat in after {
try!(self.cat_pattern_(elt_cmt.clone(), &**after_pat, op));
}
}

View File

@ -353,7 +353,7 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
// this properly would result in the necessity of computing *type*
// reachability, which might result in a compile time loss.
fn mark_destructors_reachable(&mut self) {
for (_, destructor_def_id) in self.tcx.destructor_for_type.borrow().iter() {
for (_, destructor_def_id) in &*self.tcx.destructor_for_type.borrow() {
if destructor_def_id.krate == ast::LOCAL_CRATE {
self.reachable_symbols.insert(destructor_def_id.node);
}
@ -371,7 +371,7 @@ pub fn find_reachable(tcx: &ty::ctxt,
// other crates link to us, they're going to expect to be able to
// use the lang items, so we need to be sure to mark them as
// exported.
for id in exported_items.iter() {
for id in exported_items {
reachable_context.worklist.push(*id);
}
for (_, item) in tcx.lang_items.items() {

View File

@ -20,7 +20,7 @@ use syntax::ast;
use syntax::attr::AttrMetaMethods;
pub fn update_recursion_limit(sess: &Session, krate: &ast::Crate) {
for attr in krate.attrs.iter() {
for attr in &krate.attrs {
if !attr.check_name("recursion_limit") {
continue;
}

View File

@ -888,14 +888,14 @@ fn resolve_local(visitor: &mut RegionResolutionVisitor, local: &ast::Local) {
record_rvalue_scope(visitor, &**subexpr, blk_id);
}
ast::ExprStruct(_, ref fields, _) => {
for field in fields.iter() {
for field in fields {
record_rvalue_scope_if_borrow_expr(
visitor, &*field.expr, blk_id);
}
}
ast::ExprVec(ref subexprs) |
ast::ExprTup(ref subexprs) => {
for subexpr in subexprs.iter() {
for subexpr in subexprs {
record_rvalue_scope_if_borrow_expr(
visitor, &**subexpr, blk_id);
}

View File

@ -187,14 +187,14 @@ impl<'a, 'v> Visitor<'v> for LifetimeContext<'a> {
}
fn visit_generics(&mut self, generics: &ast::Generics) {
for ty_param in generics.ty_params.iter() {
for ty_param in &*generics.ty_params {
visit::walk_ty_param_bounds_helper(self, &ty_param.bounds);
match ty_param.default {
Some(ref ty) => self.visit_ty(&**ty),
None => {}
}
}
for predicate in generics.where_clause.predicates.iter() {
for predicate in &generics.where_clause.predicates {
match predicate {
&ast::WherePredicate::BoundPredicate(ast::WhereBoundPredicate{ ref bounded_ty,
ref bounds,
@ -207,7 +207,7 @@ impl<'a, 'v> Visitor<'v> for LifetimeContext<'a> {
.. }) => {
self.visit_lifetime_ref(lifetime);
for bound in bounds.iter() {
for bound in bounds {
self.visit_lifetime_ref(bound);
}
}
@ -229,7 +229,7 @@ impl<'a, 'v> Visitor<'v> for LifetimeContext<'a> {
self.with(LateScope(&trait_ref.bound_lifetimes, self.scope), |old_scope, this| {
this.check_lifetime_defs(old_scope, &trait_ref.bound_lifetimes);
for lifetime in trait_ref.bound_lifetimes.iter() {
for lifetime in &trait_ref.bound_lifetimes {
this.visit_lifetime_def(lifetime);
}
this.visit_trait_ref(&trait_ref.trait_ref)
@ -408,7 +408,7 @@ impl<'a> LifetimeContext<'a> {
let lifetime_i = &lifetimes[i];
let special_idents = [special_idents::static_lifetime];
for lifetime in lifetimes.iter() {
for lifetime in lifetimes {
if special_idents.iter().any(|&i| i.name == lifetime.lifetime.name) {
span_err!(self.sess, lifetime.lifetime.span, E0262,
"illegal lifetime parameter name: `{}`",
@ -431,7 +431,7 @@ impl<'a> LifetimeContext<'a> {
// It is a soft error to shadow a lifetime within a parent scope.
self.check_lifetime_def_for_shadowing(old_scope, &lifetime_i.lifetime);
for bound in lifetime_i.bounds.iter() {
for bound in &lifetime_i.bounds {
self.resolve_lifetime_ref(bound);
}
}
@ -535,10 +535,10 @@ fn early_bound_lifetime_names(generics: &ast::Generics) -> Vec<ast::Name> {
let mut collector =
FreeLifetimeCollector { early_bound: &mut early_bound,
late_bound: &mut late_bound };
for ty_param in generics.ty_params.iter() {
for ty_param in &*generics.ty_params {
visit::walk_ty_param_bounds_helper(&mut collector, &ty_param.bounds);
}
for predicate in generics.where_clause.predicates.iter() {
for predicate in &generics.where_clause.predicates {
match predicate {
&ast::WherePredicate::BoundPredicate(ast::WhereBoundPredicate{ref bounds,
ref bounded_ty,
@ -551,7 +551,7 @@ fn early_bound_lifetime_names(generics: &ast::Generics) -> Vec<ast::Name> {
..}) => {
collector.visit_lifetime_ref(lifetime);
for bound in bounds.iter() {
for bound in bounds {
collector.visit_lifetime_ref(bound);
}
}
@ -562,11 +562,11 @@ fn early_bound_lifetime_names(generics: &ast::Generics) -> Vec<ast::Name> {
// Any lifetime that either has a bound or is referenced by a
// bound is early.
for lifetime_def in generics.lifetimes.iter() {
for lifetime_def in &generics.lifetimes {
if !lifetime_def.bounds.is_empty() {
shuffle(&mut early_bound, &mut late_bound,
lifetime_def.lifetime.name);
for bound in lifetime_def.bounds.iter() {
for bound in &lifetime_def.bounds {
shuffle(&mut early_bound, &mut late_bound,
bound.name);
}

View File

@ -148,7 +148,7 @@ impl Index {
/// Construct the stability index for a crate being compiled.
pub fn build(sess: &Session, krate: &Crate) -> Index {
let mut staged_api = false;
for attr in krate.attrs.iter() {
for attr in &krate.attrs {
if attr.name().get() == "staged_api" {
match attr.node.value.node {
ast::MetaWord(_) => {
@ -273,7 +273,7 @@ pub fn check_item(tcx: &ty::ctxt, item: &ast::Item,
maybe_do_stability_check(tcx, id, item.span, cb);
}
ast::ItemTrait(_, _, ref supertraits, _) => {
for t in supertraits.iter() {
for t in &**supertraits {
if let ast::TraitTyParamBound(ref t, _) = *t {
let id = ty::trait_ref_to_def_id(tcx, &t.trait_ref);
maybe_do_stability_check(tcx, id, t.trait_ref.path.span, cb);
@ -410,11 +410,11 @@ pub fn check_unused_features(sess: &Session,
let mut active_lib_features: FnvHashMap<InternedString, Span>
= lib_features.clone().into_iter().collect();
for used_feature in used_lib_features.iter() {
for used_feature in used_lib_features {
active_lib_features.remove(used_feature);
}
for (_, &span) in active_lib_features.iter() {
for (_, &span) in &active_lib_features {
sess.add_lint(lint::builtin::UNUSED_FEATURES,
ast::CRATE_NODE_ID,
span,

View File

@ -241,7 +241,7 @@ pub struct SeparateVecsPerParamSpace<T> {
impl<T: fmt::Debug> fmt::Debug for VecPerParamSpace<T> {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
try!(write!(fmt, "VecPerParamSpace {{"));
for space in ParamSpace::all().iter() {
for space in &ParamSpace::all() {
try!(write!(fmt, "{:?}: {:?}, ", *space, self.get_slice(*space)));
}
try!(write!(fmt, "}}"));
@ -317,7 +317,7 @@ impl<T> VecPerParamSpace<T> {
///
/// Unlike the `extend` method in `Vec`, this should not be assumed
/// to be a cheap operation (even when amortized over many calls).
pub fn extend<I:Iterator<Item=T>>(&mut self, space: ParamSpace, mut values: I) {
pub fn extend<I:Iterator<Item=T>>(&mut self, space: ParamSpace, values: I) {
// This could be made more efficient, obviously.
for item in values {
self.push(space, item);
@ -352,7 +352,7 @@ impl<T> VecPerParamSpace<T> {
pub fn replace(&mut self, space: ParamSpace, elems: Vec<T>) {
// FIXME (#15435): slow; O(n^2); could enhance vec to make it O(n).
self.truncate(space, 0);
for t in elems.into_iter() {
for t in elems {
self.push(space, t);
}
}

View File

@ -35,7 +35,7 @@ provide an impl. To see what I mean, consider the body of `clone_slice`:
fn clone_slice<T:Clone>(x: &[T]) -> Vec<T> {
let mut v = Vec::new();
for e in x.iter() {
for e in &x {
v.push((*e).clone()); // (*)
}
}

Some files were not shown because too many files have changed in this diff Show More