@@ -11,7 +11,7 @@ use rustc_errors::{pluralize, Applicability, DiagnosticBuilder};
11
11
use rustc_expand:: base:: { self , * } ;
12
12
use rustc_parse_format as parse;
13
13
use rustc_span:: symbol:: { sym, Ident , Symbol } ;
14
- use rustc_span:: { MultiSpan , Span } ;
14
+ use rustc_span:: { InnerSpan , MultiSpan , Span } ;
15
15
use smallvec:: SmallVec ;
16
16
17
17
use std:: borrow:: Cow ;
@@ -26,7 +26,7 @@ enum ArgumentType {
26
26
enum Position {
27
27
Exact ( usize ) ,
28
28
Capture ( usize ) ,
29
- Named ( Symbol ) ,
29
+ Named ( Symbol , InnerSpan ) ,
30
30
}
31
31
32
32
struct Context < ' a , ' b > {
@@ -247,13 +247,13 @@ impl<'a, 'b> Context<'a, 'b> {
247
247
match * p {
248
248
parse:: String ( _) => { }
249
249
parse:: NextArgument ( ref mut arg) => {
250
- if let parse:: ArgumentNamed ( s) = arg. position {
250
+ if let parse:: ArgumentNamed ( s, _ ) = arg. position {
251
251
arg. position = parse:: ArgumentIs ( lookup ( s) ) ;
252
252
}
253
- if let parse:: CountIsName ( s) = arg. format . width {
253
+ if let parse:: CountIsName ( s, _ ) = arg. format . width {
254
254
arg. format . width = parse:: CountIsParam ( lookup ( s) ) ;
255
255
}
256
- if let parse:: CountIsName ( s) = arg. format . precision {
256
+ if let parse:: CountIsName ( s, _ ) = arg. format . precision {
257
257
arg. format . precision = parse:: CountIsParam ( lookup ( s) ) ;
258
258
}
259
259
}
@@ -276,7 +276,7 @@ impl<'a, 'b> Context<'a, 'b> {
276
276
// it's written second, so it should come after width/precision.
277
277
let pos = match arg. position {
278
278
parse:: ArgumentIs ( i) | parse:: ArgumentImplicitlyIs ( i) => Exact ( i) ,
279
- parse:: ArgumentNamed ( s) => Named ( s) ,
279
+ parse:: ArgumentNamed ( s, span ) => Named ( s, span ) ,
280
280
} ;
281
281
282
282
let ty = Placeholder ( match arg. format . ty {
@@ -346,8 +346,8 @@ impl<'a, 'b> Context<'a, 'b> {
346
346
parse:: CountIsParam ( i) => {
347
347
self . verify_arg_type ( Exact ( i) , Count ) ;
348
348
}
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 ) ;
351
351
}
352
352
}
353
353
}
@@ -533,7 +533,7 @@ impl<'a, 'b> Context<'a, 'b> {
533
533
}
534
534
}
535
535
536
- Named ( name) => {
536
+ Named ( name, span ) => {
537
537
match self . names . get ( & name) {
538
538
Some ( & idx) => {
539
539
// Treat as positional arg.
@@ -548,7 +548,7 @@ impl<'a, 'b> Context<'a, 'b> {
548
548
self . arg_types . push ( Vec :: new ( ) ) ;
549
549
self . arg_unique_types . push ( Vec :: new ( ) ) ;
550
550
let span = if self . is_literal {
551
- * self . arg_spans . get ( self . curpiece ) . unwrap_or ( & self . fmtsp )
551
+ self . fmtsp . from_inner ( span )
552
552
} else {
553
553
self . fmtsp
554
554
} ;
@@ -559,7 +559,7 @@ impl<'a, 'b> Context<'a, 'b> {
559
559
} else {
560
560
let msg = format ! ( "there is no argument named `{}`" , name) ;
561
561
let sp = if self . is_literal {
562
- * self . arg_spans . get ( self . curpiece ) . unwrap_or ( & self . fmtsp )
562
+ self . fmtsp . from_inner ( span )
563
563
} else {
564
564
self . fmtsp
565
565
} ;
@@ -629,7 +629,7 @@ impl<'a, 'b> Context<'a, 'b> {
629
629
}
630
630
parse:: CountImplied => count ( sym:: Implied , None ) ,
631
631
// should never be the case, names are already resolved
632
- parse:: CountIsName ( _ ) => panic ! ( "should never happen" ) ,
632
+ parse:: CountIsName ( .. ) => panic ! ( "should never happen" ) ,
633
633
}
634
634
}
635
635
@@ -676,7 +676,7 @@ impl<'a, 'b> Context<'a, 'b> {
676
676
677
677
// should never be the case, because names are already
678
678
// resolved.
679
- parse:: ArgumentNamed ( _ ) => panic ! ( "should never happen" ) ,
679
+ parse:: ArgumentNamed ( .. ) => panic ! ( "should never happen" ) ,
680
680
}
681
681
} ;
682
682
0 commit comments