mirror of
https://github.com/rust-lang/rust.git
synced 2025-01-31 17:12:53 +00:00
Auto merge of #9161 - Victor-N-Suadicani:move_format_push_string_to_pedantic, r=flip1995
Move format_push_string to restriction Fixes #9077 (kinda) by moving the lint to the restriction group. As I noted in that issue, I think the suggested change is too much and as the OP of the issue points out, the ramifications of the change are not necessarily easily understood. As such I don't think the lint should be enabled by default. changelog: [`format_push_string`]: moved to restriction (see #9077).
This commit is contained in:
commit
10e85efc53
@ -14,6 +14,12 @@ declare_clippy_lint! {
|
||||
/// ### Why is this bad?
|
||||
/// Introduces an extra, avoidable heap allocation.
|
||||
///
|
||||
/// ### Known problems
|
||||
/// `format!` returns a `String` but `write!` returns a `Result`.
|
||||
/// Thus you are forced to ignore the `Err` variant to achieve the same API.
|
||||
///
|
||||
/// While using `write!` in the suggested way should never fail, this isn't necessarily clear to the programmer.
|
||||
///
|
||||
/// ### Example
|
||||
/// ```rust
|
||||
/// let mut s = String::new();
|
||||
@ -29,7 +35,7 @@ declare_clippy_lint! {
|
||||
/// ```
|
||||
#[clippy::version = "1.62.0"]
|
||||
pub FORMAT_PUSH_STRING,
|
||||
perf,
|
||||
restriction,
|
||||
"`format!(..)` appended to existing `String`"
|
||||
}
|
||||
declare_lint_pass!(FormatPushString => [FORMAT_PUSH_STRING]);
|
||||
|
@ -71,7 +71,6 @@ store.register_group(true, "clippy::all", Some("clippy_all"), vec![
|
||||
LintId::of(format_args::TO_STRING_IN_FORMAT_ARGS),
|
||||
LintId::of(format_impl::PRINT_IN_FORMAT_IMPL),
|
||||
LintId::of(format_impl::RECURSIVE_FORMAT_IMPL),
|
||||
LintId::of(format_push_string::FORMAT_PUSH_STRING),
|
||||
LintId::of(formatting::POSSIBLE_MISSING_COMMA),
|
||||
LintId::of(formatting::SUSPICIOUS_ASSIGNMENT_FORMATTING),
|
||||
LintId::of(formatting::SUSPICIOUS_ELSE_FORMATTING),
|
||||
|
@ -7,7 +7,6 @@ store.register_group(true, "clippy::perf", Some("clippy_perf"), vec![
|
||||
LintId::of(escape::BOXED_LOCAL),
|
||||
LintId::of(format_args::FORMAT_IN_FORMAT_ARGS),
|
||||
LintId::of(format_args::TO_STRING_IN_FORMAT_ARGS),
|
||||
LintId::of(format_push_string::FORMAT_PUSH_STRING),
|
||||
LintId::of(large_const_arrays::LARGE_CONST_ARRAYS),
|
||||
LintId::of(large_enum_variant::LARGE_ENUM_VARIANT),
|
||||
LintId::of(loops::MANUAL_MEMCPY),
|
||||
|
@ -21,6 +21,7 @@ store.register_group(true, "clippy::restriction", Some("clippy_restriction"), ve
|
||||
LintId::of(exhaustive_items::EXHAUSTIVE_STRUCTS),
|
||||
LintId::of(exit::EXIT),
|
||||
LintId::of(float_literal::LOSSY_FLOAT_LITERAL),
|
||||
LintId::of(format_push_string::FORMAT_PUSH_STRING),
|
||||
LintId::of(if_then_some_else_none::IF_THEN_SOME_ELSE_NONE),
|
||||
LintId::of(implicit_return::IMPLICIT_RETURN),
|
||||
LintId::of(indexing_slicing::INDEXING_SLICING),
|
||||
|
Loading…
Reference in New Issue
Block a user