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(
6666 // for regular string: "a"
6767 & snip[ 1 ..( snip. len( ) - 1 ) ]
6868 } ;
69- let hint = format!( "'{}'" , if ch == "'" { "\\ '" } else { ch } ) ;
69+
70+ let hint = format!( "'{}'" , match ch {
71+ "'" => "\\ '" ,
72+ r"\" => "\\ \\ " ,
73+ _ => ch,
74+ } ) ;
75+
7076 Some ( hint)
7177 } else {
7278 None
Original file line number Diff line number Diff line change @@ -56,4 +56,7 @@ fn main() {
5656 x.split('a');
5757 x.split('\'');
5858 x.split('#');
59+ // Must escape backslash in raw strings when converting to char #8060
60+ x.split('\\');
61+ x.split('\\');
5962}
Original file line number Diff line number Diff line change @@ -56,4 +56,7 @@ fn main() {
5656 x. split ( r###"a"### ) ;
5757 x. split ( r###"'"### ) ;
5858 x. split ( r###"#"### ) ;
59+ // Must escape backslash in raw strings when converting to char #8060
60+ x. split ( r#"\"# ) ;
61+ x. split ( r"\" ) ;
5962}
Original file line number Diff line number Diff line change @@ -192,5 +192,17 @@ error: single-character string constant used as pattern
192192LL | x.split(r###"#"###);
193193 | ^^^^^^^^^^ help: try using a `char` instead: `'#'`
194194
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
196208
You can’t perform that action at this time.
0 commit comments