1
Fork 0

for x in xs.into_iter() -> for x in xs

Also `for x in option.into_iter()` -> `if let Some(x) = option`
This commit is contained in:
Jorge Aparicio 2015-01-31 20:03:04 -05:00
parent d5f61b4332
commit fd702702ee
60 changed files with 78 additions and 78 deletions

View file

@ -40,7 +40,7 @@ pub fn run(lib_path: &str,
let mut cmd = Command::new(prog); let mut cmd = Command::new(prog);
cmd.args(args); cmd.args(args);
add_target_env(&mut cmd, lib_path, aux_path); add_target_env(&mut cmd, lib_path, aux_path);
for (key, val) in env.into_iter() { for (key, val) in env {
cmd.env(key, val); cmd.env(key, val);
} }
@ -72,7 +72,7 @@ pub fn run_background(lib_path: &str,
let mut cmd = Command::new(prog); let mut cmd = Command::new(prog);
cmd.args(args); cmd.args(args);
add_target_env(&mut cmd, lib_path, aux_path); add_target_env(&mut cmd, lib_path, aux_path);
for (key, val) in env.into_iter() { for (key, val) in env {
cmd.env(key, val); cmd.env(key, val);
} }

View file

@ -1503,7 +1503,7 @@ fn _arm_exec_compiled_test(config: &Config,
// run test via adb_run_wrapper // run test via adb_run_wrapper
runargs.push("shell".to_string()); runargs.push("shell".to_string());
for (key, val) in env.into_iter() { for (key, val) in env {
runargs.push(format!("{}={}", key, val)); runargs.push(format!("{}={}", key, val));
} }
runargs.push(format!("{}/adb_run_wrapper.sh", config.adb_test_dir)); runargs.push(format!("{}/adb_run_wrapper.sh", config.adb_test_dir));

View file

@ -197,7 +197,7 @@ impl<K: Ord, V> BTreeMap<K, V> {
pub fn clear(&mut self) { pub fn clear(&mut self) {
let b = self.b; let b = self.b;
// avoid recursive destructors by manually traversing the tree // avoid recursive destructors by manually traversing the tree
for _ in mem::replace(self, BTreeMap::with_b(b)).into_iter() {}; for _ in mem::replace(self, BTreeMap::with_b(b)) {};
} }
// Searching in a B-Tree is pretty straightforward. // Searching in a B-Tree is pretty straightforward.

View file

@ -1061,7 +1061,7 @@ mod tests {
let mut sum = v; let mut sum = v;
sum.push_all(u.as_slice()); sum.push_all(u.as_slice());
assert_eq!(sum.len(), m.len()); assert_eq!(sum.len(), m.len());
for elt in sum.into_iter() { for elt in sum {
assert_eq!(m.pop_front(), Some(elt)) assert_eq!(m.pop_front(), Some(elt))
} }
assert_eq!(n.len(), 0); assert_eq!(n.len(), 0);

View file

@ -2699,7 +2699,7 @@ mod tests {
} }
assert_eq!(cnt, 8); assert_eq!(cnt, 8);
for f in v.into_iter() { for f in v {
assert!(f == Foo); assert!(f == Foo);
cnt += 1; cnt += 1;
} }

View file

@ -2333,7 +2333,7 @@ mod tests {
fn test_move_items() { fn test_move_items() {
let vec = vec![1, 2, 3]; let vec = vec![1, 2, 3];
let mut vec2 : Vec<i32> = vec![]; let mut vec2 : Vec<i32> = vec![];
for i in vec.into_iter() { for i in vec {
vec2.push(i); vec2.push(i);
} }
assert!(vec2 == vec![1, 2, 3]); assert!(vec2 == vec![1, 2, 3]);
@ -2353,7 +2353,7 @@ mod tests {
fn test_move_items_zero_sized() { fn test_move_items_zero_sized() {
let vec = vec![(), (), ()]; let vec = vec![(), (), ()];
let mut vec2 : Vec<()> = vec![]; let mut vec2 : Vec<()> = vec![];
for i in vec.into_iter() { for i in vec {
vec2.push(i); vec2.push(i);
} }
assert!(vec2 == vec![(), (), ()]); assert!(vec2 == vec![(), (), ()]);

View file

@ -984,7 +984,7 @@ mod test_map {
let mut m = VecMap::new(); let mut m = VecMap::new();
m.insert(1, box 2); m.insert(1, box 2);
let mut called = false; let mut called = false;
for (k, v) in m.into_iter() { for (k, v) in m {
assert!(!called); assert!(!called);
called = true; called = true;
assert_eq!(k, 1); assert_eq!(k, 1);

View file

@ -482,7 +482,7 @@ impl<'a> Formatter<'a> {
// Writes the sign if it exists, and then the prefix if it was requested // Writes the sign if it exists, and then the prefix if it was requested
let write_prefix = |&: f: &mut Formatter| { let write_prefix = |&: f: &mut Formatter| {
for c in sign.into_iter() { if let Some(c) = sign {
let mut b = [0; 4]; let mut b = [0; 4];
let n = c.encode_utf8(&mut b).unwrap_or(0); let n = c.encode_utf8(&mut b).unwrap_or(0);
let b = unsafe { str::from_utf8_unchecked(&b[..n]) }; let b = unsafe { str::from_utf8_unchecked(&b[..n]) };

View file

@ -417,11 +417,11 @@ pub fn raw_emit_lint(sess: &Session, lint: &'static Lint,
_ => sess.bug("impossible level in raw_emit_lint"), _ => sess.bug("impossible level in raw_emit_lint"),
} }
for note in note.into_iter() { if let Some(note) = note {
sess.note(&note[]); sess.note(&note[]);
} }
for span in def.into_iter() { if let Some(span) = def {
sess.span_note(span, "lint level defined here"); sess.span_note(span, "lint level defined here");
} }
} }
@ -492,7 +492,7 @@ impl<'a, 'tcx> Context<'a, 'tcx> {
// specified closure // specified closure
let mut pushed = 0; let mut pushed = 0;
for result in gather_attrs(attrs).into_iter() { for result in gather_attrs(attrs) {
let v = match result { let v = match result {
Err(span) => { Err(span) => {
self.tcx.sess.span_err(span, "malformed lint attribute"); self.tcx.sess.span_err(span, "malformed lint attribute");
@ -519,7 +519,7 @@ impl<'a, 'tcx> Context<'a, 'tcx> {
} }
}; };
for (lint_id, level, span) in v.into_iter() { for (lint_id, level, span) in v {
let now = self.lints.get_level_source(lint_id).0; let now = self.lints.get_level_source(lint_id).0;
if now == Forbid && level != Forbid { if now == Forbid && level != Forbid {
let lint_name = lint_id.as_str(); let lint_name = lint_id.as_str();
@ -727,7 +727,7 @@ impl<'a, 'tcx> IdVisitingOperation for Context<'a, 'tcx> {
match self.tcx.sess.lints.borrow_mut().remove(&id) { match self.tcx.sess.lints.borrow_mut().remove(&id) {
None => {} None => {}
Some(lints) => { Some(lints) => {
for (lint_id, span, msg) in lints.into_iter() { for (lint_id, span, msg) in lints {
self.span_lint(lint_id.lint, span, &msg[]) self.span_lint(lint_id.lint, span, &msg[])
} }
} }

View file

@ -1589,7 +1589,7 @@ fn encode_index<T, F>(rbml_w: &mut Encoder, index: Vec<entry<T>>, mut write_fn:
T: Hash<SipHasher>, T: Hash<SipHasher>,
{ {
let mut buckets: Vec<Vec<entry<T>>> = (0..256u16).map(|_| Vec::new()).collect(); let mut buckets: Vec<Vec<entry<T>>> = (0..256u16).map(|_| Vec::new()).collect();
for elt in index.into_iter() { for elt in index {
let mut s = SipHasher::new(); let mut s = SipHasher::new();
elt.val.hash(&mut s); elt.val.hash(&mut s);
let h = s.finish() as uint; let h = s.finish() as uint;

View file

@ -425,7 +425,7 @@ impl<'a> Context<'a> {
// libraries corresponds to the crate id and hash criteria that this // libraries corresponds to the crate id and hash criteria that this
// search is being performed for. // search is being performed for.
let mut libraries = Vec::new(); let mut libraries = Vec::new();
for (_hash, (rlibs, dylibs)) in candidates.into_iter() { for (_hash, (rlibs, dylibs)) in candidates {
let mut metadata = None; let mut metadata = None;
let rlib = self.extract_one(rlibs, "rlib", &mut metadata); let rlib = self.extract_one(rlibs, "rlib", &mut metadata);
let dylib = self.extract_one(dylibs, "dylib", &mut metadata); let dylib = self.extract_one(dylibs, "dylib", &mut metadata);
@ -501,7 +501,7 @@ impl<'a> Context<'a> {
} }
} }
for (lib, kind) in m.into_iter() { for (lib, kind) in m {
info!("{} reading metadata from: {}", flavor, lib.display()); info!("{} reading metadata from: {}", flavor, lib.display());
let metadata = match get_metadata_section(self.target.options.is_like_osx, let metadata = match get_metadata_section(self.target.options.is_like_osx,
&lib) { &lib) {

View file

@ -77,7 +77,7 @@ impl<'a> fmt::Debug for Matrix<'a> {
let total_width = column_widths.iter().map(|n| *n).sum() + column_count * 3 + 1; let total_width = column_widths.iter().map(|n| *n).sum() + column_count * 3 + 1;
let br = repeat('+').take(total_width).collect::<String>(); let br = repeat('+').take(total_width).collect::<String>();
try!(write!(f, "{}\n", br)); try!(write!(f, "{}\n", br));
for row in pretty_printed_matrix.into_iter() { for row in pretty_printed_matrix {
try!(write!(f, "+")); try!(write!(f, "+"));
for (column, pat_str) in row.into_iter().enumerate() { for (column, pat_str) in row.into_iter().enumerate() {
try!(write!(f, " ")); try!(write!(f, " "));

View file

@ -318,7 +318,7 @@ fn has_allow_dead_code_or_lang_attr(attrs: &[ast::Attribute]) -> bool {
} }
let dead_code = lint::builtin::DEAD_CODE.name_lower(); let dead_code = lint::builtin::DEAD_CODE.name_lower();
for attr in lint::gather_attrs(attrs).into_iter() { for attr in lint::gather_attrs(attrs) {
match attr { match attr {
Ok((ref name, lint::Allow, _)) Ok((ref name, lint::Allow, _))
if name.get() == dead_code => return true, if name.get() == dead_code => return true,

View file

@ -352,7 +352,7 @@ impl<T> VecPerParamSpace<T> {
pub fn replace(&mut self, space: ParamSpace, elems: Vec<T>) { pub fn replace(&mut self, space: ParamSpace, elems: Vec<T>) {
// FIXME (#15435): slow; O(n^2); could enhance vec to make it O(n). // FIXME (#15435): slow; O(n^2); could enhance vec to make it O(n).
self.truncate(space, 0); self.truncate(space, 0);
for t in elems.into_iter() { for t in elems {
self.push(space, t); self.push(space, t);
} }
} }

View file

@ -125,7 +125,7 @@ impl<'tcx> FulfillmentContext<'tcx> {
let mut selcx = SelectionContext::new(infcx, typer); let mut selcx = SelectionContext::new(infcx, typer);
let normalized = project::normalize_projection_type(&mut selcx, projection_ty, cause, 0); let normalized = project::normalize_projection_type(&mut selcx, projection_ty, cause, 0);
for obligation in normalized.obligations.into_iter() { for obligation in normalized.obligations {
self.register_predicate_obligation(infcx, obligation); self.register_predicate_obligation(infcx, obligation);
} }
@ -289,7 +289,7 @@ impl<'tcx> FulfillmentContext<'tcx> {
// Now go through all the successful ones, // Now go through all the successful ones,
// registering any nested obligations for the future. // registering any nested obligations for the future.
for new_obligation in new_obligations.into_iter() { for new_obligation in new_obligations {
self.register_predicate_obligation(selcx.infcx(), new_obligation); self.register_predicate_obligation(selcx.infcx(), new_obligation);
} }
} }

View file

@ -438,7 +438,7 @@ pub fn normalize_param_env<'a,'tcx>(param_env: &ty::ParameterEnvironment<'a,'tcx
let mut fulfill_cx = FulfillmentContext::new(); let mut fulfill_cx = FulfillmentContext::new();
let Normalized { value: predicates, obligations } = let Normalized { value: predicates, obligations } =
project::normalize(selcx, cause, &param_env.caller_bounds); project::normalize(selcx, cause, &param_env.caller_bounds);
for obligation in obligations.into_iter() { for obligation in obligations {
fulfill_cx.register_predicate_obligation(selcx.infcx(), obligation); fulfill_cx.register_predicate_obligation(selcx.infcx(), obligation);
} }
try!(fulfill_cx.select_all_or_error(selcx.infcx(), param_env)); try!(fulfill_cx.select_all_or_error(selcx.infcx(), param_env));

View file

@ -204,7 +204,7 @@ impl<'a> PluginLoader<'a> {
} }
} }
for mut def in macros.into_iter() { for mut def in macros {
let name = token::get_ident(def.ident); let name = token::get_ident(def.ident);
def.use_locally = match macro_selection.as_ref() { def.use_locally = match macro_selection.as_ref() {
None => true, None => true,

View file

@ -300,7 +300,7 @@ macro_rules! options {
pub fn $buildfn(matches: &getopts::Matches) -> $struct_name pub fn $buildfn(matches: &getopts::Matches) -> $struct_name
{ {
let mut op = $defaultfn(); let mut op = $defaultfn();
for option in matches.opt_strs($prefix).into_iter() { for option in matches.opt_strs($prefix) {
let mut iter = option.splitn(1, '='); let mut iter = option.splitn(1, '=');
let key = iter.next().unwrap(); let key = iter.next().unwrap();
let value = iter.next(); let value = iter.next();
@ -831,7 +831,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
let mut describe_lints = false; let mut describe_lints = false;
for &level in &[lint::Allow, lint::Warn, lint::Deny, lint::Forbid] { 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()) {
if lint_name == "help" { if lint_name == "help" {
describe_lints = true; describe_lints = true;
} else { } else {

View file

@ -424,7 +424,7 @@ pub fn phase_2_configure_and_expand(sess: &Session,
diagnostics::plugin::expand_build_diagnostic_array); diagnostics::plugin::expand_build_diagnostic_array);
} }
for registrar in registrars.into_iter() { for registrar in registrars {
registry.args_hidden = Some(registrar.args); registry.args_hidden = Some(registrar.args);
(registrar.fun)(&mut registry); (registrar.fun)(&mut registry);
} }
@ -434,11 +434,11 @@ pub fn phase_2_configure_and_expand(sess: &Session,
{ {
let mut ls = sess.lint_store.borrow_mut(); let mut ls = sess.lint_store.borrow_mut();
for pass in lint_passes.into_iter() { for pass in lint_passes {
ls.register_pass(Some(sess), true, pass); ls.register_pass(Some(sess), true, pass);
} }
for (name, to) in lint_groups.into_iter() { for (name, to) in lint_groups {
ls.register_group(Some(sess), true, name, to); ls.register_group(Some(sess), true, name, to);
} }
} }

View file

@ -373,7 +373,7 @@ Available lint options:
println!(" {} {:7.7} {}", padded("----"), "-------", "-------"); println!(" {} {:7.7} {}", padded("----"), "-------", "-------");
let print_lints = |&: lints: Vec<&Lint>| { let print_lints = |&: lints: Vec<&Lint>| {
for lint in lints.into_iter() { for lint in lints {
let name = lint.name_lower().replace("_", "-"); let name = lint.name_lower().replace("_", "-");
println!(" {} {:7.7} {}", println!(" {} {:7.7} {}",
padded(&name[]), lint.default_level.as_str(), lint.desc); padded(&name[]), lint.default_level.as_str(), lint.desc);
@ -400,7 +400,7 @@ Available lint options:
println!(" {} {}", padded("----"), "---------"); println!(" {} {}", padded("----"), "---------");
let print_lint_groups = |&: lints: Vec<(&'static str, Vec<lint::LintId>)>| { let print_lint_groups = |&: lints: Vec<(&'static str, Vec<lint::LintId>)>| {
for (name, to) in lints.into_iter() { for (name, to) in lints {
let name = name.chars().map(|x| x.to_lowercase()) let name = name.chars().map(|x| x.to_lowercase())
.collect::<String>().replace("_", "-"); .collect::<String>().replace("_", "-");
let desc = to.into_iter().map(|x| x.as_str().replace("_", "-")) let desc = to.into_iter().map(|x| x.as_str().replace("_", "-"))

View file

@ -3607,10 +3607,10 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
TyQPath(ref qpath) => { TyQPath(ref qpath) => {
self.resolve_type(&*qpath.self_type); self.resolve_type(&*qpath.self_type);
self.resolve_trait_reference(ty.id, &*qpath.trait_ref, TraitQPath); self.resolve_trait_reference(ty.id, &*qpath.trait_ref, TraitQPath);
for ty in qpath.item_path.parameters.types().into_iter() { for ty in qpath.item_path.parameters.types() {
self.resolve_type(&**ty); self.resolve_type(&**ty);
} }
for binding in qpath.item_path.parameters.bindings().into_iter() { for binding in qpath.item_path.parameters.bindings() {
self.resolve_type(&*binding.ty); self.resolve_type(&*binding.ty);
} }
} }

View file

@ -1275,7 +1275,7 @@ fn add_upstream_native_libraries(cmd: &mut Command, sess: &Session) {
// we're just getting an ordering of crate numbers, we're not worried about // we're just getting an ordering of crate numbers, we're not worried about
// the paths. // the paths.
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 {
let libs = csearch::get_native_libraries(&sess.cstore, cnum); let libs = csearch::get_native_libraries(&sess.cstore, cnum);
for &(kind, ref lib) in &libs { for &(kind, ref lib) in &libs {
match kind { match kind {

View file

@ -48,7 +48,7 @@ pub fn run(sess: &session::Session, llmod: ModuleRef,
// load the bitcode from the archive. Then merge it into the current LLVM // load the bitcode from the archive. Then merge it into the current LLVM
// module that we've got. // module that we've got.
let crates = sess.cstore.get_used_crates(cstore::RequireStatic); let crates = sess.cstore.get_used_crates(cstore::RequireStatic);
for (cnum, path) in crates.into_iter() { for (cnum, path) in crates {
let name = sess.cstore.get_crate_data(cnum).name.clone(); let name = sess.cstore.get_crate_data(cnum).name.clone();
let path = match path { let path = match path {
Some(p) => p, Some(p) => p,

View file

@ -941,7 +941,7 @@ fn run_work_multithreaded(sess: &Session,
} }
let mut panicked = false; let mut panicked = false;
for rx in futures.into_iter() { for rx in futures {
match rx.recv() { match rx.recv() {
Ok(()) => {}, Ok(()) => {},
Err(_) => { Err(_) => {

View file

@ -1045,7 +1045,7 @@ pub fn trans_args<'a, 'blk, 'tcx>(cx: Block<'blk, 'tcx>,
})); }));
assert_eq!(arg_tys.len(), 1 + rhs.len()); assert_eq!(arg_tys.len(), 1 + rhs.len());
for (rhs, rhs_id) in rhs.into_iter() { for (rhs, rhs_id) in rhs {
llargs.push(unpack_result!(bcx, { llargs.push(unpack_result!(bcx, {
trans_arg_datum(bcx, arg_tys[1], rhs, trans_arg_datum(bcx, arg_tys[1], rhs,
arg_cleanup_scope, arg_cleanup_scope,

View file

@ -333,7 +333,7 @@ pub fn normalize_associated_type<'tcx,T>(tcx: &ty::ctxt<'tcx>, value: &T) -> T
obligations.repr(tcx)); obligations.repr(tcx));
let mut fulfill_cx = traits::FulfillmentContext::new(); let mut fulfill_cx = traits::FulfillmentContext::new();
for obligation in obligations.into_iter() { for obligation in obligations {
fulfill_cx.register_predicate_obligation(&infcx, obligation); fulfill_cx.register_predicate_obligation(&infcx, obligation);
} }
let result = drain_fulfillment_cx(DUMMY_SP, &infcx, &mut fulfill_cx, &result); let result = drain_fulfillment_cx(DUMMY_SP, &infcx, &mut fulfill_cx, &result);

View file

@ -537,7 +537,7 @@ pub fn instantiate_poly_trait_ref<'tcx>(
instantiate_trait_ref(this, &shifted_rscope, &ast_trait_ref.trait_ref, instantiate_trait_ref(this, &shifted_rscope, &ast_trait_ref.trait_ref,
self_ty, Some(&mut projections)); self_ty, Some(&mut projections));
for projection in projections.into_iter() { for projection in projections {
poly_projections.push(ty::Binder(projection)); poly_projections.push(ty::Binder(projection));
} }

View file

@ -33,7 +33,7 @@ pub fn normalize_associated_types_in<'a,'tcx,T>(infcx: &InferCtxt<'a,'tcx>,
debug!("normalize_associated_types_in: result={} predicates={}", debug!("normalize_associated_types_in: result={} predicates={}",
result.repr(infcx.tcx), result.repr(infcx.tcx),
obligations.repr(infcx.tcx)); obligations.repr(infcx.tcx));
for obligation in obligations.into_iter() { for obligation in obligations {
fulfillment_cx.register_predicate_obligation(infcx, obligation); fulfillment_cx.register_predicate_obligation(infcx, obligation);
} }
result result

View file

@ -248,7 +248,7 @@ pub fn compare_impl_method<'tcx>(tcx: &ty::ctxt<'tcx>,
let mut selcx = traits::SelectionContext::new(&infcx, &trait_param_env); let mut selcx = traits::SelectionContext::new(&infcx, &trait_param_env);
for predicate in impl_pred.fns.into_iter() { for predicate in impl_pred.fns {
let traits::Normalized { value: predicate, .. } = let traits::Normalized { value: predicate, .. } =
traits::normalize(&mut selcx, normalize_cause.clone(), &predicate); traits::normalize(&mut selcx, normalize_cause.clone(), &predicate);

View file

@ -448,7 +448,7 @@ impl<'a,'tcx> ProbeContext<'a,'tcx> {
{ {
let mut duplicates = HashSet::new(); let mut duplicates = HashSet::new();
let opt_applicable_traits = self.fcx.ccx.trait_map.get(&expr_id); let opt_applicable_traits = self.fcx.ccx.trait_map.get(&expr_id);
for applicable_traits in opt_applicable_traits.into_iter() { if let Some(applicable_traits) = opt_applicable_traits {
for &trait_did in applicable_traits { for &trait_did in applicable_traits {
if duplicates.insert(trait_did) { if duplicates.insert(trait_did) {
try!(self.assemble_extension_candidates_for_trait(trait_did)); try!(self.assemble_extension_candidates_for_trait(trait_did));

View file

@ -142,7 +142,7 @@ pub fn check_object_safety<'tcx>(tcx: &ty::ctxt<'tcx>,
ty::item_path_str(tcx, object_trait_ref.def_id())); ty::item_path_str(tcx, object_trait_ref.def_id()));
let violations = traits::object_safety_violations(tcx, object_trait_ref.clone()); let violations = traits::object_safety_violations(tcx, object_trait_ref.clone());
for violation in violations.into_iter() { for violation in violations {
match violation { match violation {
ObjectSafetyViolation::SizedSelf => { ObjectSafetyViolation::SizedSelf => {
tcx.sess.span_note( tcx.sess.span_note(
@ -269,7 +269,7 @@ fn check_object_type_binds_all_associated_types<'tcx>(tcx: &ty::ctxt<'tcx>,
associated_types.remove(&pair); associated_types.remove(&pair);
} }
for (trait_def_id, name) in associated_types.into_iter() { for (trait_def_id, name) in associated_types {
span_err!(tcx.sess, span, E0191, span_err!(tcx.sess, span, E0191,
"the value of the associated type `{}` (from the trait `{}`) must be specified", "the value of the associated type `{}` (from the trait `{}`) must be specified",
name.user_string(tcx), name.user_string(tcx),

View file

@ -268,10 +268,10 @@ impl<'ccx, 'tcx> CheckTypeWellFormedVisitor<'ccx, 'tcx> {
let selcx = &mut traits::SelectionContext::new(fcx.infcx(), fcx); let selcx = &mut traits::SelectionContext::new(fcx.infcx(), fcx);
traits::normalize(selcx, cause.clone(), &predicates) traits::normalize(selcx, cause.clone(), &predicates)
}; };
for predicate in predicates.value.into_iter() { for predicate in predicates.value {
fcx.register_predicate(traits::Obligation::new(cause.clone(), predicate)); fcx.register_predicate(traits::Obligation::new(cause.clone(), predicate));
} }
for obligation in predicates.obligations.into_iter() { for obligation in predicates.obligations {
fcx.register_predicate(obligation); fcx.register_predicate(obligation);
} }
}); });

View file

@ -1109,7 +1109,7 @@ fn ty_generics_for_trait<'a, 'tcx>(ccx: &CollectCtxt<'a, 'tcx>,
debug!("ty_generics_for_trait: assoc_predicates={}", assoc_predicates.repr(ccx.tcx)); debug!("ty_generics_for_trait: assoc_predicates={}", assoc_predicates.repr(ccx.tcx));
for assoc_predicate in assoc_predicates.into_iter() { for assoc_predicate in assoc_predicates {
generics.predicates.push(subst::TypeSpace, assoc_predicate); generics.predicates.push(subst::TypeSpace, assoc_predicate);
} }
@ -1310,7 +1310,7 @@ fn ty_generics<'a,'tcx>(ccx: &CollectCtxt<'a,'tcx>,
{ {
for type_param_def in result.types.get_slice(space) { for type_param_def in result.types.get_slice(space) {
let param_ty = ty::mk_param_from_def(tcx, type_param_def); let param_ty = ty::mk_param_from_def(tcx, type_param_def);
for predicate in ty::predicates(tcx, param_ty, &type_param_def.bounds).into_iter() { for predicate in ty::predicates(tcx, param_ty, &type_param_def.bounds) {
result.predicates.push(space, predicate); result.predicates.push(space, predicate);
} }
} }

View file

@ -1231,7 +1231,7 @@ impl Context {
_ => unreachable!() _ => unreachable!()
}; };
this.sidebar = this.build_sidebar(&m); this.sidebar = this.build_sidebar(&m);
for item in m.items.into_iter() { for item in m.items {
f(this,item); f(this,item);
} }
Ok(()) Ok(())

View file

@ -431,7 +431,7 @@ fn rust_input(cratefile: &str, externs: core::Externs, matches: &getopts::Matche
pm.add_plugin(plugin); pm.add_plugin(plugin);
} }
info!("loading plugins..."); info!("loading plugins...");
for pname in plugins.into_iter() { for pname in plugins {
pm.load_plugin(pname); pm.load_plugin(pname);
} }

View file

@ -2371,7 +2371,7 @@ impl ::Decoder for Decoder {
{ {
let obj = try!(expect!(self.pop(), Object)); let obj = try!(expect!(self.pop(), Object));
let len = obj.len(); let len = obj.len();
for (key, value) in obj.into_iter() { for (key, value) in obj {
self.stack.push(value); self.stack.push(value);
self.stack.push(Json::String(key)); self.stack.push(Json::String(key));
} }

View file

@ -649,7 +649,7 @@ pub fn rmdir_recursive(path: &Path) -> IoResult<()> {
// delete all regular files in the way and push subdirs // delete all regular files in the way and push subdirs
// on the stack // on the stack
for child in children.into_iter() { for child in children {
// FIXME(#12795) we should use lstat in all cases // FIXME(#12795) we should use lstat in all cases
let child_type = match cfg!(windows) { let child_type = match cfg!(windows) {
true => try!(update_err(stat(&child), path)), true => try!(update_err(stat(&child), path)),

View file

@ -36,7 +36,7 @@ fn with_addresses<A, T, F>(addr: A, mut action: F) -> IoResult<T> where
let addresses = try!(addr.to_socket_addr_all()); let addresses = try!(addr.to_socket_addr_all());
let mut err = DEFAULT_ERROR; let mut err = DEFAULT_ERROR;
for addr in addresses.into_iter() { for addr in addresses {
match action(addr) { match action(addr) {
Ok(r) => return Ok(r), Ok(r) => return Ok(r),
Err(e) => err = e Err(e) => err = e

View file

@ -58,7 +58,7 @@ pub fn cleanup() {
// If we never called init, not need to cleanup! // If we never called init, not need to cleanup!
if queue as uint != 0 { if queue as uint != 0 {
let queue: Box<Queue> = mem::transmute(queue); let queue: Box<Queue> = mem::transmute(queue);
for to_run in queue.into_iter() { for to_run in *queue {
to_run.invoke(()); to_run.invoke(());
} }
} }

View file

@ -508,7 +508,7 @@ mod tests {
} }
// Wait for children to pass their asserts // Wait for children to pass their asserts
for r in children.into_iter() { for r in children {
assert!(r.join().is_ok()); assert!(r.join().is_ok());
} }

View file

@ -147,7 +147,7 @@ impl Process {
// Split the value and test each path to see if the // Split the value and test each path to see if the
// program exists. // program exists.
for path in os::split_paths(v.container_as_bytes()).into_iter() { for path in os::split_paths(v.container_as_bytes()) {
let path = path.join(cfg.program().as_bytes()) let path = path.join(cfg.program().as_bytes())
.with_extension(os::consts::EXE_EXTENSION); .with_extension(os::consts::EXE_EXTENSION);
if path.exists() { if path.exists() {

View file

@ -490,7 +490,7 @@ fn find_stability_generic<'a,
pub fn find_stability(diagnostic: &SpanHandler, attrs: &[Attribute], pub fn find_stability(diagnostic: &SpanHandler, attrs: &[Attribute],
item_sp: Span) -> Option<Stability> { item_sp: Span) -> Option<Stability> {
let (s, used) = find_stability_generic(diagnostic, attrs.iter(), item_sp); let (s, used) = find_stability_generic(diagnostic, attrs.iter(), item_sp);
for used in used.into_iter() { mark_used(used) } for used in used { mark_used(used) }
return s; return s;
} }

View file

@ -25,7 +25,7 @@ pub fn expand_syntax_ext(cx: &mut base::ExtCtxt,
None => return base::DummyResult::expr(sp) None => return base::DummyResult::expr(sp)
}; };
let mut accumulator = String::new(); let mut accumulator = String::new();
for e in es.into_iter() { for e in es {
match e.node { match e.node {
ast::ExprLit(ref lit) => { ast::ExprLit(ref lit) => {
match lit.node { match lit.node {

View file

@ -1420,11 +1420,11 @@ pub fn expand_crate(parse_sess: &parse::ParseSess,
let mut cx = ExtCtxt::new(parse_sess, c.config.clone(), cfg); let mut cx = ExtCtxt::new(parse_sess, c.config.clone(), cfg);
let mut expander = MacroExpander::new(&mut cx); let mut expander = MacroExpander::new(&mut cx);
for def in imported_macros.into_iter() { for def in imported_macros {
expander.cx.insert_macro(def); expander.cx.insert_macro(def);
} }
for (name, extension) in user_exts.into_iter() { for (name, extension) in user_exts {
expander.cx.syntax_env.insert(name, extension); expander.cx.syntax_env.insert(name, extension);
} }

View file

@ -5445,7 +5445,7 @@ impl<'a> Parser<'a> {
seq_sep_trailing_allowed(token::Comma), seq_sep_trailing_allowed(token::Comma),
|p| p.parse_ty_sum() |p| p.parse_ty_sum()
); );
for ty in arg_tys.into_iter() { for ty in arg_tys {
args.push(ast::VariantArg { args.push(ast::VariantArg {
ty: ty, ty: ty,
id: ast::DUMMY_NODE_ID, id: ast::DUMMY_NODE_ID,

View file

@ -966,7 +966,7 @@ impl<'a> State<'a> {
try!(self.print_generics(generics)); try!(self.print_generics(generics));
let bounds: Vec<_> = bounds.iter().map(|b| b.clone()).collect(); let bounds: Vec<_> = bounds.iter().map(|b| b.clone()).collect();
let mut real_bounds = Vec::with_capacity(bounds.len()); let mut real_bounds = Vec::with_capacity(bounds.len());
for b in bounds.into_iter() { for b in bounds {
if let TraitTyParamBound(ref ptr, ast::TraitBoundModifier::Maybe) = b { if let TraitTyParamBound(ref ptr, ast::TraitBoundModifier::Maybe) = b {
try!(space(&mut self.s)); try!(space(&mut self.s));
try!(self.word_space("for ?")); try!(self.word_space("for ?"));

View file

@ -806,7 +806,7 @@ fn run_tests<F>(opts: &TestOpts,
// All benchmarks run at the end, in serial. // All benchmarks run at the end, in serial.
// (this includes metric fns) // (this includes metric fns)
for b in filtered_benchs_and_metrics.into_iter() { for b in filtered_benchs_and_metrics {
try!(callback(TeWait(b.desc.clone(), b.testfn.padding()))); try!(callback(TeWait(b.desc.clone(), b.testfn.padding())));
run_test(opts, !opts.run_benchmarks, b, tx.clone()); run_test(opts, !opts.run_benchmarks, b, tx.clone());
let (test, result, stdout) = rx.recv().unwrap(); let (test, result, stdout) = rx.recv().unwrap();

View file

@ -177,7 +177,7 @@ impl Subcommand for Build {
} }
Err(errors) => { Err(errors) => {
let n = errors.len(); let n = errors.len();
for err in errors.into_iter() { for err in errors {
term.err(&format!("error: {}", err)[]); term.err(&format!("error: {}", err)[]);
} }

View file

@ -64,7 +64,7 @@ impl Subcommand for Test {
} }
} }
Err(errors) => { Err(errors) => {
for err in errors.into_iter() { for err in errors {
term.err(&err[]); term.err(&err[]);
} }
return Err(box "There was an error." as Box<Error>); return Err(box "There was an error." as Box<Error>);

View file

@ -75,7 +75,7 @@ fn run(args: &[String]) {
server(&from_parent, &to_parent); server(&from_parent, &to_parent);
}); });
for r in worker_results.into_iter() { for r in worker_results {
let _ = r.join(); let _ = r.join();
} }

View file

@ -82,7 +82,7 @@ fn run(args: &[String]) {
server(&from_parent, &to_parent); server(&from_parent, &to_parent);
}); });
for r in worker_results.into_iter() { for r in worker_results {
let _ = r.join(); let _ = r.join();
} }

View file

@ -114,7 +114,7 @@ fn main() {
Thread::scoped(move || inner(depth, iterations)) Thread::scoped(move || inner(depth, iterations))
}).collect::<Vec<_>>(); }).collect::<Vec<_>>();
for message in messages.into_iter() { for message in messages {
println!("{}", message.join().ok().unwrap()); println!("{}", message.join().ok().unwrap());
} }

View file

@ -171,7 +171,7 @@ fn fannkuch(n: i32) -> (i32, i32) {
let mut checksum = 0; let mut checksum = 0;
let mut maxflips = 0; let mut maxflips = 0;
for fut in futures.into_iter() { for fut in futures {
let (cs, mf) = fut.join().ok().unwrap(); let (cs, mf) = fut.join().ok().unwrap();
checksum += cs; checksum += cs;
maxflips = cmp::max(maxflips, mf); maxflips = cmp::max(maxflips, mf);

View file

@ -308,7 +308,7 @@ fn main() {
Thread::scoped(move|| generate_frequencies(input.as_slice(), occ.len())) Thread::scoped(move|| generate_frequencies(input.as_slice(), occ.len()))
}).collect(); }).collect();
for (i, freq) in nb_freqs.into_iter() { for (i, freq) in nb_freqs {
print_frequencies(&freq.join().ok().unwrap(), i); print_frequencies(&freq.join().ok().unwrap(), i);
} }
for (&occ, freq) in OCCURRENCES.iter().zip(occ_freqs.into_iter()) { for (&occ, freq) in OCCURRENCES.iter().zip(occ_freqs.into_iter()) {

View file

@ -106,7 +106,7 @@ fn mandelbrot<W: old_io::Writer>(w: uint, mut out: W) -> old_io::IoResult<()> {
}) })
}).collect::<Vec<_>>(); }).collect::<Vec<_>>();
for res in precalc_futures.into_iter() { for res in precalc_futures {
let (rs, is) = res.join().ok().unwrap(); let (rs, is) = res.join().ok().unwrap();
precalc_r.extend(rs.into_iter()); precalc_r.extend(rs.into_iter());
precalc_i.extend(is.into_iter()); precalc_i.extend(is.into_iter());
@ -142,7 +142,7 @@ fn mandelbrot<W: old_io::Writer>(w: uint, mut out: W) -> old_io::IoResult<()> {
}).collect::<Vec<_>>(); }).collect::<Vec<_>>();
try!(writeln!(&mut out as &mut Writer, "P4\n{} {}", w, h)); try!(writeln!(&mut out as &mut Writer, "P4\n{} {}", w, h));
for res in data.into_iter() { for res in data {
try!(out.write(res.join().ok().unwrap().as_slice())); try!(out.write(res.join().ok().unwrap().as_slice()));
} }
out.flush() out.flush()

View file

@ -82,7 +82,7 @@ fn stress(num_tasks: int) {
stress_task(i); stress_task(i);
})); }));
} }
for r in results.into_iter() { for r in results {
let _ = r.join(); let _ = r.join();
} }
} }

View file

@ -215,7 +215,7 @@ fn main() {
zzz(); // #break zzz(); // #break
} }
for simple_tuple_ident in vec![(34903493u32, 232323i64)].into_iter() { for simple_tuple_ident in vec![(34903493u32, 232323i64)] {
zzz(); // #break zzz(); // #break
} }
} }

View file

@ -61,7 +61,7 @@ fn test00() {
} }
// Join spawned tasks... // Join spawned tasks...
for r in results.into_iter() { r.join(); } for r in results { r.join(); }
println!("Completed: Final number is: "); println!("Completed: Final number is: ");
println!("{}", sum); println!("{}", sum);

View file

@ -21,7 +21,7 @@ fn main() {
call(|| { call(|| {
// Move `y`, but do not move `counter`, even though it is read // Move `y`, but do not move `counter`, even though it is read
// by value (note that it is also mutated). // by value (note that it is also mutated).
for item in y.into_iter() { for item in y {
let v = counter; let v = counter;
counter += v; counter += v;
} }

View file

@ -22,7 +22,7 @@ fn main() {
// Here: `x` must be captured with a mutable reference in // Here: `x` must be captured with a mutable reference in
// order for us to append on it, and `y` must be captured by // order for us to append on it, and `y` must be captured by
// value. // value.
for item in y.into_iter() { for item in y {
x.push(item); x.push(item);
} }
}); });