diff options
| author | Lukas Wirth <me@lukaswirth.dev> | 2025-06-26 11:08:30 +0200 |
|---|---|---|
| committer | Lukas Wirth <me@lukaswirth.dev> | 2025-06-26 11:08:30 +0200 |
| commit | c190510d8c56e16ffaeff54674ed057859883a9b (patch) | |
| tree | 77c60e3f02908f9dbde6c6fda3f5778e1f4ebcaa /src/tools/rust-analyzer/crates/parser | |
| parent | 0af03671ec9e1db44c1e51a961789f0d140ec50c (diff) | |
| download | rust-c190510d8c56e16ffaeff54674ed057859883a9b.tar.gz rust-c190510d8c56e16ffaeff54674ed057859883a9b.zip | |
Parse new const trait syntax
Diffstat (limited to 'src/tools/rust-analyzer/crates/parser')
3 files changed, 9 insertions, 3 deletions
diff --git a/src/tools/rust-analyzer/crates/parser/src/grammar/generic_params.rs b/src/tools/rust-analyzer/crates/parser/src/grammar/generic_params.rs index ea5a3bc8593..55c5dc400b9 100644 --- a/src/tools/rust-analyzer/crates/parser/src/grammar/generic_params.rs +++ b/src/tools/rust-analyzer/crates/parser/src/grammar/generic_params.rs @@ -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] => { diff --git a/src/tools/rust-analyzer/crates/parser/test_data/parser/inline/ok/type_param_bounds.rast b/src/tools/rust-analyzer/crates/parser/test_data/parser/inline/ok/type_param_bounds.rast index dee860c2418..259637c898a 100644 --- a/src/tools/rust-analyzer/crates/parser/test_data/parser/inline/ok/type_param_bounds.rast +++ b/src/tools/rust-analyzer/crates/parser/test_data/parser/inline/ok/type_param_bounds.rast @@ -40,8 +40,9 @@ SOURCE_FILE PLUS "+" WHITESPACE " " TYPE_BOUND - TILDE "~" + L_BRACK "[" CONST_KW "const" + R_BRACK "]" WHITESPACE " " PATH_TYPE PATH diff --git a/src/tools/rust-analyzer/crates/parser/test_data/parser/inline/ok/type_param_bounds.rs b/src/tools/rust-analyzer/crates/parser/test_data/parser/inline/ok/type_param_bounds.rs index 5da3083b9c5..8f37af78e9f 100644 --- a/src/tools/rust-analyzer/crates/parser/test_data/parser/inline/ok/type_param_bounds.rs +++ b/src/tools/rust-analyzer/crates/parser/test_data/parser/inline/ok/type_param_bounds.rs @@ -1 +1 @@ -struct S<T: 'a + ?Sized + (Copy) + ~const Drop>; +struct S<T: 'a + ?Sized + (Copy) + [const] Drop>; |
