Skip to content

Commit bcac1fd

Browse files
committed
Consistently use repr for the escaped text of a literal
1 parent 28e905f commit bcac1fd

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

src/fallback.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1049,29 +1049,29 @@ impl Literal {
10491049
}
10501050

10511051
pub fn byte_string(bytes: &[u8]) -> Literal {
1052-
let mut escaped = "b\"".to_string();
1052+
let mut repr = "b\"".to_string();
10531053
let mut bytes = bytes.iter();
10541054
while let Some(&b) = bytes.next() {
10551055
#[allow(clippy::match_overlapping_arm)]
10561056
match b {
1057-
b'\0' => escaped.push_str(match bytes.as_slice().first() {
1057+
b'\0' => repr.push_str(match bytes.as_slice().first() {
10581058
// circumvent clippy::octal_escapes lint
10591059
Some(b'0'..=b'7') => r"\x00",
10601060
_ => r"\0",
10611061
}),
1062-
b'\t' => escaped.push_str(r"\t"),
1063-
b'\n' => escaped.push_str(r"\n"),
1064-
b'\r' => escaped.push_str(r"\r"),
1065-
b'"' => escaped.push_str("\\\""),
1066-
b'\\' => escaped.push_str("\\\\"),
1067-
b'\x20'..=b'\x7E' => escaped.push(b as char),
1062+
b'\t' => repr.push_str(r"\t"),
1063+
b'\n' => repr.push_str(r"\n"),
1064+
b'\r' => repr.push_str(r"\r"),
1065+
b'"' => repr.push_str("\\\""),
1066+
b'\\' => repr.push_str("\\\\"),
1067+
b'\x20'..=b'\x7E' => repr.push(b as char),
10681068
_ => {
1069-
let _ = write!(escaped, "\\x{:02X}", b);
1069+
let _ = write!(repr, "\\x{:02X}", b);
10701070
}
10711071
}
10721072
}
1073-
escaped.push('"');
1074-
Literal::_new(escaped)
1073+
repr.push('"');
1074+
Literal::_new(repr)
10751075
}
10761076

10771077
pub fn span(&self) -> Span {

0 commit comments

Comments
 (0)