diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-07-30 19:39:09 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2020-07-30 19:39:09 +0100 |
commit | 6f5b53013c54fa6d8429b717998cdb77a4d68b2c (patch) | |
tree | c09cf0434ecf282cf1763d34cf838952db105e0a /crates/ra_hir_def/src/attr.rs | |
parent | e28ea81b2b68a61b5c5eec3c815172b17256a25f (diff) | |
parent | fbe60a2e284035d16c2a1ee743ee88db418689aa (diff) |
Merge #5611
5611: Finalize attribute grammar r=matklad a=matklad
bors r+
🤖
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_hir_def/src/attr.rs')
-rw-r--r-- | crates/ra_hir_def/src/attr.rs | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/crates/ra_hir_def/src/attr.rs b/crates/ra_hir_def/src/attr.rs index 70ccd4305..050832ce0 100644 --- a/crates/ra_hir_def/src/attr.rs +++ b/crates/ra_hir_def/src/attr.rs | |||
@@ -151,18 +151,15 @@ pub enum AttrInput { | |||
151 | impl Attr { | 151 | impl Attr { |
152 | fn from_src(ast: ast::Attr, hygiene: &Hygiene) -> Option<Attr> { | 152 | fn from_src(ast: ast::Attr, hygiene: &Hygiene) -> Option<Attr> { |
153 | let path = ModPath::from_src(ast.path()?, hygiene)?; | 153 | let path = ModPath::from_src(ast.path()?, hygiene)?; |
154 | let input = match ast.input() { | 154 | let input = if let Some(lit) = ast.literal() { |
155 | None => None, | 155 | // FIXME: escape? raw string? |
156 | Some(ast::AttrInput::Literal(lit)) => { | 156 | let value = lit.syntax().first_token()?.text().trim_matches('"').into(); |
157 | // FIXME: escape? raw string? | 157 | Some(AttrInput::Literal(value)) |
158 | let value = lit.syntax().first_token()?.text().trim_matches('"').into(); | 158 | } else if let Some(tt) = ast.token_tree() { |
159 | Some(AttrInput::Literal(value)) | 159 | Some(AttrInput::TokenTree(ast_to_token_tree(&tt)?.0)) |
160 | } | 160 | } else { |
161 | Some(ast::AttrInput::TokenTree(tt)) => { | 161 | None |
162 | Some(AttrInput::TokenTree(ast_to_token_tree(&tt)?.0)) | ||
163 | } | ||
164 | }; | 162 | }; |
165 | |||
166 | Some(Attr { path, input }) | 163 | Some(Attr { path, input }) |
167 | } | 164 | } |
168 | } | 165 | } |