@@ -594,7 +594,7 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> {
594
594
595
595
match self . angle_brackets {
596
596
AngleBrackets :: Missing => {
597
- let span = self . path_segment . ident . span ;
597
+ let span = self . tcx . mark_span_for_resize ( self . path_segment . ident . span ) ;
598
598
599
599
// insert a suggestion of the form "Y<'a, 'b>"
600
600
let sugg = format ! ( "<{}>" , suggested_args) ;
@@ -618,6 +618,15 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> {
618
618
let last_lt = & self . gen_args . args [ self . num_provided_lifetime_args ( ) - 1 ] ;
619
619
( self . tcx . mark_span_for_resize ( last_lt. span ( ) ) . shrink_to_hi ( ) , false )
620
620
} ;
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
+ }
621
630
let has_non_lt_args = self . num_provided_type_or_const_args ( ) != 0 ;
622
631
let has_bindings = !self . gen_args . bindings . is_empty ( ) ;
623
632
@@ -647,7 +656,7 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> {
647
656
648
657
match self . angle_brackets {
649
658
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 ) ;
651
660
652
661
// insert a suggestion of the form "Y<T, U>"
653
662
let sugg = format ! ( "<{}>" , suggested_args) ;
@@ -661,6 +670,15 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> {
661
670
) ;
662
671
}
663
672
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
+ }
664
682
let gen_args_span = self . tcx . mark_span_for_resize ( self . gen_args . span ( ) . unwrap ( ) ) ;
665
683
let sugg_offset =
666
684
self . get_lifetime_args_offset ( ) + self . num_provided_type_or_const_args ( ) ;
0 commit comments