Skip to content

Commit 4d5873e

Browse files
committed
minor: align with rustc on escaping characters in macro expansion
1 parent 859d467 commit 4d5873e

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

crates/hir-def/src/macro_expansion_tests/builtin_fn_macro.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -295,13 +295,13 @@ fn test_concat_expand() {
295295
#[rustc_builtin_macro]
296296
macro_rules! concat {}
297297
298-
fn main() { concat!("foo", "r", 0, r#"bar"#, "\n", false, '\n'); }
298+
fn main() { concat!("foo", "r", 0, r#"bar"#, "\n", false, '"', '\0'); }
299299
"##,
300300
expect![[r##"
301301
#[rustc_builtin_macro]
302302
macro_rules! concat {}
303303
304-
fn main() { "foor0bar\nfalse\n"; }
304+
fn main() { "foor0bar\nfalse\"\u{0}"; }
305305
"##]],
306306
);
307307
}

crates/hir-expand/src/quote.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,8 @@ impl_to_to_tokentrees! {
196196
tt::Literal => self { self };
197197
tt::Ident => self { self };
198198
tt::Punct => self { self };
199-
&str => self { tt::Literal{text: format!("\"{}\"", self.escape_debug()).into(), id: tt::TokenId::unspecified()}};
200-
String => self { tt::Literal{text: format!("\"{}\"", self.escape_debug()).into(), id: tt::TokenId::unspecified()}}
199+
&str => self { tt::Literal{text: format!("\"{}\"", self.escape_default()).into(), id: tt::TokenId::unspecified()}};
200+
String => self { tt::Literal{text: format!("\"{}\"", self.escape_default()).into(), id: tt::TokenId::unspecified()}}
201201
}
202202

203203
#[cfg(test)]

0 commit comments

Comments
 (0)