From 3036b18c92b0ed77a36ae29d556efc57f2a37b47 Mon Sep 17 00:00:00 2001 From: Lamb Date: Sun, 14 Aug 2022 14:15:35 +0200 Subject: [PATCH 1/2] cannot cast non-exhaustive enum from foreign crate --- src/attributes/type_system.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/attributes/type_system.md b/src/attributes/type_system.md index d15836fb0..7f08557ca 100644 --- a/src/attributes/type_system.md +++ b/src/attributes/type_system.md @@ -127,6 +127,14 @@ match message { } ``` +It's also impossible 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 From bce9bb30bae071776a22ccdb09af1a78bb3aeb63 Mon Sep 17 00:00:00 2001 From: "Farya L. M" <57440804+lambinoo@users.noreply.github.com> Date: Tue, 16 Aug 2022 19:54:12 +0200 Subject: [PATCH 2/2] Update type_system.md --- src/attributes/type_system.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/attributes/type_system.md b/src/attributes/type_system.md index 7f08557ca..f378c4d1d 100644 --- a/src/attributes/type_system.md +++ b/src/attributes/type_system.md @@ -127,7 +127,7 @@ match message { } ``` -It's also impossible to cast non-exhaustive types from foreign crates. +It's also not allowed to cast non-exhaustive types from foreign crates. ```rust, ignore use othercrate::NonExhaustiveEnum;