1
1
use std:: collections:: HashSet ;
2
2
3
+ mod builtins_configure {
4
+ include ! ( "../configure.rs" ) ;
5
+ }
6
+
3
7
/// Features to enable
4
- #[ derive( Debug , PartialEq , Eq , Hash ) ]
8
+ #[ derive( Clone , Copy , Debug , PartialEq , Eq , Hash ) ]
5
9
enum Feature {
6
10
NoSysF128 ,
7
11
NoSysF128IntConvert ,
@@ -10,8 +14,16 @@ enum Feature {
10
14
NoSysF16F128Convert ,
11
15
}
12
16
13
- mod builtins_configure {
14
- include ! ( "../configure.rs" ) ;
17
+ impl Feature {
18
+ fn implies ( self ) -> & ' static [ Self ] {
19
+ match self {
20
+ Self :: NoSysF128 => [ Self :: NoSysF128IntConvert , Self :: NoSysF16F128Convert ] . as_slice ( ) ,
21
+ Self :: NoSysF128IntConvert => [ ] . as_slice ( ) ,
22
+ Self :: NoSysF16 => [ Self :: NoSysF16F64Convert , Self :: NoSysF16F128Convert ] . as_slice ( ) ,
23
+ Self :: NoSysF16F64Convert => [ ] . as_slice ( ) ,
24
+ Self :: NoSysF16F128Convert => [ ] . as_slice ( ) ,
25
+ }
26
+ }
15
27
}
16
28
17
29
fn main ( ) {
@@ -40,8 +52,6 @@ fn main() {
40
52
|| target. arch == "powerpc64"
41
53
{
42
54
features. insert ( Feature :: NoSysF128 ) ;
43
- features. insert ( Feature :: NoSysF128IntConvert ) ;
44
- features. insert ( Feature :: NoSysF16F128Convert ) ;
45
55
}
46
56
47
57
if target. arch == "x86" {
@@ -67,15 +77,22 @@ fn main() {
67
77
|| target. arch == "wasm64"
68
78
{
69
79
features. insert ( Feature :: NoSysF16 ) ;
70
- features. insert ( Feature :: NoSysF16F64Convert ) ;
71
- features. insert ( Feature :: NoSysF16F128Convert ) ;
72
80
}
73
81
74
82
// These platforms are missing either `__extendhfdf2` or `__truncdfhf2`.
75
83
if target. vendor == "apple" || target. os == "windows" {
76
84
features. insert ( Feature :: NoSysF16F64Convert ) ;
77
85
}
78
86
87
+ // Add implied features. Collection is required for borrows.
88
+ features. extend (
89
+ features
90
+ . iter ( )
91
+ . flat_map ( |x| x. implies ( ) )
92
+ . copied ( )
93
+ . collect :: < Vec < _ > > ( ) ,
94
+ ) ;
95
+
79
96
for feature in features {
80
97
let ( name, warning) = match feature {
81
98
Feature :: NoSysF128 => ( "no-sys-f128" , "using apfloat fallback for f128" ) ,
0 commit comments