@@ -18,7 +18,6 @@ use crate::tokenstream::TokenTree;
18
18
19
19
use errors:: { Applicability , DiagnosticBuilder , Handler } ;
20
20
use rustc_data_structures:: fx:: FxHashMap ;
21
- use rustc_target:: spec:: abi:: Abi ;
22
21
use syntax_pos:: { Span , DUMMY_SP , MultiSpan } ;
23
22
use log:: debug;
24
23
@@ -192,62 +191,70 @@ macro_rules! gate_feature_post {
192
191
}
193
192
194
193
impl < ' a > PostExpansionVisitor < ' a > {
195
- fn check_abi ( & self , abi : Abi , span : Span ) {
196
- match abi {
197
- Abi :: RustIntrinsic => {
194
+ fn check_abi ( & self , abi : ast:: Abi ) {
195
+ let ast:: Abi { symbol, span } = abi;
196
+
197
+ match & * symbol. as_str ( ) {
198
+ // Stable
199
+ "Rust" |
200
+ "C" |
201
+ "cdecl" |
202
+ "stdcall" |
203
+ "fastcall" |
204
+ "aapcs" |
205
+ "win64" |
206
+ "sysv64" |
207
+ "system" => { }
208
+ "rust-intrinsic" => {
198
209
gate_feature_post ! ( & self , intrinsics, span,
199
210
"intrinsics are subject to change" ) ;
200
211
} ,
201
- Abi :: PlatformIntrinsic => {
212
+ "platform-intrinsic" => {
202
213
gate_feature_post ! ( & self , platform_intrinsics, span,
203
214
"platform intrinsics are experimental and possibly buggy" ) ;
204
215
} ,
205
- Abi :: Vectorcall => {
216
+ "vectorcall" => {
206
217
gate_feature_post ! ( & self , abi_vectorcall, span,
207
218
"vectorcall is experimental and subject to change" ) ;
208
219
} ,
209
- Abi :: Thiscall => {
220
+ "thiscall" => {
210
221
gate_feature_post ! ( & self , abi_thiscall, span,
211
222
"thiscall is experimental and subject to change" ) ;
212
223
} ,
213
- Abi :: RustCall => {
224
+ "rust-call" => {
214
225
gate_feature_post ! ( & self , unboxed_closures, span,
215
226
"rust-call ABI is subject to change" ) ;
216
227
} ,
217
- Abi :: PtxKernel => {
228
+ "ptx-kernel" => {
218
229
gate_feature_post ! ( & self , abi_ptx, span,
219
230
"PTX ABIs are experimental and subject to change" ) ;
220
231
} ,
221
- Abi :: Unadjusted => {
232
+ "unadjusted" => {
222
233
gate_feature_post ! ( & self , abi_unadjusted, span,
223
234
"unadjusted ABI is an implementation detail and perma-unstable" ) ;
224
235
} ,
225
- Abi :: Msp430Interrupt => {
236
+ "msp430-interrupt" => {
226
237
gate_feature_post ! ( & self , abi_msp430_interrupt, span,
227
238
"msp430-interrupt ABI is experimental and subject to change" ) ;
228
239
} ,
229
- Abi :: X86Interrupt => {
240
+ "x86-interrupt" => {
230
241
gate_feature_post ! ( & self , abi_x86_interrupt, span,
231
242
"x86-interrupt ABI is experimental and subject to change" ) ;
232
243
} ,
233
- Abi :: AmdGpuKernel => {
244
+ "amdgpu-kernel" => {
234
245
gate_feature_post ! ( & self , abi_amdgpu_kernel, span,
235
246
"amdgpu-kernel ABI is experimental and subject to change" ) ;
236
247
} ,
237
- Abi :: EfiApi => {
248
+ "efiapi" => {
238
249
gate_feature_post ! ( & self , abi_efiapi, span,
239
250
"efiapi ABI is experimental and subject to change" ) ;
240
251
} ,
241
- // Stable
242
- Abi :: Cdecl |
243
- Abi :: Stdcall |
244
- Abi :: Fastcall |
245
- Abi :: Aapcs |
246
- Abi :: Win64 |
247
- Abi :: SysV64 |
248
- Abi :: Rust |
249
- Abi :: C |
250
- Abi :: System => { }
252
+ abi => {
253
+ self . parse_sess . span_diagnostic . delay_span_bug (
254
+ span,
255
+ & format ! ( "unrecognized ABI not caught in lowering: {}" , abi) ,
256
+ )
257
+ }
251
258
}
252
259
}
253
260
@@ -373,7 +380,7 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
373
380
fn visit_item ( & mut self , i : & ' a ast:: Item ) {
374
381
match i. kind {
375
382
ast:: ItemKind :: ForeignMod ( ref foreign_module) => {
376
- self . check_abi ( foreign_module. abi , i . span ) ;
383
+ self . check_abi ( foreign_module. abi ) ;
377
384
}
378
385
379
386
ast:: ItemKind :: Fn ( ..) => {
@@ -503,7 +510,7 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
503
510
fn visit_ty ( & mut self , ty : & ' a ast:: Ty ) {
504
511
match ty. kind {
505
512
ast:: TyKind :: BareFn ( ref bare_fn_ty) => {
506
- self . check_abi ( bare_fn_ty. abi , ty . span ) ;
513
+ self . check_abi ( bare_fn_ty. abi ) ;
507
514
}
508
515
ast:: TyKind :: Never => {
509
516
gate_feature_post ! ( & self , never_type, ty. span,
@@ -597,7 +604,7 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
597
604
// Stability of const fn methods are covered in
598
605
// `visit_trait_item` and `visit_impl_item` below; this is
599
606
// because default methods don't pass through this point.
600
- self . check_abi ( header. abi , span ) ;
607
+ self . check_abi ( header. abi ) ;
601
608
}
602
609
603
610
if fn_decl. c_variadic ( ) {
@@ -631,7 +638,7 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
631
638
match ti. kind {
632
639
ast:: TraitItemKind :: Method ( ref sig, ref block) => {
633
640
if block. is_none ( ) {
634
- self . check_abi ( sig. header . abi , ti . span ) ;
641
+ self . check_abi ( sig. header . abi ) ;
635
642
}
636
643
if sig. decl . c_variadic ( ) {
637
644
gate_feature_post ! ( & self , c_variadic, ti. span,
0 commit comments