Parse new const trait syntax

This commit is contained in:
Lukas Wirth 2025-06-26 11:08:30 +02:00
parent db07723fe9
commit 5924b38e3d
6 changed files with 19 additions and 9 deletions

View file

@ -122,7 +122,7 @@ fn lifetime_bounds(p: &mut Parser<'_>) {
}
// test type_param_bounds
// struct S<T: 'a + ?Sized + (Copy) + ~const Drop>;
// struct S<T: 'a + ?Sized + (Copy) + [const] Drop>;
pub(super) fn bounds(p: &mut Parser<'_>) {
p.expect(T![:]);
bounds_without_colon(p);
@ -187,6 +187,11 @@ fn type_bound(p: &mut Parser<'_>) -> bool {
p.bump_any();
p.expect(T![const]);
}
T!['['] => {
p.bump_any();
p.expect(T![const]);
p.expect(T![']']);
}
// test const_trait_bound
// const fn foo(_: impl const Trait) {}
T![const] => {

View file

@ -40,8 +40,9 @@ SOURCE_FILE
PLUS "+"
WHITESPACE " "
TYPE_BOUND
TILDE "~"
L_BRACK "["
CONST_KW "const"
R_BRACK "]"
WHITESPACE " "
PATH_TYPE
PATH

View file

@ -1 +1 @@
struct S<T: 'a + ?Sized + (Copy) + ~const Drop>;
struct S<T: 'a + ?Sized + (Copy) + [const] Drop>;