@@ -68,6 +68,8 @@ fn compress<'tcx>(
68
68
fn encode_args < ' tcx > (
69
69
tcx : TyCtxt < ' tcx > ,
70
70
args : GenericArgsRef < ' tcx > ,
71
+ for_def : DefId ,
72
+ has_erased_self : bool ,
71
73
dict : & mut FxHashMap < DictKey < ' tcx > , usize > ,
72
74
options : EncodeTyOptions ,
73
75
) -> String {
@@ -76,7 +78,8 @@ fn encode_args<'tcx>(
76
78
let args: Vec < GenericArg < ' _ > > = args. iter ( ) . collect ( ) ;
77
79
if !args. is_empty ( ) {
78
80
s. push ( 'I' ) ;
79
- for arg in args {
81
+ let def_generics = tcx. generics_of ( for_def) ;
82
+ for ( n, arg) in args. iter ( ) . enumerate ( ) {
80
83
match arg. unpack ( ) {
81
84
GenericArgKind :: Lifetime ( region) => {
82
85
s. push_str ( & encode_region ( region, dict) ) ;
@@ -85,7 +88,10 @@ fn encode_args<'tcx>(
85
88
s. push_str ( & encode_ty ( tcx, ty, dict, options) ) ;
86
89
}
87
90
GenericArgKind :: Const ( c) => {
88
- s. push_str ( & encode_const ( tcx, c, dict, options) ) ;
91
+ let n = n + ( has_erased_self as usize ) ;
92
+ let ct_ty =
93
+ tcx. type_of ( def_generics. param_at ( n, tcx) . def_id ) . instantiate_identity ( ) ;
94
+ s. push_str ( & encode_const ( tcx, c, ct_ty, dict, options) ) ;
89
95
}
90
96
}
91
97
}
@@ -99,6 +105,7 @@ fn encode_args<'tcx>(
99
105
fn encode_const < ' tcx > (
100
106
tcx : TyCtxt < ' tcx > ,
101
107
c : Const < ' tcx > ,
108
+ ct_ty : Ty < ' tcx > ,
102
109
dict : & mut FxHashMap < DictKey < ' tcx > , usize > ,
103
110
options : EncodeTyOptions ,
104
111
) -> String {
@@ -111,8 +118,7 @@ fn encode_const<'tcx>(
111
118
// L<element-type>E as literal argument
112
119
113
120
// Element type
114
- // THISPR
115
- s. push_str ( & encode_ty ( tcx, todo ! ( ) , dict, options) ) ;
121
+ s. push_str ( & encode_ty ( tcx, ct_ty, dict, options) ) ;
116
122
}
117
123
118
124
// Literal arguments
@@ -232,15 +238,21 @@ fn encode_predicate<'tcx>(
232
238
ty:: ExistentialPredicate :: Trait ( trait_ref) => {
233
239
let name = encode_ty_name ( tcx, trait_ref. def_id ) ;
234
240
let _ = write ! ( s, "u{}{}" , name. len( ) , & name) ;
235
- s. push_str ( & encode_args ( tcx, trait_ref. args , dict, options) ) ;
241
+ s. push_str ( & encode_args ( tcx, trait_ref. args , trait_ref . def_id , true , dict, options) ) ;
236
242
}
237
243
ty:: ExistentialPredicate :: Projection ( projection) => {
238
244
let name = encode_ty_name ( tcx, projection. def_id ) ;
239
245
let _ = write ! ( s, "u{}{}" , name. len( ) , & name) ;
240
- s. push_str ( & encode_args ( tcx, projection. args , dict, options) ) ;
246
+ s. push_str ( & encode_args ( tcx, projection. args , projection . def_id , true , dict, options) ) ;
241
247
match projection. term . unpack ( ) {
242
248
TermKind :: Ty ( ty) => s. push_str ( & encode_ty ( tcx, ty, dict, options) ) ,
243
- TermKind :: Const ( c) => s. push_str ( & encode_const ( tcx, c, dict, options) ) ,
249
+ TermKind :: Const ( c) => s. push_str ( & encode_const (
250
+ tcx,
251
+ c,
252
+ tcx. type_of ( projection. def_id ) . instantiate ( tcx, projection. args ) ,
253
+ dict,
254
+ options,
255
+ ) ) ,
244
256
}
245
257
}
246
258
ty:: ExistentialPredicate :: AutoTrait ( def_id) => {
@@ -486,7 +498,7 @@ pub fn encode_ty<'tcx>(
486
498
// <subst>, as vendor extended type.
487
499
let name = encode_ty_name ( tcx, def_id) ;
488
500
let _ = write ! ( s, "u{}{}" , name. len( ) , & name) ;
489
- s. push_str ( & encode_args ( tcx, args, dict, options) ) ;
501
+ s. push_str ( & encode_args ( tcx, args, def_id , false , dict, options) ) ;
490
502
compress ( dict, DictKey :: Ty ( ty, TyQ :: None ) , & mut s) ;
491
503
}
492
504
typeid. push_str ( & s) ;
@@ -530,7 +542,7 @@ pub fn encode_ty<'tcx>(
530
542
let mut s = String :: new ( ) ;
531
543
let name = encode_ty_name ( tcx, * def_id) ;
532
544
let _ = write ! ( s, "u{}{}" , name. len( ) , & name) ;
533
- s. push_str ( & encode_args ( tcx, args, dict, options) ) ;
545
+ s. push_str ( & encode_args ( tcx, args, * def_id , false , dict, options) ) ;
534
546
compress ( dict, DictKey :: Ty ( ty, TyQ :: None ) , & mut s) ;
535
547
typeid. push_str ( & s) ;
536
548
}
@@ -542,7 +554,7 @@ pub fn encode_ty<'tcx>(
542
554
let name = encode_ty_name ( tcx, * def_id) ;
543
555
let _ = write ! ( s, "u{}{}" , name. len( ) , & name) ;
544
556
let parent_args = tcx. mk_args ( args. as_coroutine_closure ( ) . parent_args ( ) ) ;
545
- s. push_str ( & encode_args ( tcx, parent_args, dict, options) ) ;
557
+ s. push_str ( & encode_args ( tcx, parent_args, * def_id , false , dict, options) ) ;
546
558
compress ( dict, DictKey :: Ty ( ty, TyQ :: None ) , & mut s) ;
547
559
typeid. push_str ( & s) ;
548
560
}
@@ -557,6 +569,8 @@ pub fn encode_ty<'tcx>(
557
569
s. push_str ( & encode_args (
558
570
tcx,
559
571
tcx. mk_args ( args. as_coroutine ( ) . parent_args ( ) ) ,
572
+ * def_id,
573
+ false ,
560
574
dict,
561
575
options,
562
576
) ) ;
0 commit comments