Skip to content

Commit 5242e8d

Browse files
committed
remove the redundant each method from OptVec
1 parent 032dcc5 commit 5242e8d

File tree

11 files changed

+19
-26
lines changed

11 files changed

+19
-26
lines changed

src/librustc/metadata/encoder.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -731,8 +731,8 @@ fn encode_info_for_method(ecx: &EncodeContext,
731731
}
732732

733733
let mut combined_ty_params = opt_vec::Empty;
734-
for owner_generics.ty_params.each |x| { combined_ty_params.push(copy *x) }
735-
for method_generics.ty_params.each |x| { combined_ty_params.push(copy *x) }
734+
for owner_generics.ty_params.iter().advance |x| { combined_ty_params.push(copy *x) }
735+
for method_generics.ty_params.iter().advance |x| { combined_ty_params.push(copy *x) }
736736
let len = combined_ty_params.len();
737737
encode_type_param_bounds(ebml_w, ecx, &combined_ty_params);
738738

src/librustc/middle/resolve.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3834,8 +3834,8 @@ impl Resolver {
38343834
pub fn resolve_type_parameters(@mut self,
38353835
type_parameters: &OptVec<TyParam>,
38363836
visitor: ResolveVisitor) {
3837-
for type_parameters.each |type_parameter| {
3838-
for type_parameter.bounds.each |bound| {
3837+
for type_parameters.iter().advance |type_parameter| {
3838+
for type_parameter.bounds.iter().advance |bound| {
38393839
self.resolve_type_parameter_bound(bound, visitor);
38403840
}
38413841
}
@@ -4181,13 +4181,13 @@ impl Resolver {
41814181
}
41824182
}
41834183

4184-
for bounds.each |bound| {
4184+
for bounds.iter().advance |bound| {
41854185
self.resolve_type_parameter_bound(bound, visitor);
41864186
}
41874187
}
41884188

41894189
ty_closure(c) => {
4190-
for c.bounds.each |bound| {
4190+
for c.bounds.iter().advance |bound| {
41914191
self.resolve_type_parameter_bound(bound, visitor);
41924192
}
41934193
visit_ty(ty, ((), visitor));

src/librustc/middle/typeck/astconv.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -752,7 +752,7 @@ fn conv_builtin_bounds(tcx: ty::ctxt,
752752
//! legal.
753753
754754
let mut builtin_bounds = ty::EmptyBuiltinBounds();
755-
for ast_bounds.each |ast_bound| {
755+
for ast_bounds.iter().advance |ast_bound| {
756756
match *ast_bound {
757757
ast::TraitTyParamBound(b) => {
758758
match lookup_def_tcx(tcx, b.path.span, b.ref_id) {

src/librustc/middle/typeck/collect.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -775,7 +775,7 @@ pub fn ensure_no_ty_param_bounds(ccx: &CrateCtxt,
775775
span: span,
776776
generics: &ast::Generics,
777777
thing: &'static str) {
778-
for generics.ty_params.each |ty_param| {
778+
for generics.ty_params.iter().advance |ty_param| {
779779
if ty_param.bounds.len() > 0 {
780780
ccx.tcx.sess.span_err(
781781
span,
@@ -1172,7 +1172,7 @@ pub fn ty_generics(ccx: &CrateCtxt,
11721172
builtin_bounds: ty::EmptyBuiltinBounds(),
11731173
trait_bounds: ~[]
11741174
};
1175-
for ast_bounds.each |ast_bound| {
1175+
for ast_bounds.iter().advance |ast_bound| {
11761176
match *ast_bound {
11771177
TraitTyParamBound(b) => {
11781178
let ty = ty::mk_param(ccx.tcx, param_ty.idx, param_ty.def_id);

src/librustc/middle/typeck/rscope.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ impl RegionParamNames {
5757
}
5858

5959
fn has_ident(&self, ident: ast::ident) -> bool {
60-
for self.each |region_param_name| {
60+
for self.iter().advance |region_param_name| {
6161
if *region_param_name == ident {
6262
return true;
6363
}

src/libsyntax/ast_util.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -394,10 +394,10 @@ impl id_range {
394394

395395
pub fn id_visitor<T: Copy>(vfn: @fn(node_id, T)) -> visit::vt<T> {
396396
let visit_generics: @fn(&Generics, T) = |generics, t| {
397-
for generics.ty_params.each |p| {
397+
for generics.ty_params.iter().advance |p| {
398398
vfn(p.id, copy t);
399399
}
400-
for generics.lifetimes.each |p| {
400+
for generics.lifetimes.iter().advance |p| {
401401
vfn(p.id, copy t);
402402
}
403403
};

src/libsyntax/ext/deriving/generic.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -324,11 +324,11 @@ impl<'self> TraitDef<'self> {
324324

325325
let mut trait_generics = self.generics.to_generics(cx, span, type_ident, generics);
326326
// Copy the lifetimes
327-
for generics.lifetimes.each |l| {
327+
for generics.lifetimes.iter().advance |l| {
328328
trait_generics.lifetimes.push(copy *l)
329329
};
330330
// Create the type parameters.
331-
for generics.ty_params.each |ty_param| {
331+
for generics.ty_params.iter().advance |ty_param| {
332332
// I don't think this can be moved out of the loop, since
333333
// a TyParamBound requires an ast id
334334
let mut bounds = opt_vec::from(

src/libsyntax/ext/pipes/pipec.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ impl gen_init for protocol {
374374
fn buffer_ty_path(&self, cx: @ExtCtxt) -> @ast::Ty {
375375
let mut params: OptVec<ast::TyParam> = opt_vec::Empty;
376376
for (copy self.states).iter().advance |s| {
377-
for s.generics.ty_params.each |tp| {
377+
for s.generics.ty_params.iter().advance |tp| {
378378
match params.iter().find_(|tpp| tp.ident == tpp.ident) {
379379
None => params.push(*tp),
380380
_ => ()
@@ -392,7 +392,7 @@ impl gen_init for protocol {
392392
let ext_cx = cx;
393393
let mut params: OptVec<ast::TyParam> = opt_vec::Empty;
394394
let fields = do (copy self.states).iter().transform |s| {
395-
for s.generics.ty_params.each |tp| {
395+
for s.generics.ty_params.iter().advance |tp| {
396396
match params.iter().find_(|tpp| tp.ident == tpp.ident) {
397397
None => params.push(*tp),
398398
_ => ()

src/libsyntax/opt_vec.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,6 @@ pub fn from<T>(t: ~[T]) -> OptVec<T> {
3838
}
3939

4040
impl<T> OptVec<T> {
41-
fn each(&self, blk: &fn(v: &T) -> bool) -> bool {
42-
match *self {
43-
Empty => true,
44-
Vec(ref v) => v.iter().advance(blk)
45-
}
46-
}
47-
4841
fn push(&mut self, t: T) {
4942
match *self {
5043
Vec(ref mut v) => {

src/libsyntax/print/pprust.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1743,7 +1743,7 @@ pub fn print_bounds(s: @ps, bounds: @OptVec<ast::TyParamBound>) {
17431743
if !bounds.is_empty() {
17441744
word(s.s, ":");
17451745
let mut first = true;
1746-
for bounds.each |bound| {
1746+
for bounds.iter().advance |bound| {
17471747
nbsp(s);
17481748
if first {
17491749
first = false;

src/libsyntax/visit.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ pub fn visit_foreign_item<E: Copy>(ni: @foreign_item, (e, v): (E, vt<E>)) {
334334

335335
pub fn visit_ty_param_bounds<E: Copy>(bounds: &OptVec<TyParamBound>,
336336
(e, v): (E, vt<E>)) {
337-
for bounds.each |bound| {
337+
for bounds.iter().advance |bound| {
338338
match *bound {
339339
TraitTyParamBound(ty) => visit_trait_ref(ty, (copy e, v)),
340340
RegionTyParamBound => {}
@@ -343,7 +343,7 @@ pub fn visit_ty_param_bounds<E: Copy>(bounds: &OptVec<TyParamBound>,
343343
}
344344

345345
pub fn visit_generics<E: Copy>(generics: &Generics, (e, v): (E, vt<E>)) {
346-
for generics.ty_params.each |tp| {
346+
for generics.ty_params.iter().advance |tp| {
347347
visit_ty_param_bounds(tp.bounds, (copy e, v));
348348
}
349349
}

0 commit comments

Comments
 (0)