Skip to content

Commit 28ce509

Browse files
committed
clean-up find_bound_for_assoc_item
1 parent 8edcff5 commit 28ce509

File tree

1 file changed

+12
-18
lines changed

1 file changed

+12
-18
lines changed

src/librustc_typeck/astconv.rs

+12-18
Original file line numberDiff line numberDiff line change
@@ -1112,7 +1112,7 @@ fn report_ambiguous_associated_type(tcx: &ty::ctxt,
11121112
// any ambiguity.
11131113
fn find_bound_for_assoc_item<'tcx>(this: &AstConv<'tcx>,
11141114
ty_param_node_id: ast::NodeId,
1115-
ty_param_name: Option<ast::Name>,
1115+
ty_param_name: ast::Name,
11161116
assoc_name: ast::Name,
11171117
span: Span)
11181118
-> Result<ty::PolyTraitRef<'tcx>, ErrorReported>
@@ -1138,21 +1138,11 @@ fn find_bound_for_assoc_item<'tcx>(this: &AstConv<'tcx>,
11381138
.filter(|b| this.trait_defines_associated_type_named(b.def_id(), assoc_name))
11391139
.collect();
11401140

1141-
if let Some(s) = ty_param_name {
1142-
// borrowck doesn't like this any other way
1143-
one_bound_for_assoc_type(tcx,
1144-
suitable_bounds,
1145-
&token::get_name(s),
1146-
&token::get_name(assoc_name),
1147-
span)
1148-
} else {
1149-
one_bound_for_assoc_type(tcx,
1150-
suitable_bounds,
1151-
"Self",
1152-
&token::get_name(assoc_name),
1153-
span)
1154-
1155-
}
1141+
one_bound_for_assoc_type(tcx,
1142+
suitable_bounds,
1143+
&token::get_name(ty_param_name),
1144+
&token::get_name(assoc_name),
1145+
span)
11561146
}
11571147

11581148

@@ -1251,7 +1241,11 @@ fn associated_path_def_to_ty<'tcx>(this: &AstConv<'tcx>,
12511241
}
12521242
(&ty::TyParam(_), def::DefSelfTy(Some(trait_did), None)) => {
12531243
assert_eq!(trait_did.krate, ast::LOCAL_CRATE);
1254-
match find_bound_for_assoc_item(this, trait_did.node, None, assoc_name, span) {
1244+
match find_bound_for_assoc_item(this,
1245+
trait_did.node,
1246+
token::special_idents::type_self.name,
1247+
assoc_name,
1248+
span) {
12551249
Ok(bound) => bound,
12561250
Err(ErrorReported) => return (tcx.types.err, ty_path_def),
12571251
}
@@ -1260,7 +1254,7 @@ fn associated_path_def_to_ty<'tcx>(this: &AstConv<'tcx>,
12601254
assert_eq!(param_did.krate, ast::LOCAL_CRATE);
12611255
match find_bound_for_assoc_item(this,
12621256
param_did.node,
1263-
Some(param_name),
1257+
param_name,
12641258
assoc_name,
12651259
span) {
12661260
Ok(bound) => bound,

0 commit comments

Comments
 (0)