clean-up find_bound_for_assoc_item

This commit is contained in:
Ariel Ben-Yehuda
2015-07-19 19:21:31 +03:00
parent 8edcff59d9
commit 28ce509d3c

View File

@@ -1112,7 +1112,7 @@ fn report_ambiguous_associated_type(tcx: &ty::ctxt,
// any ambiguity.
fn find_bound_for_assoc_item<'tcx>(this: &AstConv<'tcx>,
ty_param_node_id: ast::NodeId,
ty_param_name: Option<ast::Name>,
ty_param_name: ast::Name,
assoc_name: ast::Name,
span: Span)
-> Result<ty::PolyTraitRef<'tcx>, ErrorReported>
@@ -1138,21 +1138,11 @@ fn find_bound_for_assoc_item<'tcx>(this: &AstConv<'tcx>,
.filter(|b| this.trait_defines_associated_type_named(b.def_id(), assoc_name))
.collect();
if let Some(s) = ty_param_name {
// borrowck doesn't like this any other way
one_bound_for_assoc_type(tcx,
suitable_bounds,
&token::get_name(s),
&token::get_name(assoc_name),
span)
} else {
one_bound_for_assoc_type(tcx,
suitable_bounds,
"Self",
&token::get_name(assoc_name),
span)
}
one_bound_for_assoc_type(tcx,
suitable_bounds,
&token::get_name(ty_param_name),
&token::get_name(assoc_name),
span)
}
@@ -1251,7 +1241,11 @@ fn associated_path_def_to_ty<'tcx>(this: &AstConv<'tcx>,
}
(&ty::TyParam(_), def::DefSelfTy(Some(trait_did), None)) => {
assert_eq!(trait_did.krate, ast::LOCAL_CRATE);
match find_bound_for_assoc_item(this, trait_did.node, None, assoc_name, span) {
match find_bound_for_assoc_item(this,
trait_did.node,
token::special_idents::type_self.name,
assoc_name,
span) {
Ok(bound) => bound,
Err(ErrorReported) => return (tcx.types.err, ty_path_def),
}
@@ -1260,7 +1254,7 @@ fn associated_path_def_to_ty<'tcx>(this: &AstConv<'tcx>,
assert_eq!(param_did.krate, ast::LOCAL_CRATE);
match find_bound_for_assoc_item(this,
param_did.node,
Some(param_name),
param_name,
assoc_name,
span) {
Ok(bound) => bound,