Skip to content

Commit 78243f9

Browse files
committed
Merge branch '2024-10_edition-2024-reservations'
2 parents 8c3b726 + fc7e2af commit 78243f9

File tree

6 files changed

+58
-13
lines changed

6 files changed

+58
-13
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(

src/testcases.rs

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,11 @@ pub const LONGLIST: &[&str] = [
146146
"@=",
147147
"~=",
148148

149+
"##",
150+
"###",
151+
"####",
152+
"#####",
153+
149154
"x ➖ y",
150155

151156

@@ -488,11 +493,25 @@ pub const LONGLIST: &[&str] = [
488493
"'r#super",
489494
"'r#Self",
490495

491-
//// Possible future forms
492-
493-
// See rfc3593
494-
r##" #"xxx"# "##,
496+
//// Forms related to the "Guarded string literals" 2024 reservations
497+
" #\"xxx\"# ",
498+
" ##\"xxx\"## ",
499+
" ###\"xxx\"### ",
500+
" ####\"xxx\"#### ",
501+
" #####\"xxx\"##### ",
502+
" #\"xxx\" ",
503+
" ##\"xxx\"# ",
504+
" #\"xxx",
505+
" #\"\"# ",
506+
" ##\"\"## ",
507+
" #\"\" ",
508+
" ##\"\"# ",
509+
" #\"",
510+
" ###############################################################################################################################################################################################################################################################\"aaa\"############################################################################################################################################################################################################################################################### ",
511+
" ################################################################################################################################################################################################################################################################\"aaa\"################################################################################################################################################################################################################################################################ ",
512+
"£#\"\"#",
495513
"#'xxx'#",
514+
"#''#",
496515

497516

498517
//// Lifetime/label non-ascii

writeup/introduction.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,28 +11,28 @@ and a framework for comparing its output to `rustc`'s.
1111

1212
### Rust language version
1313

14-
This document describes Rust version 1.81, with the addition of
15-
[pr126452] (Raw syntax and reserved prefixes for lifetimes and labels),
16-
which is targeted for Rust 1.83.
14+
This document describes Rust version 1.83 (as it is expected to be, as of 2024-10-12).
1715

18-
That means it describes `c""` literals, but not
16+
That means it describes raw lifetimes/labels and the additional reservations in the 2024 edition, but not
1917

2018
- [rfc3349] (*Mixed UTF-8 literals*)
21-
- [rfc3593] (reserving `#"..."#` string literals)
2219

23-
Other statements in this document are intended to be true as of September 2024.
20+
Other statements in this document are intended to be true as of October 2024.
2421

2522
The comparable implementation is intended to be compiled against (and compared against)\
2623
`rustc 1.83.0-nightly (1bc403daa 2024-10-11)`
2724

2825

2926
### Editions
3027

31-
This document describes the editions supported by Rust 1.80:
28+
This document describes the editions supported by Rust 1.83:
3229
- 2015
3330
- 2018
3431
- 2021
3532

33+
and the expected changes for the in-development edition:
34+
- 2024
35+
3636
There are no differences in lexing behaviour between the 2015 and 2018 editions.
3737

3838
In the comparable implementation, "2015" is used to refer to the common behaviour of Rust 2015 and Rust 2018.

writeup/rationale.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
### Pretokenising
44

5-
The main difference between the model described in this document and the way the Reference (as of Rust 1.81) describes lexing is the split into pretokenisation and reprocessing.
5+
The main difference between the model described in this document and the way the Reference (as of Rust 1.83) describes lexing is the split into pretokenisation and reprocessing.
66

77
There are a number of forms which are errors at lexing time, even though in principle they could be analysed as multiple tokens.
88

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

writeup/rustc_oddities.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ See [rfc2457].
88

99
But this doesn't happen for lifetimes or labels, so `'Kelvin` and `'Kelvin` are different as lifetimes or labels.
1010

11-
For example, [this][playground-lifetime] compiles without warning in Rust 1.81, while [this][playground-ident] doesn't.
11+
For example, [this][playground-lifetime] compiles without warning in Rust 1.83, while [this][playground-ident] doesn't.
1212

1313
In this writeup, the <var>represented identifier</var> attribute of `Identifier` and `RawIdentifier` fine-grained tokens is in NFC,
1414
and the <var>name</var> attribute of `LifetimeOrLabel` and `RawLifetimeOrLabel` tokens isn't.

0 commit comments

Comments
 (0)