@@ -125,6 +125,18 @@ pub enum AttrKind {
|
||||
Outer,
|
||||
}
|
||||
|
||||
impl AttrKind {
|
||||
/// Returns `true` if the attr_kind is [`Inner`].
|
||||
pub fn is_inner(&self) -> bool {
|
||||
matches!(self, Self::Inner)
|
||||
}
|
||||
|
||||
/// Returns `true` if the attr_kind is [`Outer`].
|
||||
pub fn is_outer(&self) -> bool {
|
||||
matches!(self, Self::Outer)
|
||||
}
|
||||
}
|
||||
|
||||
impl ast::Attr {
|
||||
pub fn as_simple_atom(&self) -> Option<SmolStr> {
|
||||
if self.eq_token().is_some() || self.token_tree().is_some() {
|
||||
|
||||
@@ -13,7 +13,7 @@ pub(crate) fn validate_block_expr(block: ast::BlockExpr, errors: &mut Vec<Syntax
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
errors.extend(block.attrs().map(|attr| {
|
||||
errors.extend(block.attrs().filter(|attr| attr.kind().is_inner()).map(|attr| {
|
||||
SyntaxError::new(
|
||||
"A block in this position cannot accept inner attributes",
|
||||
attr.syntax().text_range(),
|
||||
|
||||
Reference in New Issue
Block a user