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