diff options
| author | Ariel Ben-Yehuda <ariel.byd@gmail.com> | 2015-07-19 19:21:31 +0300 |
|---|---|---|
| committer | Ariel Ben-Yehuda <ariel.byd@gmail.com> | 2015-07-20 00:16:37 +0300 |
| commit | 28ce509d3c0b3302e514d5835c43befaed6f449c (patch) | |
| tree | 48dd9c5f57f29c061bafbb357bdb0b588d7c0ef1 | |
| parent | 8edcff59d9131dfd78cf1897e861f0ee4140db10 (diff) | |
| download | rust-28ce509d3c0b3302e514d5835c43befaed6f449c.tar.gz rust-28ce509d3c0b3302e514d5835c43befaed6f449c.zip | |
clean-up find_bound_for_assoc_item
| -rw-r--r-- | src/librustc_typeck/astconv.rs | 30 |
1 files changed, 12 insertions, 18 deletions
diff --git a/src/librustc_typeck/astconv.rs b/src/librustc_typeck/astconv.rs index 3bb3a630041..837f1be8511 100644 --- a/src/librustc_typeck/astconv.rs +++ b/src/librustc_typeck/astconv.rs @@ -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, |
