]> git.lizzy.rs Git - rust.git/blob - tests/ui/conditional-compilation/cfg_accessible-not_sure.rs
Rollup merge of #106797 - FawazTirmizi:dev/issues/104284, r=bjorn3
[rust.git] / tests / ui / conditional-compilation / cfg_accessible-not_sure.rs
1 // revisions: edition2015 edition2021
2 // [edition2015]compile-flags: --edition=2015
3 // [edition2021]compile-flags: --edition=2021
4
5 #![feature(extern_types)]
6 #![feature(cfg_accessible)]
7
8 // Struct::unresolved - error
9
10 struct Struct {
11     existing: u8,
12 }
13
14 #[cfg_accessible(Struct::existing)] //~ ERROR not sure
15 const A: bool = true;
16 #[cfg_accessible(Struct::unresolved)] //~ ERROR not sure
17 const B: bool = true;
18
19 // Union::unresolved - error
20
21 struct Union {
22     existing: u8,
23 }
24
25 #[cfg_accessible(Union::existing)] //~ ERROR not sure
26 const A: bool = true;
27 #[cfg_accessible(Union::unresolved)] //~ ERROR not sure
28 const B: bool = true;
29
30 // Enum::unresolved - error
31
32 enum Enum {
33     Existing { existing: u8 },
34 }
35
36 #[cfg_accessible(Enum::Existing::existing)] //~ ERROR not sure
37 const A: bool = true;
38 #[cfg_accessible(Enum::Existing::unresolved)] //~ ERROR not sure
39 const B: bool = true;
40 #[cfg_accessible(Enum::unresolved)] //~ ERROR not sure
41 const C: bool = true;
42
43 // Trait::unresolved - false or error, depending on edition (error if you can write Trait::foo
44 // instead of <dyn Trait>::foo for methods like impl dyn Trait { fn foo() {} })
45
46 trait Trait {}
47 impl dyn Trait { fn existing() {} }
48
49 // FIXME: Should be an error for edition > 2015
50 #[cfg_accessible(Trait::existing)] //~ ERROR not sure
51 const A: bool = true;
52 #[cfg_accessible(Trait::unresolved)] //~ ERROR not sure
53 const B: bool = true;
54
55 // TypeAlias::unresolved - error
56
57 type TypeAlias = Struct;
58
59 #[cfg_accessible(TypeAlias::existing)] //~ ERROR not sure
60 const A: bool = true;
61 #[cfg_accessible(TypeAlias::unresolved)] //~ ERROR not sure
62 const B: bool = true;
63
64 // ForeignType::unresolved - error
65
66 extern {
67     type ForeignType;
68 }
69
70 #[cfg_accessible(ForeignType::unresolved)] //~ ERROR not sure
71 const A: bool = true;
72
73 // AssocType::unresolved - error
74
75 trait AssocType {
76     type AssocType;
77 }
78
79 #[cfg_accessible(AssocType::AssocType::unresolved)] //~ ERROR not sure
80 const A: bool = true;
81
82 // PrimitiveType::unresolved - error
83
84 #[cfg_accessible(u8::unresolved)] //~ ERROR not sure
85 const A: bool = true;
86 #[cfg_accessible(u8::is_ascii)] //~ ERROR not sure
87 const B: bool = true;
88
89 fn main() {}