Skip to content

Commit f8ac1f9

Browse files
committed
Address suggestions in PR review
1 parent d958269 commit f8ac1f9

File tree

6 files changed

+20
-3
lines changed

6 files changed

+20
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Current beta, release 2020-11-19
2222
* [`map_err_ignore`] [#5998](https://github.com/rust-lang/rust-clippy/pull/5998)
2323
* [`rc_buffer`] [#6044](https://github.com/rust-lang/rust-clippy/pull/6044)
2424
* [`to_string_in_display`] [#5831](https://github.com/rust-lang/rust-clippy/pull/5831)
25-
* [`single_char_push_str`] [#5881](https://github.com/rust-lang/rust-clippy/pull/5881)
25+
* `single_char_push_str` [#5881](https://github.com/rust-lang/rust-clippy/pull/5881)
2626

2727
### Moves and Deprecations
2828

clippy_lints/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1958,6 +1958,7 @@ pub fn register_renamed(ls: &mut rustc_lint::LintStore) {
19581958
ls.register_renamed("clippy::for_loop_over_result", "clippy::for_loops_over_fallibles");
19591959
ls.register_renamed("clippy::identity_conversion", "clippy::useless_conversion");
19601960
ls.register_renamed("clippy::zero_width_space", "clippy::invisible_characters");
1961+
ls.register_renamed("clippy::single_char_push_str", "clippy::single_char_add_str");
19611962
}
19621963

19631964
// only exists to let the dogfood integration test works.

clippy_lints/src/methods/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3266,7 +3266,7 @@ fn lint_single_char_insert_string(cx: &LateContext<'_>, expr: &hir::Expr<'_>, ar
32663266
if let Some(extension_string) = get_hint_if_single_char_arg(cx, &args[2], &mut applicability) {
32673267
let base_string_snippet =
32683268
snippet_with_applicability(cx, args[0].span.source_callsite(), "_", &mut applicability);
3269-
let pos_arg = snippet(cx, args[1].span, "..");
3269+
let pos_arg = snippet_with_applicability(cx, args[1].span, "..", &mut applicability);
32703270
let sugg = format!("{}.insert({}, {})", base_string_snippet, pos_arg, extension_string);
32713271
span_lint_and_sugg(
32723272
cx,

tests/ui/single_char_add_str.fixed

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ fn main() {
3838
string.insert(x, 'a');
3939
const Y: usize = 1;
4040
string.insert(Y, 'a');
41+
string.insert(Y, '"');
42+
string.insert(Y, '\'');
4143

4244
get_string!().insert(1, '?');
4345
}

tests/ui/single_char_add_str.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ fn main() {
3838
string.insert_str(x, r##"a"##);
3939
const Y: usize = 1;
4040
string.insert_str(Y, r##"a"##);
41+
string.insert_str(Y, r##"""##);
42+
string.insert_str(Y, r##"'"##);
4143

4244
get_string!().insert_str(1, "?");
4345
}

tests/ui/single_char_add_str.stderr

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,23 @@ error: calling `insert_str()` using a single-character string literal
7272
LL | string.insert_str(Y, r##"a"##);
7373
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `insert` with a character literal: `string.insert(Y, 'a')`
7474

75+
error: calling `insert_str()` using a single-character string literal
76+
--> $DIR/single_char_add_str.rs:41:5
77+
|
78+
LL | string.insert_str(Y, r##"""##);
79+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `insert` with a character literal: `string.insert(Y, '"')`
80+
7581
error: calling `insert_str()` using a single-character string literal
7682
--> $DIR/single_char_add_str.rs:42:5
7783
|
84+
LL | string.insert_str(Y, r##"'"##);
85+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `insert` with a character literal: `string.insert(Y, '/'')`
86+
87+
error: calling `insert_str()` using a single-character string literal
88+
--> $DIR/single_char_add_str.rs:44:5
89+
|
7890
LL | get_string!().insert_str(1, "?");
7991
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `insert` with a character literal: `get_string!().insert(1, '?')`
8092

81-
error: aborting due to 13 previous errors
93+
error: aborting due to 15 previous errors
8294

0 commit comments

Comments
 (0)