Move format_push_string and format_collect to pedantic (#13894)
Closes #11434 by moving `format_push_string` and `format_collect` to pedantic. changelog: Move `format_push_string` and `format_collect` to pedantic
This commit is contained in:
commit
e02c8857e8
4 changed files with 21 additions and 16 deletions
|
|
@ -7,6 +7,7 @@ use rustc_middle::lint::in_external_macro;
|
|||
use rustc_middle::ty::Ty;
|
||||
use rustc_session::declare_lint_pass;
|
||||
use rustc_span::Symbol;
|
||||
use std::fmt::Write;
|
||||
|
||||
declare_clippy_lint! {
|
||||
/// ### What it does
|
||||
|
|
@ -184,7 +185,7 @@ fn maybe_lint_endian_bytes(cx: &LateContext<'_>, expr: &Expr<'_>, prefix: Prefix
|
|||
help_str.push_str("either of ");
|
||||
}
|
||||
|
||||
help_str.push_str(&format!("`{ty}::{}` ", lint.as_name(prefix)));
|
||||
write!(help_str, "`{ty}::{}` ", lint.as_name(prefix)).unwrap();
|
||||
|
||||
if i != len && !only_one {
|
||||
help_str.push_str("or ");
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ declare_clippy_lint! {
|
|||
/// Detects cases where the result of a `format!` call is
|
||||
/// appended to an existing `String`.
|
||||
///
|
||||
/// ### Why restrict this?
|
||||
/// ### Why is this bad?
|
||||
/// Introduces an extra, avoidable heap allocation.
|
||||
///
|
||||
/// ### Known problems
|
||||
|
|
@ -35,7 +35,7 @@ declare_clippy_lint! {
|
|||
/// ```
|
||||
#[clippy::version = "1.62.0"]
|
||||
pub FORMAT_PUSH_STRING,
|
||||
restriction,
|
||||
pedantic,
|
||||
"`format!(..)` appended to existing `String`"
|
||||
}
|
||||
declare_lint_pass!(FormatPushString => [FORMAT_PUSH_STRING]);
|
||||
|
|
|
|||
|
|
@ -3518,7 +3518,7 @@ declare_clippy_lint! {
|
|||
/// ```
|
||||
#[clippy::version = "1.73.0"]
|
||||
pub FORMAT_COLLECT,
|
||||
perf,
|
||||
pedantic,
|
||||
"`format!`ing every element in a collection, then collecting the strings into a new `String`"
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue