mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 04:44:57 +00:00
Move parsing a single TYPE_BOUND to a separate function
This commit is contained in:
parent
bfc2ac90c8
commit
e3f9d6555b
1 changed files with 26 additions and 19 deletions
|
@ -80,9 +80,19 @@ fn lifetime_bounds(p: &mut Parser) {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) fn bounds_without_colon(p: &mut Parser) {
|
pub(super) fn bounds_without_colon(p: &mut Parser) {
|
||||||
let outer = p.start();
|
let m = p.start();
|
||||||
loop {
|
|
||||||
let inner = p.start();
|
while type_bound(p) {
|
||||||
|
if !p.eat(PLUS) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
m.complete(p, TYPE_BOUND_LIST);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn type_bound(p: &mut Parser) -> bool {
|
||||||
|
let m = p.start();
|
||||||
let has_paren = p.eat(L_PAREN);
|
let has_paren = p.eat(L_PAREN);
|
||||||
p.eat(QUESTION);
|
p.eat(QUESTION);
|
||||||
match p.current() {
|
match p.current() {
|
||||||
|
@ -90,19 +100,16 @@ pub(super) fn bounds_without_colon(p: &mut Parser) {
|
||||||
FOR_KW => types::for_type(p),
|
FOR_KW => types::for_type(p),
|
||||||
_ if paths::is_path_start(p) => types::path_type_(p, false),
|
_ if paths::is_path_start(p) => types::path_type_(p, false),
|
||||||
_ => {
|
_ => {
|
||||||
inner.abandon(p);
|
m.abandon(p);
|
||||||
break;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if has_paren {
|
if has_paren {
|
||||||
p.expect(R_PAREN);
|
p.expect(R_PAREN);
|
||||||
}
|
}
|
||||||
inner.complete(p, TYPE_BOUND);
|
m.complete(p, TYPE_BOUND);
|
||||||
if !p.eat(PLUS) {
|
|
||||||
break;
|
true
|
||||||
}
|
|
||||||
}
|
|
||||||
outer.complete(p, TYPE_BOUND_LIST);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// test where_clause
|
// test where_clause
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue