File tree 3 files changed +12
-11
lines changed
3 files changed +12
-11
lines changed Original file line number Diff line number Diff line change @@ -997,7 +997,7 @@ fn lint_named_arguments_used_positionally(
997
997
for ( symbol, ( index, span) ) in names {
998
998
if !used_argument_names. contains ( symbol. as_str ( ) ) {
999
999
let msg = format ! ( "named argument `{}` is not used by name" , symbol. as_str( ) ) ;
1000
- let arg_span = cx. arg_spans . get ( index) . copied ( ) . unwrap_or ( span ) ;
1000
+ let arg_span = cx. arg_spans . get ( index) . copied ( ) ;
1001
1001
cx. ecx . buffered_early_lint . push ( BufferedEarlyLint {
1002
1002
span : MultiSpan :: from_span ( span) ,
1003
1003
msg : msg. clone ( ) ,
Original file line number Diff line number Diff line change @@ -858,15 +858,16 @@ pub trait LintContext: Sized {
858
858
} ,
859
859
BuiltinLintDiagnostics :: NamedArgumentUsedPositionally ( positional_arg, named_arg, name) => {
860
860
db. span_label ( named_arg, "this named argument is only referred to by position in formatting string" ) ;
861
- let msg = format ! ( "this formatting argument uses named argument `{}` by position" , name) ;
862
- db. span_label ( positional_arg, msg) ;
863
- db. span_suggestion_verbose (
864
- positional_arg,
865
- "use the named argument by name to avoid ambiguity" ,
866
- format ! ( "{{{}}}" , name) ,
867
- Applicability :: MaybeIncorrect ,
868
- ) ;
869
-
861
+ if let Some ( positional_arg) = positional_arg {
862
+ let msg = format ! ( "this formatting argument uses named argument `{}` by position" , name) ;
863
+ db. span_label ( positional_arg, msg) ;
864
+ db. span_suggestion_verbose (
865
+ positional_arg,
866
+ "use the named argument by name to avoid ambiguity" ,
867
+ format ! ( "{{{}}}" , name) ,
868
+ Applicability :: MaybeIncorrect ,
869
+ ) ;
870
+ }
870
871
}
871
872
}
872
873
// Rewrap `db`, and pass control to the user.
Original file line number Diff line number Diff line change @@ -467,7 +467,7 @@ pub enum BuiltinLintDiagnostics {
467
467
/// If true, the lifetime will be fully elided.
468
468
use_span : Option < ( Span , bool ) > ,
469
469
} ,
470
- NamedArgumentUsedPositionally ( Span , Span , String ) ,
470
+ NamedArgumentUsedPositionally ( Option < Span > , Span , String ) ,
471
471
}
472
472
473
473
/// Lints that are buffered up early on in the `Session` before the
You can’t perform that action at this time.
0 commit comments