@@ -259,7 +259,7 @@ impl Printer<'tcx> for SymbolMangler<'tcx> {
259
259
}
260
260
261
261
fn print_impl_path (
262
- self ,
262
+ mut self ,
263
263
impl_def_id : DefId ,
264
264
substs : & ' tcx [ GenericArg < ' tcx > ] ,
265
265
mut self_ty : Ty < ' tcx > ,
@@ -284,12 +284,37 @@ impl Printer<'tcx> for SymbolMangler<'tcx> {
284
284
}
285
285
}
286
286
287
- self . path_append_impl (
288
- |cx| cx. print_def_path ( parent_def_id, & [ ] ) ,
289
- & key. disambiguated_data ,
290
- self_ty,
291
- impl_trait_ref,
292
- )
287
+ self . push ( match impl_trait_ref {
288
+ Some ( _) => "X" ,
289
+ None => "M" ,
290
+ } ) ;
291
+
292
+ // Encode impl generic params if the substitutions contain parameters (implying
293
+ // polymorphization is enabled) and this isn't an inherent impl.
294
+ if impl_trait_ref. is_some ( ) && substs. iter ( ) . any ( |a| a. has_param_types_or_consts ( ) ) {
295
+ self = self . path_generic_args (
296
+ |this| {
297
+ this. path_append_ns (
298
+ |cx| cx. print_def_path ( parent_def_id, & [ ] ) ,
299
+ 'I' ,
300
+ key. disambiguated_data . disambiguator as u64 ,
301
+ "" ,
302
+ )
303
+ } ,
304
+ substs,
305
+ ) ?;
306
+ } else {
307
+ self . push_disambiguator ( key. disambiguated_data . disambiguator as u64 ) ;
308
+ self = self . print_def_path ( parent_def_id, & [ ] ) ?;
309
+ }
310
+
311
+ self = self_ty. print ( self ) ?;
312
+
313
+ if let Some ( trait_ref) = impl_trait_ref {
314
+ self = self . print_def_path ( trait_ref. def_id , trait_ref. substs ) ?;
315
+ }
316
+
317
+ Ok ( self )
293
318
}
294
319
295
320
fn print_region ( mut self , region : ty:: Region < ' _ > ) -> Result < Self :: Region , Self :: Error > {
@@ -538,6 +563,7 @@ impl Printer<'tcx> for SymbolMangler<'tcx> {
538
563
self . push_ident ( & name) ;
539
564
Ok ( self )
540
565
}
566
+
541
567
fn path_qualified (
542
568
mut self ,
543
569
self_ty : Ty < ' tcx > ,
@@ -552,24 +578,16 @@ impl Printer<'tcx> for SymbolMangler<'tcx> {
552
578
}
553
579
554
580
fn path_append_impl (
555
- mut self ,
556
- print_prefix : impl FnOnce ( Self ) -> Result < Self :: Path , Self :: Error > ,
557
- disambiguated_data : & DisambiguatedDefPathData ,
558
- self_ty : Ty < ' tcx > ,
559
- trait_ref : Option < ty:: TraitRef < ' tcx > > ,
581
+ self ,
582
+ _ : impl FnOnce ( Self ) -> Result < Self :: Path , Self :: Error > ,
583
+ _ : & DisambiguatedDefPathData ,
584
+ _ : Ty < ' tcx > ,
585
+ _ : Option < ty:: TraitRef < ' tcx > > ,
560
586
) -> Result < Self :: Path , Self :: Error > {
561
- self . push ( match trait_ref {
562
- Some ( _) => "X" ,
563
- None => "M" ,
564
- } ) ;
565
- self . push_disambiguator ( disambiguated_data. disambiguator as u64 ) ;
566
- self = print_prefix ( self ) ?;
567
- self = self_ty. print ( self ) ?;
568
- if let Some ( trait_ref) = trait_ref {
569
- self = self . print_def_path ( trait_ref. def_id , trait_ref. substs ) ?;
570
- }
571
- Ok ( self )
587
+ // Inlined into `print_impl_path`
588
+ unreachable ! ( )
572
589
}
590
+
573
591
fn path_append (
574
592
self ,
575
593
print_prefix : impl FnOnce ( Self ) -> Result < Self :: Path , Self :: Error > ,
@@ -603,6 +621,7 @@ impl Printer<'tcx> for SymbolMangler<'tcx> {
603
621
name. as_ref ( ) . map_or ( "" , |s| & s[ ..] ) ,
604
622
)
605
623
}
624
+
606
625
fn path_generic_args (
607
626
mut self ,
608
627
print_prefix : impl FnOnce ( Self ) -> Result < Self :: Path , Self :: Error > ,
0 commit comments