@@ -991,6 +991,17 @@ fn trait_ref_to_object_type<'tcx>(this: &AstConv<'tcx>,
991
991
result
992
992
}
993
993
994
+ fn report_ambiguous_associated_type ( tcx : & ty:: ctxt ,
995
+ span : Span ,
996
+ type_str : & str ,
997
+ trait_str : & str ,
998
+ name : & str ) {
999
+ span_err ! ( tcx. sess, span, E0223 ,
1000
+ "ambiguous associated type; specify the type using the syntax \
1001
+ `<{} as {}>::{}`",
1002
+ type_str, trait_str, name) ;
1003
+ }
1004
+
994
1005
fn associated_path_def_to_ty < ' tcx > ( this : & AstConv < ' tcx > ,
995
1006
span : Span ,
996
1007
ty : Ty < ' tcx > ,
@@ -1011,10 +1022,8 @@ fn associated_path_def_to_ty<'tcx>(this: &AstConv<'tcx>,
1011
1022
let ty_param_node_id = if is_param {
1012
1023
ty_path_def. local_node_id ( )
1013
1024
} else {
1014
- span_err ! ( tcx. sess, span, E0223 ,
1015
- "ambiguous associated type; specify the type using the syntax \
1016
- `<{} as Trait>::{}`",
1017
- ty. user_string( tcx) , token:: get_name( assoc_name) ) ;
1025
+ report_ambiguous_associated_type (
1026
+ tcx, span, & ty. user_string ( tcx) , "Trait" , & token:: get_name ( assoc_name) ) ;
1018
1027
return ( tcx. types . err , ty_path_def) ;
1019
1028
} ;
1020
1029
@@ -1109,10 +1118,8 @@ fn qpath_to_ty<'tcx>(this: &AstConv<'tcx>,
1109
1118
ty
1110
1119
} else {
1111
1120
let path_str = ty:: item_path_str ( tcx, trait_def_id) ;
1112
- span_err ! ( tcx. sess, span, E0223 ,
1113
- "ambiguous associated type; specify the type using the syntax \
1114
- `<Type as {}>::{}`",
1115
- path_str, & token:: get_ident( item_segment. identifier) ) ;
1121
+ report_ambiguous_associated_type (
1122
+ tcx, span, "Type" , & path_str, & token:: get_ident ( item_segment. identifier ) ) ;
1116
1123
return tcx. types . err ;
1117
1124
} ;
1118
1125
0 commit comments