File tree Expand file tree Collapse file tree 2 files changed +16
-12
lines changed Expand file tree Collapse file tree 2 files changed +16
-12
lines changed Original file line number Diff line number Diff line change @@ -960,13 +960,18 @@ impl Literal {
960
960
repr. push ( '"' ) ;
961
961
let mut chars = t. chars ( ) ;
962
962
while let Some ( ch) = chars. next ( ) {
963
- if ch == '\0'
964
- && chars
965
- . as_str ( )
966
- . starts_with ( |next| '0' <= next && next <= '7' )
967
- {
968
- // circumvent clippy::octal_escapes lint
969
- repr. push_str ( "\\ x00" ) ;
963
+ if ch == '\0' {
964
+ repr. push_str (
965
+ if chars
966
+ . as_str ( )
967
+ . starts_with ( |next| '0' <= next && next <= '7' )
968
+ {
969
+ // circumvent clippy::octal_escapes lint
970
+ "\\ x00"
971
+ } else {
972
+ "\\ 0"
973
+ } ,
974
+ ) ;
970
975
} else if ch == '\'' {
971
976
// escape_debug turns this into "\'" which is unnecessary.
972
977
repr. push ( ch) ;
Original file line number Diff line number Diff line change @@ -115,11 +115,10 @@ fn literal_string() {
115
115
assert_eq ! ( Literal :: string( "foo" ) . to_string( ) , "\" foo\" " ) ;
116
116
assert_eq ! ( Literal :: string( "\" " ) . to_string( ) , "\" \\ \" \" " ) ;
117
117
assert_eq ! ( Literal :: string( "didn't" ) . to_string( ) , "\" didn't\" " ) ;
118
-
119
- let repr = Literal :: string ( "a\0 0b\0 7c\0 8d\0 e\0 " ) . to_string ( ) ;
120
- if repr != "\" a\\ x000b\\ x007c\\ u{0}8d\\ u{0}e\\ u{0}\" " {
121
- assert_eq ! ( repr, "\" a\\ x000b\\ x007c\\ 08d\\ 0e\\ 0\" " ) ;
122
- }
118
+ assert_eq ! (
119
+ Literal :: string( "a\0 0b\0 7c\0 8d\0 e\0 " ) . to_string( ) ,
120
+ "\" a\\ x000b\\ x007c\\ 08d\\ 0e\\ 0\" " ,
121
+ ) ;
123
122
}
124
123
125
124
#[ test]
You can’t perform that action at this time.
0 commit comments