@@ -16,7 +16,7 @@ use smallvec::SmallVec;
16
16
17
17
use rustc_lint_defs:: builtin:: NAMED_ARGUMENTS_USED_POSITIONALLY ;
18
18
use rustc_lint_defs:: { BufferedEarlyLint , BuiltinLintDiagnostics , LintId } ;
19
- use rustc_parse_format:: { Count , FormatSpec } ;
19
+ use rustc_parse_format:: Count ;
20
20
use std:: borrow:: Cow ;
21
21
use std:: collections:: hash_map:: Entry ;
22
22
@@ -985,20 +985,19 @@ fn lint_named_arguments_used_positionally(
985
985
}
986
986
_ => { }
987
987
} ;
988
- match a. format {
989
- FormatSpec { width : Count :: CountIsName ( s, _) , .. }
990
- | FormatSpec { precision : Count :: CountIsName ( s, _) , .. } => {
991
- used_argument_names. insert ( s) ;
992
- }
993
- _ => { }
994
- } ;
988
+ if let Count :: CountIsName ( s, _) = a. format . width {
989
+ used_argument_names. insert ( s) ;
990
+ }
991
+ if let Count :: CountIsName ( s, _) = a. format . precision {
992
+ used_argument_names. insert ( s) ;
993
+ }
995
994
}
996
995
}
997
996
998
997
for ( symbol, ( index, span) ) in names {
999
998
if !used_argument_names. contains ( symbol. as_str ( ) ) {
1000
999
let msg = format ! ( "named argument `{}` is not used by name" , symbol. as_str( ) ) ;
1001
- let arg_span = cx. arg_spans [ index] ;
1000
+ let arg_span = cx. arg_spans . get ( index) . copied ( ) . unwrap_or ( span ) ;
1002
1001
cx. ecx . buffered_early_lint . push ( BufferedEarlyLint {
1003
1002
span : MultiSpan :: from_span ( span) ,
1004
1003
msg : msg. clone ( ) ,
0 commit comments