@@ -27,9 +27,10 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
2727 help : Option < & str > ,
2828 ) {
2929 let sess = tcx. sess ;
30+ let arg_span = tcx. hir ( ) . span ( arg. id ( ) ) ;
3031 let mut err = struct_span_err ! (
3132 sess,
32- arg . span ( ) ,
33+ arg_span ,
3334 E0747 ,
3435 "{} provided when a {} was expected" ,
3536 arg. descr( ) ,
@@ -49,8 +50,8 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
4950 GenericParamDefKind :: Const { .. } ,
5051 ) => {
5152 let suggestions = vec ! [
52- ( arg . span ( ) . shrink_to_lo( ) , String :: from( "{ " ) ) ,
53- ( arg . span ( ) . shrink_to_hi( ) , String :: from( " }" ) ) ,
53+ ( arg_span . shrink_to_lo( ) , String :: from( "{ " ) ) ,
54+ ( arg_span . shrink_to_hi( ) , String :: from( " }" ) ) ,
5455 ] ;
5556 err. multipart_suggestion (
5657 "if this generic argument was intended as a const parameter, \
@@ -66,7 +67,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
6667 let snippet = sess. source_map ( ) . span_to_snippet ( tcx. hir ( ) . span ( len. hir_id ) ) ;
6768 if let Ok ( snippet) = snippet {
6869 err. span_suggestion (
69- arg . span ( ) ,
70+ arg_span ,
7071 "array type provided where a `usize` was expected, try" ,
7172 format ! ( "{{ {} }}" , snippet) ,
7273 Applicability :: MaybeIncorrect ,
@@ -450,7 +451,12 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
450451 let ( spans, labels) : ( Vec < Span > , Vec < String > ) = args. args
451452 [ offset + permitted..offset + provided]
452453 . iter ( )
453- . map ( |arg| ( arg. span ( ) , format ! ( "unexpected {} argument" , arg. short_descr( ) ) ) )
454+ . map ( |arg| {
455+ (
456+ tcx. hir ( ) . span ( arg. id ( ) ) ,
457+ format ! ( "unexpected {} argument" , arg. short_descr( ) ) ,
458+ )
459+ } )
454460 . unzip ( ) ;
455461 unexpected_spans. extend ( spans. clone ( ) ) ;
456462 ( spans, labels)
@@ -553,7 +559,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
553559 . args
554560 . iter ( )
555561 . filter_map ( |arg| match arg {
556- GenericArg :: Type ( _) | GenericArg :: Const ( _) => Some ( arg . span ( ) ) ,
562+ GenericArg :: Type ( _) | GenericArg :: Const ( _) => Some ( tcx . hir ( ) . span ( arg . id ( ) ) ) ,
557563 _ => None ,
558564 } )
559565 . collect :: < Vec < _ > > ( ) ;
@@ -599,7 +605,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
599605 let msg = "cannot specify lifetime arguments explicitly \
600606 if late bound lifetime parameters are present";
601607 let note = "the late bound lifetime parameter is introduced here" ;
602- let span = args. args [ 0 ] . span ( ) ;
608+ let span = tcx . hir ( ) . span ( args. args [ 0 ] . id ( ) ) ;
603609 if position == GenericArgPosition :: Value
604610 && arg_counts. lifetimes != param_counts. lifetimes
605611 {
0 commit comments