diag.span_suggestion(
expr.span,
- &format!("replace with `ptr::slice_from_raw_parts{mutbl_fn_str}`"),
+ format!("replace with `ptr::slice_from_raw_parts{mutbl_fn_str}`"),
sugg,
rustc_errors::Applicability::HasPlaceholders,
);
call_site,
&format!("`format!` in `{name}!` args"),
|diag| {
- diag.help(&format!(
+ diag.help(format!(
"combine the `format!(..)` arguments with the outer `{name}!(..)` call"
));
diag.help("or consider changing `format!` to `format_args!`");
);
diag.span_label(
def.variants[variants_size[1].ind].span,
- &if variants_size[1].fields_size.is_empty() {
+ if variants_size[1].fields_size.is_empty() {
"the second-largest variant carries no data at all".to_owned()
} else {
format!(
db.span_note(span, "`is_empty` defined here");
}
if let Some(self_kind) = self_kind {
- db.note(&output.expected_sig(self_kind));
+ db.note(output.expected_sig(self_kind));
}
});
}
Ok(Some(path)) => path,
Ok(None) => return Conf::default(),
Err(error) => {
- sess.struct_err(&format!("error finding Clippy's configuration file: {error}"))
+ sess.struct_err(format!("error finding Clippy's configuration file: {error}"))
.emit();
return Conf::default();
},
applicability,
);
- diag.note(&format!(
+ diag.note(format!(
"`{name}` is of type `{int_name}`, making it ineligible for `Iterator::enumerate`"
));
},
let help = format!("make the function `async` and {ret_sugg}");
diag.span_suggestion(
header_span,
- &help,
+ help,
format!("async {}{ret_snip}", &header_snip[..ret_pos]),
Applicability::MachineApplicable
);
let test_span = expr.span.until(then.span);
span_lint_and_then(cx, MANUAL_STRIP, strippings[0], &format!("stripping a {kind_word} manually"), |diag| {
- diag.span_note(test_span, &format!("the {kind_word} was tested here"));
+ diag.span_note(test_span, format!("the {kind_word} was tested here"));
multispan_sugg(
diag,
&format!("try using the `strip_{kind_word}` method"),
expr.span,
&format!("calling `to_string` on `{arg_ty}`"),
|diag| {
- diag.help(&format!(
+ diag.help(format!(
"`{self_ty}` implements `ToString` through a slower blanket impl, but `{deref_self_ty}` has a fast specialization of `ToString`"
));
let mut applicability = Applicability::MachineApplicable;
application = Applicability::Unspecified;
diag.span_help(
pat.span,
- &format!("for this change `{}` has to be mutable", snippet(cx, pat.span, "..")),
+ format!("for this change `{}` has to be mutable", snippet(cx, pat.span, "..")),
);
}
}
suggestion.push((map_arg_span.with_hi(map_arg_span.lo()), format!("{unwrap_snippet}, ")));
}
- diag.multipart_suggestion(&format!("use `{suggest}` instead"), suggestion, applicability);
+ diag.multipart_suggestion(format!("use `{suggest}` instead"), suggestion, applicability);
});
}
}
};
diag.span_suggestion_verbose(
local.span,
- &format!("try `{r}split_once`"),
+ format!("try `{r}split_once`"),
format!("let ({lhs}, {rhs}) = {self_snip}.{r}split_once({pat_snip}){unwrap};"),
app,
);
span_lint_and_then(cx, UNNECESSARY_LAZY_EVALUATIONS, expr.span, msg, |diag| {
diag.span_suggestion(
span,
- &format!("use `{simplify_using}(..)` instead"),
+ format!("use `{simplify_using}(..)` instead"),
format!("{simplify_using}({})", snippet(cx, body_expr.span, "..")),
applicability,
);
diag.span_suggestion(
assign.lhs_span,
- &format!("declare `{binding_name}` here"),
+ format!("declare `{binding_name}` here"),
let_snippet,
Applicability::MachineApplicable,
);
diag.span_suggestion_verbose(
usage.stmt.span.shrink_to_lo(),
- &format!("declare `{binding_name}` here"),
+ format!("declare `{binding_name}` here"),
format!("{let_snippet} = "),
applicability,
);
diag.span_suggestion_verbose(
usage.stmt.span.shrink_to_lo(),
- &format!("declare `{binding_name}` here"),
+ format!("declare `{binding_name}` here"),
format!("{let_snippet} = "),
applicability,
);
if is_string { "string" } else { "byte string" }
),
|diag| {
- diag.help(&format!(
+ diag.help(format!(
"octal escapes are not supported, `\\0` is always a null {}",
if is_string { "character" } else { "byte" }
));
// suggestion 2: unambiguous null byte
diag.span_suggestion(
span,
- &format!(
+ format!(
"if the null {} is intended, disambiguate using",
if is_string { "character" } else { "byte" }
),
let long = format!("{snip_a} = {}", sugg::make_binop(op.into(), a, r));
diag.span_suggestion(
expr.span,
- &format!(
+ format!(
"did you mean `{snip_a} = {snip_a} {} {snip_r}` or `{long}`? Consider replacing it with",
op.as_str()
),
|diag| {
diag.span_note(
trait_method_span,
- &format!("existing `{method_name}` defined here"),
+ format!("existing `{method_name}` defined here"),
);
},
);
// iterate on trait_spans?
diag.span_note(
trait_spans[0],
- &format!("existing `{method_name}` defined here"),
+ format!("existing `{method_name}` defined here"),
);
},
);
applicability,
);
if !is_xor_based {
- diag.note(&format!("or maybe you should use `{sugg}::mem::replace`?"));
+ diag.note(format!("or maybe you should use `{sugg}::mem::replace`?"));
}
},
);
Applicability::MaybeIncorrect,
);
diag.note(
- &format!("or maybe you should use `{sugg}::mem::replace`?")
+ format!("or maybe you should use `{sugg}::mem::replace`?")
);
}
});
&format!("transmute from `{from_ty_orig}` which has an undefined layout"),
|diag| {
if from_ty_orig.peel_refs() != from_ty.peel_refs() {
- diag.note(&format!("the contained type `{from_ty}` has an undefined layout"));
+ diag.note(format!("the contained type `{from_ty}` has an undefined layout"));
}
},
);
&format!("transmute to `{to_ty_orig}` which has an undefined layout"),
|diag| {
if to_ty_orig.peel_refs() != to_ty.peel_refs() {
- diag.note(&format!("the contained type `{to_ty}` has an undefined layout"));
+ diag.note(format!("the contained type `{to_ty}` has an undefined layout"));
}
},
);
),
|diag| {
if let Some(same_adt_did) = same_adt_did {
- diag.note(&format!(
+ diag.note(format!(
"two instances of the same generic type (`{}`) may have different layouts",
cx.tcx.item_name(same_adt_did)
));
} else {
if from_ty_orig.peel_refs() != from_ty {
- diag.note(&format!("the contained type `{from_ty}` has an undefined layout"));
+ diag.note(format!("the contained type `{from_ty}` has an undefined layout"));
}
if to_ty_orig.peel_refs() != to_ty {
- diag.note(&format!("the contained type `{to_ty}` has an undefined layout"));
+ diag.note(format!("the contained type `{to_ty}` has an undefined layout"));
}
}
},
&format!("transmute from `{from_ty_orig}` which has an undefined layout"),
|diag| {
if from_ty_orig.peel_refs() != from_ty {
- diag.note(&format!("the contained type `{from_ty}` has an undefined layout"));
+ diag.note(format!("the contained type `{from_ty}` has an undefined layout"));
}
},
);
&format!("transmute into `{to_ty_orig}` which has an undefined layout"),
|diag| {
if to_ty_orig.peel_refs() != to_ty {
- diag.note(&format!("the contained type `{to_ty}` has an undefined layout"));
+ diag.note(format!("the contained type `{to_ty}` has an undefined layout"));
}
},
);
&format!("transmute from `{from_ty}` to `{to_ty}` which could be expressed as a pointer cast instead"),
|diag| {
if let Some(arg) = sugg::Sugg::hir_opt(cx, arg) {
- let sugg = arg.as_ty(&to_ty.to_string()).to_string();
+ let sugg = arg.as_ty(to_ty.to_string()).to_string();
diag.span_suggestion(e.span, "try", sugg, Applicability::MachineApplicable);
}
},
"transmute from an integer to a pointer",
|diag| {
if let Some(arg) = sugg::Sugg::hir_opt(cx, arg) {
- diag.span_suggestion(e.span, "try", arg.as_ty(&to_ty.to_string()), Applicability::Unspecified);
+ diag.span_suggestion(e.span, "try", arg.as_ty(to_ty.to_string()), Applicability::Unspecified);
}
},
);
&format!("usage of `{outer_sym}<{generic_snippet}>`"),
|diag| {
diag.span_suggestion(hir_ty.span, "try", format!("{generic_snippet}"), applicability);
- diag.note(&format!(
+ diag.note(format!(
"`{generic_snippet}` is already a pointer, `{outer_sym}<{generic_snippet}>` allocates a pointer on the heap"
));
},
format!("{outer_sym}<{generic_snippet}>"),
applicability,
);
- diag.note(&format!(
+ diag.note(format!(
"`{inner_sym}<{generic_snippet}>` is already on the heap, `{outer_sym}<{inner_sym}<{generic_snippet}>>` makes an extra allocation"
));
},
hir_ty.span,
&format!("usage of `{outer_sym}<{inner_sym}<{generic_snippet}>>`"),
|diag| {
- diag.note(&format!(
+ diag.note(format!(
"`{inner_sym}<{generic_snippet}>` is already on the heap, `{outer_sym}<{inner_sym}<{generic_snippet}>>` makes an extra allocation"
));
- diag.help(&format!(
+ diag.help(format!(
"consider using just `{outer_sym}<{generic_snippet}>` or `{inner_sym}<{generic_snippet}>`"
));
},
if arg_snippets_without_empty_blocks.is_empty() {
db.multipart_suggestion(
- &format!("use {singular}unit literal{plural} instead"),
+ format!("use {singular}unit literal{plural} instead"),
args_to_recover
.iter()
.map(|arg| (arg.span, "()".to_string()))
let it_or_them = if plural { "them" } else { "it" };
db.span_suggestion(
expr.span,
- &format!(
+ format!(
"{or}move the expression{empty_or_s} in front of the call and replace {it_or_them} with the unit literal `()`"
),
sugg,
// print!("\n"), write!(f, "\n")
diag.multipart_suggestion(
- &format!("use `{name}ln!` instead"),
+ format!("use `{name}ln!` instead"),
vec![(name_span, format!("{name}ln")), (format_string_span, String::new())],
Applicability::MachineApplicable,
);
let newline_span = format_string_span.with_lo(hi - BytePos(3)).with_hi(hi - BytePos(1));
diag.multipart_suggestion(
- &format!("use `{name}ln!` instead"),
+ format!("use `{name}ln!` instead"),
vec![(name_span, format!("{name}ln")), (newline_span, String::new())],
Applicability::MachineApplicable,
);
fn docs_link(diag: &mut Diagnostic, lint: &'static Lint) {
if env::var("CLIPPY_DISABLE_DOCS_LINKS").is_err() {
if let Some(lint) = lint.name_lower().strip_prefix("clippy::") {
- diag.help(&format!(
+ diag.help(format!(
"for further information visit https://rust-lang.github.io/rust-clippy/{}/index.html#{lint}",
&option_env!("RUST_RELEASE_NUM").map_or("master".to_string(), |n| {
// extract just major + minor version and ignore patch versions
// run-rustfix
#![warn(clippy::manual_retain)]
-#![allow(unused)]
+#![allow(unused, clippy::redundant_clone)]
use std::collections::BTreeMap;
use std::collections::BTreeSet;
use std::collections::BinaryHeap;
// run-rustfix
#![warn(clippy::manual_retain)]
-#![allow(unused)]
+#![allow(unused, clippy::redundant_clone)]
use std::collections::BTreeMap;
use std::collections::BTreeSet;
use std::collections::BinaryHeap;