Skip to content

Commit

Permalink
writeup: update for raw lifetimes/labels and reserved lifetime/label …
Browse files Browse the repository at this point in the history
…prefixes

This corresponds to the changes made in
rust-lang/rust#126452
  • Loading branch information
mattheww committed Oct 12, 2024
1 parent ab32672 commit 077c86d
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 1 deletion.
1 change: 1 addition & 0 deletions writeup/fine_grained_tokens.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Each fine-grained token has a <dfn>kind</dfn>, and possibly also some attributes
| `Identifier` | <var>represented identifier</var> |
| `RawIdentifier` | <var>represented identifier</var> |
| `LifetimeOrLabel` | <var>name</var> |
| `RawLifetimeOrLabel` | <var>name</var> |
| `CharacterLiteral` | <var>represented character</var>, <var>suffix</var> |
| `ByteLiteral` | <var>represented byte</var>, <var>suffix</var> |
| `StringLiteral` | <var>represented string</var>, <var>suffix</var> |
Expand Down
1 change: 1 addition & 0 deletions writeup/pretokens.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Each pretoken has a *kind*, and possibly also some attributes, as described in t
| `Identifier` | <var>identifier</var> |
| `RawIdentifier` | <var>identifier</var> |
| `LifetimeOrLabel` | <var>name</var> |
| `RawLifetimeOrLabel` | <var>name</var> |
| `SingleQuoteLiteral` | <var>prefix</var>, <var>literal content</var>, <var>suffix</var> |
| `DoubleQuoteLiteral` | <var>prefix</var>, <var>literal content</var>, <var>suffix</var> |
| `RawDoubleQuoteLiteral` | <var>prefix</var>, <var>literal content</var>, <var>suffix</var> |
Expand Down
15 changes: 15 additions & 0 deletions writeup/reprocessing_cases.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
[`Identifier`](#identifier)\
[`RawIdentifier`](#rawidentifier)\
[`LifetimeOrLabel`](#lifetimeorlabel)\
[`RawLifetimeOrLabel`](#rawlifetimeorlabel)\
[`SingleQuoteLiteral`](#singlequoteliteral)\
[`DoubleQuoteLiteral`](#doublequoteliteral)\
[`RawDoubleQuoteLiteral`](#rawdoublequoteliteral)\
Expand Down Expand Up @@ -163,6 +164,20 @@ A `LifetimeOrLabel` pretoken is always accepted.
> See [NFC normalisation for lifetime/label].

#### `RawLifetimeOrLabel` { .rcase }

Fine-grained token kind produced:
`RawLifetimeOrLabel`

A `RawLifetimeOrLabel` pretoken is always accepted.

##### Attributes
<var>name</var>: copied

> Note that the name is not NFC-normalised.
> See [NFC normalisation for lifetime/label].

#### `SingleQuoteLiteral` { .rcase }

The pretokeniser guarantees the pretoken's <var>prefix</var> attribute is one of the following:
Expand Down
39 changes: 39 additions & 0 deletions writeup/rules.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
[Unterminated block comment](#unterminated-block-comment)\
[Punctuation](#punctuation)\
[Single-quoted literal](#single-quoted-literal)\
[Raw lifetime or label (Rust 2021)](#raw-lifetime-or-label-rust-2021)\
[Reserved lifetime or label prefix (Rust 2021)](#reserved-lifetime-or-label-prefix-rust-2021)\
[Lifetime or label](#lifetime-or-label)\
[Double-quoted non-raw literal (Rust 2015 and 2018)](#double-quoted-non-raw-literal-rust-2015-and-2018)\
[Double-quoted non-raw literal (Rust 2021)](#double-quoted-non-raw-literal-rust-2021)\
Expand Down Expand Up @@ -190,6 +192,43 @@ when `character_sequence` represents an iterator over the sequence of characters
| <var>suffix</var> | captured characters |


#### Raw lifetime or label (Rust 2021) { .rule }

##### Pattern
```
' r \#
(?<name>
[ \p{XID_Start} _ ]
\p{XID_Continue} *
)
```

##### Pretoken kind
`RawLifetimeOrLabel`

##### Attributes
| | |
|:----------------|:--------------------|
| <var>name</var> | captured characters |


#### Reserved lifetime or label prefix (Rust 2021) { .rule }

##### Pattern
```
'
[ \p{XID_Start} _ ]
\p{XID_Continue} *
\#
```

##### Pretoken kind
`Reserved`

##### Attributes
(none)


#### Lifetime or label { .rule }

##### Pattern
Expand Down
2 changes: 1 addition & 1 deletion writeup/rustc_oddities.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ But this doesn't happen for lifetimes or labels, so `'Kelvin` and `'Kelvin` ar
For example, [this][playground-lifetime] compiles without warning in Rust 1.80, while [this][playground-ident] doesn't.

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

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

0 comments on commit 077c86d

Please sign in to comment.