diff options
author | Aleksey Kladov <[email protected]> | 2021-04-19 15:11:49 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2021-04-19 15:11:49 +0100 |
commit | 5f89a60f1a0feab1e2e0dd37e642877552675da4 (patch) | |
tree | 43fb164ef5ca02ccf8d9e8c3bedaa66d473a019c /crates/syntax/src | |
parent | e4f7f1e1bd2ca3c1816abf87779ad8893b7bf990 (diff) |
fix: false positive about inner attrs in docs
closes #8541
Diffstat (limited to 'crates/syntax/src')
-rw-r--r-- | crates/syntax/src/ast/node_ext.rs | 12 | ||||
-rw-r--r-- | crates/syntax/src/validation/block.rs | 2 |
2 files changed, 13 insertions, 1 deletions
diff --git a/crates/syntax/src/ast/node_ext.rs b/crates/syntax/src/ast/node_ext.rs index ae98dbd26..171099661 100644 --- a/crates/syntax/src/ast/node_ext.rs +++ b/crates/syntax/src/ast/node_ext.rs | |||
@@ -125,6 +125,18 @@ pub enum AttrKind { | |||
125 | Outer, | 125 | Outer, |
126 | } | 126 | } |
127 | 127 | ||
128 | impl AttrKind { | ||
129 | /// Returns `true` if the attr_kind is [`Inner`]. | ||
130 | pub fn is_inner(&self) -> bool { | ||
131 | matches!(self, Self::Inner) | ||
132 | } | ||
133 | |||
134 | /// Returns `true` if the attr_kind is [`Outer`]. | ||
135 | pub fn is_outer(&self) -> bool { | ||
136 | matches!(self, Self::Outer) | ||
137 | } | ||
138 | } | ||
139 | |||
128 | impl ast::Attr { | 140 | impl ast::Attr { |
129 | pub fn as_simple_atom(&self) -> Option<SmolStr> { | 141 | pub fn as_simple_atom(&self) -> Option<SmolStr> { |
130 | if self.eq_token().is_some() || self.token_tree().is_some() { | 142 | if self.eq_token().is_some() || self.token_tree().is_some() { |
diff --git a/crates/syntax/src/validation/block.rs b/crates/syntax/src/validation/block.rs index ad9901468..40170014f 100644 --- a/crates/syntax/src/validation/block.rs +++ b/crates/syntax/src/validation/block.rs | |||
@@ -13,7 +13,7 @@ pub(crate) fn validate_block_expr(block: ast::BlockExpr, errors: &mut Vec<Syntax | |||
13 | _ => {} | 13 | _ => {} |
14 | } | 14 | } |
15 | } | 15 | } |
16 | errors.extend(block.attrs().map(|attr| { | 16 | errors.extend(block.attrs().filter(|attr| attr.kind().is_inner()).map(|attr| { |
17 | SyntaxError::new( | 17 | SyntaxError::new( |
18 | "A block in this position cannot accept inner attributes", | 18 | "A block in this position cannot accept inner attributes", |
19 | attr.syntax().text_range(), | 19 | attr.syntax().text_range(), |