mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 11:31:15 +00:00
Simplify item parsing
This commit is contained in:
parent
469654e088
commit
83aa6f0899
@ -1,8 +1,8 @@
|
|||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
pub(super) fn mod_contents(p: &mut Parser) {
|
pub(super) fn mod_contents(p: &mut Parser, stop_on_r_curly: bool) {
|
||||||
attributes::inner_attributes(p);
|
attributes::inner_attributes(p);
|
||||||
while !p.at(EOF) {
|
while !p.at(EOF) && !(stop_on_r_curly && p.at(R_CURLY)) {
|
||||||
item(p);
|
item(p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -152,7 +152,10 @@ fn mod_item(p: &mut Parser) {
|
|||||||
p.bump();
|
p.bump();
|
||||||
|
|
||||||
if p.expect(IDENT) && !p.eat(SEMI) {
|
if p.expect(IDENT) && !p.eat(SEMI) {
|
||||||
p.curly_block(mod_contents);
|
if p.expect(L_CURLY) {
|
||||||
|
mod_contents(p, true);
|
||||||
|
p.expect(R_CURLY);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ mod paths;
|
|||||||
pub(crate) fn file(p: &mut Parser) {
|
pub(crate) fn file(p: &mut Parser) {
|
||||||
let file = p.start();
|
let file = p.start();
|
||||||
p.eat(SHEBANG);
|
p.eat(SHEBANG);
|
||||||
items::mod_contents(p);
|
items::mod_contents(p, false);
|
||||||
file.complete(p, FILE);
|
file.complete(p, FILE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user