mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-30 22:01:37 +00:00
Parse lifetime bounds in lifetime param into TypeBoundList
This mainly aids in error recovery but also makes it a bit easier to handle lifetime resolution. While doing so it also came apparent that we were not actually lowering lifetime outlives relationships within lifetime parameter declaration bounds, so this fixes that.
This commit is contained in:
parent
df7ab62a06
commit
f3d7415bd6
14 changed files with 125 additions and 85 deletions
|
@ -56,7 +56,7 @@ fn generic_param(p: &mut Parser<'_>, m: Marker) -> bool {
|
|||
fn lifetime_param(p: &mut Parser<'_>, m: Marker) {
|
||||
assert!(p.at(LIFETIME_IDENT));
|
||||
lifetime(p);
|
||||
if p.at(T![:]) {
|
||||
if p.eat(T![:]) {
|
||||
lifetime_bounds(p);
|
||||
}
|
||||
m.complete(p, LIFETIME_PARAM);
|
||||
|
@ -106,14 +106,19 @@ fn const_param(p: &mut Parser<'_>, m: Marker) {
|
|||
}
|
||||
|
||||
fn lifetime_bounds(p: &mut Parser<'_>) {
|
||||
assert!(p.at(T![:]));
|
||||
p.bump(T![:]);
|
||||
while p.at(LIFETIME_IDENT) {
|
||||
lifetime(p);
|
||||
let marker = p.start();
|
||||
while {
|
||||
if !matches!(p.current(), LIFETIME_IDENT | T![>] | T![,]) {
|
||||
p.error("expected lifetime");
|
||||
}
|
||||
|
||||
type_bound(p)
|
||||
} {
|
||||
if !p.eat(T![+]) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
marker.complete(p, TYPE_BOUND_LIST);
|
||||
}
|
||||
|
||||
// test type_param_bounds
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue