aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdwin Cheng <[email protected]>2021-05-09 12:57:29 +0100
committerEdwin Cheng <[email protected]>2021-05-09 12:57:29 +0100
commit01ce37c8052136b3a5ab1f703f774a1b293a25b7 (patch)
tree605bf777bbade5dc9a90908ff257aae8a553c2b2
parentcf4d4f646b6227242b2d4e216e8e30b5e111e02e (diff)
Escape characters in builtin macros correctly
-rw-r--r--crates/hir_expand/src/builtin_macro.rs4
-rw-r--r--crates/hir_expand/src/quote.rs4
2 files changed, 4 insertions, 4 deletions
diff --git a/crates/hir_expand/src/builtin_macro.rs b/crates/hir_expand/src/builtin_macro.rs
index 179de61f9..0142a06ed 100644
--- a/crates/hir_expand/src/builtin_macro.rs
+++ b/crates/hir_expand/src/builtin_macro.rs
@@ -788,9 +788,9 @@ mod tests {
788 r##" 788 r##"
789 #[rustc_builtin_macro] 789 #[rustc_builtin_macro]
790 macro_rules! concat {} 790 macro_rules! concat {}
791 concat!("foo", "r", 0, r#"bar"#, false); 791 concat!("foo", "r", 0, r#"bar"#, "\n", false);
792 "##, 792 "##,
793 expect![[r#""foor0barfalse""#]], 793 expect![[r#""foor0bar\nfalse""#]],
794 ); 794 );
795 } 795 }
796} 796}
diff --git a/crates/hir_expand/src/quote.rs b/crates/hir_expand/src/quote.rs
index c82487ef0..230a59964 100644
--- a/crates/hir_expand/src/quote.rs
+++ b/crates/hir_expand/src/quote.rs
@@ -196,8 +196,8 @@ impl_to_to_tokentrees! {
196 tt::Literal => self { self }; 196 tt::Literal => self { self };
197 tt::Ident => self { self }; 197 tt::Ident => self { self };
198 tt::Punct => self { self }; 198 tt::Punct => self { self };
199 &str => 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_default().to_string()).into(), id: tt::TokenId::unspecified()}} 200 String => self { tt::Literal{text: format!("\"{}\"", self.escape_debug()).into(), id: tt::TokenId::unspecified()}}
201} 201}
202 202
203#[cfg(test)] 203#[cfg(test)]