Skip to content

Commit 10e85ef

Browse files
committed
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).
2 parents 1b23c0e + 43ac256 commit 10e85ef

File tree

4 files changed

+8
-3
lines changed

4 files changed

+8
-3
lines changed

clippy_lints/src/format_push_string.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ declare_clippy_lint! {
1414
/// ### Why is this bad?
1515
/// Introduces an extra, avoidable heap allocation.
1616
///
17+
/// ### Known problems
18+
/// `format!` returns a `String` but `write!` returns a `Result`.
19+
/// Thus you are forced to ignore the `Err` variant to achieve the same API.
20+
///
21+
/// While using `write!` in the suggested way should never fail, this isn't necessarily clear to the programmer.
22+
///
1723
/// ### Example
1824
/// ```rust
1925
/// let mut s = String::new();
@@ -29,7 +35,7 @@ declare_clippy_lint! {
2935
/// ```
3036
#[clippy::version = "1.62.0"]
3137
pub FORMAT_PUSH_STRING,
32-
perf,
38+
restriction,
3339
"`format!(..)` appended to existing `String`"
3440
}
3541
declare_lint_pass!(FormatPushString => [FORMAT_PUSH_STRING]);

clippy_lints/src/lib.register_all.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ store.register_group(true, "clippy::all", Some("clippy_all"), vec![
7171
LintId::of(format_args::TO_STRING_IN_FORMAT_ARGS),
7272
LintId::of(format_impl::PRINT_IN_FORMAT_IMPL),
7373
LintId::of(format_impl::RECURSIVE_FORMAT_IMPL),
74-
LintId::of(format_push_string::FORMAT_PUSH_STRING),
7574
LintId::of(formatting::POSSIBLE_MISSING_COMMA),
7675
LintId::of(formatting::SUSPICIOUS_ASSIGNMENT_FORMATTING),
7776
LintId::of(formatting::SUSPICIOUS_ELSE_FORMATTING),

clippy_lints/src/lib.register_perf.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ store.register_group(true, "clippy::perf", Some("clippy_perf"), vec![
77
LintId::of(escape::BOXED_LOCAL),
88
LintId::of(format_args::FORMAT_IN_FORMAT_ARGS),
99
LintId::of(format_args::TO_STRING_IN_FORMAT_ARGS),
10-
LintId::of(format_push_string::FORMAT_PUSH_STRING),
1110
LintId::of(large_const_arrays::LARGE_CONST_ARRAYS),
1211
LintId::of(large_enum_variant::LARGE_ENUM_VARIANT),
1312
LintId::of(loops::MANUAL_MEMCPY),

clippy_lints/src/lib.register_restriction.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ store.register_group(true, "clippy::restriction", Some("clippy_restriction"), ve
2121
LintId::of(exhaustive_items::EXHAUSTIVE_STRUCTS),
2222
LintId::of(exit::EXIT),
2323
LintId::of(float_literal::LOSSY_FLOAT_LITERAL),
24+
LintId::of(format_push_string::FORMAT_PUSH_STRING),
2425
LintId::of(if_then_some_else_none::IF_THEN_SOME_ELSE_NONE),
2526
LintId::of(implicit_return::IMPLICIT_RETURN),
2627
LintId::of(indexing_slicing::INDEXING_SLICING),

0 commit comments

Comments
 (0)