@@ -3,6 +3,7 @@ use lint::BuiltinLintDiag;
33use rustc_ast:: ptr:: P ;
44use rustc_ast:: token:: { self , Delimiter } ;
55use rustc_ast:: tokenstream:: TokenStream ;
6+ use rustc_ast:: AsmMacro ;
67use rustc_data_structures:: fx:: { FxHashMap , FxIndexMap } ;
78use rustc_errors:: PResult ;
89use rustc_expand:: base:: * ;
@@ -59,35 +60,6 @@ fn eat_operand_keyword<'a>(
5960 }
6061}
6162
62- // Public for rustfmt consumption.
63- #[ derive( Copy , Clone ) ]
64- pub enum AsmMacro {
65- /// The `asm!` macro
66- Asm ,
67- /// The `global_asm!` macro
68- GlobalAsm ,
69- /// The `naked_asm!` macro
70- NakedAsm ,
71- }
72-
73- impl AsmMacro {
74- const fn macro_name ( & self ) -> & ' static str {
75- match self {
76- AsmMacro :: Asm => "asm" ,
77- AsmMacro :: GlobalAsm => "global_asm" ,
78- AsmMacro :: NakedAsm => "naked_asm" ,
79- }
80- }
81-
82- const fn is_supported_option ( & self , option : ast:: InlineAsmOptions ) -> bool {
83- match self {
84- AsmMacro :: Asm => true ,
85- AsmMacro :: GlobalAsm => ast:: InlineAsmOptions :: GLOBAL_OPTIONS . contains ( option) ,
86- AsmMacro :: NakedAsm => ast:: InlineAsmOptions :: NAKED_OPTIONS . contains ( option) ,
87- }
88- }
89- }
90-
9163fn parse_args < ' a > (
9264 ecx : & ExtCtxt < ' a > ,
9365 sp : Span ,
@@ -530,6 +502,7 @@ fn parse_reg<'a>(
530502
531503fn expand_preparsed_asm (
532504 ecx : & mut ExtCtxt < ' _ > ,
505+ asm_macro : AsmMacro ,
533506 args : AsmArgs ,
534507) -> ExpandResult < Result < ast:: InlineAsm , ErrorGuaranteed > , ( ) > {
535508 let mut template = vec ! [ ] ;
@@ -820,6 +793,7 @@ fn expand_preparsed_asm(
820793 }
821794
822795 ExpandResult :: Ready ( Ok ( ast:: InlineAsm {
796+ asm_macro,
823797 template,
824798 template_strs : template_strs. into_boxed_slice ( ) ,
825799 operands : args. operands ,
@@ -836,7 +810,7 @@ pub(super) fn expand_asm<'cx>(
836810) -> MacroExpanderResult < ' cx > {
837811 ExpandResult :: Ready ( match parse_args ( ecx, sp, tts, AsmMacro :: Asm ) {
838812 Ok ( args) => {
839- let ExpandResult :: Ready ( mac) = expand_preparsed_asm ( ecx, args) else {
813+ let ExpandResult :: Ready ( mac) = expand_preparsed_asm ( ecx, AsmMacro :: Asm , args) else {
840814 return ExpandResult :: Retry ( ( ) ) ;
841815 } ;
842816 let expr = match mac {
@@ -865,7 +839,8 @@ pub(super) fn expand_global_asm<'cx>(
865839) -> MacroExpanderResult < ' cx > {
866840 ExpandResult :: Ready ( match parse_args ( ecx, sp, tts, AsmMacro :: GlobalAsm ) {
867841 Ok ( args) => {
868- let ExpandResult :: Ready ( mac) = expand_preparsed_asm ( ecx, args) else {
842+ let ExpandResult :: Ready ( mac) = expand_preparsed_asm ( ecx, AsmMacro :: GlobalAsm , args)
843+ else {
869844 return ExpandResult :: Retry ( ( ) ) ;
870845 } ;
871846 match mac {
@@ -899,7 +874,8 @@ pub(super) fn expand_naked_asm<'cx>(
899874) -> MacroExpanderResult < ' cx > {
900875 ExpandResult :: Ready ( match parse_args ( ecx, sp, tts, AsmMacro :: NakedAsm ) {
901876 Ok ( args) => {
902- let ExpandResult :: Ready ( mac) = expand_preparsed_asm ( ecx, args) else {
877+ let ExpandResult :: Ready ( mac) = expand_preparsed_asm ( ecx, AsmMacro :: NakedAsm , args)
878+ else {
903879 return ExpandResult :: Retry ( ( ) ) ;
904880 } ;
905881 let expr = match mac {
0 commit comments