]> git.lizzy.rs Git - rust.git/blob - tests/ui/option_option.rs
Merge pull request #2381 from HMPerson1/remove_is_unit_expr
[rust.git] / tests / ui / option_option.rs
1 fn input(_: Option<Option<u8>>) {
2 }
3
4 fn output() -> Option<Option<u8>> {
5     None
6 }
7
8 fn output_nested() -> Vec<Option<Option<u8>>> {
9     vec![None]
10 }
11
12 // The lint only generates one warning for this
13 fn output_nested_nested() -> Option<Option<Option<u8>>> {
14     None
15 }
16
17 struct Struct {
18     x: Option<Option<u8>>,
19 }
20
21 impl Struct {
22     fn struct_fn() -> Option<Option<u8>> {
23         None
24     }
25 }
26
27 trait Trait {
28     fn trait_fn() -> Option<Option<u8>>;
29 }
30
31 enum Enum {
32     Tuple(Option<Option<u8>>),
33     Struct{x: Option<Option<u8>>},
34 }
35
36 // The lint allows this
37 type OptionOption = Option<Option<u32>>;
38
39 // The lint allows this
40 fn output_type_alias() -> OptionOption {
41     None
42 }
43
44 // The line allows this
45 impl Trait for Struct {
46     fn trait_fn() -> Option<Option<u8>> {
47         None
48     }
49 }
50
51 fn main() {
52     input(None);
53     output();
54     output_nested();
55
56     // The lint allows this
57     let local: Option<Option<u8>> = None;
58
59     // The lint allows this
60     let expr = Some(Some(true));
61 }
62
63