Change each_bound_trait_and_supertraits to take a vec of TraitRefs.

This commit is contained in:
Michael Sullivan 2013-07-23 14:54:53 -07:00
parent 387df4e127
commit 17e30d6b4e
3 changed files with 10 additions and 13 deletions

View File

@ -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;
}
}

View File

@ -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

View File

@ -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()));