@@ -8,21 +8,24 @@ mod tests;
8
8
#[ derive( PartialEq , Eq , PartialOrd , Ord , Hash , Clone , Copy , Debug ) ]
9
9
#[ derive( HashStable_Generic , Encodable , Decodable ) ]
10
10
pub enum Abi {
11
+ // N.B., this ordering MUST match the AbiDatas array below.
12
+ // (This is ensured by the test indices_are_correct().)
13
+
11
14
// Multiplatform / generic ABIs
12
15
//
13
16
// These ABIs come first because every time we add a new ABI, we
14
17
// have to re-bless all the hashing tests. These are used in many
15
18
// places, so giving them stable values reduces test churn. The
16
19
// specific values are meaningless.
17
- Rust ,
18
- C { unwind : bool } ,
20
+ Rust = 0 ,
21
+ C = 1 ,
19
22
20
23
// Single platform ABIs
21
24
Cdecl ,
22
- Stdcall { unwind : bool } ,
25
+ Stdcall ,
23
26
Fastcall ,
24
27
Vectorcall ,
25
- Thiscall { unwind : bool } ,
28
+ Thiscall ,
26
29
Aapcs ,
27
30
Win64 ,
28
31
SysV64 ,
@@ -36,7 +39,7 @@ pub enum Abi {
36
39
CCmseNonSecureCall ,
37
40
38
41
// Multiplatform / generic ABIs
39
- System { unwind : bool } ,
42
+ System ,
40
43
RustIntrinsic ,
41
44
RustCall ,
42
45
PlatformIntrinsic ,
@@ -58,16 +61,13 @@ pub struct AbiData {
58
61
const AbiDatas : & [ AbiData ] = & [
59
62
// Cross-platform ABIs
60
63
AbiData { abi : Abi :: Rust , name : "Rust" , generic : true } ,
61
- AbiData { abi : Abi :: C { unwind : false } , name : "C" , generic : true } ,
62
- AbiData { abi : Abi :: C { unwind : true } , name : "C-unwind" , generic : true } ,
64
+ AbiData { abi : Abi :: C , name : "C" , generic : true } ,
63
65
// Platform-specific ABIs
64
66
AbiData { abi : Abi :: Cdecl , name : "cdecl" , generic : false } ,
65
- AbiData { abi : Abi :: Stdcall { unwind : false } , name : "stdcall" , generic : false } ,
66
- AbiData { abi : Abi :: Stdcall { unwind : true } , name : "stdcall-unwind" , generic : false } ,
67
+ AbiData { abi : Abi :: Stdcall , name : "stdcall" , generic : false } ,
67
68
AbiData { abi : Abi :: Fastcall , name : "fastcall" , generic : false } ,
68
69
AbiData { abi : Abi :: Vectorcall , name : "vectorcall" , generic : false } ,
69
- AbiData { abi : Abi :: Thiscall { unwind : false } , name : "thiscall" , generic : false } ,
70
- AbiData { abi : Abi :: Thiscall { unwind : true } , name : "thiscall-unwind" , generic : false } ,
70
+ AbiData { abi : Abi :: Thiscall , name : "thiscall" , generic : false } ,
71
71
AbiData { abi : Abi :: Aapcs , name : "aapcs" , generic : false } ,
72
72
AbiData { abi : Abi :: Win64 , name : "win64" , generic : false } ,
73
73
AbiData { abi : Abi :: SysV64 , name : "sysv64" , generic : false } ,
@@ -84,8 +84,7 @@ const AbiDatas: &[AbiData] = &[
84
84
} ,
85
85
AbiData { abi : Abi :: CCmseNonSecureCall , name : "C-cmse-nonsecure-call" , generic : false } ,
86
86
// Cross-platform ABIs
87
- AbiData { abi : Abi :: System { unwind : false } , name : "system" , generic : true } ,
88
- AbiData { abi : Abi :: System { unwind : true } , name : "system-unwind" , generic : true } ,
87
+ AbiData { abi : Abi :: System , name : "system" , generic : true } ,
89
88
AbiData { abi : Abi :: RustIntrinsic , name : "rust-intrinsic" , generic : true } ,
90
89
AbiData { abi : Abi :: RustCall , name : "rust-call" , generic : true } ,
91
90
AbiData { abi : Abi :: PlatformIntrinsic , name : "platform-intrinsic" , generic : true } ,
@@ -104,41 +103,7 @@ pub fn all_names() -> Vec<&'static str> {
104
103
impl Abi {
105
104
#[ inline]
106
105
pub fn index ( self ) -> usize {
107
- // N.B., this ordering MUST match the AbiDatas array above.
108
- // (This is ensured by the test indices_are_correct().)
109
- use Abi :: * ;
110
- match self {
111
- // Cross-platform ABIs
112
- Rust => 0 ,
113
- C { unwind : false } => 1 ,
114
- C { unwind : true } => 2 ,
115
- // Platform-specific ABIs
116
- Cdecl => 3 ,
117
- Stdcall { unwind : false } => 4 ,
118
- Stdcall { unwind : true } => 5 ,
119
- Fastcall => 6 ,
120
- Vectorcall => 7 ,
121
- Thiscall { unwind : false } => 8 ,
122
- Thiscall { unwind : true } => 9 ,
123
- Aapcs => 10 ,
124
- Win64 => 11 ,
125
- SysV64 => 12 ,
126
- PtxKernel => 13 ,
127
- Msp430Interrupt => 14 ,
128
- X86Interrupt => 15 ,
129
- AmdGpuKernel => 16 ,
130
- EfiApi => 17 ,
131
- AvrInterrupt => 18 ,
132
- AvrNonBlockingInterrupt => 19 ,
133
- CCmseNonSecureCall => 20 ,
134
- // Cross-platform ABIs
135
- System { unwind : false } => 21 ,
136
- System { unwind : true } => 22 ,
137
- RustIntrinsic => 23 ,
138
- RustCall => 24 ,
139
- PlatformIntrinsic => 25 ,
140
- Unadjusted => 26 ,
141
- }
106
+ self as usize
142
107
}
143
108
144
109
#[ inline]
@@ -157,8 +122,6 @@ impl Abi {
157
122
158
123
impl fmt:: Display for Abi {
159
124
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
160
- match self {
161
- abi => write ! ( f, "\" {}\" " , abi. name( ) ) ,
162
- }
125
+ write ! ( f, "\" {}\" " , self . name( ) )
163
126
}
164
127
}
0 commit comments