summaryrefslogtreecommitdiffstats
path: root/compiler/rustc_builtin_macros/src/format.rs
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/rustc_builtin_macros/src/format.rs')
-rw-r--r--compiler/rustc_builtin_macros/src/format.rs42
1 files changed, 20 insertions, 22 deletions
diff --git a/compiler/rustc_builtin_macros/src/format.rs b/compiler/rustc_builtin_macros/src/format.rs
index 214fed8e2..c5fd535b0 100644
--- a/compiler/rustc_builtin_macros/src/format.rs
+++ b/compiler/rustc_builtin_macros/src/format.rs
@@ -547,7 +547,7 @@ fn make_format_args(
span: arg_name.span.into(),
msg: format!("named argument `{}` is not used by name", arg_name.name).into(),
node_id: rustc_ast::CRATE_NODE_ID,
- lint_id: LintId::of(&NAMED_ARGUMENTS_USED_POSITIONALLY),
+ lint_id: LintId::of(NAMED_ARGUMENTS_USED_POSITIONALLY),
diagnostic: BuiltinLintDiagnostics::NamedArgumentUsedPositionally {
position_sp_to_replace,
position_sp_for_msg,
@@ -617,16 +617,22 @@ fn report_missing_placeholders(
let placeholders = pieces
.iter()
.filter_map(|piece| {
- if let parse::Piece::NextArgument(argument) = piece && let ArgumentNamed(binding) = argument.position {
- let span = fmt_span.from_inner(InnerSpan::new(argument.position_span.start, argument.position_span.end));
+ if let parse::Piece::NextArgument(argument) = piece
+ && let ArgumentNamed(binding) = argument.position
+ {
+ let span = fmt_span.from_inner(InnerSpan::new(
+ argument.position_span.start,
+ argument.position_span.end,
+ ));
Some((span, binding))
- } else { None }
+ } else {
+ None
+ }
})
.collect::<Vec<_>>();
if !placeholders.is_empty() {
- if let Some(mut new_diag) =
- report_redundant_format_arguments(ecx, &args, used, placeholders)
+ if let Some(mut new_diag) = report_redundant_format_arguments(ecx, args, used, placeholders)
{
diag.cancel();
new_diag.emit();
@@ -666,30 +672,22 @@ fn report_missing_placeholders(
if explained.contains(&sub) {
continue;
}
- explained.insert(sub.clone());
+ explained.insert(sub);
if !found_foreign {
found_foreign = true;
show_doc_note = true;
}
- if let Some(inner_sp) = pos {
- let sp = fmt_span.from_inner(inner_sp);
+ let sp = fmt_span.from_inner(pos);
- if success {
- suggestions.push((sp, trn));
- } else {
- diag.span_note(
- sp,
- format!("format specifiers use curly braces, and {}", trn),
- );
- }
+ if success {
+ suggestions.push((sp, trn));
} else {
- if success {
- diag.help(format!("`{}` should be written as `{}`", sub, trn));
- } else {
- diag.note(format!("`{}` should use curly braces, and {}", sub, trn));
- }
+ diag.span_note(
+ sp,
+ format!("format specifiers use curly braces, and {}", trn),
+ );
}
}