Skip to content

Commit b33002d

Browse files
committed
Auto merge of #9366 - Alexendoo:manual_string_new, r=xFrednet
Rename `manual_empty_string_creation` and move to pedantic Renames it to `manual_string_new` and moves it to the pedantic category Pedantic because it's a fairly minor style change but could be very noisy changelog: *doesn't need its own entry, but remember to s/manual_empty_string_creation/manual_string_new/ the changelog entry for #9295* r? `@xFrednet` to get it in before the upcoming sync as this isn't a `cargo dev rename_lint` style rename
2 parents 5735a3b + 2cb5318 commit b33002d

12 files changed

+24
-26
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3831,7 +3831,6 @@ Released 2018-09-13
38313831
[`manual_assert`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_assert
38323832
[`manual_async_fn`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_async_fn
38333833
[`manual_bits`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_bits
3834-
[`manual_empty_string_creations`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_empty_string_creations
38353834
[`manual_filter_map`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_filter_map
38363835
[`manual_find`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_find
38373836
[`manual_find_map`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_find_map
@@ -3847,6 +3846,7 @@ Released 2018-09-13
38473846
[`manual_saturating_arithmetic`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_saturating_arithmetic
38483847
[`manual_split_once`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_split_once
38493848
[`manual_str_repeat`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_str_repeat
3849+
[`manual_string_new`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_string_new
38503850
[`manual_strip`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_strip
38513851
[`manual_swap`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_swap
38523852
[`manual_unwrap_or`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_unwrap_or

clippy_lints/src/lib.register_all.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,6 @@ store.register_group(true, "clippy::all", Some("clippy_all"), vec![
122122
LintId::of(main_recursion::MAIN_RECURSION),
123123
LintId::of(manual_async_fn::MANUAL_ASYNC_FN),
124124
LintId::of(manual_bits::MANUAL_BITS),
125-
LintId::of(manual_empty_string_creations::MANUAL_EMPTY_STRING_CREATIONS),
126125
LintId::of(manual_non_exhaustive::MANUAL_NON_EXHAUSTIVE),
127126
LintId::of(manual_rem_euclid::MANUAL_REM_EUCLID),
128127
LintId::of(manual_retain::MANUAL_RETAIN),

clippy_lints/src/lib.register_lints.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,11 +240,11 @@ store.register_lints(&[
240240
manual_assert::MANUAL_ASSERT,
241241
manual_async_fn::MANUAL_ASYNC_FN,
242242
manual_bits::MANUAL_BITS,
243-
manual_empty_string_creations::MANUAL_EMPTY_STRING_CREATIONS,
244243
manual_instant_elapsed::MANUAL_INSTANT_ELAPSED,
245244
manual_non_exhaustive::MANUAL_NON_EXHAUSTIVE,
246245
manual_rem_euclid::MANUAL_REM_EUCLID,
247246
manual_retain::MANUAL_RETAIN,
247+
manual_string_new::MANUAL_STRING_NEW,
248248
manual_strip::MANUAL_STRIP,
249249
map_unit_fn::OPTION_MAP_UNIT_FN,
250250
map_unit_fn::RESULT_MAP_UNIT_FN,

clippy_lints/src/lib.register_pedantic.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ store.register_group(true, "clippy::pedantic", Some("clippy_pedantic"), vec![
4848
LintId::of(macro_use::MACRO_USE_IMPORTS),
4949
LintId::of(manual_assert::MANUAL_ASSERT),
5050
LintId::of(manual_instant_elapsed::MANUAL_INSTANT_ELAPSED),
51+
LintId::of(manual_string_new::MANUAL_STRING_NEW),
5152
LintId::of(matches::MATCH_BOOL),
5253
LintId::of(matches::MATCH_ON_VEC_ITEMS),
5354
LintId::of(matches::MATCH_SAME_ARMS),

clippy_lints/src/lib.register_style.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ store.register_group(true, "clippy::style", Some("clippy_style"), vec![
4343
LintId::of(main_recursion::MAIN_RECURSION),
4444
LintId::of(manual_async_fn::MANUAL_ASYNC_FN),
4545
LintId::of(manual_bits::MANUAL_BITS),
46-
LintId::of(manual_empty_string_creations::MANUAL_EMPTY_STRING_CREATIONS),
4746
LintId::of(manual_non_exhaustive::MANUAL_NON_EXHAUSTIVE),
4847
LintId::of(match_result_ok::MATCH_RESULT_OK),
4948
LintId::of(matches::COLLAPSIBLE_MATCH),

clippy_lints/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,11 +267,11 @@ mod main_recursion;
267267
mod manual_assert;
268268
mod manual_async_fn;
269269
mod manual_bits;
270-
mod manual_empty_string_creations;
271270
mod manual_instant_elapsed;
272271
mod manual_non_exhaustive;
273272
mod manual_rem_euclid;
274273
mod manual_retain;
274+
mod manual_string_new;
275275
mod manual_strip;
276276
mod map_unit_fn;
277277
mod match_result_ok;
@@ -894,7 +894,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
894894
store.register_late_pass(|| Box::new(std_instead_of_core::StdReexports::default()));
895895
store.register_late_pass(|| Box::new(manual_instant_elapsed::ManualInstantElapsed));
896896
store.register_late_pass(|| Box::new(partialeq_to_none::PartialeqToNone));
897-
store.register_late_pass(|| Box::new(manual_empty_string_creations::ManualEmptyStringCreations));
897+
store.register_late_pass(|| Box::new(manual_string_new::ManualStringNew));
898898
store.register_late_pass(|| Box::new(unused_peekable::UnusedPeekable));
899899
// add lints here, do not remove this comment, it's used in `new_lint`
900900
}

clippy_lints/src/manual_empty_string_creations.rs renamed to clippy_lints/src/manual_string_new.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,13 @@ declare_clippy_lint! {
2929
/// let b = String::new();
3030
/// ```
3131
#[clippy::version = "1.65.0"]
32-
pub MANUAL_EMPTY_STRING_CREATIONS,
33-
style,
32+
pub MANUAL_STRING_NEW,
33+
pedantic,
3434
"empty String is being created manually"
3535
}
36-
declare_lint_pass!(ManualEmptyStringCreations => [MANUAL_EMPTY_STRING_CREATIONS]);
36+
declare_lint_pass!(ManualStringNew => [MANUAL_STRING_NEW]);
3737

38-
impl LateLintPass<'_> for ManualEmptyStringCreations {
38+
impl LateLintPass<'_> for ManualStringNew {
3939
fn check_expr(&mut self, cx: &LateContext<'_>, expr: &Expr<'_>) {
4040
if expr.span.from_expansion() {
4141
return;
@@ -75,11 +75,10 @@ fn is_expr_kind_empty_str(expr_kind: &ExprKind<'_>) -> bool {
7575
false
7676
}
7777

78-
/// Emits the `MANUAL_EMPTY_STRING_CREATION` warning and suggests the appropriate fix.
7978
fn warn_then_suggest(cx: &LateContext<'_>, span: Span) {
8079
span_lint_and_sugg(
8180
cx,
82-
MANUAL_EMPTY_STRING_CREATIONS,
81+
MANUAL_STRING_NEW,
8382
span,
8483
"empty String is being created manually",
8584
"consider using",

tests/ui/manual_empty_string_creations.fixed renamed to tests/ui/manual_string_new.fixed

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// run-rustfix
22

3-
#![warn(clippy::manual_empty_string_creations)]
3+
#![warn(clippy::manual_string_new)]
44

55
macro_rules! create_strings_from_macro {
66
// When inside a macro, nothing should warn to prevent false positives.

tests/ui/manual_empty_string_creations.rs renamed to tests/ui/manual_string_new.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// run-rustfix
22

3-
#![warn(clippy::manual_empty_string_creations)]
3+
#![warn(clippy::manual_string_new)]
44

55
macro_rules! create_strings_from_macro {
66
// When inside a macro, nothing should warn to prevent false positives.

tests/ui/manual_empty_string_creations.stderr renamed to tests/ui/manual_string_new.stderr

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,55 @@
11
error: empty String is being created manually
2-
--> $DIR/manual_empty_string_creations.rs:15:13
2+
--> $DIR/manual_string_new.rs:15:13
33
|
44
LL | let _ = "".to_string();
55
| ^^^^^^^^^^^^^^ help: consider using: `String::new()`
66
|
7-
= note: `-D clippy::manual-empty-string-creations` implied by `-D warnings`
7+
= note: `-D clippy::manual-string-new` implied by `-D warnings`
88

99
error: empty String is being created manually
10-
--> $DIR/manual_empty_string_creations.rs:18:13
10+
--> $DIR/manual_string_new.rs:18:13
1111
|
1212
LL | let _ = "".to_owned();
1313
| ^^^^^^^^^^^^^ help: consider using: `String::new()`
1414

1515
error: empty String is being created manually
16-
--> $DIR/manual_empty_string_creations.rs:21:21
16+
--> $DIR/manual_string_new.rs:21:21
1717
|
1818
LL | let _: String = "".into();
1919
| ^^^^^^^^^ help: consider using: `String::new()`
2020

2121
error: empty String is being created manually
22-
--> $DIR/manual_empty_string_creations.rs:28:13
22+
--> $DIR/manual_string_new.rs:28:13
2323
|
2424
LL | let _ = String::from("");
2525
| ^^^^^^^^^^^^^^^^ help: consider using: `String::new()`
2626

2727
error: empty String is being created manually
28-
--> $DIR/manual_empty_string_creations.rs:29:13
28+
--> $DIR/manual_string_new.rs:29:13
2929
|
3030
LL | let _ = <String>::from("");
3131
| ^^^^^^^^^^^^^^^^^^ help: consider using: `String::new()`
3232

3333
error: empty String is being created manually
34-
--> $DIR/manual_empty_string_creations.rs:34:13
34+
--> $DIR/manual_string_new.rs:34:13
3535
|
3636
LL | let _ = String::try_from("").unwrap();
3737
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `String::new()`
3838

3939
error: empty String is being created manually
40-
--> $DIR/manual_empty_string_creations.rs:40:21
40+
--> $DIR/manual_string_new.rs:40:21
4141
|
4242
LL | let _: String = From::from("");
4343
| ^^^^^^^^^^^^^^ help: consider using: `String::new()`
4444

4545
error: empty String is being created manually
46-
--> $DIR/manual_empty_string_creations.rs:45:21
46+
--> $DIR/manual_string_new.rs:45:21
4747
|
4848
LL | let _: String = TryFrom::try_from("").unwrap();
4949
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `String::new()`
5050

5151
error: empty String is being created manually
52-
--> $DIR/manual_empty_string_creations.rs:48:21
52+
--> $DIR/manual_string_new.rs:48:21
5353
|
5454
LL | let _: String = TryFrom::try_from("").expect("this should warn");
5555
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using: `String::new()`

tests/ui/unnecessary_owned_empty_strings.fixed

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ fn main() {
1212
ref_str_argument("");
1313

1414
// should be linted
15-
#[allow(clippy::manual_empty_string_creations)]
15+
#[allow(clippy::manual_string_new)]
1616
ref_str_argument("");
1717

1818
// should not be linted

tests/ui/unnecessary_owned_empty_strings.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ fn main() {
1212
ref_str_argument(&String::new());
1313

1414
// should be linted
15-
#[allow(clippy::manual_empty_string_creations)]
15+
#[allow(clippy::manual_string_new)]
1616
ref_str_argument(&String::from(""));
1717

1818
// should not be linted

0 commit comments

Comments
 (0)