Skip to content

Commit e647eb1

Browse files
authored
Merge pull request #1249 from lambinoo/I-91161-non-exhaustive-cast-documentation
#[non_exhaustive] on variant blocks cross-crate as casts
2 parents 8d28c49 + bce9bb3 commit e647eb1

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/attributes/type_system.md

+8
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,14 @@ match message {
127127
}
128128
```
129129

130+
It's also not allowed to cast non-exhaustive types from foreign crates.
131+
```rust, ignore
132+
use othercrate::NonExhaustiveEnum;
133+
134+
// Cannot cast a non-exhaustive enum outside of its defining crate.
135+
let _ = NonExhaustiveEnum::default() as u8;
136+
```
137+
130138
Non-exhaustive types are always considered inhabited in downstream crates.
131139

132140
[_MetaWord_]: ../attributes.md#meta-item-attribute-syntax

0 commit comments

Comments
 (0)