Implement unsafe attribute parsing

This commit is contained in:
Lukas Wirth 2024-05-06 12:09:31 +02:00
parent c4618fe14d
commit e1aeed3aed
8 changed files with 534 additions and 11 deletions

View file

@ -778,7 +778,10 @@ impl Meta {
pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
pub fn token_tree(&self) -> Option<TokenTree> { support::child(&self.syntax) }
pub fn l_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T!['(']) }
pub fn r_paren_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![')']) }
pub fn eq_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![=]) }
pub fn unsafe_token(&self) -> Option<SyntaxToken> { support::token(&self.syntax, T![unsafe]) }
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]

View file

@ -9,7 +9,7 @@ use crate::{
pub(crate) fn validate_block_expr(block: ast::BlockExpr, errors: &mut Vec<SyntaxError>) {
if let Some(parent) = block.syntax().parent() {
match parent.kind() {
FN | EXPR_STMT | STMT_LIST => return,
FN | EXPR_STMT | STMT_LIST | MACRO_STMTS => return,
_ => {}
}
}