]> git.proxmox.com Git - rustc.git/blob - tests/ui/deriving/deriving-default-enum.rs
New upstream version 1.68.2+dfsg1
[rustc.git] / tests / ui / deriving / deriving-default-enum.rs
1 // run-pass
2
3 // nb: does not impl Default
4 #[derive(Debug, PartialEq)]
5 struct NotDefault;
6
7 #[derive(Debug, Default, PartialEq)]
8 enum Foo {
9 #[default]
10 Alpha,
11 #[allow(dead_code)]
12 Beta(NotDefault),
13 }
14
15 // #[default] on a generic enum does not add `Default` bounds to the type params.
16 #[derive(Default)]
17 enum MyOption<T> {
18 #[default]
19 None,
20 #[allow(dead_code)]
21 Some(T),
22 }
23
24 fn main() {
25 assert_eq!(Foo::default(), Foo::Alpha);
26 assert!(matches!(MyOption::<NotDefault>::default(), MyOption::None));
27 }