Skip to content

Commit 0e46ed8

Browse files
committed
Cleanups
1 parent 795b8cf commit 0e46ed8

File tree

2 files changed

+13
-14
lines changed

2 files changed

+13
-14
lines changed

crates/ra_parser/src/grammar/expressions.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,6 @@ fn is_expr_stmt_attr_allowed(kind: SyntaxKind) -> bool {
7979
}
8080

8181
pub(super) fn stmt(p: &mut Parser, with_semi: StmtWithSemi) {
82-
// test block_items
83-
// fn a() { fn b() {} }
8482
let m = p.start();
8583
// test attr_on_expr_stmt
8684
// fn foo() {
@@ -97,6 +95,8 @@ pub(super) fn stmt(p: &mut Parser, with_semi: StmtWithSemi) {
9795
return;
9896
}
9997

98+
// test block_items
99+
// fn a() { fn b() {} }
100100
let m = match items::maybe_item(p, m, items::ItemFlavor::Mod) {
101101
Ok(()) => return,
102102
Err(m) => m,

crates/ra_parser/src/grammar/patterns.rs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,6 @@ fn pattern_single_r(p: &mut Parser, recovery_set: TokenSet) {
7070
return;
7171
}
7272
}
73-
// test marco_pat
74-
// fn main() {
75-
// let m!(x) = 0;
76-
// }
77-
if lhs.kind() == PATH_PAT && p.at(T![!]) {
78-
let m = lhs.undo_completion(p);
79-
items::macro_call_after_excl(p);
80-
m.complete(p, MACRO_CALL);
81-
}
8273
}
8374
}
8475

@@ -92,12 +83,12 @@ fn atom_pat(p: &mut Parser, recovery_set: TokenSet) -> Option<CompletedMarker> {
9283
IDENT => match p.nth(1) {
9384
// Checks the token after an IDENT to see if a pattern is a path (Struct { .. }) or macro
9485
// (T![x]).
95-
T!['('] | T!['{'] | T![!] => path_pat(p),
86+
T!['('] | T!['{'] | T![!] => path_or_macro_pat(p),
9687
T![:] if p.nth_at(1, T![::]) => path_pat(p),
9788
_ => bind_pat(p, true),
9889
},
9990

100-
_ if paths::is_use_path_start(p) => path_pat(p),
91+
_ if paths::is_use_path_start(p) => path_or_macro_pat(p),
10192
_ if is_literal_pat_start(p) => literal_pat(p),
10293

10394
T![.] if p.at(T![..]) => dot_dot_pat(p),
@@ -146,7 +137,7 @@ fn literal_pat(p: &mut Parser) -> CompletedMarker {
146137
// let Bar { .. } = ();
147138
// let Bar(..) = ();
148139
// }
149-
fn path_pat(p: &mut Parser) -> CompletedMarker {
140+
fn path_or_macro_pat(p: &mut Parser) -> CompletedMarker {
150141
assert!(paths::is_use_path_start(p));
151142
let m = p.start();
152143
paths::expr_path(p);
@@ -159,6 +150,14 @@ fn path_pat(p: &mut Parser) -> CompletedMarker {
159150
record_field_pat_list(p);
160151
RECORD_PAT
161152
}
153+
// test marco_pat
154+
// fn main() {
155+
// let m!(x) = 0;
156+
// }
157+
T![!] => {
158+
items::macro_call_after_excl(p);
159+
MACRO_CALL
160+
}
162161
_ => PATH_PAT,
163162
};
164163
m.complete(p, kind)

0 commit comments

Comments
 (0)