@@ -7,7 +7,6 @@ use rustc::ty::layout::HasTyCtxt;
7
7
use rustc_target:: abi:: { Variants , VariantIdx } ;
8
8
use crate :: traits:: * ;
9
9
10
- use std:: fmt;
11
10
use syntax_pos:: { DUMMY_SP , BytePos , Span } ;
12
11
use syntax:: symbol:: kw;
13
12
@@ -92,29 +91,6 @@ impl<D> DebugScope<D> {
92
91
}
93
92
}
94
93
95
- // HACK(eddyb) helpers for `set_var_name` calls, move elsewhere?
96
- enum Either < T , U > {
97
- Left ( T ) ,
98
- Right ( U ) ,
99
- }
100
-
101
- impl < T : fmt:: Display , U : fmt:: Display > fmt:: Display for Either < T , U > {
102
- fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
103
- match self {
104
- Either :: Left ( x) => x. fmt ( f) ,
105
- Either :: Right ( x) => x. fmt ( f) ,
106
- }
107
- }
108
- }
109
-
110
- struct DisplayViaDebug < T > ( T ) ;
111
-
112
- impl < T : fmt:: Debug > fmt:: Display for DisplayViaDebug < T > {
113
- fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
114
- self . 0 . fmt ( f)
115
- }
116
- }
117
-
118
94
impl < ' a , ' tcx , Bx : BuilderMethods < ' a , ' tcx > > FunctionCx < ' a , ' tcx , Bx > {
119
95
pub fn set_debug_loc (
120
96
& mut self ,
@@ -207,26 +183,26 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
207
183
208
184
let local_ref = & self . locals [ local] ;
209
185
210
- {
186
+ if !bx . sess ( ) . fewer_names ( ) {
211
187
let name = match name {
212
- Some ( name) if name != kw:: Invalid => Either :: Left ( name) ,
213
- _ => Either :: Right ( DisplayViaDebug ( local) ) ,
188
+ Some ( name) if name != kw:: Invalid => name. to_string ( ) ,
189
+ _ => format ! ( "{:?}" , local) ,
214
190
} ;
215
191
match local_ref {
216
192
LocalRef :: Place ( place) |
217
193
LocalRef :: UnsizedPlace ( place) => {
218
- bx. set_var_name ( place. llval , name) ;
194
+ bx. set_var_name ( place. llval , & name) ;
219
195
}
220
196
LocalRef :: Operand ( Some ( operand) ) => match operand. val {
221
197
OperandValue :: Ref ( x, ..) |
222
198
OperandValue :: Immediate ( x) => {
223
- bx. set_var_name ( x, name) ;
199
+ bx. set_var_name ( x, & name) ;
224
200
}
225
201
OperandValue :: Pair ( a, b) => {
226
202
// FIXME(eddyb) these are scalar components,
227
203
// maybe extract the high-level fields?
228
- bx. set_var_name ( a, format_args ! ( "{} .0", name ) ) ;
229
- bx. set_var_name ( b, format_args ! ( "{} .1", name ) ) ;
204
+ bx. set_var_name ( a, & ( name . clone ( ) + " .0") ) ;
205
+ bx. set_var_name ( b, & ( name + " .1") ) ;
230
206
}
231
207
}
232
208
LocalRef :: Operand ( None ) => { }
0 commit comments