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 <jonasschievink@gmail.com>
This commit is contained in:
bors[bot]
2020-12-18 19:27:18 +00:00
committed by GitHub
6 changed files with 97 additions and 3 deletions

View File

@@ -205,6 +205,13 @@ impl ast::Type {
}
}
impl ast::Attr {
/// Returns `text`, parsed as an attribute, but only if it has no errors.
pub fn parse(text: &str) -> Result<Self, ()> {
parsing::parse_text_fragment(text, parser::FragmentKind::Attr)
}
}
/// Matches a `SyntaxNode` against an `ast` type.
///
/// # Example: