@@ -65,7 +65,7 @@ impl<'tcx> WrongNumberOfGenericArgs<'_, 'tcx> {
6565 let def_kind = self . tcx . def_kind ( self . def_id ) . descr ( self . def_id ) ;
6666 let ( quantifier, bound) = self . quantifier_and_bound ( ) ;
6767
68- if self . gen_args . span ( ) . is_some ( ) {
68+ if self . gen_args . span ( |id| self . tcx . hir ( ) . span ( id ) ) . is_some ( ) {
6969 format ! (
7070 "this {} takes {}{} {} argument{} but {}{} {} argument{} {} supplied" ,
7171 def_kind,
@@ -122,7 +122,7 @@ impl<'tcx> WrongNumberOfGenericArgs<'_, 'tcx> {
122122
123123 for ( i, arg) in args {
124124 err. span_label (
125- arg . span ( ) ,
125+ self . tcx . hir ( ) . span ( arg . id ( ) ) ,
126126 if i + 1 == self . provided {
127127 format ! (
128128 "supplied {} {} argument{}" ,
@@ -139,7 +139,7 @@ impl<'tcx> WrongNumberOfGenericArgs<'_, 'tcx> {
139139
140140 fn suggest ( & self , err : & mut DiagnosticBuilder < ' _ > ) {
141141 if self . provided == 0 {
142- if self . gen_args . span ( ) . is_some ( ) {
142+ if self . gen_args . span ( |id| self . tcx . hir ( ) . span ( id ) ) . is_some ( ) {
143143 self . suggest_adding_args ( err) ;
144144 } else {
145145 self . suggest_creating_generics ( err) ;
@@ -206,11 +206,14 @@ impl<'tcx> WrongNumberOfGenericArgs<'_, 'tcx> {
206206 let missing_arg_count = self . expected_min - self . provided ;
207207
208208 let ( span, sugg_prefix) = if self . args_offset + self . provided == 0 {
209- let span = self . gen_args . args [ 0 ] . span ( ) . shrink_to_lo ( ) ;
209+ let span = self . tcx . hir ( ) . span ( self . gen_args . args [ 0 ] . id ( ) ) . shrink_to_lo ( ) ;
210210 ( span, "" )
211211 } else {
212- let span =
213- self . gen_args . args [ self . args_offset + self . provided - 1 ] . span ( ) . shrink_to_hi ( ) ;
212+ let span = self
213+ . tcx
214+ . hir ( )
215+ . span ( self . gen_args . args [ self . args_offset + self . provided - 1 ] . id ( ) )
216+ . shrink_to_hi ( ) ;
214217 ( span, ", " )
215218 } ;
216219
@@ -249,7 +252,7 @@ impl<'tcx> WrongNumberOfGenericArgs<'_, 'tcx> {
249252 . path_segment
250253 . args
251254 . unwrap ( )
252- . span_ext ( sm)
255+ . span_ext ( sm, |id| self . tcx . hir ( ) . span ( id ) )
253256 . unwrap ( )
254257 . with_lo ( self . path_segment . ident . span . hi ( ) ) ;
255258
@@ -293,19 +296,23 @@ impl<'tcx> WrongNumberOfGenericArgs<'_, 'tcx> {
293296 let last_argument_ends_generics = to_idx + 1 == self . gen_args . args . len ( ) ;
294297
295298 if !first_argument_starts_generics && last_argument_ends_generics {
296- ( self . gen_args . args [ from_idx - 1 ] . span ( ) . hi ( ) , true )
299+ ( self . tcx . hir ( ) . span ( self . gen_args . args [ from_idx - 1 ] . id ( ) ) . hi ( ) , true )
297300 } else {
298- ( self . gen_args . args [ from_idx] . span ( ) . lo ( ) , false )
301+ ( self . tcx . hir ( ) . span ( self . gen_args . args [ from_idx] . id ( ) ) . lo ( ) , false )
299302 }
300303 } ;
301304
302305 let to = {
303- let hi = self . gen_args . args [ to_idx] . span ( ) . hi ( ) ;
306+ let hi = self . tcx . hir ( ) . span ( self . gen_args . args [ to_idx] . id ( ) ) . hi ( ) ;
304307
305308 if comma_eaten {
306309 hi
307310 } else {
308- self . gen_args . args . get ( to_idx + 1 ) . map ( |arg| arg. span ( ) . lo ( ) ) . unwrap_or ( hi)
311+ self . gen_args
312+ . args
313+ . get ( to_idx + 1 )
314+ . map ( |arg| self . tcx . hir ( ) . span ( arg. id ( ) ) . lo ( ) )
315+ . unwrap_or ( hi)
309316 }
310317 } ;
311318
0 commit comments