mirror of
https://github.com/rust-lang/rust.git
synced 2025-01-31 17:12:53 +00:00
rollup merge of #21830: japaric/for-cleanup
Conflicts: src/librustc/metadata/filesearch.rs src/librustc_back/target/mod.rs src/libstd/os.rs src/libstd/sys/windows/os.rs src/libsyntax/ext/tt/macro_parser.rs src/libsyntax/print/pprust.rs src/test/compile-fail/issue-2149.rs
This commit is contained in:
commit
7335c7dd63
@ -277,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) {
|
||||
@ -305,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;
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
|
@ -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 {
|
||||
@ -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("",
|
||||
|
@ -27,7 +27,7 @@ static OS_TABLE: &'static [(&'static str, &'static str)] = &[
|
||||
];
|
||||
|
||||
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
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
}
|
||||
});
|
||||
|
@ -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())
|
||||
}
|
||||
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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)]
|
||||
|
@ -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);
|
||||
|
@ -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
|
||||
|
@ -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)));
|
||||
|
@ -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();
|
||||
|
@ -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![(), (), ()]);
|
||||
|
@ -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);
|
||||
}
|
||||
@ -924,7 +924,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 +984,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 +1112,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));
|
||||
}
|
||||
}
|
||||
|
@ -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};
|
||||
|
@ -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 {
|
||||
|
@ -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 {
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
@ -588,7 +588,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 +617,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 +638,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 +946,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)>,
|
||||
@ -2205,7 +2205,7 @@ impl<A, B, I, U, F> Iterator for FlatMap<A, B, I, U, F> where
|
||||
#[inline]
|
||||
fn next(&mut self) -> Option<B> {
|
||||
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)
|
||||
}
|
||||
@ -2238,7 +2238,7 @@ impl<A, B, I, U, F> DoubleEndedIterator for FlatMap<A, B, I, U, F> where
|
||||
#[inline]
|
||||
fn next_back(&mut self) -> Option<B> {
|
||||
loop {
|
||||
for inner in self.backiter.iter_mut() {
|
||||
if let Some(ref mut inner) = self.backiter {
|
||||
match inner.next_back() {
|
||||
None => (),
|
||||
y => return y
|
||||
|
@ -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)]
|
||||
|
@ -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 {
|
||||
|
@ -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
|
||||
|
@ -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> {
|
||||
|
@ -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];
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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)]
|
||||
|
@ -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,
|
||||
|
@ -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);
|
||||
|
@ -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())
|
||||
|
@ -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)
|
||||
}
|
||||
}}
|
||||
|
@ -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);
|
||||
|
@ -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 {
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
@ -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)]
|
||||
|
@ -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));
|
||||
}
|
||||
@ -691,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;
|
||||
}
|
||||
@ -793,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="..."]
|
||||
@ -877,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);
|
||||
}
|
||||
}
|
||||
@ -886,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);
|
||||
}
|
||||
}
|
||||
@ -1056,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);
|
||||
}
|
||||
@ -1354,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 {
|
||||
@ -1369,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");
|
||||
@ -1385,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[])
|
||||
}
|
||||
}
|
||||
@ -1402,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));
|
||||
}
|
||||
}
|
||||
@ -1879,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")
|
||||
|
@ -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(¬e[]);
|
||||
}
|
||||
|
||||
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())
|
||||
|
@ -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| {
|
||||
|
@ -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*/) }
|
||||
}
|
||||
|
@ -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();
|
||||
|
@ -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"));
|
||||
|
@ -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 ¶m.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;
|
||||
}
|
||||
|
@ -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(),
|
||||
@ -243,8 +243,7 @@ pub fn rust_path() -> Vec<Path> {
|
||||
}
|
||||
cwd.pop();
|
||||
}
|
||||
let h = env::home_dir();
|
||||
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);
|
||||
|
@ -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())[]);
|
||||
|
@ -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));
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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 \
|
||||
|
@ -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 {
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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");
|
||||
|
@ -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);
|
||||
|
@ -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();
|
||||
|
@ -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 };
|
||||
|
@ -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[]
|
||||
|
@ -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(<.lifetime.name) ||
|
||||
!remove.contains(<.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);
|
||||
}
|
||||
|
@ -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 {
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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 {}",
|
||||
|
@ -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
|
||||
|
@ -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());
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
@ -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() {
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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,
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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()); // (*)
|
||||
}
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ use util::ppaux::{Repr, UserString};
|
||||
|
||||
pub fn report_fulfillment_errors<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>,
|
||||
errors: &Vec<FulfillmentError<'tcx>>) {
|
||||
for error in errors.iter() {
|
||||
for error in errors {
|
||||
report_fulfillment_error(infcx, error);
|
||||
}
|
||||
}
|
||||
@ -68,7 +68,7 @@ fn report_on_unimplemented<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>,
|
||||
span: Span) -> Option<String> {
|
||||
let def_id = trait_ref.def_id;
|
||||
let mut report = None;
|
||||
for item in ty::get_attrs(infcx.tcx, def_id).iter() {
|
||||
for item in &*ty::get_attrs(infcx.tcx, def_id) {
|
||||
if item.check_name("rustc_on_unimplemented") {
|
||||
let err_sp = if item.meta().span == DUMMY_SP {
|
||||
span
|
||||
|
@ -125,7 +125,7 @@ impl<'tcx> FulfillmentContext<'tcx> {
|
||||
let mut selcx = SelectionContext::new(infcx, typer);
|
||||
let normalized = project::normalize_projection_type(&mut selcx, projection_ty, cause, 0);
|
||||
|
||||
for obligation in normalized.obligations.into_iter() {
|
||||
for obligation in normalized.obligations {
|
||||
self.register_predicate_obligation(infcx, obligation);
|
||||
}
|
||||
|
||||
@ -289,7 +289,7 @@ impl<'tcx> FulfillmentContext<'tcx> {
|
||||
|
||||
// Now go through all the successful ones,
|
||||
// registering any nested obligations for the future.
|
||||
for new_obligation in new_obligations.into_iter() {
|
||||
for new_obligation in new_obligations {
|
||||
self.register_predicate_obligation(selcx.infcx(), new_obligation);
|
||||
}
|
||||
}
|
||||
|
@ -438,7 +438,7 @@ pub fn normalize_param_env<'a,'tcx>(param_env: &ty::ParameterEnvironment<'a,'tcx
|
||||
let mut fulfill_cx = FulfillmentContext::new();
|
||||
let Normalized { value: predicates, obligations } =
|
||||
project::normalize(selcx, cause, ¶m_env.caller_bounds);
|
||||
for obligation in obligations.into_iter() {
|
||||
for obligation in obligations {
|
||||
fulfill_cx.register_predicate_obligation(selcx.infcx(), obligation);
|
||||
}
|
||||
try!(fulfill_cx.select_all_or_error(selcx.infcx(), param_env));
|
||||
|
@ -176,7 +176,7 @@ fn object_safety_violations_for_method<'tcx>(tcx: &ty::ctxt<'tcx>,
|
||||
// The `Self` type is erased, so it should not appear in list of
|
||||
// arguments or return type apart from the receiver.
|
||||
let ref sig = method.fty.sig;
|
||||
for &input_ty in sig.0.inputs[1..].iter() {
|
||||
for &input_ty in &sig.0.inputs[1..] {
|
||||
if contains_illegal_self_type_reference(tcx, trait_def_id, input_ty) {
|
||||
return Some(MethodViolationCode::ReferencesSelf);
|
||||
}
|
||||
|
@ -802,7 +802,7 @@ fn confirm_impl_candidate<'cx,'tcx>(
|
||||
|
||||
let impl_items = &impl_items_map[impl_vtable.impl_def_id];
|
||||
let mut impl_ty = None;
|
||||
for impl_item in impl_items.iter() {
|
||||
for impl_item in impl_items {
|
||||
let assoc_type = match impl_or_trait_items_map[impl_item.def_id()] {
|
||||
ty::TypeTraitItem(ref assoc_type) => assoc_type.clone(),
|
||||
ty::MethodTraitItem(..) => { continue; }
|
||||
|
@ -295,7 +295,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||
|
||||
fn evaluate_predicates_recursively<'a,'o,I>(&mut self,
|
||||
stack: Option<&TraitObligationStack<'o, 'tcx>>,
|
||||
mut predicates: I)
|
||||
predicates: I)
|
||||
-> EvaluationResult<'tcx>
|
||||
where I : Iterator<Item=&'a PredicateObligation<'tcx>>, 'tcx:'a
|
||||
{
|
||||
@ -1089,7 +1089,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||
debug!("assemble_candidates_from_impls(self_ty={})", self_ty.repr(self.tcx()));
|
||||
|
||||
let all_impls = self.all_impls(obligation.predicate.def_id());
|
||||
for &impl_def_id in all_impls.iter() {
|
||||
for &impl_def_id in &all_impls {
|
||||
self.infcx.probe(|snapshot| {
|
||||
let (skol_obligation_trait_pred, skol_map) =
|
||||
self.infcx().skolemize_late_bound_regions(&obligation.predicate, snapshot);
|
||||
|
@ -343,7 +343,7 @@ pub fn get_vtable_index_of_object_method<'tcx>(tcx: &ty::ctxt<'tcx>,
|
||||
}
|
||||
|
||||
let trait_items = ty::trait_items(tcx, bound_ref.def_id());
|
||||
for trait_item in trait_items.iter() {
|
||||
for trait_item in &**trait_items {
|
||||
match *trait_item {
|
||||
ty::MethodTraitItem(_) => method_count += 1,
|
||||
ty::TypeTraitItem(_) => {}
|
||||
|
@ -872,7 +872,7 @@ macro_rules! sty_debug_print {
|
||||
$(let mut $variant = total;)*
|
||||
|
||||
|
||||
for (_, t) in tcx.interner.borrow().iter() {
|
||||
for (_, t) in &*tcx.interner.borrow() {
|
||||
let variant = match t.sty {
|
||||
ty::ty_bool | ty::ty_char | ty::ty_int(..) | ty::ty_uint(..) |
|
||||
ty::ty_float(..) | ty::ty_str => continue,
|
||||
@ -2579,7 +2579,7 @@ impl FlagComputation {
|
||||
&ty_trait(box TyTrait { ref principal, ref bounds }) => {
|
||||
let mut computation = FlagComputation::new();
|
||||
computation.add_substs(principal.0.substs);
|
||||
for projection_bound in bounds.projection_bounds.iter() {
|
||||
for projection_bound in &bounds.projection_bounds {
|
||||
let mut proj_computation = FlagComputation::new();
|
||||
proj_computation.add_projection_predicate(&projection_bound.0);
|
||||
computation.add_bound_computation(&proj_computation);
|
||||
@ -2618,7 +2618,7 @@ impl FlagComputation {
|
||||
}
|
||||
|
||||
fn add_tys(&mut self, tys: &[Ty]) {
|
||||
for &ty in tys.iter() {
|
||||
for &ty in tys {
|
||||
self.add_ty(ty);
|
||||
}
|
||||
}
|
||||
@ -3530,7 +3530,7 @@ pub fn type_contents<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> TypeContents {
|
||||
// make no assumptions (other than that it cannot have an
|
||||
// in-scope type parameter within, which makes no sense).
|
||||
let mut tc = TC::All - TC::InteriorParam;
|
||||
for bound in bounds.builtin_bounds.iter() {
|
||||
for bound in &bounds.builtin_bounds {
|
||||
tc = tc - match bound {
|
||||
BoundSync | BoundSend | BoundCopy => TC::None,
|
||||
BoundSized => TC::Nonsized,
|
||||
@ -4644,7 +4644,7 @@ pub fn stmt_node_id(s: &ast::Stmt) -> ast::NodeId {
|
||||
pub fn field_idx_strict(tcx: &ctxt, name: ast::Name, fields: &[field])
|
||||
-> uint {
|
||||
let mut i = 0;
|
||||
for f in fields.iter() { if f.name == name { return i; } i += 1; }
|
||||
for f in fields { if f.name == name { return i; } i += 1; }
|
||||
tcx.sess.bug(&format!(
|
||||
"no field named `{}` found in the list of fields `{:?}`",
|
||||
token::get_name(name),
|
||||
@ -5468,25 +5468,25 @@ pub fn predicates<'tcx>(
|
||||
{
|
||||
let mut vec = Vec::new();
|
||||
|
||||
for builtin_bound in bounds.builtin_bounds.iter() {
|
||||
for builtin_bound in &bounds.builtin_bounds {
|
||||
match traits::trait_ref_for_builtin_bound(tcx, builtin_bound, param_ty) {
|
||||
Ok(trait_ref) => { vec.push(trait_ref.as_predicate()); }
|
||||
Err(ErrorReported) => { }
|
||||
}
|
||||
}
|
||||
|
||||
for ®ion_bound in bounds.region_bounds.iter() {
|
||||
for ®ion_bound in &bounds.region_bounds {
|
||||
// account for the binder being introduced below; no need to shift `param_ty`
|
||||
// because, at present at least, it can only refer to early-bound regions
|
||||
let region_bound = ty_fold::shift_region(region_bound, 1);
|
||||
vec.push(ty::Binder(ty::OutlivesPredicate(param_ty, region_bound)).as_predicate());
|
||||
}
|
||||
|
||||
for bound_trait_ref in bounds.trait_bounds.iter() {
|
||||
for bound_trait_ref in &bounds.trait_bounds {
|
||||
vec.push(bound_trait_ref.as_predicate());
|
||||
}
|
||||
|
||||
for projection in bounds.projection_bounds.iter() {
|
||||
for projection in &bounds.projection_bounds {
|
||||
vec.push(projection.as_predicate());
|
||||
}
|
||||
|
||||
@ -5931,17 +5931,17 @@ pub fn populate_implementations_for_type_if_necessary(tcx: &ctxt,
|
||||
|
||||
// Record the trait->implementation mappings, if applicable.
|
||||
let associated_traits = csearch::get_impl_trait(tcx, impl_def_id);
|
||||
for trait_ref in associated_traits.iter() {
|
||||
if let Some(ref trait_ref) = associated_traits {
|
||||
record_trait_implementation(tcx, trait_ref.def_id, impl_def_id);
|
||||
}
|
||||
|
||||
// For any methods that use a default implementation, add them to
|
||||
// the map. This is a bit unfortunate.
|
||||
for impl_item_def_id in impl_items.iter() {
|
||||
for impl_item_def_id in &impl_items {
|
||||
let method_def_id = impl_item_def_id.def_id();
|
||||
match impl_or_trait_item(tcx, method_def_id) {
|
||||
MethodTraitItem(method) => {
|
||||
for &source in method.provided_source.iter() {
|
||||
if let Some(source) = method.provided_source {
|
||||
tcx.provided_method_sources
|
||||
.borrow_mut()
|
||||
.insert(method_def_id, source);
|
||||
@ -5985,11 +5985,11 @@ pub fn populate_implementations_for_trait_if_necessary(
|
||||
|
||||
// For any methods that use a default implementation, add them to
|
||||
// the map. This is a bit unfortunate.
|
||||
for impl_item_def_id in impl_items.iter() {
|
||||
for impl_item_def_id in &impl_items {
|
||||
let method_def_id = impl_item_def_id.def_id();
|
||||
match impl_or_trait_item(tcx, method_def_id) {
|
||||
MethodTraitItem(method) => {
|
||||
for &source in method.provided_source.iter() {
|
||||
if let Some(source) = method.provided_source {
|
||||
tcx.provided_method_sources
|
||||
.borrow_mut()
|
||||
.insert(method_def_id, source);
|
||||
@ -6121,7 +6121,7 @@ pub fn hash_crate_independent<'tcx>(tcx: &ctxt<'tcx>, ty: Ty<'tcx>, svh: &Svh) -
|
||||
};
|
||||
let fn_sig = |&: state: &mut SipHasher, sig: &Binder<FnSig<'tcx>>| {
|
||||
let sig = anonymize_late_bound_regions(tcx, sig).0;
|
||||
for a in sig.inputs.iter() { helper(tcx, *a, svh, state); }
|
||||
for a in &sig.inputs { helper(tcx, *a, svh, state); }
|
||||
if let ty::FnConverging(output) = sig.output {
|
||||
helper(tcx, output, svh, state);
|
||||
}
|
||||
@ -6270,7 +6270,7 @@ pub fn construct_free_substs<'a,'tcx>(
|
||||
free_id: ast::NodeId,
|
||||
region_params: &[RegionParameterDef])
|
||||
{
|
||||
for r in region_params.iter() {
|
||||
for r in region_params {
|
||||
regions.push(r.space, ty::free_region_from_def(free_id, r));
|
||||
}
|
||||
}
|
||||
@ -6278,7 +6278,7 @@ pub fn construct_free_substs<'a,'tcx>(
|
||||
fn push_types_from_defs<'tcx>(tcx: &ty::ctxt<'tcx>,
|
||||
types: &mut VecPerParamSpace<Ty<'tcx>>,
|
||||
defs: &[TypeParameterDef<'tcx>]) {
|
||||
for def in defs.iter() {
|
||||
for def in defs {
|
||||
debug!("construct_parameter_environment(): push_types_from_defs: def={:?}",
|
||||
def.repr(tcx));
|
||||
let ty = ty::mk_param_from_def(tcx, def);
|
||||
@ -6351,7 +6351,7 @@ pub fn construct_parameter_environment<'a,'tcx>(
|
||||
fn record_region_bounds<'tcx>(tcx: &ty::ctxt<'tcx>, predicates: &[ty::Predicate<'tcx>]) {
|
||||
debug!("record_region_bounds(predicates={:?})", predicates.repr(tcx));
|
||||
|
||||
for predicate in predicates.iter() {
|
||||
for predicate in predicates {
|
||||
match *predicate {
|
||||
Predicate::Projection(..) |
|
||||
Predicate::Trait(..) |
|
||||
@ -6870,7 +6870,7 @@ pub fn can_type_implement_copy<'a,'tcx>(param_env: &ParameterEnvironment<'a, 'tc
|
||||
let did = match self_type.sty {
|
||||
ty::ty_struct(struct_did, substs) => {
|
||||
let fields = ty::struct_fields(tcx, struct_did, substs);
|
||||
for field in fields.iter() {
|
||||
for field in &fields {
|
||||
if type_moves_by_default(param_env, span, field.mt.ty) {
|
||||
return Err(FieldDoesNotImplementCopy(field.name))
|
||||
}
|
||||
@ -6879,8 +6879,8 @@ pub fn can_type_implement_copy<'a,'tcx>(param_env: &ParameterEnvironment<'a, 'tc
|
||||
}
|
||||
ty::ty_enum(enum_did, substs) => {
|
||||
let enum_variants = ty::enum_variants(tcx, enum_did);
|
||||
for variant in enum_variants.iter() {
|
||||
for variant_arg_type in variant.args.iter() {
|
||||
for variant in &*enum_variants {
|
||||
for variant_arg_type in &variant.args {
|
||||
let substd_arg_type =
|
||||
variant_arg_type.subst(tcx, substs);
|
||||
if type_moves_by_default(param_env, span, substd_arg_type) {
|
||||
|
@ -78,7 +78,7 @@ fn verify(sess: &Session, items: &lang_items::LanguageItems) {
|
||||
|
||||
let mut missing = HashSet::new();
|
||||
sess.cstore.iter_crate_data(|cnum, _| {
|
||||
for item in csearch::get_missing_lang_items(&sess.cstore, cnum).iter() {
|
||||
for item in &csearch::get_missing_lang_items(&sess.cstore, cnum) {
|
||||
missing.insert(*item);
|
||||
}
|
||||
});
|
||||
|
@ -48,7 +48,7 @@ pub fn find_plugin_registrar(diagnostic: &diagnostic::SpanHandler,
|
||||
},
|
||||
_ => {
|
||||
diagnostic.handler().err("multiple plugin registration functions found");
|
||||
for &(_, span) in finder.registrars.iter() {
|
||||
for &(_, span) in &finder.registrars {
|
||||
diagnostic.span_note(span, "one is here");
|
||||
}
|
||||
diagnostic.handler().abort_if_errors();
|
||||
|
@ -73,7 +73,7 @@ pub fn load_plugins(sess: &Session, krate: &ast::Crate,
|
||||
// We need to error on `#[macro_use] extern crate` when it isn't at the
|
||||
// crate root, because `$crate` won't work properly. Identify these by
|
||||
// spans, because the crate map isn't set up yet.
|
||||
for item in krate.module.items.iter() {
|
||||
for item in &krate.module.items {
|
||||
if let ast::ItemExternCrate(_) = item.node {
|
||||
loader.span_whitelist.insert(item.span);
|
||||
}
|
||||
@ -82,7 +82,7 @@ pub fn load_plugins(sess: &Session, krate: &ast::Crate,
|
||||
visit::walk_crate(&mut loader, krate);
|
||||
|
||||
if let Some(plugins) = addl_plugins {
|
||||
for plugin in plugins.iter() {
|
||||
for plugin in &plugins {
|
||||
loader.load_plugin(CrateOrString::Str(plugin.as_slice()),
|
||||
None, None, None)
|
||||
}
|
||||
@ -107,7 +107,7 @@ impl<'a, 'v> Visitor<'v> for PluginLoader<'a> {
|
||||
let mut plugin_attr = None;
|
||||
let mut macro_selection = Some(HashSet::new()); // None => load all
|
||||
let mut reexport = HashSet::new();
|
||||
for attr in item.attrs.iter() {
|
||||
for attr in &item.attrs {
|
||||
let mut used = true;
|
||||
match attr.name().get() {
|
||||
"phase" => {
|
||||
@ -127,7 +127,7 @@ impl<'a, 'v> Visitor<'v> for PluginLoader<'a> {
|
||||
macro_selection = None;
|
||||
}
|
||||
if let (Some(sel), Some(names)) = (macro_selection.as_mut(), names) {
|
||||
for name in names.iter() {
|
||||
for name in names {
|
||||
if let ast::MetaWord(ref name) = name.node {
|
||||
sel.insert(name.clone());
|
||||
} else {
|
||||
@ -145,7 +145,7 @@ impl<'a, 'v> Visitor<'v> for PluginLoader<'a> {
|
||||
}
|
||||
};
|
||||
|
||||
for name in names.iter() {
|
||||
for name in names {
|
||||
if let ast::MetaWord(ref name) = name.node {
|
||||
reexport.insert(name.clone());
|
||||
} else {
|
||||
@ -204,7 +204,7 @@ impl<'a> PluginLoader<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
for mut def in macros.into_iter() {
|
||||
for mut def in macros {
|
||||
let name = token::get_ident(def.ident);
|
||||
def.use_locally = match macro_selection.as_ref() {
|
||||
None => true,
|
||||
|
@ -300,13 +300,13 @@ macro_rules! options {
|
||||
pub fn $buildfn(matches: &getopts::Matches) -> $struct_name
|
||||
{
|
||||
let mut op = $defaultfn();
|
||||
for option in matches.opt_strs($prefix).into_iter() {
|
||||
for option in matches.opt_strs($prefix) {
|
||||
let mut iter = option.splitn(1, '=');
|
||||
let key = iter.next().unwrap();
|
||||
let value = iter.next();
|
||||
let option_to_lookup = key.replace("-", "_");
|
||||
let mut found = false;
|
||||
for &(candidate, setter, opt_type_desc, _) in $stat.iter() {
|
||||
for &(candidate, setter, opt_type_desc, _) in $stat {
|
||||
if option_to_lookup != candidate { continue }
|
||||
if !setter(&mut op, value) {
|
||||
match (value, opt_type_desc) {
|
||||
@ -830,8 +830,8 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
|
||||
let mut lint_opts = vec!();
|
||||
let mut describe_lints = false;
|
||||
|
||||
for &level in [lint::Allow, lint::Warn, lint::Deny, lint::Forbid].iter() {
|
||||
for lint_name in matches.opt_strs(level.as_str()).into_iter() {
|
||||
for &level in &[lint::Allow, lint::Warn, lint::Deny, lint::Forbid] {
|
||||
for lint_name in matches.opt_strs(level.as_str()) {
|
||||
if lint_name == "help" {
|
||||
describe_lints = true;
|
||||
} else {
|
||||
@ -853,7 +853,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
|
||||
let mut output_types = Vec::new();
|
||||
if !debugging_opts.parse_only && !no_trans {
|
||||
let unparsed_output_types = matches.opt_strs("emit");
|
||||
for unparsed_output_type in unparsed_output_types.iter() {
|
||||
for unparsed_output_type in &unparsed_output_types {
|
||||
for part in unparsed_output_type.split(',') {
|
||||
let output_type = match part.as_slice() {
|
||||
"asm" => OutputTypeAssembly,
|
||||
@ -923,7 +923,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
|
||||
};
|
||||
|
||||
let mut search_paths = SearchPaths::new();
|
||||
for s in matches.opt_strs("L").iter() {
|
||||
for s in &matches.opt_strs("L") {
|
||||
search_paths.add_path(&s[]);
|
||||
}
|
||||
|
||||
@ -997,7 +997,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
|
||||
};
|
||||
|
||||
let mut externs = HashMap::new();
|
||||
for arg in matches.opt_strs("extern").iter() {
|
||||
for arg in &matches.opt_strs("extern") {
|
||||
let mut parts = arg.splitn(1, '=');
|
||||
let name = match parts.next() {
|
||||
Some(s) => s,
|
||||
@ -1049,7 +1049,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
|
||||
pub fn parse_crate_types_from_list(list_list: Vec<String>) -> Result<Vec<CrateType>, String> {
|
||||
|
||||
let mut crate_types: Vec<CrateType> = Vec::new();
|
||||
for unparsed_crate_type in list_list.iter() {
|
||||
for unparsed_crate_type in &list_list {
|
||||
for part in unparsed_crate_type.split(',') {
|
||||
let new_part = match part {
|
||||
"lib" => default_lib_output(),
|
||||
|
@ -163,7 +163,7 @@ pub fn can_reach<T, S>(edges_map: &HashMap<T, Vec<T>, S>, source: T,
|
||||
while i < queue.len() {
|
||||
match edges_map.get(&queue[i]) {
|
||||
Some(edges) => {
|
||||
for target in edges.iter() {
|
||||
for target in edges {
|
||||
if *target == destination {
|
||||
return true;
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ impl Hasher for FnvHasher {
|
||||
impl Writer for FnvHasher {
|
||||
fn write(&mut self, bytes: &[u8]) {
|
||||
let FnvHasher(mut hash) = *self;
|
||||
for byte in bytes.iter() {
|
||||
for byte in bytes {
|
||||
hash = hash ^ (*byte as u64);
|
||||
hash = hash * 0x100000001b3;
|
||||
}
|
||||
|
@ -494,11 +494,11 @@ pub fn parameterized<'tcx>(cx: &ctxt<'tcx>,
|
||||
0
|
||||
};
|
||||
|
||||
for t in tps[..tps.len() - num_defaults].iter() {
|
||||
for t in &tps[..tps.len() - num_defaults] {
|
||||
strs.push(ty_to_string(cx, *t))
|
||||
}
|
||||
|
||||
for projection in projections.iter() {
|
||||
for projection in projections {
|
||||
strs.push(format!("{}={}",
|
||||
projection.projection_ty.item_name.user_string(cx),
|
||||
projection.ty.user_string(cx)));
|
||||
@ -665,7 +665,7 @@ impl<'tcx> UserString<'tcx> for ty::TyTrait<'tcx> {
|
||||
components.push(tap.user_string(tcx));
|
||||
|
||||
// Builtin bounds.
|
||||
for bound in bounds.builtin_bounds.iter() {
|
||||
for bound in &bounds.builtin_bounds {
|
||||
components.push(bound.user_string(tcx));
|
||||
}
|
||||
|
||||
@ -748,7 +748,7 @@ impl<'tcx> Repr<'tcx> for subst::RegionSubsts {
|
||||
impl<'tcx> Repr<'tcx> for ty::BuiltinBounds {
|
||||
fn repr(&self, _tcx: &ctxt) -> String {
|
||||
let mut res = Vec::new();
|
||||
for b in self.iter() {
|
||||
for b in self {
|
||||
res.push(match b {
|
||||
ty::BoundSend => "Send".to_string(),
|
||||
ty::BoundSized => "Sized".to_string(),
|
||||
@ -764,7 +764,7 @@ impl<'tcx> Repr<'tcx> for ty::ParamBounds<'tcx> {
|
||||
fn repr(&self, tcx: &ctxt<'tcx>) -> String {
|
||||
let mut res = Vec::new();
|
||||
res.push(self.builtin_bounds.repr(tcx));
|
||||
for t in self.trait_bounds.iter() {
|
||||
for t in &self.trait_bounds {
|
||||
res.push(t.repr(tcx));
|
||||
}
|
||||
res.connect("+")
|
||||
@ -1157,7 +1157,7 @@ impl<'tcx> UserString<'tcx> for ty::ParamBounds<'tcx> {
|
||||
if !s.is_empty() {
|
||||
result.push(s);
|
||||
}
|
||||
for n in self.trait_bounds.iter() {
|
||||
for n in &self.trait_bounds {
|
||||
result.push(n.user_string(tcx));
|
||||
}
|
||||
result.connect(" + ")
|
||||
@ -1173,11 +1173,11 @@ impl<'tcx> Repr<'tcx> for ty::ExistentialBounds<'tcx> {
|
||||
res.push(region_str);
|
||||
}
|
||||
|
||||
for bound in self.builtin_bounds.iter() {
|
||||
for bound in &self.builtin_bounds {
|
||||
res.push(bound.user_string(tcx));
|
||||
}
|
||||
|
||||
for projection_bound in self.projection_bounds.iter() {
|
||||
for projection_bound in &self.projection_bounds {
|
||||
res.push(projection_bound.user_string(tcx));
|
||||
}
|
||||
|
||||
|
@ -99,7 +99,7 @@ pub fn find_library(name: &str, osprefix: &str, ossuffix: &str,
|
||||
let oslibname = format!("{}{}{}", osprefix, name, ossuffix);
|
||||
let unixlibname = format!("lib{}.a", name);
|
||||
|
||||
for path in search_paths.iter() {
|
||||
for path in search_paths {
|
||||
debug!("looking for {} inside {:?}", name, path.display());
|
||||
let test = path.join(&oslibname[]);
|
||||
if test.exists() { return test }
|
||||
@ -244,7 +244,7 @@ impl<'a> ArchiveBuilder<'a> {
|
||||
// 32,768, and we leave a bit of extra space for the program name.
|
||||
static ARG_LENGTH_LIMIT: uint = 32000;
|
||||
|
||||
for member_name in self.members.iter() {
|
||||
for member_name in &self.members {
|
||||
let len = member_name.as_vec().len();
|
||||
|
||||
// `len + 1` to account for the space that's inserted before each
|
||||
@ -297,7 +297,7 @@ impl<'a> ArchiveBuilder<'a> {
|
||||
// all SYMDEF files as these are just magical placeholders which get
|
||||
// re-created when we make a new archive anyway.
|
||||
let files = try!(fs::readdir(loc.path()));
|
||||
for file in files.iter() {
|
||||
for file in &files {
|
||||
let filename = file.filename_str().unwrap();
|
||||
if skip(filename) { continue }
|
||||
if filename.contains(".SYMDEF") { continue }
|
||||
|
@ -51,7 +51,7 @@ pub fn get_rpath_flags<F, G>(config: RPathConfig<F, G>) -> Vec<String> where
|
||||
|
||||
fn rpaths_to_flags(rpaths: &[String]) -> Vec<String> {
|
||||
let mut ret = Vec::new();
|
||||
for rpath in rpaths.iter() {
|
||||
for rpath in rpaths {
|
||||
ret.push(format!("-Wl,-rpath,{}", &(*rpath)[]));
|
||||
}
|
||||
return ret;
|
||||
@ -63,7 +63,7 @@ fn get_rpaths<F, G>(mut config: RPathConfig<F, G>, libs: &[Path]) -> Vec<String>
|
||||
{
|
||||
debug!("output: {:?}", config.out_filename.display());
|
||||
debug!("libs:");
|
||||
for libpath in libs.iter() {
|
||||
for libpath in libs {
|
||||
debug!(" {:?}", libpath.display());
|
||||
}
|
||||
|
||||
@ -77,7 +77,7 @@ fn get_rpaths<F, G>(mut config: RPathConfig<F, G>, libs: &[Path]) -> Vec<String>
|
||||
|
||||
fn log_rpaths(desc: &str, rpaths: &[String]) {
|
||||
debug!("{} rpaths:", desc);
|
||||
for rpath in rpaths.iter() {
|
||||
for rpath in rpaths {
|
||||
debug!(" {}", *rpath);
|
||||
}
|
||||
}
|
||||
@ -138,7 +138,7 @@ fn get_install_prefix_rpath<F, G>(config: RPathConfig<F, G>) -> String where
|
||||
fn minimize_rpaths(rpaths: &[String]) -> Vec<String> {
|
||||
let mut set = HashSet::new();
|
||||
let mut minimized = Vec::new();
|
||||
for rpath in rpaths.iter() {
|
||||
for rpath in rpaths {
|
||||
if set.insert(&rpath[]) {
|
||||
minimized.push(rpath.clone());
|
||||
}
|
||||
|
@ -557,7 +557,7 @@ mod tests {
|
||||
|
||||
fn test_hash<D: Digest>(sh: &mut D, tests: &[Test]) {
|
||||
// Test that it works when accepting the message all at once
|
||||
for t in tests.iter() {
|
||||
for t in tests {
|
||||
sh.reset();
|
||||
sh.input_str(t.input.as_slice());
|
||||
let out_str = sh.result_str();
|
||||
@ -565,7 +565,7 @@ mod tests {
|
||||
}
|
||||
|
||||
// Test that it works when accepting the message in pieces
|
||||
for t in tests.iter() {
|
||||
for t in tests {
|
||||
sh.reset();
|
||||
let len = t.input.len();
|
||||
let mut left = len;
|
||||
|
@ -79,7 +79,7 @@ impl Svh {
|
||||
// avoid collisions.
|
||||
let mut state = SipHasher::new();
|
||||
|
||||
for data in metadata.iter() {
|
||||
for data in metadata {
|
||||
data.hash(&mut state);
|
||||
}
|
||||
|
||||
@ -97,7 +97,7 @@ impl Svh {
|
||||
//
|
||||
// We hash only the MetaItems instead of the entire Attribute
|
||||
// to avoid hashing the AttrId
|
||||
for attr in krate.attrs.iter() {
|
||||
for attr in &krate.attrs {
|
||||
attr.node.value.hash(&mut state);
|
||||
}
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user