mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-11-01 12:24:29 +00:00
Implement unsafe attribute parsing
This commit is contained in:
parent
c4618fe14d
commit
e1aeed3aed
8 changed files with 534 additions and 11 deletions
|
|
@ -314,7 +314,9 @@ Attr =
|
|||
'#' '!'? '[' Meta ']'
|
||||
|
||||
Meta =
|
||||
Path ('=' Expr | TokenTree)?
|
||||
'unsafe' '(' Path ('=' Expr | TokenTree)? ')'
|
||||
| Path ('=' Expr | TokenTree)?
|
||||
|
||||
|
||||
//****************************//
|
||||
// Statements and Expressions //
|
||||
|
|
@ -391,7 +393,6 @@ FormatArgsExpr =
|
|||
FormatArgsArg =
|
||||
(Name '=')? Expr
|
||||
|
||||
# MacroCallExpr
|
||||
MacroExpr =
|
||||
MacroCall
|
||||
|
||||
|
|
|
|||
|
|
@ -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)]
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue