File tree Expand file tree Collapse file tree 2 files changed +29
-0
lines changed
src/test/ui/rfc-2008-non-exhaustive Expand file tree Collapse file tree 2 files changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -30,3 +30,15 @@ pub enum VariantNonExhaustive {
3030pub enum NonExhaustiveSingleVariant {
3131 A ( bool ) ,
3232}
33+
34+ #[ repr( u8 ) ]
35+ pub enum FieldLessWithNonExhaustiveVariant {
36+ A ,
37+ B ,
38+ #[ non_exhaustive]
39+ C ,
40+ }
41+
42+ impl Default for FieldLessWithNonExhaustiveVariant {
43+ fn default ( ) -> Self { Self :: A }
44+ }
Original file line number Diff line number Diff line change 1+ // aux-build:enums.rs
2+ // run-pass
3+
4+ extern crate enums;
5+
6+ use enums:: FieldLessWithNonExhaustiveVariant ;
7+
8+ fn main ( ) {
9+ let e = FieldLessWithNonExhaustiveVariant :: default ( ) ;
10+ // FIXME: https://github.com/rust-lang/rust/issues/91161
11+ // This `as` cast *should* be an error, since it would fail
12+ // if the non-exhaustive variant got fields. But today it
13+ // doesn't. The fix for that will update this test to
14+ // show an error (and not be run-pass any more).
15+ let d = e as u8 ;
16+ assert_eq ! ( d, 0 ) ;
17+ }
You can’t perform that action at this time.
0 commit comments