Skip to content

Commit 93b3775

Browse files
committed
Make ' a forbidden follower for the RawLifetimeOrLabel rule
This mirrors the changes from rust-lang/rust#132341 which have been backported to appear in Rust 1.83
1 parent c271568 commit 93b3775

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

src/lexlucid/pretokenisation/pretokenisation_rules.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -224,9 +224,9 @@ fn make_named_rules() -> BTreeMap<RuleName, Rule> {
224224
)
225225
"##)),
226226

227-
// Lifetime or label
227+
// Raw lifetime or label
228228
(RuleName::RawLifetimeOrLabel2021,
229-
Rule::new_regex(
229+
Rule::new_regex_with_forbidden_follower(
230230
|cp| PretokenData::RawLifetimeOrLabel {
231231
name: cp["name"].into(),
232232
}, r##"\A
@@ -235,7 +235,8 @@ fn make_named_rules() -> BTreeMap<RuleName, Rule> {
235235
[ \p{XID_Start} _ ]
236236
\p{XID_Continue} *
237237
)
238-
"##)),
238+
"##,
239+
|c| c == '\'')),
239240

240241
// Reserved lifetime or label prefix
241242
(RuleName::ReservedLifetimeOrLabelPrefix2021,

writeup/rationale.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ rather than trying to write non-overlapping lexer rules as the Reference does.
3131
The model described in this document uses one-character lookahead (beyond the token which will be matched) in the prelexing step, in two cases:
3232

3333
- the lifetime-or-label rule, to prevent `'ab'c'` being analysed as `'ab` followed by `'c`
34+
(and similarly for the raw-lifetime-or-label rule)
3435
- the rule for float literals ending in `.`, to make sure that `1.a` is analysed as `1` `.` `a` rather than `1.` `a`
3536

3637
I think some kind of lookahead is unavoidable in these cases.

writeup/rules.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,10 @@ when `character_sequence` represents an iterator over the sequence of characters
219219
)
220220
```
221221

222+
Forbidden followers:
223+
224+
- The character <b>'</b>
225+
222226
##### Pretoken kind
223227
`RawLifetimeOrLabel`
224228

0 commit comments

Comments
 (0)