Skip to content

Commit 01ce37c

Browse files
committed
Escape characters in builtin macros correctly
1 parent cf4d4f6 commit 01ce37c

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

crates/hir_expand/src/builtin_macro.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -788,9 +788,9 @@ mod tests {
788788
r##"
789789
#[rustc_builtin_macro]
790790
macro_rules! concat {}
791-
concat!("foo", "r", 0, r#"bar"#, false);
791+
concat!("foo", "r", 0, r#"bar"#, "\n", false);
792792
"##,
793-
expect![[r#""foor0barfalse""#]],
793+
expect![[r#""foor0bar\nfalse""#]],
794794
);
795795
}
796796
}

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_default().to_string()).into(), id: tt::TokenId::unspecified()}};
200-
String => self { tt::Literal{text: format!("{:?}", self.escape_default().to_string()).into(), id: tt::TokenId::unspecified()}}
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()}}
201201
}
202202

203203
#[cfg(test)]

0 commit comments

Comments
 (0)