@@ -18,7 +18,6 @@ use crate::tokenstream::TokenTree;
1818
1919use errors:: { Applicability , DiagnosticBuilder , Handler } ;
2020use rustc_data_structures:: fx:: FxHashMap ;
21- use rustc_target:: spec:: abi:: Abi ;
2221use syntax_pos:: { Span , DUMMY_SP , MultiSpan } ;
2322use log:: debug;
2423
@@ -192,62 +191,70 @@ macro_rules! gate_feature_post {
192191}
193192
194193impl < ' 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" => {
198209 gate_feature_post ! ( & self , intrinsics, span,
199210 "intrinsics are subject to change" ) ;
200211 } ,
201- Abi :: PlatformIntrinsic => {
212+ "platform-intrinsic" => {
202213 gate_feature_post ! ( & self , platform_intrinsics, span,
203214 "platform intrinsics are experimental and possibly buggy" ) ;
204215 } ,
205- Abi :: Vectorcall => {
216+ "vectorcall" => {
206217 gate_feature_post ! ( & self , abi_vectorcall, span,
207218 "vectorcall is experimental and subject to change" ) ;
208219 } ,
209- Abi :: Thiscall => {
220+ "thiscall" => {
210221 gate_feature_post ! ( & self , abi_thiscall, span,
211222 "thiscall is experimental and subject to change" ) ;
212223 } ,
213- Abi :: RustCall => {
224+ "rust-call" => {
214225 gate_feature_post ! ( & self , unboxed_closures, span,
215226 "rust-call ABI is subject to change" ) ;
216227 } ,
217- Abi :: PtxKernel => {
228+ "ptx-kernel" => {
218229 gate_feature_post ! ( & self , abi_ptx, span,
219230 "PTX ABIs are experimental and subject to change" ) ;
220231 } ,
221- Abi :: Unadjusted => {
232+ "unadjusted" => {
222233 gate_feature_post ! ( & self , abi_unadjusted, span,
223234 "unadjusted ABI is an implementation detail and perma-unstable" ) ;
224235 } ,
225- Abi :: Msp430Interrupt => {
236+ "msp430-interrupt" => {
226237 gate_feature_post ! ( & self , abi_msp430_interrupt, span,
227238 "msp430-interrupt ABI is experimental and subject to change" ) ;
228239 } ,
229- Abi :: X86Interrupt => {
240+ "x86-interrupt" => {
230241 gate_feature_post ! ( & self , abi_x86_interrupt, span,
231242 "x86-interrupt ABI is experimental and subject to change" ) ;
232243 } ,
233- Abi :: AmdGpuKernel => {
244+ "amdgpu-kernel" => {
234245 gate_feature_post ! ( & self , abi_amdgpu_kernel, span,
235246 "amdgpu-kernel ABI is experimental and subject to change" ) ;
236247 } ,
237- Abi :: EfiApi => {
248+ "efiapi" => {
238249 gate_feature_post ! ( & self , abi_efiapi, span,
239250 "efiapi ABI is experimental and subject to change" ) ;
240251 } ,
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+ }
251258 }
252259 }
253260
@@ -373,7 +380,7 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
373380 fn visit_item ( & mut self , i : & ' a ast:: Item ) {
374381 match i. kind {
375382 ast:: ItemKind :: ForeignMod ( ref foreign_module) => {
376- self . check_abi ( foreign_module. abi , i . span ) ;
383+ self . check_abi ( foreign_module. abi ) ;
377384 }
378385
379386 ast:: ItemKind :: Fn ( ..) => {
@@ -503,7 +510,7 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
503510 fn visit_ty ( & mut self , ty : & ' a ast:: Ty ) {
504511 match ty. kind {
505512 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 ) ;
507514 }
508515 ast:: TyKind :: Never => {
509516 gate_feature_post ! ( & self , never_type, ty. span,
@@ -597,7 +604,7 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
597604 // Stability of const fn methods are covered in
598605 // `visit_trait_item` and `visit_impl_item` below; this is
599606 // because default methods don't pass through this point.
600- self . check_abi ( header. abi , span ) ;
607+ self . check_abi ( header. abi ) ;
601608 }
602609
603610 if fn_decl. c_variadic ( ) {
@@ -631,7 +638,7 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
631638 match ti. kind {
632639 ast:: TraitItemKind :: Method ( ref sig, ref block) => {
633640 if block. is_none ( ) {
634- self . check_abi ( sig. header . abi , ti . span ) ;
641+ self . check_abi ( sig. header . abi ) ;
635642 }
636643 if sig. decl . c_variadic ( ) {
637644 gate_feature_post ! ( & self , c_variadic, ti. span,
0 commit comments