feat(syntax): RTN in bounds

Limited syntactic support for experimental return type notations.
https://github.com/rust-lang/rust/issues/109417
This commit is contained in:
tamasfe 2023-04-01 15:26:03 +02:00
parent ffb04ae32d
commit 0b9c0c5088
No known key found for this signature in database
GPG key ID: 2373047D27CA4E47
8 changed files with 103 additions and 2 deletions

View file

@ -76,6 +76,7 @@ fn generic_arg(p: &mut Parser<'_>) -> bool {
}
}
}
IDENT if p.nth(1) == T!['('] && p.nth_at(2, T![..]) => return_type_arg(p),
_ if p.at_ts(types::TYPE_FIRST) => type_arg(p),
_ => return false,
}
@ -139,3 +140,20 @@ fn type_arg(p: &mut Parser<'_>) {
types::type_(p);
m.complete(p, TYPE_ARG);
}
// test return_type_arg
// type T = S<foo(..): Send>;
pub(super) fn return_type_arg(p: &mut Parser<'_>) {
let m = p.start();
p.expect(IDENT);
p.expect(T!['(']);
p.expect(T![..]);
p.expect(T![')']);
if !p.at(T![:]) {
p.error("expected :");
m.abandon(p);
return;
}
generic_params::bounds(p);
m.complete(p, RETURN_TYPE_ARG);
}