From f24bba74d02a14552693a8d4b11b74bb8ffa93db Mon Sep 17 00:00:00 2001 From: Edwin Cheng Date: Fri, 15 Nov 2019 22:13:41 +0800 Subject: Fixed a bug for string lit in quote --- crates/ra_hir_expand/src/quote.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'crates/ra_hir_expand/src') diff --git a/crates/ra_hir_expand/src/quote.rs b/crates/ra_hir_expand/src/quote.rs index 35133d216..65a35e52f 100644 --- a/crates/ra_hir_expand/src/quote.rs +++ b/crates/ra_hir_expand/src/quote.rs @@ -172,12 +172,12 @@ impl_to_to_tokentrees! { u32 => self { tt::Literal{text: self.to_string().into()} }; usize => self { tt::Literal{text: self.to_string().into()}}; i32 => self { tt::Literal{text: self.to_string().into()}}; - &str => self { tt::Literal{text: self.to_string().into()}}; - String => self { tt::Literal{text: self.into()}}; tt::Leaf => self { self }; tt::Literal => self { self }; tt::Ident => self { self }; - tt::Punct => self { self } + tt::Punct => self { self }; + &str => self { tt::Literal{text: format!("{:?}", self.escape_default().to_string()).into()}}; + String => self { tt::Literal{text: format!("{:?}", self.escape_default().to_string()).into()}} } #[cfg(test)] @@ -200,7 +200,7 @@ mod tests { let a = 20; assert_eq!(quote!(#a).to_string(), "20"); let s: String = "hello".into(); - assert_eq!(quote!(#s).to_string(), "hello"); + assert_eq!(quote!(#s).to_string(), "\"hello\""); } fn mk_ident(name: &str) -> tt::Ident { -- cgit v1.2.3