mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 12:54:58 +00:00
Implement unsafe attribute parsing
This commit is contained in:
parent
c4618fe14d
commit
e1aeed3aed
8 changed files with 534 additions and 11 deletions
|
@ -36,8 +36,33 @@ fn attr(p: &mut Parser<'_>, inner: bool) {
|
|||
attr.complete(p, ATTR);
|
||||
}
|
||||
|
||||
// test metas
|
||||
// #![simple_ident]
|
||||
// #![simple::path]
|
||||
// #![simple_ident_expr = ""]
|
||||
// #![simple::path::Expr = ""]
|
||||
// #![simple_ident_tt(a b c)]
|
||||
// #![simple_ident_tt[a b c]]
|
||||
// #![simple_ident_tt{a b c}]
|
||||
// #![simple::path::tt(a b c)]
|
||||
// #![simple::path::tt[a b c]]
|
||||
// #![simple::path::tt{a b c}]
|
||||
// #![unsafe(simple_ident)]
|
||||
// #![unsafe(simple::path)]
|
||||
// #![unsafe(simple_ident_expr = "")]
|
||||
// #![unsafe(simple::path::Expr = "")]
|
||||
// #![unsafe(simple_ident_tt(a b c))]
|
||||
// #![unsafe(simple_ident_tt[a b c])]
|
||||
// #![unsafe(simple_ident_tt{a b c})]
|
||||
// #![unsafe(simple::path::tt(a b c))]
|
||||
// #![unsafe(simple::path::tt[a b c])]
|
||||
// #![unsafe(simple::path::tt{a b c})]
|
||||
pub(super) fn meta(p: &mut Parser<'_>) {
|
||||
let meta = p.start();
|
||||
let is_unsafe = p.eat(T![unsafe]);
|
||||
if is_unsafe {
|
||||
p.expect(T!['(']);
|
||||
}
|
||||
paths::use_path(p);
|
||||
|
||||
match p.current() {
|
||||
|
@ -50,6 +75,9 @@ pub(super) fn meta(p: &mut Parser<'_>) {
|
|||
T!['('] | T!['['] | T!['{'] => items::token_tree(p),
|
||||
_ => {}
|
||||
}
|
||||
if is_unsafe {
|
||||
p.expect(T![')']);
|
||||
}
|
||||
|
||||
meta.complete(p, META);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue