Skip to content

Commit a5eb504

Browse files
committed
Add forward reference for non_exhaustive exception
The normative rule about destructuring and capturing does not itself state the exception for `non_exhaustive` enums. That exception follows below. Let's add an admonition to link down to it so it's not missed. It's not great having this duplication; it'd be better if we weren't restating this fact twice. But it's not clear what to do about this. The first statement is making a broader statement about tuples, structs, and single-variant enums. The section that follows below is focused on discriminants. We'll think about this more later.
1 parent e5f4c8b commit a5eb504

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/types/closure.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,9 @@ c();
205205
r[type.closure.capture.precision.wildcard.destructuring]
206206
Destructuring tuples, structs, and single-variant enums does not, by itself, cause a read or the place to be captured.
207207

208+
> [!NOTE]
209+
> Enums marked with [`#[non_exhaustive]`][attributes.type-system.non_exhaustive] from other crates are always treated as having multiple variants. See *[type.closure.capture.precision.discriminants.non_exhaustive]*.
210+
208211
```rust,no_run
209212
struct S; // A non-`Copy` type.
210213

0 commit comments

Comments
 (0)