aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_expand/src
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2019-11-19 08:27:27 +0000
committerGitHub <[email protected]>2019-11-19 08:27:27 +0000
commitd2782ab1c1ec0b9f2ac2131859a9ee880f97bc12 (patch)
tree6ee965ff6e6bfbf879ed442e6ca9b70e01388d5c /crates/ra_hir_expand/src
parentc3e61d7e8e48115b9b864ec8cdb4652a37e68cd6 (diff)
parentf24bba74d02a14552693a8d4b11b74bb8ffa93db (diff)
Merge #2312
2312: Fixed string literal quoting r=matklad a=edwin0cheng It fixed a bug which `quote!` should return a literal escaped instead of original string. Co-authored-by: Edwin Cheng <[email protected]>
Diffstat (limited to 'crates/ra_hir_expand/src')
-rw-r--r--crates/ra_hir_expand/src/quote.rs8
1 files changed, 4 insertions, 4 deletions
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! {
172 u32 => self { tt::Literal{text: self.to_string().into()} }; 172 u32 => self { tt::Literal{text: self.to_string().into()} };
173 usize => self { tt::Literal{text: self.to_string().into()}}; 173 usize => self { tt::Literal{text: self.to_string().into()}};
174 i32 => self { tt::Literal{text: self.to_string().into()}}; 174 i32 => self { tt::Literal{text: self.to_string().into()}};
175 &str => self { tt::Literal{text: self.to_string().into()}};
176 String => self { tt::Literal{text: self.into()}};
177 tt::Leaf => self { self }; 175 tt::Leaf => self { self };
178 tt::Literal => self { self }; 176 tt::Literal => self { self };
179 tt::Ident => self { self }; 177 tt::Ident => self { self };
180 tt::Punct => self { self } 178 tt::Punct => self { self };
179 &str => self { tt::Literal{text: format!("{:?}", self.escape_default().to_string()).into()}};
180 String => self { tt::Literal{text: format!("{:?}", self.escape_default().to_string()).into()}}
181} 181}
182 182
183#[cfg(test)] 183#[cfg(test)]
@@ -200,7 +200,7 @@ mod tests {
200 let a = 20; 200 let a = 20;
201 assert_eq!(quote!(#a).to_string(), "20"); 201 assert_eq!(quote!(#a).to_string(), "20");
202 let s: String = "hello".into(); 202 let s: String = "hello".into();
203 assert_eq!(quote!(#s).to_string(), "hello"); 203 assert_eq!(quote!(#s).to_string(), "\"hello\"");
204 } 204 }
205 205
206 fn mk_ident(name: &str) -> tt::Ident { 206 fn mk_ident(name: &str) -> tt::Ident {