This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +12
-11
lines changed Expand file tree Collapse file tree 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(
997997 for ( symbol, ( index, span) ) in names {
998998 if !used_argument_names. contains ( symbol. as_str ( ) ) {
999999 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 ( ) ;
10011001 cx. ecx . buffered_early_lint . push ( BufferedEarlyLint {
10021002 span : MultiSpan :: from_span ( span) ,
10031003 msg : msg. clone ( ) ,
Original file line number Diff line number Diff line change @@ -858,15 +858,16 @@ pub trait LintContext: Sized {
858858 } ,
859859 BuiltinLintDiagnostics :: NamedArgumentUsedPositionally ( positional_arg, named_arg, name) => {
860860 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+ }
870871 }
871872 }
872873 // 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 {
467467 /// If true, the lifetime will be fully elided.
468468 use_span : Option < ( Span , bool ) > ,
469469 } ,
470- NamedArgumentUsedPositionally ( Span , Span , String ) ,
470+ NamedArgumentUsedPositionally ( Option < Span > , Span , String ) ,
471471}
472472
473473/// Lints that are buffered up early on in the `Session` before the
You can’t perform that action at this time.
0 commit comments