@@ -7,7 +7,6 @@ use rustc::ty::layout::HasTyCtxt;
77use rustc_target:: abi:: { Variants , VariantIdx } ;
88use crate :: traits:: * ;
99
10- use std:: fmt;
1110use syntax_pos:: { DUMMY_SP , BytePos , Span } ;
1211use syntax:: symbol:: kw;
1312
@@ -92,29 +91,6 @@ impl<D> DebugScope<D> {
9291 }
9392}
9493
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-
11894impl < ' a , ' tcx , Bx : BuilderMethods < ' a , ' tcx > > FunctionCx < ' a , ' tcx , Bx > {
11995 pub fn set_debug_loc (
12096 & mut self ,
@@ -207,26 +183,26 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
207183
208184 let local_ref = & self . locals [ local] ;
209185
210- {
186+ if !bx . sess ( ) . fewer_names ( ) {
211187 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) ,
214190 } ;
215191 match local_ref {
216192 LocalRef :: Place ( place) |
217193 LocalRef :: UnsizedPlace ( place) => {
218- bx. set_var_name ( place. llval , name) ;
194+ bx. set_var_name ( place. llval , & name) ;
219195 }
220196 LocalRef :: Operand ( Some ( operand) ) => match operand. val {
221197 OperandValue :: Ref ( x, ..) |
222198 OperandValue :: Immediate ( x) => {
223- bx. set_var_name ( x, name) ;
199+ bx. set_var_name ( x, & name) ;
224200 }
225201 OperandValue :: Pair ( a, b) => {
226202 // FIXME(eddyb) these are scalar components,
227203 // 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") ) ;
230206 }
231207 }
232208 LocalRef :: Operand ( None ) => { }
0 commit comments