Skip to content

Commit 09531b7

Browse files
committed
minor: simplify
1 parent 0005678 commit 09531b7

File tree

2 files changed

+7
-20
lines changed

2 files changed

+7
-20
lines changed

crates/parser/src/grammar/generic_args.rs

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -32,37 +32,24 @@ fn generic_arg(p: &mut Parser) {
3232
// fn print_all<T: Iterator<Item, Item::Item, Item::<true>, Item: Display, Item<'a> = Item>>(printables: T) {}
3333
IDENT if [T![<], T![=], T![:]].contains(&p.nth(1)) => {
3434
let m = p.start();
35-
let path_ty = p.start();
36-
let path = p.start();
37-
let path_seg = p.start();
3835
name_ref(p);
3936
opt_generic_arg_list(p, false);
4037
match p.current() {
4138
// NameRef<...> =
4239
T![=] => {
4340
p.bump_any();
4441
types::type_(p);
45-
46-
path_seg.abandon(p);
47-
path.abandon(p);
48-
path_ty.abandon(p);
4942
m.complete(p, ASSOC_TYPE_ARG);
5043
}
5144
// NameRef<...>:
5245
T![:] if !p.at(T![::]) => {
5346
generic_params::bounds(p);
54-
55-
path_seg.abandon(p);
56-
path.abandon(p);
57-
path_ty.abandon(p);
5847
m.complete(p, ASSOC_TYPE_ARG);
5948
}
6049
_ => {
61-
path_seg.complete(p, PATH_SEGMENT);
62-
let qual = path.complete(p, PATH);
63-
paths::type_path_for_qualifier(p, qual);
64-
path_ty.complete(p, PATH_TYPE);
65-
m.complete(p, TYPE_ARG);
50+
let m = m.complete(p, PATH_SEGMENT).precede(p).complete(p, PATH);
51+
let m = paths::type_path_for_qualifier(p, m);
52+
m.precede(p).complete(p, PATH_TYPE).precede(p).complete(p, TYPE_ARG);
6653
}
6754
}
6855
}

crates/parser/src/grammar/paths.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ pub(super) fn expr_path(p: &mut Parser) {
2727
path(p, Mode::Expr)
2828
}
2929

30-
pub(crate) fn type_path_for_qualifier(p: &mut Parser, qual: CompletedMarker) {
30+
pub(crate) fn type_path_for_qualifier(p: &mut Parser, qual: CompletedMarker) -> CompletedMarker {
3131
path_for_qualifier(p, Mode::Type, qual)
3232
}
3333

@@ -42,10 +42,10 @@ fn path(p: &mut Parser, mode: Mode) {
4242
let path = p.start();
4343
path_segment(p, mode, true);
4444
let qual = path.complete(p, PATH);
45-
path_for_qualifier(p, mode, qual)
45+
path_for_qualifier(p, mode, qual);
4646
}
4747

48-
fn path_for_qualifier(p: &mut Parser, mode: Mode, mut qual: CompletedMarker) {
48+
fn path_for_qualifier(p: &mut Parser, mode: Mode, mut qual: CompletedMarker) -> CompletedMarker {
4949
loop {
5050
let use_tree = matches!(p.nth(2), T![*] | T!['{']);
5151
if p.at(T![::]) && !use_tree {
@@ -55,7 +55,7 @@ fn path_for_qualifier(p: &mut Parser, mode: Mode, mut qual: CompletedMarker) {
5555
let path = path.complete(p, PATH);
5656
qual = path;
5757
} else {
58-
break;
58+
return qual;
5959
}
6060
}
6161
}

0 commit comments

Comments
 (0)