mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-10 15:14:29 +00:00
Address suggestions in PR review
This commit is contained in:
parent
d958269fe5
commit
f8ac1f99ef
6 changed files with 20 additions and 3 deletions
|
@ -22,7 +22,7 @@ Current beta, release 2020-11-19
|
|||
* [`map_err_ignore`] [#5998](https://github.com/rust-lang/rust-clippy/pull/5998)
|
||||
* [`rc_buffer`] [#6044](https://github.com/rust-lang/rust-clippy/pull/6044)
|
||||
* [`to_string_in_display`] [#5831](https://github.com/rust-lang/rust-clippy/pull/5831)
|
||||
* [`single_char_push_str`] [#5881](https://github.com/rust-lang/rust-clippy/pull/5881)
|
||||
* `single_char_push_str` [#5881](https://github.com/rust-lang/rust-clippy/pull/5881)
|
||||
|
||||
### Moves and Deprecations
|
||||
|
||||
|
|
|
@ -1958,6 +1958,7 @@ pub fn register_renamed(ls: &mut rustc_lint::LintStore) {
|
|||
ls.register_renamed("clippy::for_loop_over_result", "clippy::for_loops_over_fallibles");
|
||||
ls.register_renamed("clippy::identity_conversion", "clippy::useless_conversion");
|
||||
ls.register_renamed("clippy::zero_width_space", "clippy::invisible_characters");
|
||||
ls.register_renamed("clippy::single_char_push_str", "clippy::single_char_add_str");
|
||||
}
|
||||
|
||||
// only exists to let the dogfood integration test works.
|
||||
|
|
|
@ -3266,7 +3266,7 @@ fn lint_single_char_insert_string(cx: &LateContext<'_>, expr: &hir::Expr<'_>, ar
|
|||
if let Some(extension_string) = get_hint_if_single_char_arg(cx, &args[2], &mut applicability) {
|
||||
let base_string_snippet =
|
||||
snippet_with_applicability(cx, args[0].span.source_callsite(), "_", &mut applicability);
|
||||
let pos_arg = snippet(cx, args[1].span, "..");
|
||||
let pos_arg = snippet_with_applicability(cx, args[1].span, "..", &mut applicability);
|
||||
let sugg = format!("{}.insert({}, {})", base_string_snippet, pos_arg, extension_string);
|
||||
span_lint_and_sugg(
|
||||
cx,
|
||||
|
|
|
@ -38,6 +38,8 @@ fn main() {
|
|||
string.insert(x, 'a');
|
||||
const Y: usize = 1;
|
||||
string.insert(Y, 'a');
|
||||
string.insert(Y, '"');
|
||||
string.insert(Y, '\'');
|
||||
|
||||
get_string!().insert(1, '?');
|
||||
}
|
||||
|
|
|
@ -38,6 +38,8 @@ fn main() {
|
|||
string.insert_str(x, r##"a"##);
|
||||
const Y: usize = 1;
|
||||
string.insert_str(Y, r##"a"##);
|
||||
string.insert_str(Y, r##"""##);
|
||||
string.insert_str(Y, r##"'"##);
|
||||
|
||||
get_string!().insert_str(1, "?");
|
||||
}
|
||||
|
|
|
@ -72,11 +72,23 @@ error: calling `insert_str()` using a single-character string literal
|
|||
LL | string.insert_str(Y, r##"a"##);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `insert` with a character literal: `string.insert(Y, 'a')`
|
||||
|
||||
error: calling `insert_str()` using a single-character string literal
|
||||
--> $DIR/single_char_add_str.rs:41:5
|
||||
|
|
||||
LL | string.insert_str(Y, r##"""##);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `insert` with a character literal: `string.insert(Y, '"')`
|
||||
|
||||
error: calling `insert_str()` using a single-character string literal
|
||||
--> $DIR/single_char_add_str.rs:42:5
|
||||
|
|
||||
LL | string.insert_str(Y, r##"'"##);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `insert` with a character literal: `string.insert(Y, '/'')`
|
||||
|
||||
error: calling `insert_str()` using a single-character string literal
|
||||
--> $DIR/single_char_add_str.rs:44:5
|
||||
|
|
||||
LL | get_string!().insert_str(1, "?");
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `insert` with a character literal: `get_string!().insert(1, '?')`
|
||||
|
||||
error: aborting due to 13 previous errors
|
||||
error: aborting due to 15 previous errors
|
||||
|
||||
|
|
Loading…
Reference in a new issue