mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-28 22:13:39 +00:00
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 <edwin0cheng@gmail.com>
This commit is contained in:
commit
d2782ab1c1
1 changed files with 4 additions and 4 deletions
|
@ -172,12 +172,12 @@ impl_to_to_tokentrees! {
|
||||||
u32 => self { tt::Literal{text: self.to_string().into()} };
|
u32 => self { tt::Literal{text: self.to_string().into()} };
|
||||||
usize => 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()}};
|
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::Leaf => self { self };
|
||||||
tt::Literal => self { self };
|
tt::Literal => self { self };
|
||||||
tt::Ident => 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)]
|
#[cfg(test)]
|
||||||
|
@ -200,7 +200,7 @@ mod tests {
|
||||||
let a = 20;
|
let a = 20;
|
||||||
assert_eq!(quote!(#a).to_string(), "20");
|
assert_eq!(quote!(#a).to_string(), "20");
|
||||||
let s: String = "hello".into();
|
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 {
|
fn mk_ident(name: &str) -> tt::Ident {
|
||||||
|
|
Loading…
Reference in a new issue