@@ -65,80 +65,89 @@ impl ExprCollector<'_> {
65
65
continue ;
66
66
}
67
67
ast:: AsmPiece :: AsmOperandNamed ( op) => {
68
- if let Some ( name) = op. name ( ) {
69
- let sym = Symbol :: intern ( & name. text ( ) ) ;
70
- named_args. insert ( sym . clone ( ) , slot) ;
71
- named_pos. insert ( slot, sym ) ;
68
+ let name = op. name ( ) . map ( |name| Symbol :: intern ( & name . text ( ) ) ) ;
69
+ if let Some ( name ) = & name {
70
+ named_args. insert ( name . clone ( ) , slot) ;
71
+ named_pos. insert ( slot, name . clone ( ) ) ;
72
72
}
73
73
let Some ( op) = op. asm_operand ( ) else { continue } ;
74
- match op {
75
- ast:: AsmOperand :: AsmRegOperand ( op) => {
76
- let Some ( dir_spec) = op. asm_dir_spec ( ) else {
77
- continue ;
78
- } ;
79
- let Some ( reg) = lower_reg ( op. asm_reg_spec ( ) ) else {
80
- continue ;
81
- } ;
82
- if dir_spec. in_token ( ) . is_some ( ) {
83
- let expr = self . collect_expr_opt (
84
- op. asm_operand_expr ( ) . and_then ( |it| it. in_expr ( ) ) ,
85
- ) ;
86
- AsmOperand :: In { reg, expr }
87
- } else if dir_spec. out_token ( ) . is_some ( ) {
88
- let expr = self . collect_expr_opt (
89
- op. asm_operand_expr ( ) . and_then ( |it| it. in_expr ( ) ) ,
90
- ) ;
91
- AsmOperand :: Out { reg, expr : Some ( expr) , late : false }
92
- } else if dir_spec. lateout_token ( ) . is_some ( ) {
93
- let expr = self . collect_expr_opt (
94
- op. asm_operand_expr ( ) . and_then ( |it| it. in_expr ( ) ) ,
95
- ) ;
96
- AsmOperand :: Out { reg, expr : Some ( expr) , late : true }
97
- } else if dir_spec. inout_token ( ) . is_some ( ) {
98
- let Some ( op_expr) = op. asm_operand_expr ( ) else { continue } ;
99
- let in_expr = self . collect_expr_opt ( op_expr. in_expr ( ) ) ;
100
- let out_expr = op_expr. out_expr ( ) . map ( |it| self . collect_expr ( it) ) ;
101
- match out_expr {
102
- Some ( out_expr) => AsmOperand :: SplitInOut {
103
- reg,
104
- in_expr,
105
- out_expr : Some ( out_expr) ,
106
- late : false ,
107
- } ,
108
- None => AsmOperand :: InOut { reg, expr : in_expr, late : false } ,
109
- }
110
- } else if dir_spec. inlateout_token ( ) . is_some ( ) {
111
- let Some ( op_expr) = op. asm_operand_expr ( ) else { continue } ;
112
- let in_expr = self . collect_expr_opt ( op_expr. in_expr ( ) ) ;
113
- let out_expr = op_expr. out_expr ( ) . map ( |it| self . collect_expr ( it) ) ;
114
- match out_expr {
115
- Some ( out_expr) => AsmOperand :: SplitInOut {
116
- reg,
117
- in_expr,
118
- out_expr : Some ( out_expr) ,
119
- late : false ,
120
- } ,
121
- None => AsmOperand :: InOut { reg, expr : in_expr, late : false } ,
74
+ (
75
+ name. map ( Name :: new_symbol_root) ,
76
+ match op {
77
+ ast:: AsmOperand :: AsmRegOperand ( op) => {
78
+ let Some ( dir_spec) = op. asm_dir_spec ( ) else {
79
+ continue ;
80
+ } ;
81
+ let Some ( reg) = lower_reg ( op. asm_reg_spec ( ) ) else {
82
+ continue ;
83
+ } ;
84
+ if dir_spec. in_token ( ) . is_some ( ) {
85
+ let expr = self . collect_expr_opt (
86
+ op. asm_operand_expr ( ) . and_then ( |it| it. in_expr ( ) ) ,
87
+ ) ;
88
+ AsmOperand :: In { reg, expr }
89
+ } else if dir_spec. out_token ( ) . is_some ( ) {
90
+ let expr = self . collect_expr_opt (
91
+ op. asm_operand_expr ( ) . and_then ( |it| it. in_expr ( ) ) ,
92
+ ) ;
93
+ AsmOperand :: Out { reg, expr : Some ( expr) , late : false }
94
+ } else if dir_spec. lateout_token ( ) . is_some ( ) {
95
+ let expr = self . collect_expr_opt (
96
+ op. asm_operand_expr ( ) . and_then ( |it| it. in_expr ( ) ) ,
97
+ ) ;
98
+ AsmOperand :: Out { reg, expr : Some ( expr) , late : true }
99
+ } else if dir_spec. inout_token ( ) . is_some ( ) {
100
+ let Some ( op_expr) = op. asm_operand_expr ( ) else { continue } ;
101
+ let in_expr = self . collect_expr_opt ( op_expr. in_expr ( ) ) ;
102
+ let out_expr =
103
+ op_expr. out_expr ( ) . map ( |it| self . collect_expr ( it) ) ;
104
+ match out_expr {
105
+ Some ( out_expr) => AsmOperand :: SplitInOut {
106
+ reg,
107
+ in_expr,
108
+ out_expr : Some ( out_expr) ,
109
+ late : false ,
110
+ } ,
111
+ None => {
112
+ AsmOperand :: InOut { reg, expr : in_expr, late : false }
113
+ }
114
+ }
115
+ } else if dir_spec. inlateout_token ( ) . is_some ( ) {
116
+ let Some ( op_expr) = op. asm_operand_expr ( ) else { continue } ;
117
+ let in_expr = self . collect_expr_opt ( op_expr. in_expr ( ) ) ;
118
+ let out_expr =
119
+ op_expr. out_expr ( ) . map ( |it| self . collect_expr ( it) ) ;
120
+ match out_expr {
121
+ Some ( out_expr) => AsmOperand :: SplitInOut {
122
+ reg,
123
+ in_expr,
124
+ out_expr : Some ( out_expr) ,
125
+ late : false ,
126
+ } ,
127
+ None => {
128
+ AsmOperand :: InOut { reg, expr : in_expr, late : false }
129
+ }
130
+ }
131
+ } else {
132
+ continue ;
122
133
}
123
- } else {
124
- continue ;
125
134
}
126
- }
127
- ast :: AsmOperand :: AsmLabel ( l ) => {
128
- AsmOperand :: Label ( self . collect_block_opt ( l . block_expr ( ) ) )
129
- }
130
- ast :: AsmOperand :: AsmConst ( c ) => {
131
- AsmOperand :: Const ( self . collect_expr_opt ( c . expr ( ) ) )
132
- }
133
- ast :: AsmOperand :: AsmSym ( s ) => {
134
- let Some ( path) =
135
- s . path ( ) . and_then ( |p| self . expander . parse_path ( self . db , p ) )
136
- else {
137
- continue ;
138
- } ;
139
- AsmOperand :: Sym ( path )
140
- }
141
- }
135
+ ast :: AsmOperand :: AsmLabel ( l ) => {
136
+ AsmOperand :: Label ( self . collect_block_opt ( l . block_expr ( ) ) )
137
+ }
138
+ ast :: AsmOperand :: AsmConst ( c ) => {
139
+ AsmOperand :: Const ( self . collect_expr_opt ( c . expr ( ) ) )
140
+ }
141
+ ast :: AsmOperand :: AsmSym ( s ) => {
142
+ let Some ( path ) =
143
+ s . path ( ) . and_then ( |p| self . expander . parse_path ( self . db , p ) )
144
+ else {
145
+ continue ;
146
+ } ;
147
+ AsmOperand :: Sym ( path )
148
+ }
149
+ } ,
150
+ )
142
151
}
143
152
} ;
144
153
operands. push ( op) ;
@@ -204,7 +213,7 @@ impl ExprCollector<'_> {
204
213
rustc_parse_format:: Piece :: NextArgument ( arg) => {
205
214
// let span = arg_spans.next();
206
215
207
- let ( operand_idx, name ) = match arg. position {
216
+ let ( operand_idx, _name ) = match arg. position {
208
217
rustc_parse_format:: ArgumentIs ( idx)
209
218
| rustc_parse_format:: ArgumentImplicitlyIs ( idx) => {
210
219
if idx >= operands. len ( )
@@ -227,7 +236,7 @@ impl ExprCollector<'_> {
227
236
228
237
if let Some ( operand_idx) = operand_idx {
229
238
if let Some ( position_span) = to_span ( arg. position_span ) {
230
- mappings. push ( ( position_span, operand_idx, name ) ) ;
239
+ mappings. push ( ( position_span, operand_idx) ) ;
231
240
}
232
241
}
233
242
}
0 commit comments