diff options
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/rustc_builtin_macros/src/errors.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_builtin_macros/src/format.rs | 8 |
2 files changed, 8 insertions, 2 deletions
diff --git a/compiler/rustc_builtin_macros/src/errors.rs b/compiler/rustc_builtin_macros/src/errors.rs index 7a8ec5cfdf3..fde4270334b 100644 --- a/compiler/rustc_builtin_macros/src/errors.rs +++ b/compiler/rustc_builtin_macros/src/errors.rs @@ -657,7 +657,7 @@ pub(crate) struct FormatRedundantArgs { pub(crate) note: MultiSpan, #[subdiagnostic] - pub(crate) sugg: FormatRedundantArgsSugg, + pub(crate) sugg: Option<FormatRedundantArgsSugg>, } #[derive(Subdiagnostic)] diff --git a/compiler/rustc_builtin_macros/src/format.rs b/compiler/rustc_builtin_macros/src/format.rs index e08fded01fb..7c78be17653 100644 --- a/compiler/rustc_builtin_macros/src/format.rs +++ b/compiler/rustc_builtin_macros/src/format.rs @@ -767,11 +767,17 @@ fn report_redundant_format_arguments<'a>( suggestion_spans.push(span); } + let sugg = if args.named_args().len() == 0 { + Some(errors::FormatRedundantArgsSugg { spans: suggestion_spans }) + } else { + None + }; + return Some(ecx.create_err(errors::FormatRedundantArgs { n: args_spans.len(), span: MultiSpan::from(args_spans), note: multispan, - sugg: errors::FormatRedundantArgsSugg { spans: suggestion_spans }, + sugg, })); } |
