Skip to content

Commit

Permalink
Merge pull request #1249 from lambinoo/I-91161-non-exhaustive-cast-do…
Browse files Browse the repository at this point in the history
…cumentation

#[non_exhaustive] on variant blocks cross-crate as casts
  • Loading branch information
ehuss committed Aug 16, 2022
2 parents 8d28c49 + bce9bb3 commit e647eb1
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/attributes/type_system.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,14 @@ match message {
}
```

It's also not allowed to cast non-exhaustive types from foreign crates.
```rust, ignore
use othercrate::NonExhaustiveEnum;
// Cannot cast a non-exhaustive enum outside of its defining crate.
let _ = NonExhaustiveEnum::default() as u8;
```

Non-exhaustive types are always considered inhabited in downstream crates.

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

0 comments on commit e647eb1

Please sign in to comment.