@@ -77,13 +77,15 @@ impl InferenceDiagnosticsData {
77
77
!( self . name == "_" && matches ! ( self . kind, UnderspecifiedArgKind :: Type { .. } ) )
78
78
}
79
79
80
- fn where_x_is_kind ( & self , in_type : Ty < ' _ > ) -> & ' static str {
81
- if self . name == "_" {
80
+ fn where_x_is_kind ( & self , in_type : Ty < ' _ > , is_collect : bool ) -> & ' static str {
81
+ if is_collect {
82
+ "empty"
83
+ } else if in_type. is_ty_infer ( ) {
84
+ "anon"
85
+ } else if self . name == "_" {
82
86
// FIXME: Consider specializing this message if there is a single `_`
83
87
// in the type.
84
88
"underscore"
85
- } else if in_type. is_ty_infer ( ) {
86
- "empty"
87
89
} else {
88
90
"has_name"
89
91
}
@@ -190,6 +192,7 @@ fn ty_to_string<'tcx>(infcx: &InferCtxt<'tcx>, ty: Ty<'tcx>) -> String {
190
192
// We don't want the regular output for `fn`s because it includes its path in
191
193
// invalid pseudo-syntax, we want the `fn`-pointer output instead.
192
194
ty:: FnDef ( ..) => ty. fn_sig ( infcx. tcx ) . print ( printer) . unwrap ( ) . into_buffer ( ) ,
195
+ _ if ty. is_ty_infer ( ) => "Type" . to_string ( ) ,
193
196
// FIXME: The same thing for closures, but this only works when the closure
194
197
// does not capture anything.
195
198
//
@@ -411,7 +414,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
411
414
infer_subdiags. push ( SourceKindSubdiag :: LetLike {
412
415
span : insert_span,
413
416
name : pattern_name. map ( |name| name. to_string ( ) ) . unwrap_or_else ( String :: new) ,
414
- x_kind : if is_collect { "empty" } else { arg_data. where_x_is_kind ( ty) } ,
417
+ x_kind : arg_data. where_x_is_kind ( ty, is_collect ) ,
415
418
prefix_kind : arg_data. kind . clone ( ) ,
416
419
prefix : arg_data. kind . try_get_prefix ( ) . unwrap_or_default ( ) ,
417
420
arg_name : arg_data. name ,
@@ -427,7 +430,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
427
430
infer_subdiags. push ( SourceKindSubdiag :: LetLike {
428
431
span : insert_span,
429
432
name : String :: new ( ) ,
430
- x_kind : arg_data. where_x_is_kind ( ty) ,
433
+ x_kind : arg_data. where_x_is_kind ( ty, false ) ,
431
434
prefix_kind : arg_data. kind . clone ( ) ,
432
435
prefix : arg_data. kind . try_get_prefix ( ) . unwrap_or_default ( ) ,
433
436
arg_name : arg_data. name ,
0 commit comments