Skip to content

Commit de4ff1e

Browse files
committed
Add the ReservedHashForms2024 rule
This implements the edition 2024 reservations: #" ## See rust-lang/rust#123951 (comment)
1 parent 59a2a01 commit de4ff1e

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

src/lexlucid/pretokenisation/pretokenisation_rules.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ enum RuleName {
2929
LineComment,
3030
BlockComment,
3131
UnterminatedBlockComment,
32+
ReservedHashForms2024,
3233
Punctuation,
3334
SingleQuotedLiteral,
3435
RawLifetimeOrLabel2021,
@@ -108,6 +109,7 @@ const RULES_FOR_EDITION_2024: &[RuleName] = [
108109
RuleName::LineComment,
109110
RuleName::BlockComment,
110111
RuleName::UnterminatedBlockComment,
112+
RuleName::ReservedHashForms2024,
111113
RuleName::Punctuation,
112114
RuleName::SingleQuotedLiteral,
113115
RuleName::RawLifetimeOrLabel2021,
@@ -177,6 +179,14 @@ fn make_named_rules() -> BTreeMap<RuleName, Rule> {
177179
/ \*
178180
"##)),
179181

182+
// Reserved hashes (Rust 2024)
183+
(RuleName::ReservedHashForms2024,
184+
Rule::new_regex(
185+
|_| PretokenData::Reserved, r##"\A
186+
\#
187+
( \# | " )
188+
"##)),
189+
180190
// Punctuation
181191
(RuleName::Punctuation,
182192
Rule::new_regex(

writeup/rules.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
[Line comment](#line-comment)\
55
[Block comment](#block-comment)\
66
[Unterminated block comment](#unterminated-block-comment)\
7+
[Reserved hash forms (Rust 2024)](#reserved-hash-forms-rust-2024)\
78
[Punctuation](#punctuation)\
89
[Single-quoted literal](#single-quoted-literal)\
910
[Raw lifetime or label (Rust 2021)](#raw-lifetime-or-label-rust-2021)\
@@ -139,6 +140,21 @@ when `character_sequence` represents an iterator over the sequence of characters
139140
(none)
140141

141142

143+
#### Reserved hash forms (Rust 2024) { .rule }
144+
145+
##### Pattern
146+
```
147+
\#
148+
( \# | " )
149+
```
150+
151+
##### Pretoken kind
152+
`Reserved`
153+
154+
##### Attributes
155+
(none)
156+
157+
142158
#### Punctuation { .rule }
143159

144160
##### Pattern

0 commit comments

Comments
 (0)