@@ -594,7 +594,7 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> {
594594
595595 match self . angle_brackets {
596596 AngleBrackets :: Missing => {
597- let span = self . path_segment . ident . span ;
597+ let span = self . tcx . mark_span_for_resize ( self . path_segment . ident . span ) ;
598598
599599 // insert a suggestion of the form "Y<'a, 'b>"
600600 let sugg = format ! ( "<{}>" , suggested_args) ;
@@ -618,6 +618,15 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> {
618618 let last_lt = & self . gen_args . args [ self . num_provided_lifetime_args ( ) - 1 ] ;
619619 ( self . tcx . mark_span_for_resize ( last_lt. span ( ) ) . shrink_to_hi ( ) , false )
620620 } ;
621+ let path_sp = self . path_segment . ident . span . peel_ctxt ( ) ;
622+ if !self . gen_args . args . iter ( ) . all ( |arg| {
623+ arg. span ( ) . can_be_used_for_suggestions ( )
624+ && arg. span ( ) . peel_ctxt ( ) . ctxt ( ) == path_sp. ctxt ( )
625+ } ) || !path_sp. can_be_used_for_suggestions ( )
626+ {
627+ // Do not suggest syntax when macros are involved. (#90557)
628+ return ;
629+ }
621630 let has_non_lt_args = self . num_provided_type_or_const_args ( ) != 0 ;
622631 let has_bindings = !self . gen_args . bindings . is_empty ( ) ;
623632
@@ -647,7 +656,7 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> {
647656
648657 match self . angle_brackets {
649658 AngleBrackets :: Missing | AngleBrackets :: Implied => {
650- let span = self . path_segment . ident . span ;
659+ let span = self . tcx . mark_span_for_resize ( self . path_segment . ident . span ) ;
651660
652661 // insert a suggestion of the form "Y<T, U>"
653662 let sugg = format ! ( "<{}>" , suggested_args) ;
@@ -661,6 +670,15 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> {
661670 ) ;
662671 }
663672 AngleBrackets :: Available => {
673+ let path_sp = self . path_segment . ident . span . peel_ctxt ( ) ;
674+ if !self . gen_args . args . iter ( ) . all ( |arg| {
675+ arg. span ( ) . can_be_used_for_suggestions ( )
676+ && arg. span ( ) . peel_ctxt ( ) . ctxt ( ) == path_sp. ctxt ( )
677+ } ) || !path_sp. can_be_used_for_suggestions ( )
678+ {
679+ // Do not suggest syntax when macros are involved. (#90557)
680+ return ;
681+ }
664682 let gen_args_span = self . tcx . mark_span_for_resize ( self . gen_args . span ( ) . unwrap ( ) ) ;
665683 let sugg_offset =
666684 self . get_lifetime_args_offset ( ) + self . num_provided_type_or_const_args ( ) ;
0 commit comments