@@ -3,6 +3,7 @@ use lint::BuiltinLintDiag;
3
3
use rustc_ast:: ptr:: P ;
4
4
use rustc_ast:: token:: { self , Delimiter } ;
5
5
use rustc_ast:: tokenstream:: TokenStream ;
6
+ use rustc_ast:: AsmMacro ;
6
7
use rustc_data_structures:: fx:: { FxHashMap , FxIndexMap } ;
7
8
use rustc_errors:: PResult ;
8
9
use rustc_expand:: base:: * ;
@@ -59,35 +60,6 @@ fn eat_operand_keyword<'a>(
59
60
}
60
61
}
61
62
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
-
91
63
fn parse_args < ' a > (
92
64
ecx : & ExtCtxt < ' a > ,
93
65
sp : Span ,
@@ -530,6 +502,7 @@ fn parse_reg<'a>(
530
502
531
503
fn expand_preparsed_asm (
532
504
ecx : & mut ExtCtxt < ' _ > ,
505
+ asm_macro : AsmMacro ,
533
506
args : AsmArgs ,
534
507
) -> ExpandResult < Result < ast:: InlineAsm , ErrorGuaranteed > , ( ) > {
535
508
let mut template = vec ! [ ] ;
@@ -820,6 +793,7 @@ fn expand_preparsed_asm(
820
793
}
821
794
822
795
ExpandResult :: Ready ( Ok ( ast:: InlineAsm {
796
+ asm_macro,
823
797
template,
824
798
template_strs : template_strs. into_boxed_slice ( ) ,
825
799
operands : args. operands ,
@@ -836,7 +810,7 @@ pub(super) fn expand_asm<'cx>(
836
810
) -> MacroExpanderResult < ' cx > {
837
811
ExpandResult :: Ready ( match parse_args ( ecx, sp, tts, AsmMacro :: Asm ) {
838
812
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 {
840
814
return ExpandResult :: Retry ( ( ) ) ;
841
815
} ;
842
816
let expr = match mac {
@@ -865,7 +839,8 @@ pub(super) fn expand_global_asm<'cx>(
865
839
) -> MacroExpanderResult < ' cx > {
866
840
ExpandResult :: Ready ( match parse_args ( ecx, sp, tts, AsmMacro :: GlobalAsm ) {
867
841
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 {
869
844
return ExpandResult :: Retry ( ( ) ) ;
870
845
} ;
871
846
match mac {
@@ -899,7 +874,8 @@ pub(super) fn expand_naked_asm<'cx>(
899
874
) -> MacroExpanderResult < ' cx > {
900
875
ExpandResult :: Ready ( match parse_args ( ecx, sp, tts, AsmMacro :: NakedAsm ) {
901
876
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 {
903
879
return ExpandResult :: Retry ( ( ) ) ;
904
880
} ;
905
881
let expr = match mac {
0 commit comments