mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-02 14:51:48 +00:00
Add new TYPE_BOUND_LIST and TYPE_BOUND syntax kinds
These are now used when parsing type bounds. In addition parsing paths inside a bound now does not recursively parse paths, rather they are treated as separate bounds, separated by +.
This commit is contained in:
parent
9ebd14a14e
commit
23fdc562bf
5 changed files with 95 additions and 2 deletions
|
@ -2,6 +2,7 @@ use super::*;
|
|||
|
||||
// test trait_item
|
||||
// trait T<U>: Hash + Clone where U: Copy {}
|
||||
// trait X<U: Debug + Display>: Hash + Clone where U: Copy {}
|
||||
pub(super) fn trait_def(p: &mut Parser) {
|
||||
assert!(p.at(TRAIT_KW));
|
||||
p.bump();
|
||||
|
|
|
@ -80,22 +80,29 @@ fn lifetime_bounds(p: &mut Parser) {
|
|||
}
|
||||
|
||||
pub(super) fn bounds_without_colon(p: &mut Parser) {
|
||||
let outer = p.start();
|
||||
loop {
|
||||
let inner = p.start();
|
||||
let has_paren = p.eat(L_PAREN);
|
||||
p.eat(QUESTION);
|
||||
match p.current() {
|
||||
LIFETIME => p.bump(),
|
||||
FOR_KW => types::for_type(p),
|
||||
_ if paths::is_path_start(p) => types::path_type(p),
|
||||
_ => break,
|
||||
_ if paths::is_path_start(p) => types::path_type_(p, false),
|
||||
_ => {
|
||||
inner.abandon(p);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if has_paren {
|
||||
p.expect(R_PAREN);
|
||||
}
|
||||
inner.complete(p, TYPE_BOUND);
|
||||
if !p.eat(PLUS) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
outer.complete(p, TYPE_BOUND_LIST);
|
||||
}
|
||||
|
||||
// test where_clause
|
||||
|
|
|
@ -228,6 +228,8 @@ pub enum SyntaxKind {
|
|||
PARAM,
|
||||
SELF_PARAM,
|
||||
ARG_LIST,
|
||||
TYPE_BOUND,
|
||||
TYPE_BOUND_LIST,
|
||||
}
|
||||
use self::SyntaxKind::*;
|
||||
|
||||
|
@ -567,6 +569,8 @@ impl SyntaxKind {
|
|||
PARAM => &SyntaxInfo { name: "PARAM" },
|
||||
SELF_PARAM => &SyntaxInfo { name: "SELF_PARAM" },
|
||||
ARG_LIST => &SyntaxInfo { name: "ARG_LIST" },
|
||||
TYPE_BOUND => &SyntaxInfo { name: "TYPE_BOUND" },
|
||||
TYPE_BOUND_LIST => &SyntaxInfo { name: "TYPE_BOUND_LIST" },
|
||||
TOMBSTONE => &SyntaxInfo { name: "TOMBSTONE" },
|
||||
EOF => &SyntaxInfo { name: "EOF" },
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue