Skip to content

Commit 077c86d

Browse files
committed
writeup: update for raw lifetimes/labels and reserved lifetime/label prefixes
This corresponds to the changes made in rust-lang/rust#126452
1 parent ab32672 commit 077c86d

File tree

5 files changed

+57
-1
lines changed

5 files changed

+57
-1
lines changed

writeup/fine_grained_tokens.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Each fine-grained token has a <dfn>kind</dfn>, and possibly also some attributes
1515
| `Identifier` | <var>represented identifier</var> |
1616
| `RawIdentifier` | <var>represented identifier</var> |
1717
| `LifetimeOrLabel` | <var>name</var> |
18+
| `RawLifetimeOrLabel` | <var>name</var> |
1819
| `CharacterLiteral` | <var>represented character</var>, <var>suffix</var> |
1920
| `ByteLiteral` | <var>represented byte</var>, <var>suffix</var> |
2021
| `StringLiteral` | <var>represented string</var>, <var>suffix</var> |

writeup/pretokens.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Each pretoken has a *kind*, and possibly also some attributes, as described in t
1414
| `Identifier` | <var>identifier</var> |
1515
| `RawIdentifier` | <var>identifier</var> |
1616
| `LifetimeOrLabel` | <var>name</var> |
17+
| `RawLifetimeOrLabel` | <var>name</var> |
1718
| `SingleQuoteLiteral` | <var>prefix</var>, <var>literal content</var>, <var>suffix</var> |
1819
| `DoubleQuoteLiteral` | <var>prefix</var>, <var>literal content</var>, <var>suffix</var> |
1920
| `RawDoubleQuoteLiteral` | <var>prefix</var>, <var>literal content</var>, <var>suffix</var> |

writeup/reprocessing_cases.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
[`Identifier`](#identifier)\
99
[`RawIdentifier`](#rawidentifier)\
1010
[`LifetimeOrLabel`](#lifetimeorlabel)\
11+
[`RawLifetimeOrLabel`](#rawlifetimeorlabel)\
1112
[`SingleQuoteLiteral`](#singlequoteliteral)\
1213
[`DoubleQuoteLiteral`](#doublequoteliteral)\
1314
[`RawDoubleQuoteLiteral`](#rawdoublequoteliteral)\
@@ -163,6 +164,20 @@ A `LifetimeOrLabel` pretoken is always accepted.
163164
> See [NFC normalisation for lifetime/label].
164165
165166

167+
#### `RawLifetimeOrLabel` { .rcase }
168+
169+
Fine-grained token kind produced:
170+
`RawLifetimeOrLabel`
171+
172+
A `RawLifetimeOrLabel` pretoken is always accepted.
173+
174+
##### Attributes
175+
<var>name</var>: copied
176+
177+
> Note that the name is not NFC-normalised.
178+
> See [NFC normalisation for lifetime/label].
179+
180+
166181
#### `SingleQuoteLiteral` { .rcase }
167182

168183
The pretokeniser guarantees the pretoken's <var>prefix</var> attribute is one of the following:

writeup/rules.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
[Unterminated block comment](#unterminated-block-comment)\
77
[Punctuation](#punctuation)\
88
[Single-quoted literal](#single-quoted-literal)\
9+
[Raw lifetime or label (Rust 2021)](#raw-lifetime-or-label-rust-2021)\
10+
[Reserved lifetime or label prefix (Rust 2021)](#reserved-lifetime-or-label-prefix-rust-2021)\
911
[Lifetime or label](#lifetime-or-label)\
1012
[Double-quoted non-raw literal (Rust 2015 and 2018)](#double-quoted-non-raw-literal-rust-2015-and-2018)\
1113
[Double-quoted non-raw literal (Rust 2021)](#double-quoted-non-raw-literal-rust-2021)\
@@ -190,6 +192,43 @@ when `character_sequence` represents an iterator over the sequence of characters
190192
| <var>suffix</var> | captured characters |
191193

192194

195+
#### Raw lifetime or label (Rust 2021) { .rule }
196+
197+
##### Pattern
198+
```
199+
' r \#
200+
(?<name>
201+
[ \p{XID_Start} _ ]
202+
\p{XID_Continue} *
203+
)
204+
```
205+
206+
##### Pretoken kind
207+
`RawLifetimeOrLabel`
208+
209+
##### Attributes
210+
| | |
211+
|:----------------|:--------------------|
212+
| <var>name</var> | captured characters |
213+
214+
215+
#### Reserved lifetime or label prefix (Rust 2021) { .rule }
216+
217+
##### Pattern
218+
```
219+
'
220+
[ \p{XID_Start} _ ]
221+
\p{XID_Continue} *
222+
\#
223+
```
224+
225+
##### Pretoken kind
226+
`Reserved`
227+
228+
##### Attributes
229+
(none)
230+
231+
193232
#### Lifetime or label { .rule }
194233

195234
##### Pattern

writeup/rustc_oddities.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ But this doesn't happen for lifetimes or labels, so `'Kelvin` and `'Kelvin` ar
1111
For example, [this][playground-lifetime] compiles without warning in Rust 1.80, 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,
14-
and the <var>name</var> attribute of `LifetimeOrLabel` tokens isn't.
14+
and the <var>name</var> attribute of `LifetimeOrLabel` and `RawLifetimeOrLabel` tokens isn't.
1515

1616
I think this behaviour is a promising candidate for provoking the
1717
"Wait...that's what we currently do? We should fix that."

0 commit comments

Comments
 (0)