@@ -11,7 +11,7 @@ use rustc_errors::{pluralize, Applicability, DiagnosticBuilder};
1111use rustc_expand:: base:: { self , * } ;
1212use rustc_parse_format as parse;
1313use rustc_span:: symbol:: { sym, Ident , Symbol } ;
14- use rustc_span:: { MultiSpan , Span } ;
14+ use rustc_span:: { InnerSpan , MultiSpan , Span } ;
1515use smallvec:: SmallVec ;
1616
1717use std:: borrow:: Cow ;
@@ -26,7 +26,7 @@ enum ArgumentType {
2626enum Position {
2727 Exact ( usize ) ,
2828 Capture ( usize ) ,
29- Named ( Symbol ) ,
29+ Named ( Symbol , InnerSpan ) ,
3030}
3131
3232struct Context < ' a , ' b > {
@@ -247,13 +247,13 @@ impl<'a, 'b> Context<'a, 'b> {
247247 match * p {
248248 parse:: String ( _) => { }
249249 parse:: NextArgument ( ref mut arg) => {
250- if let parse:: ArgumentNamed ( s) = arg. position {
250+ if let parse:: ArgumentNamed ( s, _ ) = arg. position {
251251 arg. position = parse:: ArgumentIs ( lookup ( s) ) ;
252252 }
253- if let parse:: CountIsName ( s) = arg. format . width {
253+ if let parse:: CountIsName ( s, _ ) = arg. format . width {
254254 arg. format . width = parse:: CountIsParam ( lookup ( s) ) ;
255255 }
256- if let parse:: CountIsName ( s) = arg. format . precision {
256+ if let parse:: CountIsName ( s, _ ) = arg. format . precision {
257257 arg. format . precision = parse:: CountIsParam ( lookup ( s) ) ;
258258 }
259259 }
@@ -276,7 +276,7 @@ impl<'a, 'b> Context<'a, 'b> {
276276 // it's written second, so it should come after width/precision.
277277 let pos = match arg. position {
278278 parse:: ArgumentIs ( i) | parse:: ArgumentImplicitlyIs ( i) => Exact ( i) ,
279- parse:: ArgumentNamed ( s) => Named ( s) ,
279+ parse:: ArgumentNamed ( s, span ) => Named ( s, span ) ,
280280 } ;
281281
282282 let ty = Placeholder ( match arg. format . ty {
@@ -346,8 +346,8 @@ impl<'a, 'b> Context<'a, 'b> {
346346 parse:: CountIsParam ( i) => {
347347 self . verify_arg_type ( Exact ( i) , Count ) ;
348348 }
349- parse:: CountIsName ( s) => {
350- self . verify_arg_type ( Named ( s) , Count ) ;
349+ parse:: CountIsName ( s, span ) => {
350+ self . verify_arg_type ( Named ( s, span ) , Count ) ;
351351 }
352352 }
353353 }
@@ -533,7 +533,7 @@ impl<'a, 'b> Context<'a, 'b> {
533533 }
534534 }
535535
536- Named ( name) => {
536+ Named ( name, span ) => {
537537 match self . names . get ( & name) {
538538 Some ( & idx) => {
539539 // Treat as positional arg.
@@ -548,7 +548,7 @@ impl<'a, 'b> Context<'a, 'b> {
548548 self . arg_types . push ( Vec :: new ( ) ) ;
549549 self . arg_unique_types . push ( Vec :: new ( ) ) ;
550550 let span = if self . is_literal {
551- * self . arg_spans . get ( self . curpiece ) . unwrap_or ( & self . fmtsp )
551+ self . fmtsp . from_inner ( span )
552552 } else {
553553 self . fmtsp
554554 } ;
@@ -559,7 +559,7 @@ impl<'a, 'b> Context<'a, 'b> {
559559 } else {
560560 let msg = format ! ( "there is no argument named `{}`" , name) ;
561561 let sp = if self . is_literal {
562- * self . arg_spans . get ( self . curpiece ) . unwrap_or ( & self . fmtsp )
562+ self . fmtsp . from_inner ( span )
563563 } else {
564564 self . fmtsp
565565 } ;
@@ -629,7 +629,7 @@ impl<'a, 'b> Context<'a, 'b> {
629629 }
630630 parse:: CountImplied => count ( sym:: Implied , None ) ,
631631 // should never be the case, names are already resolved
632- parse:: CountIsName ( _ ) => panic ! ( "should never happen" ) ,
632+ parse:: CountIsName ( .. ) => panic ! ( "should never happen" ) ,
633633 }
634634 }
635635
@@ -676,7 +676,7 @@ impl<'a, 'b> Context<'a, 'b> {
676676
677677 // should never be the case, because names are already
678678 // resolved.
679- parse:: ArgumentNamed ( _ ) => panic ! ( "should never happen" ) ,
679+ parse:: ArgumentNamed ( .. ) => panic ! ( "should never happen" ) ,
680680 }
681681 } ;
682682
0 commit comments