@@ -449,7 +449,8 @@ fn infer_placeholder_type<'tcx>(
449
449
} )
450
450
. unwrap_or_else ( || {
451
451
let mut visitor = HirPlaceholderCollector :: default ( ) ;
452
- if let Some ( ty) = tcx. hir_node_by_def_id ( def_id) . ty ( ) {
452
+ let node = tcx. hir_node_by_def_id ( def_id) ;
453
+ if let Some ( ty) = node. ty ( ) {
453
454
visitor. visit_ty ( ty) ;
454
455
}
455
456
// If we have just one span, let's try to steal a const `_` feature error.
@@ -465,7 +466,15 @@ fn infer_placeholder_type<'tcx>(
465
466
}
466
467
let mut diag = bad_placeholder ( cx, visitor. spans , kind) ;
467
468
468
- if !ty. references_error ( ) {
469
+ // HACK(#69396): Stashing and stealing diagnostics does not interact
470
+ // well with macros which may delay more than one diagnostic on the
471
+ // same span. If this happens, we will fall through to this arm, so
472
+ // we need to suppress the suggestion since it's invalid. Ideally we
473
+ // would suppress the duplicated error too, but that's really hard.
474
+ if span. is_empty ( ) && span. from_expansion ( ) {
475
+ // An approximately better primary message + no suggestion...
476
+ diag. primary_message ( "missing type for item" ) ;
477
+ } else if !ty. references_error ( ) {
469
478
if let Some ( ty) = ty. make_suggestable ( tcx, false , None ) {
470
479
diag. span_suggestion_verbose (
471
480
span,
0 commit comments