for x in xs.iter() -> for x in &xs

This commit is contained in:
Jorge Aparicio 2015-01-31 12:20:46 -05:00
parent 9f90d666e0
commit d5d7e6565a
269 changed files with 1063 additions and 1064 deletions

View file

@ -276,7 +276,7 @@ pub fn make_tests(config: &Config) -> Vec<test::TestDescAndFn> {
config.src_base.display()); config.src_base.display());
let mut tests = Vec::new(); let mut tests = Vec::new();
let dirs = fs::readdir(&config.src_base).unwrap(); let dirs = fs::readdir(&config.src_base).unwrap();
for file in dirs.iter() { for file in &dirs {
let file = file.clone(); let file = file.clone();
debug!("inspecting file {:?}", file.display()); debug!("inspecting file {:?}", file.display());
if is_test(config, &file) { if is_test(config, &file) {
@ -304,13 +304,13 @@ pub fn is_test(config: &Config, testfile: &Path) -> bool {
let mut valid = false; let mut valid = false;
for ext in valid_extensions.iter() { for ext in &valid_extensions {
if name.ends_with(ext.as_slice()) { if name.ends_with(ext.as_slice()) {
valid = true; valid = true;
} }
} }
for pre in invalid_prefixes.iter() { for pre in &invalid_prefixes {
if name.starts_with(pre.as_slice()) { if name.starts_with(pre.as_slice()) {
valid = false; valid = false;
} }

View file

@ -46,7 +46,7 @@ pub fn run(lib_path: &str,
match cmd.spawn() { match cmd.spawn() {
Ok(mut process) => { Ok(mut process) => {
for input in input.iter() { if let Some(input) = input {
process.stdin.as_mut().unwrap().write_all(input.as_bytes()).unwrap(); process.stdin.as_mut().unwrap().write_all(input.as_bytes()).unwrap();
} }
let ProcessOutput { status, output, error } = let ProcessOutput { status, output, error } =
@ -78,7 +78,7 @@ pub fn run_background(lib_path: &str,
match cmd.spawn() { match cmd.spawn() {
Ok(mut process) => { Ok(mut process) => {
for input in input.iter() { if let Some(input) = input {
process.stdin.as_mut().unwrap().write_all(input.as_bytes()).unwrap(); process.stdin.as_mut().unwrap().write_all(input.as_bytes()).unwrap();
} }

View file

@ -547,7 +547,7 @@ fn run_debuginfo_gdb_test(config: &Config, props: &TestProps, testfile: &Path) {
exe_file.as_str().unwrap().replace("\\", "\\\\"))[]); exe_file.as_str().unwrap().replace("\\", "\\\\"))[]);
// Add line breakpoints // Add line breakpoints
for line in breakpoint_lines.iter() { for line in &breakpoint_lines {
script_str.push_str(&format!("break '{}':{}\n", script_str.push_str(&format!("break '{}':{}\n",
testfile.filename_display(), testfile.filename_display(),
*line)[]); *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"); script_str.push_str("type category enable Rust\n");
// Set breakpoints on every line that contains the string "#break" // 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", script_str.push_str(format!("breakpoint set --line {}\n",
line).as_slice()); line).as_slice());
} }
// Append the other commands // Append the other commands
for line in commands.iter() { for line in &commands {
script_str.push_str(line.as_slice()); script_str.push_str(line.as_slice());
script_str.push_str("\n"); 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 rest = line.trim();
let mut first = true; let mut first = true;
let mut failed = false; let mut failed = false;
for frag in check_fragments[i].iter() { for frag in &check_fragments[i] {
let found = if first { let found = if first {
if rest.starts_with(frag.as_slice()) { if rest.starts_with(frag.as_slice()) {
Some(0) Some(0)
@ -915,7 +915,7 @@ fn check_error_patterns(props: &TestProps,
missing_patterns[0]).as_slice(), missing_patterns[0]).as_slice(),
proc_res); proc_res);
} else { } else {
for pattern in missing_patterns.iter() { for pattern in missing_patterns {
error(format!("error pattern '{}' not found!", error(format!("error pattern '{}' not found!",
*pattern).as_slice()); *pattern).as_slice());
} }
@ -935,7 +935,7 @@ fn check_no_compiler_crash(proc_res: &ProcRes) {
fn check_forbid_output(props: &TestProps, fn check_forbid_output(props: &TestProps,
output_to_check: &str, output_to_check: &str,
proc_res: &ProcRes) { proc_res: &ProcRes) {
for pat in props.forbid_output.iter() { for pat in &props.forbid_output {
if output_to_check.contains(pat.as_slice()) { if output_to_check.contains(pat.as_slice()) {
fatal_proc_rec("forbidden pattern found in compiler output", proc_res); 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 // FIXME (#9639): This needs to handle non-utf8 paths
let extra_link_args = vec!("-L".to_string(), aux_dir.as_str().unwrap().to_string()); 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 abs_ab = config.aux_base.join(rel_ab.as_slice());
let aux_props = header::load_props(&abs_ab); let aux_props = header::load_props(&abs_ab);
let mut crate_type = if aux_props.no_prefer_dynamic { let mut crate_type = if aux_props.no_prefer_dynamic {
@ -1510,7 +1510,7 @@ fn _arm_exec_compiled_test(config: &Config,
runargs.push(format!("{}", config.adb_test_dir)); runargs.push(format!("{}", config.adb_test_dir));
runargs.push(format!("{}", prog_short)); runargs.push(format!("{}", prog_short));
for tv in args.args.iter() { for tv in &args.args {
runargs.push(tv.to_string()); runargs.push(tv.to_string());
} }
procsrv::run("", 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 tdir = aux_output_dir_name(config, testfile);
let dirs = fs::readdir(&tdir).unwrap(); let dirs = fs::readdir(&tdir).unwrap();
for file in dirs.iter() { for file in &dirs {
if file.extension_str() == Some("so") { if file.extension_str() == Some("so") {
// FIXME (#9639): This needs to handle non-utf8 paths // FIXME (#9639): This needs to handle non-utf8 paths
let copy_result = procsrv::run("", let copy_result = procsrv::run("",

View file

@ -26,7 +26,7 @@ static OS_TABLE: &'static [(&'static str, &'static str)] = &[
]; ];
pub fn get_os(triple: &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) { if triple.contains(triple_os) {
return os return os
} }

View file

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

View file

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

View file

@ -696,7 +696,7 @@ mod tests {
let iterout = [9, 5, 3]; let iterout = [9, 5, 3];
let heap = BinaryHeap::from_vec(data); let heap = BinaryHeap::from_vec(data);
let mut i = 0; let mut i = 0;
for el in heap.iter() { for el in &heap {
assert_eq!(*el, iterout[i]); assert_eq!(*el, iterout[i]);
i += 1; i += 1;
} }
@ -884,7 +884,7 @@ mod tests {
let mut q: BinaryHeap<uint> = xs.iter().rev().map(|&x| x).collect(); 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); assert_eq!(q.pop().unwrap(), x);
} }
} }

View file

@ -976,7 +976,7 @@ impl Ord for Bitv {
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
impl fmt::Debug for Bitv { impl fmt::Debug for Bitv {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { 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 })); try!(write!(fmt, "{}", if bit { 1u32 } else { 0u32 }));
} }
Ok(()) Ok(())
@ -1743,7 +1743,7 @@ impl fmt::Debug for BitvSet {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
try!(write!(fmt, "BitvSet {{")); try!(write!(fmt, "BitvSet {{"));
let mut first = true; let mut first = true;
for n in self.iter() { for n in self {
if !first { if !first {
try!(write!(fmt, ", ")); try!(write!(fmt, ", "));
} }
@ -1756,7 +1756,7 @@ impl fmt::Debug for BitvSet {
impl<S: hash::Writer + hash::Hasher> hash::Hash<S> for BitvSet { impl<S: hash::Writer + hash::Hasher> hash::Hash<S> for BitvSet {
fn hash(&self, state: &mut S) { fn hash(&self, state: &mut S) {
for pos in self.iter() { for pos in self {
pos.hash(state); pos.hash(state);
} }
} }
@ -2600,7 +2600,7 @@ mod bitv_bench {
b.iter(|| { b.iter(|| {
let mut sum = 0u; let mut sum = 0u;
for _ in 0u..10 { for _ in 0u..10 {
for pres in bitv.iter() { for pres in &bitv {
sum += pres as uint; sum += pres as uint;
} }
} }
@ -2613,7 +2613,7 @@ mod bitv_bench {
let bitv = Bitv::from_elem(BENCH_BITS, false); let bitv = Bitv::from_elem(BENCH_BITS, false);
b.iter(|| { b.iter(|| {
let mut sum = 0u; let mut sum = 0u;
for pres in bitv.iter() { for pres in &bitv {
sum += pres as uint; sum += pres as uint;
} }
sum sum
@ -2674,8 +2674,8 @@ mod bitv_set_test {
fn test_bitv_set_frombitv_init() { fn test_bitv_set_frombitv_init() {
let bools = [true, false]; let bools = [true, false];
let lengths = [10, 64, 100]; let lengths = [10, 64, 100];
for &b in bools.iter() { for &b in &bools {
for &l in lengths.iter() { for &l in &lengths {
let bitset = BitvSet::from_bitv(Bitv::from_elem(l, b)); let bitset = BitvSet::from_bitv(Bitv::from_elem(l, b));
assert_eq!(bitset.contains(&1u), b); assert_eq!(bitset.contains(&1u), b);
assert_eq!(bitset.contains(&(l-1u)), b); assert_eq!(bitset.contains(&(l-1u)), b);
@ -3062,7 +3062,7 @@ mod bitv_set_bench {
|idx| {idx % 3 == 0})); |idx| {idx % 3 == 0}));
b.iter(|| { b.iter(|| {
let mut sum = 0u; let mut sum = 0u;
for idx in bitv.iter() { for idx in &bitv {
sum += idx as uint; sum += idx as uint;
} }
sum sum

View file

@ -856,7 +856,7 @@ impl<K: Ord, V> Extend<(K, V)> for BTreeMap<K, V> {
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
impl<S: Hasher, K: Hash<S>, V: Hash<S>> Hash<S> for BTreeMap<K, V> { impl<S: Hasher, K: Hash<S>, V: Hash<S>> Hash<S> for BTreeMap<K, V> {
fn hash(&self, state: &mut S) { fn hash(&self, state: &mut S) {
for elt in self.iter() { for elt in self {
elt.hash(state); elt.hash(state);
} }
} }
@ -1946,7 +1946,7 @@ mod bench {
} }
b.iter(|| { b.iter(|| {
for entry in map.iter() { for entry in &map {
black_box(entry); black_box(entry);
} }
}); });

View file

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

View file

@ -791,8 +791,8 @@ mod test {
let mut set_a = BTreeSet::new(); let mut set_a = BTreeSet::new();
let mut set_b = BTreeSet::new(); let mut set_b = BTreeSet::new();
for x in a.iter() { assert!(set_a.insert(*x)) } for x in a { assert!(set_a.insert(*x)) }
for y in b.iter() { assert!(set_b.insert(*y)) } for y in b { assert!(set_b.insert(*y)) }
let mut i = 0; let mut i = 0;
f(&set_a, &set_b, Counter { i: &mut i, expected: expected }); 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(); let set: BTreeSet<int> = xs.iter().map(|&x| x).collect();
for x in xs.iter() { for x in &xs {
assert!(set.contains(x)); assert!(set.contains(x));
} }
} }

View file

@ -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> { impl<S: Writer + Hasher, A: Hash<S>> Hash<S> for DList<A> {
fn hash(&self, state: &mut S) { fn hash(&self, state: &mut S) {
self.len().hash(state); self.len().hash(state);
for elt in self.iter() { for elt in self {
elt.hash(state); elt.hash(state);
} }
} }

View file

@ -36,7 +36,7 @@ impl<E:CLike + fmt::Debug> fmt::Debug for EnumSet<E> {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
try!(write!(fmt, "EnumSet {{")); try!(write!(fmt, "EnumSet {{"));
let mut first = true; let mut first = true;
for e in self.iter() { for e in self {
if !first { if !first {
try!(write!(fmt, ", ")); try!(write!(fmt, ", "));
} }

View file

@ -1573,7 +1573,7 @@ impl<A: Ord> Ord for RingBuf<A> {
impl<S: Writer + Hasher, A: Hash<S>> Hash<S> for RingBuf<A> { impl<S: Writer + Hasher, A: Hash<S>> Hash<S> for RingBuf<A> {
fn hash(&self, state: &mut S) { fn hash(&self, state: &mut S) {
self.len().hash(state); self.len().hash(state);
for elt in self.iter() { for elt in self {
elt.hash(state); elt.hash(state);
} }
} }
@ -1856,7 +1856,7 @@ mod tests {
b.iter(|| { b.iter(|| {
let mut sum = 0; let mut sum = 0;
for &i in ring.iter() { for &i in &ring {
sum += i; sum += i;
} }
test::black_box(sum); test::black_box(sum);

View file

@ -1118,7 +1118,7 @@ impl<T: Clone, V: AsSlice<T>> SliceConcatExt<T, Vec<T>> for [V] {
fn concat(&self) -> Vec<T> { fn concat(&self) -> Vec<T> {
let size = self.iter().fold(0u, |acc, v| acc + v.as_slice().len()); let size = self.iter().fold(0u, |acc, v| acc + v.as_slice().len());
let mut result = Vec::with_capacity(size); let mut result = Vec::with_capacity(size);
for v in self.iter() { for v in self {
result.push_all(v.as_slice()) result.push_all(v.as_slice())
} }
result result
@ -1128,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 size = self.iter().fold(0u, |acc, v| acc + v.as_slice().len());
let mut result = Vec::with_capacity(size + self.len()); let mut result = Vec::with_capacity(size + self.len());
let mut first = true; let mut first = true;
for v in self.iter() { for v in self {
if first { first = false } else { result.push(sep.clone()) } if first { first = false } else { result.push(sep.clone()) }
result.push_all(v.as_slice()) result.push_all(v.as_slice())
} }
@ -2681,13 +2681,13 @@ mod tests {
assert_eq!(v.len(), 3); assert_eq!(v.len(), 3);
let mut cnt = 0u; let mut cnt = 0u;
for f in v.iter() { for f in &v {
assert!(*f == Foo); assert!(*f == Foo);
cnt += 1; cnt += 1;
} }
assert_eq!(cnt, 3); assert_eq!(cnt, 3);
for f in v[1..3].iter() { for f in &v[1..3] {
assert!(*f == Foo); assert!(*f == Foo);
cnt += 1; cnt += 1;
} }
@ -2707,7 +2707,7 @@ mod tests {
let xs: [Foo; 3] = [Foo, Foo, Foo]; let xs: [Foo; 3] = [Foo, Foo, Foo];
cnt = 0; cnt = 0;
for f in xs.iter() { for f in &xs {
assert!(*f == Foo); assert!(*f == Foo);
cnt += 1; cnt += 1;
} }
@ -2858,7 +2858,7 @@ mod bench {
b.iter(|| { b.iter(|| {
let mut sum = 0; let mut sum = 0;
for x in v.iter() { for x in &v {
sum += *x; sum += *x;
} }
// sum == 11806, to stop dead code elimination. // sum == 11806, to stop dead code elimination.

View file

@ -99,7 +99,7 @@ impl<S: Str> SliceConcatExt<str, String> for [S] {
let len = s.iter().map(|s| s.as_slice().len()).sum(); let len = s.iter().map(|s| s.as_slice().len()).sum();
let mut result = String::with_capacity(len); let mut result = String::with_capacity(len);
for s in s.iter() { for s in s {
result.push_str(s.as_slice()) result.push_str(s.as_slice())
} }
@ -125,7 +125,7 @@ impl<S: Str> SliceConcatExt<str, String> for [S] {
let mut result = String::with_capacity(len); let mut result = String::with_capacity(len);
let mut first = true; let mut first = true;
for s in s.iter() { for s in s {
if first { if first {
first = false; first = false;
} else { } else {
@ -2005,7 +2005,7 @@ mod tests {
let s = "ศไทย中华Việt Nam"; let s = "ศไทย中华Việt Nam";
let v = vec!['ศ','ไ','ท','ย','中','华','V','i','ệ','t',' ','N','a','m']; let v = vec!['ศ','ไ','ท','ย','中','华','V','i','ệ','t',' ','N','a','m'];
let mut pos = 0; let mut pos = 0;
for ch in v.iter() { for ch in &v {
assert!(s.char_at(pos) == *ch); assert!(s.char_at(pos) == *ch);
pos += ch.to_string().len(); pos += ch.to_string().len();
} }
@ -2703,7 +2703,7 @@ mod tests {
&["\u{378}\u{308}\u{903}"], &["\u{378}\u{308}", "\u{903}"]), &["\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 // test forward iterator
assert!(order::equals(s.graphemes(true), g.iter().map(|&x| x))); assert!(order::equals(s.graphemes(true), g.iter().map(|&x| x)));
assert!(order::equals(s.graphemes(false), g.iter().map(|&x| x))); assert!(order::equals(s.graphemes(false), g.iter().map(|&x| x)));
@ -2713,7 +2713,7 @@ mod tests {
assert!(order::equals(s.graphemes(false).rev(), g.iter().rev().map(|&x| x))); 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 // test forward iterator
assert!(order::equals(s.graphemes(true), gt.iter().map(|&x| x))); assert!(order::equals(s.graphemes(true), gt.iter().map(|&x| x)));
assert!(order::equals(s.graphemes(false), gf.iter().map(|&x| x))); assert!(order::equals(s.graphemes(false), gf.iter().map(|&x| x)));

View file

@ -1118,7 +1118,7 @@ mod tests {
(String::from_str("\u{20000}"), (String::from_str("\u{20000}"),
vec![0xD840, 0xDC00])]; vec![0xD840, 0xDC00])];
for p in pairs.iter() { for p in &pairs {
let (s, u) = (*p).clone(); let (s, u) = (*p).clone();
let s_as_utf16 = s.utf16_units().collect::<Vec<u16>>(); let s_as_utf16 = s.utf16_units().collect::<Vec<u16>>();
let u_as_string = String::from_utf16(u.as_slice()).unwrap(); let u_as_string = String::from_utf16(u.as_slice()).unwrap();

View file

@ -1547,7 +1547,7 @@ impl<T> Drop for Vec<T> {
// zeroed (when moving out, because of #[unsafe_no_drop_flag]). // zeroed (when moving out, because of #[unsafe_no_drop_flag]).
if self.cap != 0 { if self.cap != 0 {
unsafe { unsafe {
for x in self.iter() { for x in &*self {
ptr::read(x); ptr::read(x);
} }
dealloc(*self.ptr, self.cap) dealloc(*self.ptr, self.cap)
@ -2129,7 +2129,7 @@ mod tests {
v.push(()); v.push(());
assert_eq!(v.iter().count(), 2); assert_eq!(v.iter().count(), 2);
for &() in v.iter() {} for &() in &v {}
assert_eq!(v.iter_mut().count(), 2); assert_eq!(v.iter_mut().count(), 2);
v.push(()); v.push(());

View file

@ -90,7 +90,7 @@ impl<S: Writer + Hasher, V: Hash<S>> Hash<S> for VecMap<V> {
// In order to not traverse the `VecMap` twice, count the elements // In order to not traverse the `VecMap` twice, count the elements
// during iteration. // during iteration.
let mut count: uint = 0; let mut count: uint = 0;
for elt in self.iter() { for elt in self {
elt.hash(state); elt.hash(state);
count += 1; count += 1;
} }
@ -1112,7 +1112,7 @@ mod test_map {
let map: VecMap<char> = xs.iter().map(|&x| x).collect(); 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)); assert_eq!(map.get(&k), Some(&v));
} }
} }

View file

@ -888,7 +888,7 @@ impl<T: Debug> Debug for [T] {
try!(write!(f, "[")); try!(write!(f, "["));
} }
let mut is_first = true; let mut is_first = true;
for x in self.iter() { for x in self {
if is_first { if is_first {
is_first = false; is_first = false;
} else { } else {

View file

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

View file

@ -66,11 +66,11 @@ fn test_partial_min() {
(1.0f64, NAN, None) (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); 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); assert!(partial_min(a, b) == result);
} }
} }
@ -99,11 +99,11 @@ fn test_partial_max() {
(1.0f64, NAN, None) (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); 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); assert!(partial_max(a, b) == result);
} }
} }

View file

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

View file

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

View file

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

View file

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

View file

@ -305,7 +305,7 @@ mod tests {
let mut rng = CountingRng { i: 0 }; let mut rng = CountingRng { i: 0 };
for &val in expected.iter() { for &val in &expected {
assert_eq!(wc.ind_sample(&mut rng), val) assert_eq!(wc.ind_sample(&mut rng), val)
} }
}} }}

View file

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

View file

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

View file

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

View file

@ -459,7 +459,7 @@ impl LintPass for ImproperCTypes {
} }
fn check_foreign_fn(cx: &Context, decl: &ast::FnDecl) { 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); check_ty(cx, &*input.ty);
} }
if let ast::Return(ref ret_ty) = decl.output { if let ast::Return(ref ret_ty) = decl.output {
@ -469,7 +469,7 @@ impl LintPass for ImproperCTypes {
match it.node { match it.node {
ast::ItemForeignMod(ref nmod) if nmod.abi != abi::RustIntrinsic => { ast::ItemForeignMod(ref nmod) if nmod.abi != abi::RustIntrinsic => {
for ni in nmod.items.iter() { for ni in &nmod.items {
match ni.node { match ni.node {
ast::ForeignItemFn(ref decl, _) => check_foreign_fn(cx, &**decl), ast::ForeignItemFn(ref decl, _) => check_foreign_fn(cx, &**decl),
ast::ForeignItemStatic(ref t, _) => check_ty(cx, &**t) 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 // If it's a struct, we also have to check the fields' types
match it.node { match it.node {
ast::ItemStruct(ref struct_def, _) => { 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, self.check_heap_type(cx, struct_field.span,
ty::node_id_to_type(cx.tcx, struct_field.node.id)); ty::node_id_to_type(cx.tcx, struct_field.node.id));
} }
@ -683,7 +683,7 @@ impl LintPass for UnusedAttributes {
"no_builtins", "no_builtins",
]; ];
for &name in ATTRIBUTE_WHITELIST.iter() { for &name in ATTRIBUTE_WHITELIST {
if attr.check_name(name) { if attr.check_name(name) {
break; break;
} }
@ -785,7 +785,7 @@ impl LintPass for UnusedResults {
} }
fn check_must_use(cx: &Context, attrs: &[ast::Attribute], sp: Span) -> bool { 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") { if attr.check_name("must_use") {
let mut msg = "unused result which must be used".to_string(); let mut msg = "unused result which must be used".to_string();
// check for #[must_use="..."] // check for #[must_use="..."]
@ -869,7 +869,7 @@ impl LintPass for NonCamelCaseTypes {
ast::ItemEnum(ref enum_definition, _) => { ast::ItemEnum(ref enum_definition, _) => {
if has_extern_repr { return } if has_extern_repr { return }
self.check_case(cx, "type", it.ident, it.span); 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); self.check_case(cx, "variant", variant.node.name, variant.span);
} }
} }
@ -878,7 +878,7 @@ impl LintPass for NonCamelCaseTypes {
} }
fn check_generics(&mut self, cx: &Context, it: &ast::Generics) { 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); self.check_case(cx, "type parameter", gen.ident, gen.span);
} }
} }
@ -1048,7 +1048,7 @@ impl LintPass for NonSnakeCase {
fn check_struct_def(&mut self, cx: &Context, s: &ast::StructDef, fn check_struct_def(&mut self, cx: &Context, s: &ast::StructDef,
_: ast::Ident, _: &ast::Generics, _: ast::NodeId) { _: 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 { if let ast::StructField_ { kind: ast::NamedField(ident, _), .. } = sf.node {
self.check_snake_case(cx, "structure field", ident, sf.span); self.check_snake_case(cx, "structure field", ident, sf.span);
} }
@ -1346,7 +1346,7 @@ impl UnusedMut {
// avoid false warnings in match arms with multiple patterns // avoid false warnings in match arms with multiple patterns
let mut mutables = FnvHashMap(); 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| { pat_util::pat_bindings(&cx.tcx.def_map, &**p, |mode, id, _, path1| {
let ident = path1.node; let ident = path1.node;
if let ast::BindByValue(ast::MutMutable) = mode { if let ast::BindByValue(ast::MutMutable) = mode {
@ -1361,7 +1361,7 @@ impl UnusedMut {
} }
let used_mutables = cx.tcx.used_mut_nodes.borrow(); 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)) { if !v.iter().any(|e| used_mutables.contains(e)) {
cx.span_lint(UNUSED_MUT, cx.tcx.map.span(v[0]), cx.span_lint(UNUSED_MUT, cx.tcx.map.span(v[0]),
"variable does not need to be mutable"); "variable does not need to be mutable");
@ -1377,7 +1377,7 @@ impl LintPass for UnusedMut {
fn check_expr(&mut self, cx: &Context, e: &ast::Expr) { fn check_expr(&mut self, cx: &Context, e: &ast::Expr) {
if let ast::ExprMatch(_, ref arms, _) = e.node { 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[]) self.check_unused_mut_pat(cx, &a.pats[])
} }
} }
@ -1394,7 +1394,7 @@ impl LintPass for UnusedMut {
fn check_fn(&mut self, cx: &Context, fn check_fn(&mut self, cx: &Context,
_: visit::FnKind, decl: &ast::FnDecl, _: visit::FnKind, decl: &ast::FnDecl,
_: &ast::Block, _: Span, _: ast::NodeId) { _: &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)); self.check_unused_mut_pat(cx, slice::ref_slice(&a.pat));
} }
} }
@ -1871,7 +1871,7 @@ impl LintPass for UnconditionalRecursion {
if cx.current_level(UNCONDITIONAL_RECURSION) != Level::Allow { if cx.current_level(UNCONDITIONAL_RECURSION) != Level::Allow {
let sess = cx.sess(); let sess = cx.sess();
// offer some help to the programmer. // 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_note(*call, "recursive call site")
} }
sess.span_help(sp, "a `loop` may express intention better if this is on purpose") sess.span_help(sp, "a `loop` may express intention better if this is on purpose")

View file

@ -116,7 +116,7 @@ impl LintStore {
pub fn register_pass(&mut self, sess: Option<&Session>, pub fn register_pass(&mut self, sess: Option<&Session>,
from_plugin: bool, pass: LintPassObject) { from_plugin: bool, pass: LintPassObject) {
for &lint in pass.get_lints().iter() { for &lint in pass.get_lints() {
self.lints.push((*lint, from_plugin)); self.lints.push((*lint, from_plugin));
let id = LintId::of(*lint); let id = LintId::of(*lint);
@ -260,7 +260,7 @@ impl LintStore {
} }
pub fn process_command_line(&mut self, sess: &Session) { 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) { match self.find_lint(&lint_name[], sess, None) {
Some(lint_id) => self.set_level(lint_id, (level, CommandLine)), Some(lint_id) => self.set_level(lint_id, (level, CommandLine)),
None => { None => {
@ -340,7 +340,7 @@ macro_rules! run_lints { ($cx:expr, $f:ident, $($args:expr),*) => ({
pub fn gather_attrs(attrs: &[ast::Attribute]) pub fn gather_attrs(attrs: &[ast::Attribute])
-> Vec<Result<(InternedString, Level, Span), Span>> { -> Vec<Result<(InternedString, Level, Span), Span>> {
let mut out = vec!(); let mut out = vec!();
for attr in attrs.iter() { for attr in attrs {
let level = match Level::from_str(attr.name().get()) { let level = match Level::from_str(attr.name().get()) {
None => continue, None => continue,
Some(lvl) => lvl, 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 { out.push(match meta.node {
ast::MetaWord(ref lint_name) => Ok((lint_name.clone(), level, meta.span)), ast::MetaWord(ref lint_name) => Ok((lint_name.clone(), level, meta.span)),
_ => Err(meta.span), _ => Err(meta.span),
@ -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 // If we missed any lints added to the session, then there's a bug somewhere
// in the iteration code. // in the iteration code.
for (id, v) in tcx.sess.lints.borrow().iter() { for (id, v) in &*tcx.sess.lints.borrow() {
for &(lint, span, ref msg) in v.iter() { for &(lint, span, ref msg) in v {
tcx.sess.span_bug(span, tcx.sess.span_bug(span,
format!("unprocessed lint {} at {}: {}", format!("unprocessed lint {} at {}: {}",
lint.as_str(), tcx.map.node_to_string(*id), *msg).as_slice()) lint.as_str(), tcx.map.node_to_string(*id), *msg).as_slice())

View file

@ -162,7 +162,7 @@ impl<'a> CrateReader<'a> {
dump_crates(&self.sess.cstore); 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); register_native_lib(self.sess, None, name.clone(), kind);
} }
} }
@ -235,7 +235,7 @@ impl<'a> CrateReader<'a> {
None None
}) })
.collect::<Vec<&ast::Attribute>>(); .collect::<Vec<&ast::Attribute>>();
for m in link_args.iter() { for m in &link_args {
match m.value_str() { match m.value_str() {
Some(linkarg) => self.sess.cstore.add_used_link_args(linkarg.get()), Some(linkarg) => self.sess.cstore.add_used_link_args(linkarg.get()),
None => { /* fallthrough */ } None => { /* fallthrough */ }
@ -250,7 +250,7 @@ impl<'a> CrateReader<'a> {
None None
}) })
.collect::<Vec<&ast::Attribute>>(); .collect::<Vec<&ast::Attribute>>();
for m in link_args.iter() { for m in &link_args {
match m.meta_item_list() { match m.meta_item_list() {
Some(items) => { Some(items) => {
let kind = items.iter().find(|k| { let kind = items.iter().find(|k| {

View file

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

View file

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

View file

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

View file

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

View file

@ -66,7 +66,7 @@ impl<'a> FileSearch<'a> {
// Try RUST_PATH // Try RUST_PATH
if !found { if !found {
let rustpath = rust_path(); let rustpath = rust_path();
for path in rustpath.iter() { for path in &rustpath {
let tlib_path = make_rustpkg_lib_path( let tlib_path = make_rustpkg_lib_path(
self.sysroot, path, self.triple); self.sysroot, path, self.triple);
debug!("is {} in visited_dirs? {}", tlib_path.display(), debug!("is {} in visited_dirs? {}", tlib_path.display(),
@ -243,8 +243,7 @@ pub fn rust_path() -> Vec<Path> {
} }
cwd.pop(); cwd.pop();
} }
let h = os::homedir(); if let Some(h) = os::homedir() {
for h in h.iter() {
let p = h.join(".rust"); let p = h.join(".rust");
if !env_rust_path.contains(&p) && p.exists() { if !env_rust_path.contains(&p) && p.exists() {
env_rust_path.push(p); env_rust_path.push(p);

View file

@ -452,7 +452,7 @@ impl<'a> Context<'a> {
&format!("multiple matching crates for `{}`", &format!("multiple matching crates for `{}`",
self.crate_name)[]); self.crate_name)[]);
self.sess.note("candidates:"); self.sess.note("candidates:");
for lib in libraries.iter() { for lib in &libraries {
match lib.dylib { match lib.dylib {
Some((ref p, _)) => { Some((ref p, _)) => {
self.sess.note(&format!("path: {}", self.sess.note(&format!("path: {}",

View file

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

View file

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

View file

@ -766,7 +766,7 @@ fn encode_vec_per_param_space<T, F>(rbml_w: &mut Encoder,
mut f: F) where mut f: F) where
F: FnMut(&mut Encoder, &T), 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.emit_from_vec(v.get_slice(space),
|rbml_w, n| Ok(f(rbml_w, n))).unwrap(); |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); 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.tag(c::tag_table_def, |rbml_w| {
rbml_w.id(id); rbml_w.id(id);
rbml_w.tag(c::tag_table_val, |rbml_w| (*def).encode(rbml_w).unwrap()); 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.tag(c::tag_table_node_type, |rbml_w| {
rbml_w.id(id); rbml_w.id(id);
rbml_w.tag(c::tag_table_val, |rbml_w| { 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.tag(c::tag_table_item_subst, |rbml_w| {
rbml_w.id(id); rbml_w.id(id);
rbml_w.tag(c::tag_table_val, |rbml_w| { 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.tag(c::tag_table_freevars, |rbml_w| {
rbml_w.id(id); rbml_w.id(id);
rbml_w.tag(c::tag_table_val, |rbml_w| { 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.tag(c::tag_table_upvar_capture_map, |rbml_w| {
rbml_w.id(id); rbml_w.id(id);
rbml_w.tag(c::tag_table_val, |rbml_w| { 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 }; 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.tag(c::tag_table_tcache, |rbml_w| {
rbml_w.id(id); rbml_w.id(id);
rbml_w.tag(c::tag_table_val, |rbml_w| { 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.tag(c::tag_table_param_defs, |rbml_w| {
rbml_w.id(id); rbml_w.id(id);
rbml_w.tag(c::tag_table_val, |rbml_w| { 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); 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.tag(c::tag_table_method_map, |rbml_w| {
rbml_w.id(id); rbml_w.id(id);
rbml_w.tag(c::tag_table_val, |rbml_w| { 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.tag(c::tag_table_object_cast_map, |rbml_w| {
rbml_w.id(id); rbml_w.id(id);
rbml_w.tag(c::tag_table_val, |rbml_w| { 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 { match *adjustment {
_ if ty::adjust_is_object(adjustment) => { _ if ty::adjust_is_object(adjustment) => {
let method_call = MethodCall::autoobject(id); 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.tag(c::tag_table_method_map, |rbml_w| {
rbml_w.id(id); rbml_w.id(id);
rbml_w.tag(c::tag_table_val, |rbml_w| { 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)); assert!(!ty::adjust_is_object(adjustment));
for autoderef in 0..adj.autoderefs { for autoderef in 0..adj.autoderefs {
let method_call = MethodCall::autoderef(id, autoderef); 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.tag(c::tag_table_method_map, |rbml_w| {
rbml_w.id(id); rbml_w.id(id);
rbml_w.tag(c::tag_table_val, |rbml_w| { 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.tag(c::tag_table_closure_tys, |rbml_w| {
rbml_w.id(id); rbml_w.id(id);
rbml_w.tag(c::tag_table_val, |rbml_w| { 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.tag(c::tag_table_closure_kinds, |rbml_w| {
rbml_w.id(id); rbml_w.id(id);
rbml_w.tag(c::tag_table_val, |rbml_w| { rbml_w.tag(c::tag_table_val, |rbml_w| {
encode_closure_kind(rbml_w, closure_kind) encode_closure_kind(rbml_w, *closure_kind)
}) })
}) })
} }

View file

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

View file

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

View file

@ -157,7 +157,7 @@ fn check_expr(cx: &mut MatchCheckCtxt, ex: &ast::Expr) {
visit::walk_expr(cx, ex); visit::walk_expr(cx, ex);
match ex.node { match ex.node {
ast::ExprMatch(ref scrut, ref arms, source) => { ast::ExprMatch(ref scrut, ref arms, source) => {
for arm in arms.iter() { for arm in arms {
// First, check legality of move bindings. // First, check legality of move bindings.
check_legality_of_move_bindings(cx, check_legality_of_move_bindings(cx,
arm.guard.is_some(), arm.guard.is_some(),
@ -285,8 +285,8 @@ fn check_arms(cx: &MatchCheckCtxt,
source: ast::MatchSource) { source: ast::MatchSource) {
let mut seen = Matrix(vec![]); let mut seen = Matrix(vec![]);
let mut printed_if_let_err = false; let mut printed_if_let_err = false;
for &(ref pats, guard) in arms.iter() { for &(ref pats, guard) in arms {
for pat in pats.iter() { for pat in pats {
let v = vec![&**pat]; let v = vec![&**pat];
match is_useful(cx, &seen, &v[], LeaveOutWitness) { 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); 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| { is_refutable(cx, &*input.pat, |pat| {
span_err!(cx.tcx.sess, input.pat.span, E0006, span_err!(cx.tcx.sess, input.pat.span, E0006,
"refutable pattern in function argument: `{}` not covered", "refutable pattern in function argument: `{}` not covered",
@ -1012,7 +1012,7 @@ fn check_legality_of_move_bindings(cx: &MatchCheckCtxt,
let tcx = cx.tcx; let tcx = cx.tcx;
let def_map = &tcx.def_map; let def_map = &tcx.def_map;
let mut by_ref_span = None; let mut by_ref_span = None;
for pat in pats.iter() { for pat in pats {
pat_bindings(def_map, &**pat, |bm, _, span, _path| { pat_bindings(def_map, &**pat, |bm, _, span, _path| {
match bm { match bm {
ast::BindByRef(_) => { 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| { walk_pat(&**pat, |p| {
if pat_is_binding(def_map, &*p) { if pat_is_binding(def_map, &*p) {
match p.node { match p.node {

View file

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

View file

@ -399,7 +399,7 @@ impl<'a, 'tcx, O:DataFlowOperator> DataFlowContext<'a, 'tcx, O> {
let mut orig_kills = self.kills[start.. end].to_vec(); let mut orig_kills = self.kills[start.. end].to_vec();
let mut changed = false; 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); let opt_cfg_idx = self.nodeid_to_index.get(&node_id).map(|&i|i);
match opt_cfg_idx { match opt_cfg_idx {
Some(cfg_idx) => { Some(cfg_idx) => {
@ -550,7 +550,7 @@ fn bits_to_string(words: &[uint]) -> String {
// Note: this is a little endian printout of bytes. // Note: this is a little endian printout of bytes.
for &word in words.iter() { for &word in words {
let mut v = word; let mut v = word;
for _ in 0..uint::BYTES { for _ in 0..uint::BYTES {
result.push(sep); result.push(sep);

View file

@ -173,7 +173,7 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {
} }
}; };
let fields = ty::lookup_struct_fields(self.tcx, id); let fields = ty::lookup_struct_fields(self.tcx, id);
for pat in pats.iter() { for pat in pats {
let field_id = fields.iter() let field_id = fields.iter()
.find(|field| field.name == pat.node.ident.name).unwrap().id; .find(|field| field.name == pat.node.ident.name).unwrap().id;
self.live_symbols.insert(field_id.node); self.live_symbols.insert(field_id.node);
@ -356,7 +356,7 @@ impl<'v> Visitor<'v> for LifeSeeder {
self.worklist.extend(enum_def.variants.iter().map(|variant| variant.node.id)); self.worklist.extend(enum_def.variants.iter().map(|variant| variant.node.id));
} }
ast::ItemImpl(_, _, _, Some(ref _trait_ref), _, ref impl_items) => { 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 { match *impl_item {
ast::MethodImplItem(ref method) => { ast::MethodImplItem(ref method) => {
self.worklist.push(method.id); 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 // 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 // the warning to be consistent, we also seed the worklist with
// exported symbols. // exported symbols.
for id in exported_items.iter() { for id in exported_items {
worklist.push(*id); worklist.push(*id);
} }
for id in reachable_symbols.iter() { for id in reachable_symbols {
worklist.push(*id); worklist.push(*id);
} }
@ -499,8 +499,8 @@ impl<'a, 'tcx> DeadVisitor<'a, 'tcx> {
match self.tcx.inherent_impls.borrow().get(&local_def(id)) { match self.tcx.inherent_impls.borrow().get(&local_def(id)) {
None => (), None => (),
Some(impl_list) => { Some(impl_list) => {
for impl_did in impl_list.iter() { for impl_did in &**impl_list {
for item_did in (*impl_items)[*impl_did].iter() { for item_did in &(*impl_items)[*impl_did] {
if self.live_symbols.contains(&item_did.def_id() if self.live_symbols.contains(&item_did.def_id()
.node) { .node) {
return true; return true;
@ -536,7 +536,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for DeadVisitor<'a, 'tcx> {
} else { } else {
match item.node { match item.node {
ast::ItemEnum(ref enum_def, _) => { 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) { if self.should_warn_about_variant(&variant.node) {
self.warn_dead_code(variant.node.id, variant.span, self.warn_dead_code(variant.node.id, variant.span,
variant.node.name, "variant"); variant.node.name, "variant");

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1208,7 +1208,7 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> {
} }
} }
Some(&def::DefConst(..)) => { Some(&def::DefConst(..)) => {
for subpat in subpats.iter() { for subpat in subpats {
try!(self.cat_pattern_(cmt.clone(), &**subpat, op)); 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, _) => { ast::PatStruct(_, ref field_pats, _) => {
// {f1: p1, ..., fN: pN} // {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 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); 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)); 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) => { ast::PatVec(ref before, ref slice, ref after) => {
let elt_cmt = try!(self.cat_index(pat, try!(self.deref_vec(pat, cmt)))); 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)); 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_ty = try!(self.pat_ty(&**slice_pat));
let slice_cmt = self.cat_rvalue_node(pat.id(), pat.span(), slice_ty); let slice_cmt = self.cat_rvalue_node(pat.id(), pat.span(), slice_ty);
try!(self.cat_pattern_(slice_cmt, &**slice_pat, op)); 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)); try!(self.cat_pattern_(elt_cmt.clone(), &**after_pat, op));
} }
} }

View file

@ -353,7 +353,7 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> {
// this properly would result in the necessity of computing *type* // this properly would result in the necessity of computing *type*
// reachability, which might result in a compile time loss. // reachability, which might result in a compile time loss.
fn mark_destructors_reachable(&mut self) { 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 { if destructor_def_id.krate == ast::LOCAL_CRATE {
self.reachable_symbols.insert(destructor_def_id.node); 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 // 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 // use the lang items, so we need to be sure to mark them as
// exported. // exported.
for id in exported_items.iter() { for id in exported_items {
reachable_context.worklist.push(*id); reachable_context.worklist.push(*id);
} }
for (_, item) in tcx.lang_items.items() { for (_, item) in tcx.lang_items.items() {

View file

@ -20,7 +20,7 @@ use syntax::ast;
use syntax::attr::AttrMetaMethods; use syntax::attr::AttrMetaMethods;
pub fn update_recursion_limit(sess: &Session, krate: &ast::Crate) { 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") { if !attr.check_name("recursion_limit") {
continue; continue;
} }

View file

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

View file

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

View file

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

View file

@ -241,7 +241,7 @@ pub struct SeparateVecsPerParamSpace<T> {
impl<T: fmt::Debug> fmt::Debug for VecPerParamSpace<T> { impl<T: fmt::Debug> fmt::Debug for VecPerParamSpace<T> {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
try!(write!(fmt, "VecPerParamSpace {{")); 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, "{:?}: {:?}, ", *space, self.get_slice(*space)));
} }
try!(write!(fmt, "}}")); try!(write!(fmt, "}}"));

View file

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

View file

@ -28,7 +28,7 @@ use util::ppaux::{Repr, UserString};
pub fn report_fulfillment_errors<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>, pub fn report_fulfillment_errors<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>,
errors: &Vec<FulfillmentError<'tcx>>) { errors: &Vec<FulfillmentError<'tcx>>) {
for error in errors.iter() { for error in errors {
report_fulfillment_error(infcx, error); report_fulfillment_error(infcx, error);
} }
} }
@ -68,7 +68,7 @@ fn report_on_unimplemented<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>,
span: Span) -> Option<String> { span: Span) -> Option<String> {
let def_id = trait_ref.def_id; let def_id = trait_ref.def_id;
let mut report = None; 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") { if item.check_name("rustc_on_unimplemented") {
let err_sp = if item.meta().span == DUMMY_SP { let err_sp = if item.meta().span == DUMMY_SP {
span span

View file

@ -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 // The `Self` type is erased, so it should not appear in list of
// arguments or return type apart from the receiver. // arguments or return type apart from the receiver.
let ref sig = method.fty.sig; 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) { if contains_illegal_self_type_reference(tcx, trait_def_id, input_ty) {
return Some(MethodViolationCode::ReferencesSelf); return Some(MethodViolationCode::ReferencesSelf);
} }

View file

@ -802,7 +802,7 @@ fn confirm_impl_candidate<'cx,'tcx>(
let impl_items = &impl_items_map[impl_vtable.impl_def_id]; let impl_items = &impl_items_map[impl_vtable.impl_def_id];
let mut impl_ty = None; 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()] { let assoc_type = match impl_or_trait_items_map[impl_item.def_id()] {
ty::TypeTraitItem(ref assoc_type) => assoc_type.clone(), ty::TypeTraitItem(ref assoc_type) => assoc_type.clone(),
ty::MethodTraitItem(..) => { continue; } ty::MethodTraitItem(..) => { continue; }

View file

@ -1089,7 +1089,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
debug!("assemble_candidates_from_impls(self_ty={})", self_ty.repr(self.tcx())); debug!("assemble_candidates_from_impls(self_ty={})", self_ty.repr(self.tcx()));
let all_impls = self.all_impls(obligation.predicate.def_id()); 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| { self.infcx.probe(|snapshot| {
let (skol_obligation_trait_pred, skol_map) = let (skol_obligation_trait_pred, skol_map) =
self.infcx().skolemize_late_bound_regions(&obligation.predicate, snapshot); self.infcx().skolemize_late_bound_regions(&obligation.predicate, snapshot);

View file

@ -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()); 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 { match *trait_item {
ty::MethodTraitItem(_) => method_count += 1, ty::MethodTraitItem(_) => method_count += 1,
ty::TypeTraitItem(_) => {} ty::TypeTraitItem(_) => {}

View file

@ -872,7 +872,7 @@ macro_rules! sty_debug_print {
$(let mut $variant = total;)* $(let mut $variant = total;)*
for (_, t) in tcx.interner.borrow().iter() { for (_, t) in &*tcx.interner.borrow() {
let variant = match t.sty { let variant = match t.sty {
ty::ty_bool | ty::ty_char | ty::ty_int(..) | ty::ty_uint(..) | ty::ty_bool | ty::ty_char | ty::ty_int(..) | ty::ty_uint(..) |
ty::ty_float(..) | ty::ty_str => continue, ty::ty_float(..) | ty::ty_str => continue,
@ -2579,7 +2579,7 @@ impl FlagComputation {
&ty_trait(box TyTrait { ref principal, ref bounds }) => { &ty_trait(box TyTrait { ref principal, ref bounds }) => {
let mut computation = FlagComputation::new(); let mut computation = FlagComputation::new();
computation.add_substs(principal.0.substs); 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(); let mut proj_computation = FlagComputation::new();
proj_computation.add_projection_predicate(&projection_bound.0); proj_computation.add_projection_predicate(&projection_bound.0);
computation.add_bound_computation(&proj_computation); computation.add_bound_computation(&proj_computation);
@ -2618,7 +2618,7 @@ impl FlagComputation {
} }
fn add_tys(&mut self, tys: &[Ty]) { fn add_tys(&mut self, tys: &[Ty]) {
for &ty in tys.iter() { for &ty in tys {
self.add_ty(ty); 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 // make no assumptions (other than that it cannot have an
// in-scope type parameter within, which makes no sense). // in-scope type parameter within, which makes no sense).
let mut tc = TC::All - TC::InteriorParam; let mut tc = TC::All - TC::InteriorParam;
for bound in bounds.builtin_bounds.iter() { for bound in &bounds.builtin_bounds {
tc = tc - match bound { tc = tc - match bound {
BoundSync | BoundSend | BoundCopy => TC::None, BoundSync | BoundSend | BoundCopy => TC::None,
BoundSized => TC::Nonsized, 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]) pub fn field_idx_strict(tcx: &ctxt, name: ast::Name, fields: &[field])
-> uint { -> uint {
let mut i = 0; 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!( tcx.sess.bug(&format!(
"no field named `{}` found in the list of fields `{:?}`", "no field named `{}` found in the list of fields `{:?}`",
token::get_name(name), token::get_name(name),
@ -5468,25 +5468,25 @@ pub fn predicates<'tcx>(
{ {
let mut vec = Vec::new(); 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) { match traits::trait_ref_for_builtin_bound(tcx, builtin_bound, param_ty) {
Ok(trait_ref) => { vec.push(trait_ref.as_predicate()); } Ok(trait_ref) => { vec.push(trait_ref.as_predicate()); }
Err(ErrorReported) => { } Err(ErrorReported) => { }
} }
} }
for &region_bound in bounds.region_bounds.iter() { for &region_bound in &bounds.region_bounds {
// account for the binder being introduced below; no need to shift `param_ty` // 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 // because, at present at least, it can only refer to early-bound regions
let region_bound = ty_fold::shift_region(region_bound, 1); let region_bound = ty_fold::shift_region(region_bound, 1);
vec.push(ty::Binder(ty::OutlivesPredicate(param_ty, region_bound)).as_predicate()); 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()); 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()); 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. // Record the trait->implementation mappings, if applicable.
let associated_traits = csearch::get_impl_trait(tcx, impl_def_id); 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); record_trait_implementation(tcx, trait_ref.def_id, impl_def_id);
} }
// For any methods that use a default implementation, add them to // For any methods that use a default implementation, add them to
// the map. This is a bit unfortunate. // 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(); let method_def_id = impl_item_def_id.def_id();
match impl_or_trait_item(tcx, method_def_id) { match impl_or_trait_item(tcx, method_def_id) {
MethodTraitItem(method) => { MethodTraitItem(method) => {
for &source in method.provided_source.iter() { if let Some(source) = method.provided_source {
tcx.provided_method_sources tcx.provided_method_sources
.borrow_mut() .borrow_mut()
.insert(method_def_id, source); .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 // For any methods that use a default implementation, add them to
// the map. This is a bit unfortunate. // 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(); let method_def_id = impl_item_def_id.def_id();
match impl_or_trait_item(tcx, method_def_id) { match impl_or_trait_item(tcx, method_def_id) {
MethodTraitItem(method) => { MethodTraitItem(method) => {
for &source in method.provided_source.iter() { if let Some(source) = method.provided_source {
tcx.provided_method_sources tcx.provided_method_sources
.borrow_mut() .borrow_mut()
.insert(method_def_id, source); .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 fn_sig = |&: state: &mut SipHasher, sig: &Binder<FnSig<'tcx>>| {
let sig = anonymize_late_bound_regions(tcx, sig).0; 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 { if let ty::FnConverging(output) = sig.output {
helper(tcx, output, svh, state); helper(tcx, output, svh, state);
} }
@ -6270,7 +6270,7 @@ pub fn construct_free_substs<'a,'tcx>(
free_id: ast::NodeId, free_id: ast::NodeId,
region_params: &[RegionParameterDef]) 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)); 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>, fn push_types_from_defs<'tcx>(tcx: &ty::ctxt<'tcx>,
types: &mut VecPerParamSpace<Ty<'tcx>>, types: &mut VecPerParamSpace<Ty<'tcx>>,
defs: &[TypeParameterDef<'tcx>]) { defs: &[TypeParameterDef<'tcx>]) {
for def in defs.iter() { for def in defs {
debug!("construct_parameter_environment(): push_types_from_defs: def={:?}", debug!("construct_parameter_environment(): push_types_from_defs: def={:?}",
def.repr(tcx)); def.repr(tcx));
let ty = ty::mk_param_from_def(tcx, def); 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>]) { fn record_region_bounds<'tcx>(tcx: &ty::ctxt<'tcx>, predicates: &[ty::Predicate<'tcx>]) {
debug!("record_region_bounds(predicates={:?})", predicates.repr(tcx)); debug!("record_region_bounds(predicates={:?})", predicates.repr(tcx));
for predicate in predicates.iter() { for predicate in predicates {
match *predicate { match *predicate {
Predicate::Projection(..) | Predicate::Projection(..) |
Predicate::Trait(..) | 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 { let did = match self_type.sty {
ty::ty_struct(struct_did, substs) => { ty::ty_struct(struct_did, substs) => {
let fields = ty::struct_fields(tcx, 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) { if type_moves_by_default(param_env, span, field.mt.ty) {
return Err(FieldDoesNotImplementCopy(field.name)) 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) => { ty::ty_enum(enum_did, substs) => {
let enum_variants = ty::enum_variants(tcx, enum_did); let enum_variants = ty::enum_variants(tcx, enum_did);
for variant in enum_variants.iter() { for variant in &*enum_variants {
for variant_arg_type in variant.args.iter() { for variant_arg_type in &variant.args {
let substd_arg_type = let substd_arg_type =
variant_arg_type.subst(tcx, substs); variant_arg_type.subst(tcx, substs);
if type_moves_by_default(param_env, span, substd_arg_type) { if type_moves_by_default(param_env, span, substd_arg_type) {

View file

@ -78,7 +78,7 @@ fn verify(sess: &Session, items: &lang_items::LanguageItems) {
let mut missing = HashSet::new(); let mut missing = HashSet::new();
sess.cstore.iter_crate_data(|cnum, _| { 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); missing.insert(*item);
} }
}); });

View file

@ -48,7 +48,7 @@ pub fn find_plugin_registrar(diagnostic: &diagnostic::SpanHandler,
}, },
_ => { _ => {
diagnostic.handler().err("multiple plugin registration functions found"); 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.span_note(span, "one is here");
} }
diagnostic.handler().abort_if_errors(); diagnostic.handler().abort_if_errors();

View file

@ -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 // 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 // crate root, because `$crate` won't work properly. Identify these by
// spans, because the crate map isn't set up yet. // 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 { if let ast::ItemExternCrate(_) = item.node {
loader.span_whitelist.insert(item.span); 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); visit::walk_crate(&mut loader, krate);
if let Some(plugins) = addl_plugins { if let Some(plugins) = addl_plugins {
for plugin in plugins.iter() { for plugin in &plugins {
loader.load_plugin(CrateOrString::Str(plugin.as_slice()), loader.load_plugin(CrateOrString::Str(plugin.as_slice()),
None, None, None) None, None, None)
} }
@ -107,7 +107,7 @@ impl<'a, 'v> Visitor<'v> for PluginLoader<'a> {
let mut plugin_attr = None; let mut plugin_attr = None;
let mut macro_selection = Some(HashSet::new()); // None => load all let mut macro_selection = Some(HashSet::new()); // None => load all
let mut reexport = HashSet::new(); let mut reexport = HashSet::new();
for attr in item.attrs.iter() { for attr in &item.attrs {
let mut used = true; let mut used = true;
match attr.name().get() { match attr.name().get() {
"phase" => { "phase" => {
@ -127,7 +127,7 @@ impl<'a, 'v> Visitor<'v> for PluginLoader<'a> {
macro_selection = None; macro_selection = None;
} }
if let (Some(sel), Some(names)) = (macro_selection.as_mut(), names) { 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 { if let ast::MetaWord(ref name) = name.node {
sel.insert(name.clone()); sel.insert(name.clone());
} else { } 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 { if let ast::MetaWord(ref name) = name.node {
reexport.insert(name.clone()); reexport.insert(name.clone());
} else { } else {

View file

@ -306,7 +306,7 @@ macro_rules! options {
let value = iter.next(); let value = iter.next();
let option_to_lookup = key.replace("-", "_"); let option_to_lookup = key.replace("-", "_");
let mut found = false; 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 option_to_lookup != candidate { continue }
if !setter(&mut op, value) { if !setter(&mut op, value) {
match (value, opt_type_desc) { match (value, opt_type_desc) {
@ -830,7 +830,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
let mut lint_opts = vec!(); let mut lint_opts = vec!();
let mut describe_lints = false; let mut describe_lints = false;
for &level in [lint::Allow, lint::Warn, lint::Deny, lint::Forbid].iter() { for &level in &[lint::Allow, lint::Warn, lint::Deny, lint::Forbid] {
for lint_name in matches.opt_strs(level.as_str()).into_iter() { for lint_name in matches.opt_strs(level.as_str()).into_iter() {
if lint_name == "help" { if lint_name == "help" {
describe_lints = true; describe_lints = true;
@ -853,7 +853,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
let mut output_types = Vec::new(); let mut output_types = Vec::new();
if !debugging_opts.parse_only && !no_trans { if !debugging_opts.parse_only && !no_trans {
let unparsed_output_types = matches.opt_strs("emit"); 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(',') { for part in unparsed_output_type.split(',') {
let output_type = match part.as_slice() { let output_type = match part.as_slice() {
"asm" => OutputTypeAssembly, "asm" => OutputTypeAssembly,
@ -923,7 +923,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
}; };
let mut search_paths = SearchPaths::new(); 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[]); search_paths.add_path(&s[]);
} }
@ -997,7 +997,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
}; };
let mut externs = HashMap::new(); 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 mut parts = arg.splitn(1, '=');
let name = match parts.next() { let name = match parts.next() {
Some(s) => s, 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> { pub fn parse_crate_types_from_list(list_list: Vec<String>) -> Result<Vec<CrateType>, String> {
let mut crate_types: Vec<CrateType> = Vec::new(); 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(',') { for part in unparsed_crate_type.split(',') {
let new_part = match part { let new_part = match part {
"lib" => default_lib_output(), "lib" => default_lib_output(),

View file

@ -163,7 +163,7 @@ pub fn can_reach<T, S>(edges_map: &HashMap<T, Vec<T>, S>, source: T,
while i < queue.len() { while i < queue.len() {
match edges_map.get(&queue[i]) { match edges_map.get(&queue[i]) {
Some(edges) => { Some(edges) => {
for target in edges.iter() { for target in edges {
if *target == destination { if *target == destination {
return true; return true;
} }

View file

@ -62,7 +62,7 @@ impl Hasher for FnvHasher {
impl Writer for FnvHasher { impl Writer for FnvHasher {
fn write(&mut self, bytes: &[u8]) { fn write(&mut self, bytes: &[u8]) {
let FnvHasher(mut hash) = *self; let FnvHasher(mut hash) = *self;
for byte in bytes.iter() { for byte in bytes {
hash = hash ^ (*byte as u64); hash = hash ^ (*byte as u64);
hash = hash * 0x100000001b3; hash = hash * 0x100000001b3;
} }

View file

@ -494,11 +494,11 @@ pub fn parameterized<'tcx>(cx: &ctxt<'tcx>,
0 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)) strs.push(ty_to_string(cx, *t))
} }
for projection in projections.iter() { for projection in projections {
strs.push(format!("{}={}", strs.push(format!("{}={}",
projection.projection_ty.item_name.user_string(cx), projection.projection_ty.item_name.user_string(cx),
projection.ty.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)); components.push(tap.user_string(tcx));
// Builtin bounds. // Builtin bounds.
for bound in bounds.builtin_bounds.iter() { for bound in &bounds.builtin_bounds {
components.push(bound.user_string(tcx)); components.push(bound.user_string(tcx));
} }
@ -748,7 +748,7 @@ impl<'tcx> Repr<'tcx> for subst::RegionSubsts {
impl<'tcx> Repr<'tcx> for ty::BuiltinBounds { impl<'tcx> Repr<'tcx> for ty::BuiltinBounds {
fn repr(&self, _tcx: &ctxt) -> String { fn repr(&self, _tcx: &ctxt) -> String {
let mut res = Vec::new(); let mut res = Vec::new();
for b in self.iter() { for b in self {
res.push(match b { res.push(match b {
ty::BoundSend => "Send".to_string(), ty::BoundSend => "Send".to_string(),
ty::BoundSized => "Sized".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 { fn repr(&self, tcx: &ctxt<'tcx>) -> String {
let mut res = Vec::new(); let mut res = Vec::new();
res.push(self.builtin_bounds.repr(tcx)); 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.push(t.repr(tcx));
} }
res.connect("+") res.connect("+")
@ -1157,7 +1157,7 @@ impl<'tcx> UserString<'tcx> for ty::ParamBounds<'tcx> {
if !s.is_empty() { if !s.is_empty() {
result.push(s); result.push(s);
} }
for n in self.trait_bounds.iter() { for n in &self.trait_bounds {
result.push(n.user_string(tcx)); result.push(n.user_string(tcx));
} }
result.connect(" + ") result.connect(" + ")
@ -1173,11 +1173,11 @@ impl<'tcx> Repr<'tcx> for ty::ExistentialBounds<'tcx> {
res.push(region_str); res.push(region_str);
} }
for bound in self.builtin_bounds.iter() { for bound in &self.builtin_bounds {
res.push(bound.user_string(tcx)); 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)); res.push(projection_bound.user_string(tcx));
} }

View file

@ -99,7 +99,7 @@ pub fn find_library(name: &str, osprefix: &str, ossuffix: &str,
let oslibname = format!("{}{}{}", osprefix, name, ossuffix); let oslibname = format!("{}{}{}", osprefix, name, ossuffix);
let unixlibname = format!("lib{}.a", name); let unixlibname = format!("lib{}.a", name);
for path in search_paths.iter() { for path in search_paths {
debug!("looking for {} inside {:?}", name, path.display()); debug!("looking for {} inside {:?}", name, path.display());
let test = path.join(&oslibname[]); let test = path.join(&oslibname[]);
if test.exists() { return test } 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. // 32,768, and we leave a bit of extra space for the program name.
static ARG_LENGTH_LIMIT: uint = 32000; 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(); let len = member_name.as_vec().len();
// `len + 1` to account for the space that's inserted before each // `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 // all SYMDEF files as these are just magical placeholders which get
// re-created when we make a new archive anyway. // re-created when we make a new archive anyway.
let files = try!(fs::readdir(loc.path())); let files = try!(fs::readdir(loc.path()));
for file in files.iter() { for file in &files {
let filename = file.filename_str().unwrap(); let filename = file.filename_str().unwrap();
if skip(filename) { continue } if skip(filename) { continue }
if filename.contains(".SYMDEF") { continue } if filename.contains(".SYMDEF") { continue }

View file

@ -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> { fn rpaths_to_flags(rpaths: &[String]) -> Vec<String> {
let mut ret = Vec::new(); let mut ret = Vec::new();
for rpath in rpaths.iter() { for rpath in rpaths {
ret.push(format!("-Wl,-rpath,{}", &(*rpath)[])); ret.push(format!("-Wl,-rpath,{}", &(*rpath)[]));
} }
return ret; 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!("output: {:?}", config.out_filename.display());
debug!("libs:"); debug!("libs:");
for libpath in libs.iter() { for libpath in libs {
debug!(" {:?}", libpath.display()); 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]) { fn log_rpaths(desc: &str, rpaths: &[String]) {
debug!("{} rpaths:", desc); debug!("{} rpaths:", desc);
for rpath in rpaths.iter() { for rpath in rpaths {
debug!(" {}", *rpath); debug!(" {}", *rpath);
} }
} }
@ -139,7 +139,7 @@ fn get_install_prefix_rpath<F, G>(config: RPathConfig<F, G>) -> String where
fn minimize_rpaths(rpaths: &[String]) -> Vec<String> { fn minimize_rpaths(rpaths: &[String]) -> Vec<String> {
let mut set = HashSet::new(); let mut set = HashSet::new();
let mut minimized = Vec::new(); let mut minimized = Vec::new();
for rpath in rpaths.iter() { for rpath in rpaths {
if set.insert(&rpath[]) { if set.insert(&rpath[]) {
minimized.push(rpath.clone()); minimized.push(rpath.clone());
} }

View file

@ -557,7 +557,7 @@ mod tests {
fn test_hash<D: Digest>(sh: &mut D, tests: &[Test]) { fn test_hash<D: Digest>(sh: &mut D, tests: &[Test]) {
// Test that it works when accepting the message all at once // Test that it works when accepting the message all at once
for t in tests.iter() { for t in tests {
sh.reset(); sh.reset();
sh.input_str(t.input.as_slice()); sh.input_str(t.input.as_slice());
let out_str = sh.result_str(); let out_str = sh.result_str();
@ -565,7 +565,7 @@ mod tests {
} }
// Test that it works when accepting the message in pieces // Test that it works when accepting the message in pieces
for t in tests.iter() { for t in tests {
sh.reset(); sh.reset();
let len = t.input.len(); let len = t.input.len();
let mut left = len; let mut left = len;

View file

@ -79,7 +79,7 @@ impl Svh {
// avoid collisions. // avoid collisions.
let mut state = SipHasher::new(); let mut state = SipHasher::new();
for data in metadata.iter() { for data in metadata {
data.hash(&mut state); data.hash(&mut state);
} }
@ -97,7 +97,7 @@ impl Svh {
// //
// We hash only the MetaItems instead of the entire Attribute // We hash only the MetaItems instead of the entire Attribute
// to avoid hashing the AttrId // to avoid hashing the AttrId
for attr in krate.attrs.iter() { for attr in &krate.attrs {
attr.node.value.hash(&mut state); attr.node.value.hash(&mut state);
} }

View file

@ -384,7 +384,7 @@ impl Target {
let paths = os::split_paths(&target_path[]); let paths = os::split_paths(&target_path[]);
// FIXME 16351: add a sane default search path? // FIXME 16351: add a sane default search path?
for dir in paths.iter() { for dir in &paths {
let p = dir.join(path.clone()); let p = dir.join(path.clone());
if p.is_file() { if p.is_file() {
return load_file(&p); return load_file(&p);

View file

@ -279,7 +279,7 @@ impl<'a, 'tcx> CheckLoanCtxt<'a, 'tcx> {
let loan_path = owned_ptr_base_path(loan_path); let loan_path = owned_ptr_base_path(loan_path);
let cont = self.each_in_scope_loan(scope, |loan| { let cont = self.each_in_scope_loan(scope, |loan| {
let mut ret = true; let mut ret = true;
for restr_path in loan.restricted_paths.iter() { for restr_path in &loan.restricted_paths {
if **restr_path == *loan_path { if **restr_path == *loan_path {
if !op(loan) { if !op(loan) {
ret = false; ret = false;
@ -361,7 +361,7 @@ impl<'a, 'tcx> CheckLoanCtxt<'a, 'tcx> {
debug!("new_loan_indices = {:?}", new_loan_indices); debug!("new_loan_indices = {:?}", new_loan_indices);
self.each_issued_loan(scope, |issued_loan| { self.each_issued_loan(scope, |issued_loan| {
for &new_loan_index in new_loan_indices.iter() { for &new_loan_index in &new_loan_indices {
let new_loan = &self.all_loans[new_loan_index]; let new_loan = &self.all_loans[new_loan_index];
self.report_error_if_loans_conflict(issued_loan, new_loan); self.report_error_if_loans_conflict(issued_loan, new_loan);
} }
@ -370,7 +370,7 @@ impl<'a, 'tcx> CheckLoanCtxt<'a, 'tcx> {
for (i, &x) in new_loan_indices.iter().enumerate() { for (i, &x) in new_loan_indices.iter().enumerate() {
let old_loan = &self.all_loans[x]; let old_loan = &self.all_loans[x];
for &y in new_loan_indices[(i+1) ..].iter() { for &y in &new_loan_indices[(i+1) ..] {
let new_loan = &self.all_loans[y]; let new_loan = &self.all_loans[y];
self.report_error_if_loans_conflict(old_loan, new_loan); self.report_error_if_loans_conflict(old_loan, new_loan);
} }
@ -416,7 +416,7 @@ impl<'a, 'tcx> CheckLoanCtxt<'a, 'tcx> {
} }
let loan2_base_path = owned_ptr_base_path_rc(&loan2.loan_path); let loan2_base_path = owned_ptr_base_path_rc(&loan2.loan_path);
for restr_path in loan1.restricted_paths.iter() { for restr_path in &loan1.restricted_paths {
if *restr_path != loan2_base_path { continue; } if *restr_path != loan2_base_path { continue; }
// If new_loan is something like `x.a`, and old_loan is something like `x.b`, we would // If new_loan is something like `x.a`, and old_loan is something like `x.b`, we would

View file

@ -204,14 +204,14 @@ pub fn fixup_fragment_sets<'tcx>(this: &MoveData<'tcx>, tcx: &ty::ctxt<'tcx>) {
debug!("fragments 1 assigned: {:?}", path_lps(&assigned[])); debug!("fragments 1 assigned: {:?}", path_lps(&assigned[]));
// Second, build parents from the moved and assigned. // Second, build parents from the moved and assigned.
for m in moved.iter() { for m in &moved {
let mut p = this.path_parent(*m); let mut p = this.path_parent(*m);
while p != InvalidMovePathIndex { while p != InvalidMovePathIndex {
parents.push(p); parents.push(p);
p = this.path_parent(p); p = this.path_parent(p);
} }
} }
for a in assigned.iter() { for a in &assigned {
let mut p = this.path_parent(*a); let mut p = this.path_parent(*a);
while p != InvalidMovePathIndex { while p != InvalidMovePathIndex {
parents.push(p); parents.push(p);
@ -231,15 +231,15 @@ pub fn fixup_fragment_sets<'tcx>(this: &MoveData<'tcx>, tcx: &ty::ctxt<'tcx>) {
debug!("fragments 3 assigned: {:?}", path_lps(&assigned[])); debug!("fragments 3 assigned: {:?}", path_lps(&assigned[]));
// Fourth, build the leftover from the moved, assigned, and parents. // Fourth, build the leftover from the moved, assigned, and parents.
for m in moved.iter() { for m in &moved {
let lp = this.path_loan_path(*m); let lp = this.path_loan_path(*m);
add_fragment_siblings(this, tcx, &mut unmoved, lp, None); add_fragment_siblings(this, tcx, &mut unmoved, lp, None);
} }
for a in assigned.iter() { for a in &assigned {
let lp = this.path_loan_path(*a); let lp = this.path_loan_path(*a);
add_fragment_siblings(this, tcx, &mut unmoved, lp, None); add_fragment_siblings(this, tcx, &mut unmoved, lp, None);
} }
for p in parents.iter() { for p in &parents {
let lp = this.path_loan_path(*p); let lp = this.path_loan_path(*p);
add_fragment_siblings(this, tcx, &mut unmoved, lp, None); add_fragment_siblings(this, tcx, &mut unmoved, lp, None);
} }
@ -369,7 +369,7 @@ fn add_fragment_siblings_for_extension<'tcx>(this: &MoveData<'tcx>,
let fields = ty::lookup_struct_fields(tcx, def_id); let fields = ty::lookup_struct_fields(tcx, def_id);
match *origin_field_name { match *origin_field_name {
mc::NamedField(ast_name) => { mc::NamedField(ast_name) => {
for f in fields.iter() { for f in &fields {
if f.name == ast_name { if f.name == ast_name {
continue; continue;
} }
@ -407,7 +407,7 @@ fn add_fragment_siblings_for_extension<'tcx>(this: &MoveData<'tcx>,
match *origin_field_name { match *origin_field_name {
mc::NamedField(ast_name) => { mc::NamedField(ast_name) => {
let variant_arg_names = variant_info.arg_names.as_ref().unwrap(); let variant_arg_names = variant_info.arg_names.as_ref().unwrap();
for variant_arg_ident in variant_arg_names.iter() { for variant_arg_ident in variant_arg_names {
if variant_arg_ident.name == ast_name { if variant_arg_ident.name == ast_name {
continue; continue;
} }

View file

@ -67,10 +67,10 @@ pub struct GroupedMoveErrors<'tcx> {
fn report_move_errors<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>, fn report_move_errors<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>,
errors: &Vec<MoveError<'tcx>>) { errors: &Vec<MoveError<'tcx>>) {
let grouped_errors = group_errors_with_same_origin(errors); let grouped_errors = group_errors_with_same_origin(errors);
for error in grouped_errors.iter() { for error in &grouped_errors {
report_cannot_move_out_of(bccx, error.move_from.clone()); report_cannot_move_out_of(bccx, error.move_from.clone());
let mut is_first_note = true; let mut is_first_note = true;
for move_to in error.move_to_places.iter() { for move_to in &error.move_to_places {
note_move_destination(bccx, move_to.span, note_move_destination(bccx, move_to.span,
&move_to.ident, is_first_note); &move_to.ident, is_first_note);
is_first_note = false; is_first_note = false;
@ -81,7 +81,7 @@ fn report_move_errors<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>,
fn group_errors_with_same_origin<'tcx>(errors: &Vec<MoveError<'tcx>>) fn group_errors_with_same_origin<'tcx>(errors: &Vec<MoveError<'tcx>>)
-> Vec<GroupedMoveErrors<'tcx>> { -> Vec<GroupedMoveErrors<'tcx>> {
let mut grouped_errors = Vec::new(); let mut grouped_errors = Vec::new();
for error in errors.iter() { for error in errors {
append_to_grouped_errors(&mut grouped_errors, error) append_to_grouped_errors(&mut grouped_errors, error)
} }
return grouped_errors; return grouped_errors;

View file

@ -475,13 +475,13 @@ impl<'tcx> MoveData<'tcx> {
self.kill_moves(assignment.path, assignment.id, dfcx_moves); self.kill_moves(assignment.path, assignment.id, dfcx_moves);
} }
for assignment in self.path_assignments.borrow().iter() { for assignment in &*self.path_assignments.borrow() {
self.kill_moves(assignment.path, assignment.id, dfcx_moves); self.kill_moves(assignment.path, assignment.id, dfcx_moves);
} }
// Kill all moves related to a variable `x` when // Kill all moves related to a variable `x` when
// it goes out of scope: // it goes out of scope:
for path in self.paths.borrow().iter() { for path in &*self.paths.borrow() {
match path.loan_path.kind { match path.loan_path.kind {
LpVar(..) | LpUpvar(..) | LpDowncast(..) => { LpVar(..) | LpUpvar(..) | LpDowncast(..) => {
let kill_scope = path.loan_path.kill_scope(tcx); let kill_scope = path.loan_path.kill_scope(tcx);
@ -633,11 +633,11 @@ impl<'a, 'tcx> FlowedMoveData<'a, 'tcx> {
//! Returns the kind of a move of `loan_path` by `id`, if one exists. //! Returns the kind of a move of `loan_path` by `id`, if one exists.
let mut ret = None; let mut ret = None;
for loan_path_index in self.move_data.path_map.borrow().get(&*loan_path).iter() { if let Some(loan_path_index) = self.move_data.path_map.borrow().get(&*loan_path) {
self.dfcx_moves.each_gen_bit(id, |move_index| { self.dfcx_moves.each_gen_bit(id, |move_index| {
let the_move = self.move_data.moves.borrow(); let the_move = self.move_data.moves.borrow();
let the_move = (*the_move)[move_index]; let the_move = (*the_move)[move_index];
if the_move.path == **loan_path_index { if the_move.path == *loan_path_index {
ret = Some(the_move.kind); ret = Some(the_move.kind);
false false
} else { } else {
@ -688,7 +688,7 @@ impl<'a, 'tcx> FlowedMoveData<'a, 'tcx> {
ret = false; ret = false;
} }
} else { } else {
for &loan_path_index in opt_loan_path_index.iter() { if let Some(loan_path_index) = opt_loan_path_index {
let cont = self.move_data.each_base_path(moved_path, |p| { let cont = self.move_data.each_base_path(moved_path, |p| {
if p == loan_path_index { if p == loan_path_index {
// Scenario 3: some extension of `loan_path` // Scenario 3: some extension of `loan_path`
@ -699,7 +699,7 @@ impl<'a, 'tcx> FlowedMoveData<'a, 'tcx> {
true true
} }
}); });
if !cont { ret = false; break } if !cont { ret = false; }
} }
} }
ret ret

View file

@ -56,7 +56,7 @@ impl<'a, 'tcx> DataflowLabeller<'a, 'tcx> {
debug!("dataflow_for({:?}, id={}) {:?}", e, id, self.variants); debug!("dataflow_for({:?}, id={}) {:?}", e, id, self.variants);
let mut sets = "".to_string(); let mut sets = "".to_string();
let mut seen_one = false; let mut seen_one = false;
for &variant in self.variants.iter() { for &variant in &self.variants {
if seen_one { sets.push_str(" "); } else { seen_one = true; } if seen_one { sets.push_str(" "); } else { seen_one = true; }
sets.push_str(variant.short_name()); sets.push_str(variant.short_name());
sets.push_str(": "); sets.push_str(": ");

View file

@ -760,11 +760,11 @@ fn write_out_deps(sess: &Session,
id: &str) { id: &str) {
let mut out_filenames = Vec::new(); let mut out_filenames = Vec::new();
for output_type in sess.opts.output_types.iter() { for output_type in &sess.opts.output_types {
let file = outputs.path(*output_type); let file = outputs.path(*output_type);
match *output_type { match *output_type {
config::OutputTypeExe => { config::OutputTypeExe => {
for output in sess.crate_types.borrow().iter() { for output in &*sess.crate_types.borrow() {
let p = link::filename_for_input(sess, *output, let p = link::filename_for_input(sess, *output,
id, &file); id, &file);
out_filenames.push(p); out_filenames.push(p);
@ -800,7 +800,7 @@ fn write_out_deps(sess: &Session,
.map(|fmap| escape_dep_filename(&fmap.name[])) .map(|fmap| escape_dep_filename(&fmap.name[]))
.collect(); .collect();
let mut file = try!(old_io::File::create(&deps_filename)); let mut file = try!(old_io::File::create(&deps_filename));
for path in out_filenames.iter() { for path in &out_filenames {
try!(write!(&mut file as &mut Writer, try!(write!(&mut file as &mut Writer,
"{}: {}\n\n", path.display(), files.connect(" "))); "{}: {}\n\n", path.display(), files.connect(" ")));
} }

View file

@ -435,7 +435,7 @@ Available lint options:
fn describe_debug_flags() { fn describe_debug_flags() {
println!("\nAvailable debug options:\n"); println!("\nAvailable debug options:\n");
for &(name, _, opt_type_desc, desc) in config::DB_OPTIONS.iter() { for &(name, _, opt_type_desc, desc) in config::DB_OPTIONS {
let (width, extra) = match opt_type_desc { let (width, extra) = match opt_type_desc {
Some(..) => (21, "=val"), Some(..) => (21, "=val"),
None => (25, "") None => (25, "")
@ -447,7 +447,7 @@ fn describe_debug_flags() {
fn describe_codegen_flags() { fn describe_codegen_flags() {
println!("\nAvailable codegen options:\n"); println!("\nAvailable codegen options:\n");
for &(name, _, opt_type_desc, desc) in config::CG_OPTIONS.iter() { for &(name, _, opt_type_desc, desc) in config::CG_OPTIONS {
let (width, extra) = match opt_type_desc { let (width, extra) = match opt_type_desc {
Some(..) => (21, "=val"), Some(..) => (21, "=val"),
None => (25, "") None => (25, "")
@ -542,7 +542,7 @@ fn print_crate_info(sess: &Session,
if sess.opts.prints.len() == 0 { return false } if sess.opts.prints.len() == 0 { return false }
let attrs = input.map(|input| parse_crate_attrs(sess, input)); let attrs = input.map(|input| parse_crate_attrs(sess, input));
for req in sess.opts.prints.iter() { for req in &sess.opts.prints {
match *req { match *req {
PrintRequest::Sysroot => println!("{}", sess.sysroot().display()), PrintRequest::Sysroot => println!("{}", sess.sysroot().display()),
PrintRequest::FileNames | PrintRequest::FileNames |
@ -566,7 +566,7 @@ fn print_crate_info(sess: &Session,
let crate_types = driver::collect_crate_types(sess, attrs); let crate_types = driver::collect_crate_types(sess, attrs);
let metadata = driver::collect_crate_metadata(sess, attrs); let metadata = driver::collect_crate_metadata(sess, attrs);
*sess.crate_metadata.borrow_mut() = metadata; *sess.crate_metadata.borrow_mut() = metadata;
for &style in crate_types.iter() { for &style in &crate_types {
let fname = link::filename_for_input(sess, style, let fname = link::filename_for_input(sess, style,
id.as_slice(), id.as_slice(),
&t_outputs.with_extension("")); &t_outputs.with_extension(""));
@ -645,7 +645,7 @@ pub fn monitor<F:FnOnce()+Send>(f: F) {
BUG_REPORT_URL), BUG_REPORT_URL),
"run with `RUST_BACKTRACE=1` for a backtrace".to_string(), "run with `RUST_BACKTRACE=1` for a backtrace".to_string(),
]; ];
for note in xs.iter() { for note in &xs {
emitter.emit(None, &note[], None, diagnostic::Note) emitter.emit(None, &note[], None, diagnostic::Note)
} }

View file

@ -147,7 +147,7 @@ impl<'a, 'tcx> Env<'a, 'tcx> {
} }
pub fn create_region_hierarchy(&self, rh: &RH) { pub fn create_region_hierarchy(&self, rh: &RH) {
for child_rh in rh.sub.iter() { for child_rh in rh.sub {
self.create_region_hierarchy(child_rh); self.create_region_hierarchy(child_rh);
self.infcx.tcx.region_maps.record_encl_scope( self.infcx.tcx.region_maps.record_encl_scope(
CodeExtent::from_node_id(child_rh.id), CodeExtent::from_node_id(child_rh.id),
@ -181,7 +181,7 @@ impl<'a, 'tcx> Env<'a, 'tcx> {
names: &[String]) names: &[String])
-> Option<ast::NodeId> { -> Option<ast::NodeId> {
assert!(idx < names.len()); assert!(idx < names.len());
for item in m.items.iter() { for item in &m.items {
if item.ident.user_string(this.infcx.tcx) == names[idx] { if item.ident.user_string(this.infcx.tcx) == names[idx] {
return search(this, &**item, idx+1, names); return search(this, &**item, idx+1, names);
} }

View file

@ -261,13 +261,13 @@ impl AttrBuilder {
} }
pub fn apply_llfn(&self, llfn: ValueRef) { pub fn apply_llfn(&self, llfn: ValueRef) {
for &(idx, ref attr) in self.attrs.iter() { for &(idx, ref attr) in &self.attrs {
attr.apply_llfn(idx as c_uint, llfn); attr.apply_llfn(idx as c_uint, llfn);
} }
} }
pub fn apply_callsite(&self, callsite: ValueRef) { pub fn apply_callsite(&self, callsite: ValueRef) {
for &(idx, ref attr) in self.attrs.iter() { for &(idx, ref attr) in &self.attrs {
attr.apply_callsite(idx as c_uint, callsite); attr.apply_callsite(idx as c_uint, callsite);
} }
} }

View file

@ -79,7 +79,7 @@ impl<'v> Visitor<'v> for ParentVisitor {
// Enum variants are parented to the enum definition itself because // Enum variants are parented to the enum definition itself because
// they inherit privacy // they inherit privacy
ast::ItemEnum(ref def, _) => { ast::ItemEnum(ref def, _) => {
for variant in def.variants.iter() { for variant in &def.variants {
// The parent is considered the enclosing enum because the // The parent is considered the enclosing enum because the
// enum will dictate the privacy visibility of this variant // enum will dictate the privacy visibility of this variant
// instead. // instead.
@ -93,7 +93,7 @@ impl<'v> Visitor<'v> for ParentVisitor {
// parent all the methods to the trait to indicate that they're // parent all the methods to the trait to indicate that they're
// private. // private.
ast::ItemTrait(_, _, _, ref methods) if item.vis != ast::Public => { ast::ItemTrait(_, _, _, ref methods) if item.vis != ast::Public => {
for m in methods.iter() { for m in methods {
match *m { match *m {
ast::ProvidedMethod(ref m) => { ast::ProvidedMethod(ref m) => {
self.parents.insert(m.id, item.id); self.parents.insert(m.id, item.id);
@ -139,7 +139,7 @@ impl<'v> Visitor<'v> for ParentVisitor {
// While we have the id of the struct definition, go ahead and parent // While we have the id of the struct definition, go ahead and parent
// all the fields. // all the fields.
for field in s.fields.iter() { for field in &s.fields {
self.parents.insert(field.node.id, self.curparent); self.parents.insert(field.node.id, self.curparent);
} }
visit::walk_struct_def(self, s) visit::walk_struct_def(self, s)
@ -233,7 +233,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for EmbargoVisitor<'a, 'tcx> {
// Enum variants inherit from their parent, so if the enum is // Enum variants inherit from their parent, so if the enum is
// public all variants are public unless they're explicitly priv // public all variants are public unless they're explicitly priv
ast::ItemEnum(ref def, _) if public_first => { ast::ItemEnum(ref def, _) if public_first => {
for variant in def.variants.iter() { for variant in &def.variants {
self.exported_items.insert(variant.node.id); self.exported_items.insert(variant.node.id);
} }
} }
@ -278,7 +278,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for EmbargoVisitor<'a, 'tcx> {
}); });
if public_ty || public_trait { if public_ty || public_trait {
for impl_item in impl_items.iter() { for impl_item in impl_items {
match *impl_item { match *impl_item {
ast::MethodImplItem(ref method) => { ast::MethodImplItem(ref method) => {
let meth_public = let meth_public =
@ -299,7 +299,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for EmbargoVisitor<'a, 'tcx> {
// Default methods on traits are all public so long as the trait // Default methods on traits are all public so long as the trait
// is public // is public
ast::ItemTrait(_, _, _, ref methods) if public_first => { ast::ItemTrait(_, _, _, ref methods) if public_first => {
for method in methods.iter() { for method in methods {
match *method { match *method {
ast::ProvidedMethod(ref m) => { ast::ProvidedMethod(ref m) => {
debug!("provided {}", m.id); debug!("provided {}", m.id);
@ -359,7 +359,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for EmbargoVisitor<'a, 'tcx> {
// crate module gets processed as well. // crate module gets processed as well.
if self.prev_exported { if self.prev_exported {
assert!(self.export_map.contains_key(&id), "wut {}", id); assert!(self.export_map.contains_key(&id), "wut {}", id);
for export in self.export_map[id].iter() { for export in &self.export_map[id] {
if is_local(export.def_id) { if is_local(export.def_id) {
self.reexports.insert(export.def_id.node); self.reexports.insert(export.def_id.node);
} }
@ -837,7 +837,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for PrivacyVisitor<'a, 'tcx> {
match vpath.node { match vpath.node {
ast::ViewPathSimple(..) | ast::ViewPathGlob(..) => {} ast::ViewPathSimple(..) | ast::ViewPathGlob(..) => {}
ast::ViewPathList(ref prefix, ref list) => { ast::ViewPathList(ref prefix, ref list) => {
for pid in list.iter() { for pid in list {
match pid.node { match pid.node {
ast::PathListIdent { id, name } => { ast::PathListIdent { id, name } => {
debug!("privacy - ident item {}", id); debug!("privacy - ident item {}", id);
@ -898,7 +898,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for PrivacyVisitor<'a, 'tcx> {
ast::ExprStruct(_, ref fields, _) => { ast::ExprStruct(_, ref fields, _) => {
match ty::expr_ty(self.tcx, expr).sty { match ty::expr_ty(self.tcx, expr).sty {
ty::ty_struct(id, _) => { ty::ty_struct(id, _) => {
for field in (*fields).iter() { for field in &(*fields) {
self.check_field(expr.span, id, self.check_field(expr.span, id,
NamedField(field.ident.node)); NamedField(field.ident.node));
} }
@ -906,7 +906,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for PrivacyVisitor<'a, 'tcx> {
ty::ty_enum(_, _) => { ty::ty_enum(_, _) => {
match self.tcx.def_map.borrow()[expr.id].clone() { match self.tcx.def_map.borrow()[expr.id].clone() {
def::DefVariant(_, variant_id, _) => { def::DefVariant(_, variant_id, _) => {
for field in fields.iter() { for field in fields {
self.check_field(expr.span, variant_id, self.check_field(expr.span, variant_id,
NamedField(field.ident.node)); NamedField(field.ident.node));
} }
@ -971,7 +971,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for PrivacyVisitor<'a, 'tcx> {
ast::PatStruct(_, ref fields, _) => { ast::PatStruct(_, ref fields, _) => {
match ty::pat_ty(self.tcx, pattern).sty { match ty::pat_ty(self.tcx, pattern).sty {
ty::ty_struct(id, _) => { ty::ty_struct(id, _) => {
for field in fields.iter() { for field in fields {
self.check_field(pattern.span, id, self.check_field(pattern.span, id,
NamedField(field.node.ident)); NamedField(field.node.ident));
} }
@ -979,7 +979,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for PrivacyVisitor<'a, 'tcx> {
ty::ty_enum(_, _) => { ty::ty_enum(_, _) => {
match self.tcx.def_map.borrow().get(&pattern.id) { match self.tcx.def_map.borrow().get(&pattern.id) {
Some(&def::DefVariant(_, variant_id, _)) => { Some(&def::DefVariant(_, variant_id, _)) => {
for field in fields.iter() { for field in fields {
self.check_field(pattern.span, variant_id, self.check_field(pattern.span, variant_id,
NamedField(field.node.ident)); NamedField(field.node.ident));
} }
@ -1091,7 +1091,7 @@ impl<'a, 'tcx> SanePrivacyVisitor<'a, 'tcx> {
check_inherited(item.span, item.vis, check_inherited(item.span, item.vis,
"visibility qualifiers have no effect on trait \ "visibility qualifiers have no effect on trait \
impls"); impls");
for impl_item in impl_items.iter() { for impl_item in impl_items {
match *impl_item { match *impl_item {
ast::MethodImplItem(ref m) => { ast::MethodImplItem(ref m) => {
check_inherited(m.span, m.pe_vis(), ""); check_inherited(m.span, m.pe_vis(), "");
@ -1112,7 +1112,7 @@ impl<'a, 'tcx> SanePrivacyVisitor<'a, 'tcx> {
} }
ast::ItemEnum(ref def, _) => { ast::ItemEnum(ref def, _) => {
for v in def.variants.iter() { for v in &def.variants {
match v.node.vis { match v.node.vis {
ast::Public => { ast::Public => {
if item.vis == ast::Public { if item.vis == ast::Public {
@ -1126,7 +1126,7 @@ impl<'a, 'tcx> SanePrivacyVisitor<'a, 'tcx> {
} }
ast::ItemTrait(_, _, _, ref methods) => { ast::ItemTrait(_, _, _, ref methods) => {
for m in methods.iter() { for m in methods {
match *m { match *m {
ast::ProvidedMethod(ref m) => { ast::ProvidedMethod(ref m) => {
check_inherited(m.span, m.pe_vis(), check_inherited(m.span, m.pe_vis(),
@ -1157,7 +1157,7 @@ impl<'a, 'tcx> SanePrivacyVisitor<'a, 'tcx> {
} }
} }
let check_struct = |&: def: &ast::StructDef| { let check_struct = |&: def: &ast::StructDef| {
for f in def.fields.iter() { for f in &def.fields {
match f.node.kind { match f.node.kind {
ast::NamedField(_, p) => check_inherited(tcx, f.span, p), ast::NamedField(_, p) => check_inherited(tcx, f.span, p),
ast::UnnamedField(..) => {} ast::UnnamedField(..) => {}
@ -1167,7 +1167,7 @@ impl<'a, 'tcx> SanePrivacyVisitor<'a, 'tcx> {
check_inherited(tcx, item.span, item.vis); check_inherited(tcx, item.span, item.vis);
match item.node { match item.node {
ast::ItemImpl(_, _, _, _, _, ref impl_items) => { ast::ItemImpl(_, _, _, _, _, ref impl_items) => {
for impl_item in impl_items.iter() { for impl_item in impl_items {
match *impl_item { match *impl_item {
ast::MethodImplItem(ref m) => { ast::MethodImplItem(ref m) => {
check_inherited(tcx, m.span, m.pe_vis()); check_inherited(tcx, m.span, m.pe_vis());
@ -1177,12 +1177,12 @@ impl<'a, 'tcx> SanePrivacyVisitor<'a, 'tcx> {
} }
} }
ast::ItemForeignMod(ref fm) => { ast::ItemForeignMod(ref fm) => {
for i in fm.items.iter() { for i in &fm.items {
check_inherited(tcx, i.span, i.vis); check_inherited(tcx, i.span, i.vis);
} }
} }
ast::ItemEnum(ref def, _) => { ast::ItemEnum(ref def, _) => {
for v in def.variants.iter() { for v in &def.variants {
check_inherited(tcx, v.span, v.node.vis); check_inherited(tcx, v.span, v.node.vis);
} }
} }
@ -1190,7 +1190,7 @@ impl<'a, 'tcx> SanePrivacyVisitor<'a, 'tcx> {
ast::ItemStruct(ref def, _) => check_struct(&**def), ast::ItemStruct(ref def, _) => check_struct(&**def),
ast::ItemTrait(_, _, _, ref methods) => { ast::ItemTrait(_, _, _, ref methods) => {
for m in methods.iter() { for m in methods {
match *m { match *m {
ast::RequiredMethod(..) => {} ast::RequiredMethod(..) => {}
ast::ProvidedMethod(ref m) => check_inherited(tcx, m.span, ast::ProvidedMethod(ref m) => check_inherited(tcx, m.span,
@ -1302,7 +1302,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for VisiblePrivateTypesVisitor<'a, 'tcx> {
return return
} }
for bound in bounds.iter() { for bound in &**bounds {
self.check_ty_param_bound(bound) self.check_ty_param_bound(bound)
} }
} }
@ -1371,7 +1371,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for VisiblePrivateTypesVisitor<'a, 'tcx> {
match *trait_ref { match *trait_ref {
None => { None => {
for impl_item in impl_items.iter() { for impl_item in impl_items {
match *impl_item { match *impl_item {
ast::MethodImplItem(ref method) => { ast::MethodImplItem(ref method) => {
visit::walk_method_helper(self, &**method) visit::walk_method_helper(self, &**method)
@ -1400,7 +1400,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for VisiblePrivateTypesVisitor<'a, 'tcx> {
// impl Public<Private> { ... }. Any public static // impl Public<Private> { ... }. Any public static
// methods will be visible as `Public::foo`. // methods will be visible as `Public::foo`.
let mut found_pub_static = false; let mut found_pub_static = false;
for impl_item in impl_items.iter() { for impl_item in impl_items {
match *impl_item { match *impl_item {
ast::MethodImplItem(ref method) => { ast::MethodImplItem(ref method) => {
if method.pe_explicit_self().node == if method.pe_explicit_self().node ==
@ -1439,15 +1439,15 @@ impl<'a, 'tcx, 'v> Visitor<'v> for VisiblePrivateTypesVisitor<'a, 'tcx> {
} }
fn visit_generics(&mut self, generics: &ast::Generics) { fn visit_generics(&mut self, generics: &ast::Generics) {
for ty_param in generics.ty_params.iter() { for ty_param in &*generics.ty_params {
for bound in ty_param.bounds.iter() { for bound in &*ty_param.bounds {
self.check_ty_param_bound(bound) self.check_ty_param_bound(bound)
} }
} }
for predicate in generics.where_clause.predicates.iter() { for predicate in &generics.where_clause.predicates {
match predicate { match predicate {
&ast::WherePredicate::BoundPredicate(ref bound_pred) => { &ast::WherePredicate::BoundPredicate(ref bound_pred) => {
for bound in bound_pred.bounds.iter() { for bound in &*bound_pred.bounds {
self.check_ty_param_bound(bound) self.check_ty_param_bound(bound)
} }
} }

View file

@ -223,8 +223,8 @@ impl<'a, 'b:'a, 'tcx:'b> GraphBuilder<'a, 'b, 'tcx> {
token::get_name(name))[]); token::get_name(name))[]);
{ {
let r = child.span_for_namespace(ns); let r = child.span_for_namespace(ns);
for sp in r.iter() { if let Some(sp) = r {
self.session.span_note(*sp, self.session.span_note(sp,
&format!("first definition of {} `{}` here", &format!("first definition of {} `{}` here",
namespace_error_to_string(duplicate_type), namespace_error_to_string(duplicate_type),
token::get_name(name))[]); token::get_name(name))[]);
@ -238,7 +238,7 @@ impl<'a, 'b:'a, 'tcx:'b> GraphBuilder<'a, 'b, 'tcx> {
fn block_needs_anonymous_module(&mut self, block: &Block) -> bool { fn block_needs_anonymous_module(&mut self, block: &Block) -> bool {
// Check each statement. // Check each statement.
for statement in block.stmts.iter() { for statement in &block.stmts {
match statement.node { match statement.node {
StmtDecl(ref declaration, _) => { StmtDecl(ref declaration, _) => {
match declaration.node { match declaration.node {
@ -338,7 +338,7 @@ impl<'a, 'b:'a, 'tcx:'b> GraphBuilder<'a, 'b, 'tcx> {
} }
} }
for source_item in source_items.iter() { for source_item in source_items {
let (module_path, name) = match source_item.node { let (module_path, name) = match source_item.node {
PathListIdent { name, .. } => PathListIdent { name, .. } =>
(module_path.clone(), name.name), (module_path.clone(), name.name),
@ -477,7 +477,7 @@ impl<'a, 'b:'a, 'tcx:'b> GraphBuilder<'a, 'b, 'tcx> {
let module = name_bindings.get_module(); let module = name_bindings.get_module();
for variant in (*enum_definition).variants.iter() { for variant in &(*enum_definition).variants {
self.build_reduced_graph_for_variant( self.build_reduced_graph_for_variant(
&**variant, &**variant,
local_def(item.id), local_def(item.id),
@ -591,7 +591,7 @@ impl<'a, 'b:'a, 'tcx:'b> GraphBuilder<'a, 'b, 'tcx> {
}; };
// For each implementation item... // For each implementation item...
for impl_item in impl_items.iter() { for impl_item in impl_items {
match *impl_item { match *impl_item {
MethodImplItem(ref method) => { MethodImplItem(ref method) => {
// Add the method to the module. // Add the method to the module.
@ -675,7 +675,7 @@ impl<'a, 'b:'a, 'tcx:'b> GraphBuilder<'a, 'b, 'tcx> {
let def_id = local_def(item.id); let def_id = local_def(item.id);
// Add the names of all the items to the trait info. // Add the names of all the items to the trait info.
for trait_item in items.iter() { for trait_item in items {
let (name, kind) = match *trait_item { let (name, kind) = match *trait_item {
ast::RequiredMethod(_) | ast::RequiredMethod(_) |
ast::ProvidedMethod(_) => { ast::ProvidedMethod(_) => {
@ -926,7 +926,7 @@ impl<'a, 'b:'a, 'tcx:'b> GraphBuilder<'a, 'b, 'tcx> {
let trait_item_def_ids = let trait_item_def_ids =
csearch::get_trait_item_def_ids(&self.session.cstore, def_id); csearch::get_trait_item_def_ids(&self.session.cstore, def_id);
for trait_item_def_id in trait_item_def_ids.iter() { for trait_item_def_id in &trait_item_def_ids {
let (trait_item_name, trait_item_kind) = let (trait_item_name, trait_item_kind) =
csearch::get_trait_item_name_and_kind( csearch::get_trait_item_name_and_kind(
&self.session.cstore, &self.session.cstore,
@ -1082,7 +1082,7 @@ impl<'a, 'b:'a, 'tcx:'b> GraphBuilder<'a, 'b, 'tcx> {
// Add each static method to the module. // Add each static method to the module.
let new_parent = type_module; let new_parent = type_module;
for method_info in methods.iter() { for method_info in methods {
let name = method_info.name; let name = method_info.name;
debug!("(building reduced graph for \ debug!("(building reduced graph for \
external crate) creating \ external crate) creating \

View file

@ -136,7 +136,7 @@ impl<'a, 'b, 'v, 'tcx> Visitor<'v> for UnusedImportCheckVisitor<'a, 'b, 'tcx> {
} }
ViewPathList(_, ref list) => { ViewPathList(_, ref list) => {
for i in list.iter() { for i in list {
self.finalize_import(i.node.id(), i.span); self.finalize_import(i.node.id(), i.span);
} }
} }

View file

@ -1031,7 +1031,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
self.current_module = orig_module; self.current_module = orig_module;
build_reduced_graph::populate_module_if_necessary(self, &module_); build_reduced_graph::populate_module_if_necessary(self, &module_);
for (_, child_node) in module_.children.borrow().iter() { for (_, child_node) in &*module_.children.borrow() {
match child_node.get_module_if_available() { match child_node.get_module_if_available() {
None => { None => {
// Nothing to do. // Nothing to do.
@ -1042,7 +1042,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
} }
} }
for (_, child_module) in module_.anonymous_children.borrow().iter() { for (_, child_module) in &*module_.anonymous_children.borrow() {
self.resolve_imports_for_module_subtree(child_module.clone()); self.resolve_imports_for_module_subtree(child_module.clone());
} }
} }
@ -1087,7 +1087,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
fn names_to_string(&self, names: &[Name]) -> String { fn names_to_string(&self, names: &[Name]) -> String {
let mut first = true; let mut first = true;
let mut result = String::new(); let mut result = String::new();
for name in names.iter() { for name in names {
if first { if first {
first = false first = false
} else { } else {
@ -1596,7 +1596,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
// Add all resolved imports from the containing module. // Add all resolved imports from the containing module.
let import_resolutions = containing_module.import_resolutions.borrow(); let import_resolutions = containing_module.import_resolutions.borrow();
for (ident, target_import_resolution) in import_resolutions.iter() { for (ident, target_import_resolution) in &*import_resolutions {
debug!("(resolving glob import) writing module resolution \ debug!("(resolving glob import) writing module resolution \
{} into `{}`", {} into `{}`",
token::get_name(*ident), token::get_name(*ident),
@ -1657,7 +1657,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
// Add all children from the containing module. // Add all children from the containing module.
build_reduced_graph::populate_module_if_necessary(self, &containing_module); build_reduced_graph::populate_module_if_necessary(self, &containing_module);
for (&name, name_bindings) in containing_module.children.borrow().iter() { for (&name, name_bindings) in &*containing_module.children.borrow() {
self.merge_import_resolution(module_, self.merge_import_resolution(module_,
containing_module.clone(), containing_module.clone(),
import_directive, import_directive,
@ -1667,7 +1667,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
} }
// Add external module children from the containing module. // Add external module children from the containing module.
for (&name, module) in containing_module.external_module_children.borrow().iter() { for (&name, module) in &*containing_module.external_module_children.borrow() {
let name_bindings = let name_bindings =
Rc::new(Resolver::create_name_bindings_from_module(module.clone())); Rc::new(Resolver::create_name_bindings_from_module(module.clone()));
self.merge_import_resolution(module_, self.merge_import_resolution(module_,
@ -2519,7 +2519,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
// Descend into children and anonymous children. // Descend into children and anonymous children.
build_reduced_graph::populate_module_if_necessary(self, &module_); build_reduced_graph::populate_module_if_necessary(self, &module_);
for (_, child_node) in module_.children.borrow().iter() { for (_, child_node) in &*module_.children.borrow() {
match child_node.get_module_if_available() { match child_node.get_module_if_available() {
None => { None => {
// Continue. // Continue.
@ -2530,7 +2530,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
} }
} }
for (_, module_) in module_.anonymous_children.borrow().iter() { for (_, module_) in &*module_.anonymous_children.borrow() {
self.report_unresolved_imports(module_.clone()); self.report_unresolved_imports(module_.clone());
} }
} }
@ -2609,7 +2609,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
DlDef(d @ DefLocal(_)) => { DlDef(d @ DefLocal(_)) => {
let node_id = d.def_id().node; let node_id = d.def_id().node;
let mut def = d; let mut def = d;
for rib in ribs.iter() { for rib in ribs {
match rib.kind { match rib.kind {
NormalRibKind => { NormalRibKind => {
// Nothing to do. Continue. // Nothing to do. Continue.
@ -2680,7 +2680,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
} }
DlDef(def @ DefTyParam(..)) | DlDef(def @ DefTyParam(..)) |
DlDef(def @ DefSelfTy(..)) => { DlDef(def @ DefSelfTy(..)) => {
for rib in ribs.iter() { for rib in ribs {
match rib.kind { match rib.kind {
NormalRibKind | ClosureRibKind(..) => { NormalRibKind | ClosureRibKind(..) => {
// Nothing to do. Continue. // Nothing to do. Continue.
@ -2795,8 +2795,8 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
// enum item: resolve all the variants' discrs, // enum item: resolve all the variants' discrs,
// then resolve the ty params // then resolve the ty params
ItemEnum(ref enum_def, ref generics) => { ItemEnum(ref enum_def, ref generics) => {
for variant in (*enum_def).variants.iter() { for variant in &(*enum_def).variants {
for dis_expr in variant.node.disr_expr.iter() { if let Some(ref dis_expr) = variant.node.disr_expr {
// resolve the discriminator expr // resolve the discriminator expr
// as a constant // as a constant
self.with_constant_rib(|this| { self.with_constant_rib(|this| {
@ -2863,7 +2863,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
this.resolve_type_parameter_bounds(item.id, bounds, this.resolve_type_parameter_bounds(item.id, bounds,
TraitDerivation); TraitDerivation);
for trait_item in (*trait_items).iter() { for trait_item in &(*trait_items) {
// Create a new rib for the trait_item-specific type // Create a new rib for the trait_item-specific type
// parameters. // parameters.
// //
@ -2885,7 +2885,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
this.resolve_where_clause(&ty_m.generics this.resolve_where_clause(&ty_m.generics
.where_clause); .where_clause);
for argument in ty_m.decl.inputs.iter() { for argument in &ty_m.decl.inputs {
this.resolve_type(&*argument.ty); this.resolve_type(&*argument.ty);
} }
@ -2929,7 +2929,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
ItemForeignMod(ref foreign_module) => { ItemForeignMod(ref foreign_module) => {
self.with_scope(Some(name), |this| { self.with_scope(Some(name), |this| {
for foreign_item in foreign_module.items.iter() { for foreign_item in &foreign_module.items {
match foreign_item.node { match foreign_item.node {
ForeignItemFn(_, ref generics) => { ForeignItemFn(_, ref generics) => {
this.with_type_parameter_rib( this.with_type_parameter_rib(
@ -3075,7 +3075,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
} }
Some(declaration) => { Some(declaration) => {
let mut bindings_list = HashMap::new(); let mut bindings_list = HashMap::new();
for argument in declaration.inputs.iter() { for argument in &declaration.inputs {
this.resolve_pattern(&*argument.pat, this.resolve_pattern(&*argument.pat,
ArgumentIrrefutableMode, ArgumentIrrefutableMode,
&mut bindings_list); &mut bindings_list);
@ -3103,14 +3103,14 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
fn resolve_type_parameters(&mut self, fn resolve_type_parameters(&mut self,
type_parameters: &OwnedSlice<TyParam>) { type_parameters: &OwnedSlice<TyParam>) {
for type_parameter in type_parameters.iter() { for type_parameter in &**type_parameters {
self.resolve_type_parameter(type_parameter); self.resolve_type_parameter(type_parameter);
} }
} }
fn resolve_type_parameter(&mut self, fn resolve_type_parameter(&mut self,
type_parameter: &TyParam) { type_parameter: &TyParam) {
for bound in type_parameter.bounds.iter() { for bound in &*type_parameter.bounds {
self.resolve_type_parameter_bound(type_parameter.id, bound, self.resolve_type_parameter_bound(type_parameter.id, bound,
TraitBoundingTypeParameter); TraitBoundingTypeParameter);
} }
@ -3124,7 +3124,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
id: NodeId, id: NodeId,
type_parameter_bounds: &OwnedSlice<TyParamBound>, type_parameter_bounds: &OwnedSlice<TyParamBound>,
reference_type: TraitReferenceType) { reference_type: TraitReferenceType) {
for type_parameter_bound in type_parameter_bounds.iter() { for type_parameter_bound in &**type_parameter_bounds {
self.resolve_type_parameter_bound(id, type_parameter_bound, self.resolve_type_parameter_bound(id, type_parameter_bound,
reference_type); reference_type);
} }
@ -3193,12 +3193,12 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
} }
fn resolve_where_clause(&mut self, where_clause: &ast::WhereClause) { fn resolve_where_clause(&mut self, where_clause: &ast::WhereClause) {
for predicate in where_clause.predicates.iter() { for predicate in &where_clause.predicates {
match predicate { match predicate {
&ast::WherePredicate::BoundPredicate(ref bound_pred) => { &ast::WherePredicate::BoundPredicate(ref bound_pred) => {
self.resolve_type(&*bound_pred.bounded_ty); self.resolve_type(&*bound_pred.bounded_ty);
for bound in bound_pred.bounds.iter() { for bound in &*bound_pred.bounds {
self.resolve_type_parameter_bound(bound_pred.bounded_ty.id, bound, self.resolve_type_parameter_bound(bound_pred.bounded_ty.id, bound,
TraitBoundingTypeParameter); TraitBoundingTypeParameter);
} }
@ -3236,7 +3236,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
this.resolve_where_clause(&generics.where_clause); this.resolve_where_clause(&generics.where_clause);
// Resolve fields. // Resolve fields.
for field in fields.iter() { for field in fields {
this.resolve_type(&*field.node.ty); this.resolve_type(&*field.node.ty);
} }
}); });
@ -3320,7 +3320,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
this.resolve_type(self_type); this.resolve_type(self_type);
this.with_current_self_type(self_type, |this| { this.with_current_self_type(self_type, |this| {
for impl_item in impl_items.iter() { for impl_item in impl_items {
match *impl_item { match *impl_item {
MethodImplItem(ref method) => { MethodImplItem(ref method) => {
// If this is a trait impl, ensure the method // If this is a trait impl, ensure the method
@ -3375,7 +3375,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
fn check_trait_item(&self, name: Name, span: Span) { fn check_trait_item(&self, name: Name, span: Span) {
// If there is a TraitRef in scope for an impl, then the method must be in the trait. // If there is a TraitRef in scope for an impl, then the method must be in the trait.
for &(did, ref trait_ref) in self.current_trait_ref.iter() { if let Some((did, ref trait_ref)) = self.current_trait_ref {
if self.trait_item_map.get(&(name, did)).is_none() { if self.trait_item_map.get(&(name, did)).is_none() {
let path_str = self.path_names_to_string(&trait_ref.path); let path_str = self.path_names_to_string(&trait_ref.path);
self.resolve_error(span, self.resolve_error(span,
@ -3442,7 +3442,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
for (i, p) in arm.pats.iter().enumerate() { for (i, p) in arm.pats.iter().enumerate() {
let map_i = self.binding_mode_map(&**p); let map_i = self.binding_mode_map(&**p);
for (&key, &binding_0) in map_0.iter() { for (&key, &binding_0) in &map_0 {
match map_i.get(&key) { match map_i.get(&key) {
None => { None => {
self.resolve_error( self.resolve_error(
@ -3465,7 +3465,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
} }
} }
for (&key, &binding) in map_i.iter() { for (&key, &binding) in &map_i {
if !map_0.contains_key(&key) { if !map_0.contains_key(&key) {
self.resolve_error( self.resolve_error(
binding.span, binding.span,
@ -3482,7 +3482,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
self.value_ribs.push(Rib::new(NormalRibKind)); self.value_ribs.push(Rib::new(NormalRibKind));
let mut bindings_list = HashMap::new(); let mut bindings_list = HashMap::new();
for pattern in arm.pats.iter() { for pattern in &arm.pats {
self.resolve_pattern(&**pattern, RefutableMode, &mut bindings_list); self.resolve_pattern(&**pattern, RefutableMode, &mut bindings_list);
} }
@ -3513,7 +3513,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
// Check for imports appearing after non-item statements. // Check for imports appearing after non-item statements.
let mut found_non_item = false; let mut found_non_item = false;
for statement in block.stmts.iter() { for statement in &block.stmts {
if let ast::StmtDecl(ref declaration, _) = statement.node { if let ast::StmtDecl(ref declaration, _) = statement.node {
if let ast::DeclItem(ref i) = declaration.node { if let ast::DeclItem(ref i) = declaration.node {
match i.node { match i.node {
@ -4365,7 +4365,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
let mut values: Vec<uint> = Vec::new(); let mut values: Vec<uint> = Vec::new();
for rib in this.value_ribs.iter().rev() { for rib in this.value_ribs.iter().rev() {
for (&k, _) in rib.bindings.iter() { for (&k, _) in &rib.bindings {
maybes.push(token::get_name(k)); maybes.push(token::get_name(k));
values.push(uint::MAX); values.push(uint::MAX);
} }
@ -4640,7 +4640,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
build_reduced_graph::populate_module_if_necessary(self, &search_module); build_reduced_graph::populate_module_if_necessary(self, &search_module);
{ {
for (_, child_names) in search_module.children.borrow().iter() { for (_, child_names) in &*search_module.children.borrow() {
let def = match child_names.def_for_namespace(TypeNS) { let def = match child_names.def_for_namespace(TypeNS) {
Some(def) => def, Some(def) => def,
None => continue None => continue
@ -4656,7 +4656,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
} }
// Look for imports. // Look for imports.
for (_, import) in search_module.import_resolutions.borrow().iter() { for (_, import) in &*search_module.import_resolutions.borrow() {
let target = match import.target_for_namespace(TypeNS) { let target = match import.target_for_namespace(TypeNS) {
None => continue, None => continue,
Some(target) => target, Some(target) => target,
@ -4766,13 +4766,13 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
debug!("Children:"); debug!("Children:");
build_reduced_graph::populate_module_if_necessary(self, &module_); build_reduced_graph::populate_module_if_necessary(self, &module_);
for (&name, _) in module_.children.borrow().iter() { for (&name, _) in &*module_.children.borrow() {
debug!("* {}", token::get_name(name)); debug!("* {}", token::get_name(name));
} }
debug!("Import resolutions:"); debug!("Import resolutions:");
let import_resolutions = module_.import_resolutions.borrow(); let import_resolutions = module_.import_resolutions.borrow();
for (&name, import_resolution) in import_resolutions.iter() { for (&name, import_resolution) in &*import_resolutions {
let value_repr; let value_repr;
match import_resolution.target_for_namespace(ValueNS) { match import_resolution.target_for_namespace(ValueNS) {
None => { value_repr = "".to_string(); } None => { value_repr = "".to_string(); }

View file

@ -80,7 +80,7 @@ impl<'a, 'b, 'tcx> ExportRecorder<'a, 'b, 'tcx> {
self.record_exports_for_module(&*module_); self.record_exports_for_module(&*module_);
build_reduced_graph::populate_module_if_necessary(self.resolver, &module_); build_reduced_graph::populate_module_if_necessary(self.resolver, &module_);
for (_, child_name_bindings) in module_.children.borrow().iter() { for (_, child_name_bindings) in &*module_.children.borrow() {
match child_name_bindings.get_module_if_available() { match child_name_bindings.get_module_if_available() {
None => { None => {
// Nothing to do. // Nothing to do.
@ -91,7 +91,7 @@ impl<'a, 'b, 'tcx> ExportRecorder<'a, 'b, 'tcx> {
} }
} }
for (_, child_module) in module_.anonymous_children.borrow().iter() { for (_, child_module) in &*module_.anonymous_children.borrow() {
self.record_exports_for_module_subtree(child_module.clone()); self.record_exports_for_module_subtree(child_module.clone());
} }
} }
@ -133,12 +133,12 @@ impl<'a, 'b, 'tcx> ExportRecorder<'a, 'b, 'tcx> {
fn add_exports_for_module(&mut self, fn add_exports_for_module(&mut self,
exports: &mut Vec<Export>, exports: &mut Vec<Export>,
module_: &Module) { module_: &Module) {
for (name, importresolution) in module_.import_resolutions.borrow().iter() { for (name, importresolution) in &*module_.import_resolutions.borrow() {
if !importresolution.is_public { if !importresolution.is_public {
continue continue
} }
let xs = [TypeNS, ValueNS]; let xs = [TypeNS, ValueNS];
for &ns in xs.iter() { for &ns in &xs {
match importresolution.target_for_namespace(ns) { match importresolution.target_for_namespace(ns) {
Some(target) => { Some(target) => {
debug!("(computing exports) maybe export '{}'", debug!("(computing exports) maybe export '{}'",

View file

@ -194,7 +194,7 @@ fn symbol_hash<'tcx>(tcx: &ty::ctxt<'tcx>,
symbol_hasher.input_str(&link_meta.crate_name[]); symbol_hasher.input_str(&link_meta.crate_name[]);
symbol_hasher.input_str("-"); symbol_hasher.input_str("-");
symbol_hasher.input_str(link_meta.crate_hash.as_str()); symbol_hasher.input_str(link_meta.crate_hash.as_str());
for meta in tcx.sess.crate_metadata.borrow().iter() { for meta in &*tcx.sess.crate_metadata.borrow() {
symbol_hasher.input_str(&meta[]); symbol_hasher.input_str(&meta[]);
} }
symbol_hasher.input_str("-"); symbol_hasher.input_str("-");
@ -370,7 +370,7 @@ pub fn link_binary(sess: &Session,
outputs: &OutputFilenames, outputs: &OutputFilenames,
crate_name: &str) -> Vec<Path> { crate_name: &str) -> Vec<Path> {
let mut out_filenames = Vec::new(); let mut out_filenames = Vec::new();
for &crate_type in sess.crate_types.borrow().iter() { for &crate_type in &*sess.crate_types.borrow() {
if invalid_output_for_target(sess, crate_type) { if invalid_output_for_target(sess, crate_type) {
sess.bug(&format!("invalid output type `{:?}` for target os `{}`", sess.bug(&format!("invalid output type `{:?}` for target os `{}`",
crate_type, sess.opts.target_triple)[]); crate_type, sess.opts.target_triple)[]);
@ -535,7 +535,7 @@ fn link_rlib<'a>(sess: &'a Session,
let mut ab = ArchiveBuilder::create(config); let mut ab = ArchiveBuilder::create(config);
ab.add_file(obj_filename).unwrap(); ab.add_file(obj_filename).unwrap();
for &(ref l, kind) in sess.cstore.get_used_libraries().borrow().iter() { for &(ref l, kind) in &*sess.cstore.get_used_libraries().borrow() {
match kind { match kind {
cstore::NativeStatic => { cstore::NativeStatic => {
ab.add_native_library(&l[]).unwrap(); ab.add_native_library(&l[]).unwrap();
@ -721,7 +721,7 @@ fn link_staticlib(sess: &Session, obj_filename: &Path, out_filename: &Path) {
let crates = sess.cstore.get_used_crates(cstore::RequireStatic); let crates = sess.cstore.get_used_crates(cstore::RequireStatic);
let mut all_native_libs = vec![]; let mut all_native_libs = vec![];
for &(cnum, ref path) in crates.iter() { for &(cnum, ref path) in &crates {
let ref name = sess.cstore.get_crate_data(cnum).name; let ref name = sess.cstore.get_crate_data(cnum).name;
let p = match *path { let p = match *path {
Some(ref p) => p.clone(), None => { Some(ref p) => p.clone(), None => {
@ -746,7 +746,7 @@ fn link_staticlib(sess: &Session, obj_filename: &Path, out_filename: &Path) {
and so may need to be preserved"); and so may need to be preserved");
} }
for &(kind, ref lib) in all_native_libs.iter() { for &(kind, ref lib) in &all_native_libs {
let name = match kind { let name = match kind {
cstore::NativeStatic => "static library", cstore::NativeStatic => "static library",
cstore::NativeUnknown => "library", cstore::NativeUnknown => "library",
@ -1133,7 +1133,7 @@ fn add_upstream_rust_crates(cmd: &mut Command, sess: &Session,
// crates. // crates.
let deps = sess.cstore.get_used_crates(cstore::RequireDynamic); let deps = sess.cstore.get_used_crates(cstore::RequireDynamic);
for &(cnum, _) in deps.iter() { for &(cnum, _) in &deps {
// We may not pass all crates through to the linker. Some crates may // We may not pass all crates through to the linker. Some crates may
// appear statically in an existing dylib, meaning we'll pick up all the // appear statically in an existing dylib, meaning we'll pick up all the
// symbols from the dylib. // symbols from the dylib.
@ -1277,7 +1277,7 @@ fn add_upstream_native_libraries(cmd: &mut Command, sess: &Session) {
let crates = sess.cstore.get_used_crates(cstore::RequireStatic); let crates = sess.cstore.get_used_crates(cstore::RequireStatic);
for (cnum, _) in crates.into_iter() { for (cnum, _) in crates.into_iter() {
let libs = csearch::get_native_libraries(&sess.cstore, cnum); let libs = csearch::get_native_libraries(&sess.cstore, cnum);
for &(kind, ref lib) in libs.iter() { for &(kind, ref lib) in &libs {
match kind { match kind {
cstore::NativeUnknown => { cstore::NativeUnknown => {
cmd.arg(format!("-l{}", *lib)); cmd.arg(format!("-l{}", *lib));

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