diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-12-18 19:27:18 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2020-12-18 19:27:18 +0000 |
commit | c073e4f6ba5e4f2754262ea02ad3bb23e78e1f3e (patch) | |
tree | 524b2882b071232a2603f657279e7ac9c459950f /crates/syntax/src/lib.rs | |
parent | 25185c1418022868e2f7ec1599e32a34d63e8314 (diff) | |
parent | aab9cc9cfb64aea659f2f9b588e8a4f392e2c4e1 (diff) |
Merge #6934
6934: Implement `cfg_attr` handling r=jonas-schievink a=jonas-schievink
Part of https://github.com/rust-analyzer/rust-analyzer/issues/5548
Co-authored-by: Jonas Schievink <[email protected]>
Diffstat (limited to 'crates/syntax/src/lib.rs')
-rw-r--r-- | crates/syntax/src/lib.rs | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/crates/syntax/src/lib.rs b/crates/syntax/src/lib.rs index e753b11bb..4d272f367 100644 --- a/crates/syntax/src/lib.rs +++ b/crates/syntax/src/lib.rs | |||
@@ -205,6 +205,13 @@ impl ast::Type { | |||
205 | } | 205 | } |
206 | } | 206 | } |
207 | 207 | ||
208 | impl ast::Attr { | ||
209 | /// Returns `text`, parsed as an attribute, but only if it has no errors. | ||
210 | pub fn parse(text: &str) -> Result<Self, ()> { | ||
211 | parsing::parse_text_fragment(text, parser::FragmentKind::Attr) | ||
212 | } | ||
213 | } | ||
214 | |||
208 | /// Matches a `SyntaxNode` against an `ast` type. | 215 | /// Matches a `SyntaxNode` against an `ast` type. |
209 | /// | 216 | /// |
210 | /// # Example: | 217 | /// # Example: |