aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLukas Wirth <[email protected]>2020-12-07 18:05:06 +0000
committerLukas Wirth <[email protected]>2020-12-07 18:58:17 +0000
commitefe86a42dc922ca2cb38227f3b0bf6a420d3cfca (patch)
treef89891e7746701bbe1a70af4f3200f96040c63f7
parent1caaa201fa55caaedaa124d23934c178bdf15b18 (diff)
Remove raw pre and suffixes from string attr literals
-rw-r--r--crates/hir_def/src/attr.rs7
1 files changed, 5 insertions, 2 deletions
diff --git a/crates/hir_def/src/attr.rs b/crates/hir_def/src/attr.rs
index 98293aad3..4e8b908d0 100644
--- a/crates/hir_def/src/attr.rs
+++ b/crates/hir_def/src/attr.rs
@@ -195,8 +195,11 @@ impl Attr {
195 fn from_src(ast: ast::Attr, hygiene: &Hygiene) -> Option<Attr> { 195 fn from_src(ast: ast::Attr, hygiene: &Hygiene) -> Option<Attr> {
196 let path = ModPath::from_src(ast.path()?, hygiene)?; 196 let path = ModPath::from_src(ast.path()?, hygiene)?;
197 let input = if let Some(lit) = ast.literal() { 197 let input = if let Some(lit) = ast.literal() {
198 // FIXME: escape? raw string? 198 let value = if let ast::LiteralKind::String(string) = lit.kind() {
199 let value = lit.syntax().first_token()?.text().trim_matches('"').into(); 199 string.value()?.into()
200 } else {
201 lit.syntax().first_token()?.text().trim_matches('"').into()
202 };
200 Some(AttrInput::Literal(value)) 203 Some(AttrInput::Literal(value))
201 } else if let Some(tt) = ast.token_tree() { 204 } else if let Some(tt) = ast.token_tree() {
202 Some(AttrInput::TokenTree(ast_to_token_tree(&tt)?.0)) 205 Some(AttrInput::TokenTree(ast_to_token_tree(&tt)?.0))