@@ -77,13 +77,15 @@ impl InferenceDiagnosticsData {
7777 !( self . name == "_" && matches ! ( self . kind, UnderspecifiedArgKind :: Type { .. } ) )
7878 }
7979
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 == "_" {
8286 // FIXME: Consider specializing this message if there is a single `_`
8387 // in the type.
8488 "underscore"
85- } else if in_type. is_ty_infer ( ) {
86- "empty"
8789 } else {
8890 "has_name"
8991 }
@@ -190,6 +192,7 @@ fn ty_to_string<'tcx>(infcx: &InferCtxt<'tcx>, ty: Ty<'tcx>) -> String {
190192 // We don't want the regular output for `fn`s because it includes its path in
191193 // invalid pseudo-syntax, we want the `fn`-pointer output instead.
192194 ty:: FnDef ( ..) => ty. fn_sig ( infcx. tcx ) . print ( printer) . unwrap ( ) . into_buffer ( ) ,
195+ _ if ty. is_ty_infer ( ) => "Type" . to_string ( ) ,
193196 // FIXME: The same thing for closures, but this only works when the closure
194197 // does not capture anything.
195198 //
@@ -411,7 +414,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
411414 infer_subdiags. push ( SourceKindSubdiag :: LetLike {
412415 span : insert_span,
413416 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 ) ,
415418 prefix_kind : arg_data. kind . clone ( ) ,
416419 prefix : arg_data. kind . try_get_prefix ( ) . unwrap_or_default ( ) ,
417420 arg_name : arg_data. name ,
@@ -427,7 +430,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
427430 infer_subdiags. push ( SourceKindSubdiag :: LetLike {
428431 span : insert_span,
429432 name : String :: new ( ) ,
430- x_kind : arg_data. where_x_is_kind ( ty) ,
433+ x_kind : arg_data. where_x_is_kind ( ty, false ) ,
431434 prefix_kind : arg_data. kind . clone ( ) ,
432435 prefix : arg_data. kind . try_get_prefix ( ) . unwrap_or_default ( ) ,
433436 arg_name : arg_data. name ,
0 commit comments