Enable parsing of attributes inside a match block

We allow invalid inner attributes to be parsed, e.g. inner attributes that are
not directly after the opening brace of the match block.

Instead we run validation on `MatchArmList` to allow better reporting of errors.
This commit is contained in:
Ville Penttinen 2019-02-17 19:08:34 +02:00
parent 982f72c022
commit 1c97c1ac11
16 changed files with 589 additions and 1 deletions

View file

@ -153,6 +153,20 @@ impl FnDef {
}
impl Attr {
pub fn is_inner(&self) -> bool {
let tt = match self.value() {
None => return false,
Some(tt) => tt,
};
let prev = match tt.syntax().prev_sibling() {
None => return false,
Some(prev) => prev,
};
prev.kind() == EXCL
}
pub fn as_atom(&self) -> Option<SmolStr> {
let tt = self.value()?;
let (_bra, attr, _ket) = tt.syntax().children().collect_tuple()?;