@@ -21,6 +21,7 @@ mod ok_expect;
21
21
mod option_as_ref_deref;
22
22
mod option_map_unwrap_or;
23
23
mod single_char_insert_string;
24
+ mod single_char_push_string;
24
25
mod skip_while_next;
25
26
mod string_extend_chars;
26
27
mod suspicious_map;
@@ -1778,7 +1779,7 @@ impl<'tcx> LateLintPass<'tcx> for Methods {
1778
1779
1779
1780
if let Some ( fn_def_id) = cx. typeck_results ( ) . type_dependent_def_id ( expr. hir_id ) {
1780
1781
if match_def_path ( cx, fn_def_id, & paths:: PUSH_STR ) {
1781
- lint_single_char_push_string ( cx, expr, args) ;
1782
+ single_char_push_string :: check ( cx, expr, args) ;
1782
1783
} else if match_def_path ( cx, fn_def_id, & paths:: INSERT_STR ) {
1783
1784
single_char_insert_string:: check ( cx, expr, args) ;
1784
1785
}
@@ -3217,25 +3218,6 @@ fn lint_single_char_pattern(cx: &LateContext<'_>, _expr: &hir::Expr<'_>, arg: &h
3217
3218
}
3218
3219
}
3219
3220
3220
- /// lint for length-1 `str`s as argument for `push_str`
3221
- fn lint_single_char_push_string ( cx : & LateContext < ' _ > , expr : & hir:: Expr < ' _ > , args : & [ hir:: Expr < ' _ > ] ) {
3222
- let mut applicability = Applicability :: MachineApplicable ;
3223
- if let Some ( extension_string) = get_hint_if_single_char_arg ( cx, & args[ 1 ] , & mut applicability) {
3224
- let base_string_snippet =
3225
- snippet_with_applicability ( cx, args[ 0 ] . span . source_callsite ( ) , ".." , & mut applicability) ;
3226
- let sugg = format ! ( "{}.push({})" , base_string_snippet, extension_string) ;
3227
- span_lint_and_sugg (
3228
- cx,
3229
- SINGLE_CHAR_ADD_STR ,
3230
- expr. span ,
3231
- "calling `push_str()` using a single-character string literal" ,
3232
- "consider using `push` with a character literal" ,
3233
- sugg,
3234
- applicability,
3235
- ) ;
3236
- }
3237
- }
3238
-
3239
3221
/// Checks for the `USELESS_ASREF` lint.
3240
3222
fn lint_asref ( cx : & LateContext < ' _ > , expr : & hir:: Expr < ' _ > , call_name : & str , as_ref_args : & [ hir:: Expr < ' _ > ] ) {
3241
3223
// when we get here, we've already checked that the call name is "as_ref" or "as_mut"
0 commit comments