File tree Expand file tree Collapse file tree 4 files changed +26
-2
lines changed Expand file tree Collapse file tree 4 files changed +26
-2
lines changed Original file line number Diff line number Diff line change @@ -66,7 +66,13 @@ pub(super) fn get_hint_if_single_char_arg(
66
66
// for regular string: "a"
67
67
& snip[ 1 ..( snip. len( ) - 1 ) ]
68
68
} ;
69
- let hint = format!( "'{}'" , if ch == "'" { "\\ '" } else { ch } ) ;
69
+
70
+ let hint = format!( "'{}'" , match ch {
71
+ "'" => "\\ '" ,
72
+ r"\" => "\\ \\ " ,
73
+ _ => ch,
74
+ } ) ;
75
+
70
76
Some ( hint)
71
77
} else {
72
78
None
Original file line number Diff line number Diff line change @@ -56,4 +56,7 @@ fn main() {
56
56
x.split('a');
57
57
x.split('\'');
58
58
x.split('#');
59
+ // Must escape backslash in raw strings when converting to char #8060
60
+ x.split('\\');
61
+ x.split('\\');
59
62
}
Original file line number Diff line number Diff line change @@ -56,4 +56,7 @@ fn main() {
56
56
x. split ( r###"a"### ) ;
57
57
x. split ( r###"'"### ) ;
58
58
x. split ( r###"#"### ) ;
59
+ // Must escape backslash in raw strings when converting to char #8060
60
+ x. split ( r#"\"# ) ;
61
+ x. split ( r"\" ) ;
59
62
}
Original file line number Diff line number Diff line change @@ -192,5 +192,17 @@ error: single-character string constant used as pattern
192
192
LL | x.split(r###"#"###);
193
193
| ^^^^^^^^^^ help: try using a `char` instead: `'#'`
194
194
195
- error: aborting due to 32 previous errors
195
+ error: single-character string constant used as pattern
196
+ --> $DIR/single_char_pattern.rs:60:13
197
+ |
198
+ LL | x.split(r#"/"#);
199
+ | ^^^^^^ help: try using a `char` instead: `'/'`
200
+
201
+ error: single-character string constant used as pattern
202
+ --> $DIR/single_char_pattern.rs:61:13
203
+ |
204
+ LL | x.split(r"/");
205
+ | ^^^^ help: try using a `char` instead: `'/'`
206
+
207
+ error: aborting due to 34 previous errors
196
208
You can’t perform that action at this time.
0 commit comments