@@ -3,13 +3,13 @@ use rustc_ast::visit::{self, AssocCtxt, FnCtxt, FnKind, Visitor};
3
3
use rustc_ast:: { AssocConstraint , AssocConstraintKind , NodeId } ;
4
4
use rustc_ast:: { PatKind , RangeEnd , VariantData } ;
5
5
use rustc_errors:: { struct_span_err, Applicability , StashKey } ;
6
- use rustc_feature:: Features ;
7
- use rustc_feature:: { AttributeGate , BuiltinAttribute , BUILTIN_ATTRIBUTE_MAP } ;
8
- use rustc_session:: parse:: { feature_err, feature_warn} ;
6
+ use rustc_feature:: { AttributeGate , BuiltinAttribute , Features , GateIssue , BUILTIN_ATTRIBUTE_MAP } ;
7
+ use rustc_session:: parse:: { feature_err, feature_err_issue, feature_warn} ;
9
8
use rustc_session:: Session ;
10
9
use rustc_span:: source_map:: Spanned ;
11
10
use rustc_span:: symbol:: sym;
12
11
use rustc_span:: Span ;
12
+ use rustc_target:: spec:: abi;
13
13
14
14
macro_rules! gate_feature_fn {
15
15
( $visitor: expr, $has_feature: expr, $span: expr, $name: expr, $explain: expr, $help: expr) => { {
@@ -84,210 +84,26 @@ impl<'a> PostExpansionVisitor<'a> {
84
84
}
85
85
}
86
86
87
- match symbol_unescaped. as_str ( ) {
88
- // Stable
89
- "Rust" | "C" | "cdecl" | "stdcall" | "fastcall" | "aapcs" | "win64" | "sysv64"
90
- | "system" => { }
91
- "rust-intrinsic" => {
92
- gate_feature_post ! ( & self , intrinsics, span, "intrinsics are subject to change" ) ;
93
- }
94
- "platform-intrinsic" => {
95
- gate_feature_post ! (
96
- & self ,
97
- platform_intrinsics,
98
- span,
99
- "platform intrinsics are experimental and possibly buggy"
100
- ) ;
101
- }
102
- "vectorcall" => {
103
- gate_feature_post ! (
104
- & self ,
105
- abi_vectorcall,
106
- span,
107
- "vectorcall is experimental and subject to change"
108
- ) ;
109
- }
110
- "thiscall" => {
111
- gate_feature_post ! (
112
- & self ,
113
- abi_thiscall,
114
- span,
115
- "thiscall is experimental and subject to change"
116
- ) ;
117
- }
118
- "rust-call" => {
119
- gate_feature_post ! (
120
- & self ,
121
- unboxed_closures,
122
- span,
123
- "rust-call ABI is subject to change"
124
- ) ;
125
- }
126
- "rust-cold" => {
127
- gate_feature_post ! (
128
- & self ,
129
- rust_cold_cc,
130
- span,
131
- "rust-cold is experimental and subject to change"
132
- ) ;
133
- }
134
- "ptx-kernel" => {
135
- gate_feature_post ! (
136
- & self ,
137
- abi_ptx,
138
- span,
139
- "PTX ABIs are experimental and subject to change"
140
- ) ;
141
- }
142
- "unadjusted" => {
143
- gate_feature_post ! (
144
- & self ,
145
- abi_unadjusted,
146
- span,
147
- "unadjusted ABI is an implementation detail and perma-unstable"
148
- ) ;
149
- }
150
- "msp430-interrupt" => {
151
- gate_feature_post ! (
152
- & self ,
153
- abi_msp430_interrupt,
154
- span,
155
- "msp430-interrupt ABI is experimental and subject to change"
156
- ) ;
157
- }
158
- "x86-interrupt" => {
159
- gate_feature_post ! (
160
- & self ,
161
- abi_x86_interrupt,
162
- span,
163
- "x86-interrupt ABI is experimental and subject to change"
164
- ) ;
165
- }
166
- "amdgpu-kernel" => {
167
- gate_feature_post ! (
168
- & self ,
169
- abi_amdgpu_kernel,
170
- span,
171
- "amdgpu-kernel ABI is experimental and subject to change"
172
- ) ;
173
- }
174
- "avr-interrupt" | "avr-non-blocking-interrupt" => {
175
- gate_feature_post ! (
176
- & self ,
177
- abi_avr_interrupt,
178
- span,
179
- "avr-interrupt and avr-non-blocking-interrupt ABIs are experimental and subject to change"
180
- ) ;
181
- }
182
- "efiapi" => {
183
- gate_feature_post ! (
184
- & self ,
185
- abi_efiapi,
186
- span,
187
- "efiapi ABI is experimental and subject to change"
188
- ) ;
189
- }
190
- "C-cmse-nonsecure-call" => {
191
- gate_feature_post ! (
192
- & self ,
193
- abi_c_cmse_nonsecure_call,
194
- span,
195
- "C-cmse-nonsecure-call ABI is experimental and subject to change"
196
- ) ;
197
- }
198
- "C-unwind" => {
199
- gate_feature_post ! (
200
- & self ,
201
- c_unwind,
202
- span,
203
- "C-unwind ABI is experimental and subject to change"
204
- ) ;
205
- }
206
- "stdcall-unwind" => {
207
- gate_feature_post ! (
208
- & self ,
209
- c_unwind,
87
+ match abi:: is_enabled ( & self . features , span, symbol_unescaped. as_str ( ) ) {
88
+ Ok ( ( ) ) => ( ) ,
89
+ Err ( abi:: AbiDisabled :: Unstable { feature, explain } ) => {
90
+ feature_err_issue (
91
+ & self . sess . parse_sess ,
92
+ feature,
210
93
span,
211
- "stdcall-unwind ABI is experimental and subject to change"
212
- ) ;
213
- }
214
- "system-unwind" => {
215
- gate_feature_post ! (
216
- & self ,
217
- c_unwind,
218
- span,
219
- "system-unwind ABI is experimental and subject to change"
220
- ) ;
221
- }
222
- "thiscall-unwind" => {
223
- gate_feature_post ! (
224
- & self ,
225
- c_unwind,
226
- span,
227
- "thiscall-unwind ABI is experimental and subject to change"
228
- ) ;
229
- }
230
- "cdecl-unwind" => {
231
- gate_feature_post ! (
232
- & self ,
233
- c_unwind,
234
- span,
235
- "cdecl-unwind ABI is experimental and subject to change"
236
- ) ;
237
- }
238
- "fastcall-unwind" => {
239
- gate_feature_post ! (
240
- & self ,
241
- c_unwind,
242
- span,
243
- "fastcall-unwind ABI is experimental and subject to change"
244
- ) ;
245
- }
246
- "vectorcall-unwind" => {
247
- gate_feature_post ! (
248
- & self ,
249
- c_unwind,
250
- span,
251
- "vectorcall-unwind ABI is experimental and subject to change"
252
- ) ;
253
- }
254
- "aapcs-unwind" => {
255
- gate_feature_post ! (
256
- & self ,
257
- c_unwind,
258
- span,
259
- "aapcs-unwind ABI is experimental and subject to change"
260
- ) ;
261
- }
262
- "win64-unwind" => {
263
- gate_feature_post ! (
264
- & self ,
265
- c_unwind,
266
- span,
267
- "win64-unwind ABI is experimental and subject to change"
268
- ) ;
269
- }
270
- "sysv64-unwind" => {
271
- gate_feature_post ! (
272
- & self ,
273
- c_unwind,
274
- span,
275
- "sysv64-unwind ABI is experimental and subject to change"
276
- ) ;
277
- }
278
- "wasm" => {
279
- gate_feature_post ! (
280
- & self ,
281
- wasm_abi,
282
- span,
283
- "wasm ABI is experimental and subject to change"
284
- ) ;
94
+ GateIssue :: Language ,
95
+ explain,
96
+ )
97
+ . emit ( ) ;
285
98
}
286
- abi => {
99
+ Err ( abi:: AbiDisabled :: Unrecognized ) => {
287
100
if self . sess . opts . pretty . map_or ( true , |ppm| ppm. needs_hir ( ) ) {
288
101
self . sess . parse_sess . span_diagnostic . delay_span_bug (
289
102
span,
290
- & format ! ( "unrecognized ABI not caught in lowering: {}" , abi) ,
103
+ & format ! (
104
+ "unrecognized ABI not caught in lowering: {}" ,
105
+ symbol_unescaped. as_str( )
106
+ ) ,
291
107
) ;
292
108
}
293
109
}
0 commit comments