From 17e30d6b4ef5c6fb4d6257323903cba1213cae8f Mon Sep 17 00:00:00 2001 From: Michael Sullivan Date: Tue, 23 Jul 2013 14:54:53 -0700 Subject: [PATCH] Change each_bound_trait_and_supertraits to take a vec of TraitRefs. --- src/librustc/middle/ty.rs | 7 ++++--- src/librustc/middle/typeck/check/method.rs | 12 ++++-------- src/librustc/middle/typeck/check/vtable.rs | 4 ++-- 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index 2381cb069e5..6a75c845f16 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -4348,9 +4348,9 @@ pub fn determine_inherited_purity(parent: (ast::purity, ast::node_id), // relation on the supertraits from each bounded trait's constraint // list. pub fn each_bound_trait_and_supertraits(tcx: ctxt, - bounds: &ParamBounds, + bounds: &[@TraitRef], f: &fn(@TraitRef) -> bool) -> bool { - for bounds.trait_bounds.iter().advance |&bound_trait_ref| { + for bounds.iter().advance |&bound_trait_ref| { let mut supertrait_set = HashMap::new(); let mut trait_refs = ~[]; let mut i = 0; @@ -4392,7 +4392,8 @@ pub fn count_traits_and_supertraits(tcx: ctxt, type_param_defs: &[TypeParameterDef]) -> uint { let mut total = 0; for type_param_defs.iter().advance |type_param_def| { - for each_bound_trait_and_supertraits(tcx, type_param_def.bounds) |_| { + for each_bound_trait_and_supertraits( + tcx, type_param_def.bounds.trait_bounds) |_| { total += 1; } } diff --git a/src/librustc/middle/typeck/check/method.rs b/src/librustc/middle/typeck/check/method.rs index 545a16a7993..5e2fff3b25d 100644 --- a/src/librustc/middle/typeck/check/method.rs +++ b/src/librustc/middle/typeck/check/method.rs @@ -413,7 +413,8 @@ impl<'self> LookupContext<'self> { }; self.push_inherent_candidates_from_bounds( - rcvr_ty, &*type_param_def.bounds, param_numbered(param_ty.idx)); + rcvr_ty, type_param_def.bounds.trait_bounds, + param_numbered(param_ty.idx)); } @@ -423,18 +424,13 @@ impl<'self> LookupContext<'self> { let tcx = self.tcx(); let trait_ref = ty::lookup_trait_def(tcx, did).trait_ref; - let bounds = ParamBounds { - builtin_bounds: EmptyBuiltinBounds(), - trait_bounds: ~[trait_ref] - }; - self.push_inherent_candidates_from_bounds( - self_ty, &bounds, param_self); + self_ty, &[trait_ref], param_self); } pub fn push_inherent_candidates_from_bounds(&self, self_ty: ty::t, - bounds: &ParamBounds, + bounds: &[@TraitRef], param: param_index) { let tcx = self.tcx(); let mut next_bound_idx = 0; // count only trait bounds diff --git a/src/librustc/middle/typeck/check/vtable.rs b/src/librustc/middle/typeck/check/vtable.rs index 056b330e9c5..07f82a5ef20 100644 --- a/src/librustc/middle/typeck/check/vtable.rs +++ b/src/librustc/middle/typeck/check/vtable.rs @@ -132,7 +132,7 @@ fn lookup_vtables_for_param(vcx: &VtableContext, let mut param_result = ~[]; for ty::each_bound_trait_and_supertraits( - tcx, type_param_bounds) |trait_ref| + tcx, type_param_bounds.trait_bounds) |trait_ref| { // ...and here trait_ref is each bound that was declared on A, // expressed in terms of the type parameters. @@ -249,7 +249,7 @@ fn lookup_vtable(vcx: &VtableContext, let mut n_bound = 0; let type_param_def = tcx.ty_param_defs.get(&did.node); for ty::each_bound_trait_and_supertraits( - tcx, type_param_def.bounds) |bound_trait_ref| + tcx, type_param_def.bounds.trait_bounds) |bound_trait_ref| { debug!("checking bounds trait %s", bound_trait_ref.repr(vcx.tcx()));