@@ -6,9 +6,9 @@ use crate::errors::{
6
6
use rustc_data_structures:: fx:: FxHashMap ;
7
7
use rustc_errors:: { pluralize, struct_span_err, Applicability , Diagnostic , ErrorGuaranteed } ;
8
8
use rustc_hir as hir;
9
- use rustc_hir:: def_id:: { DefId , LocalDefId } ;
9
+ use rustc_hir:: def_id:: DefId ;
10
10
use rustc_infer:: traits:: FulfillmentError ;
11
- use rustc_middle:: ty:: { self , suggest_constraining_type_param, Ty , TyCtxt } ;
11
+ use rustc_middle:: ty:: { self , suggest_constraining_type_param, Ty , TyCtxt , TyParam } ;
12
12
use rustc_session:: parse:: feature_err;
13
13
use rustc_span:: edit_distance:: find_best_match_for_name;
14
14
use rustc_span:: symbol:: { sym, Ident } ;
@@ -100,8 +100,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
100
100
pub ( crate ) fn complain_about_assoc_type_not_found < I > (
101
101
& self ,
102
102
all_candidates : impl Fn ( ) -> I ,
103
- ty_param_name : & str ,
104
- ty_param_def_id : Option < LocalDefId > ,
103
+ ty_param : TyParam < ' _ > ,
105
104
assoc_name : Ident ,
106
105
span : Span ,
107
106
) -> ErrorGuaranteed
@@ -118,7 +117,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
118
117
E0220 ,
119
118
"associated type `{}` not found for `{}`" ,
120
119
assoc_name,
121
- ty_param_name
120
+ ty_param . 0 ,
122
121
) ;
123
122
124
123
if is_dummy {
@@ -200,7 +199,8 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
200
199
) ,
201
200
) ;
202
201
let hir = self . tcx ( ) . hir ( ) ;
203
- if let Some ( def_id) = ty_param_def_id
202
+ if let Some ( def_id) = ty_param. 1
203
+ && let Some ( def_id) = def_id. as_local ( )
204
204
&& let parent = hir. get_parent_item ( hir. local_def_id_to_hir_id ( def_id) )
205
205
&& let Some ( generics) = hir. get_generics ( parent. def_id )
206
206
{
@@ -228,10 +228,9 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
228
228
self . tcx ( ) ,
229
229
generics,
230
230
& mut err,
231
- & ty_param_name ,
231
+ ty_param ,
232
232
& trait_name,
233
233
None ,
234
- None ,
235
234
)
236
235
&& suggested_name != assoc_name. name
237
236
{
@@ -263,7 +262,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
263
262
264
263
err. span_suggestion (
265
264
assoc_name. span ,
266
- format ! ( "`{ty_param_name }` has the following associated type" ) ,
265
+ format ! ( "`{}` has the following associated type" , ty_param . 0 ) ,
267
266
all_candidate_names. first ( ) . unwrap ( ) . to_string ( ) ,
268
267
applicability,
269
268
) ;
0 commit comments