@@ -68,6 +68,7 @@ fn compress<'tcx>(
6868fn encode_args < ' tcx > (
6969 tcx : TyCtxt < ' tcx > ,
7070 args : GenericArgsRef < ' tcx > ,
71+ for_def : DefId ,
7172 dict : & mut FxHashMap < DictKey < ' tcx > , usize > ,
7273 options : EncodeTyOptions ,
7374) -> String {
@@ -76,7 +77,7 @@ fn encode_args<'tcx>(
7677 let args: Vec < GenericArg < ' _ > > = args. iter ( ) . collect ( ) ;
7778 if !args. is_empty ( ) {
7879 s. push ( 'I' ) ;
79- for arg in args {
80+ for ( n , arg) in args. iter ( ) . enumerate ( ) {
8081 match arg. unpack ( ) {
8182 GenericArgKind :: Lifetime ( region) => {
8283 s. push_str ( & encode_region ( region, dict) ) ;
@@ -85,7 +86,10 @@ fn encode_args<'tcx>(
8586 s. push_str ( & encode_ty ( tcx, ty, dict, options) ) ;
8687 }
8788 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) ) ;
8993 }
9094 }
9195 }
@@ -99,6 +103,7 @@ fn encode_args<'tcx>(
99103fn encode_const < ' tcx > (
100104 tcx : TyCtxt < ' tcx > ,
101105 c : Const < ' tcx > ,
106+ ct_ty : Ty < ' tcx > ,
102107 dict : & mut FxHashMap < DictKey < ' tcx > , usize > ,
103108 options : EncodeTyOptions ,
104109) -> String {
@@ -111,8 +116,7 @@ fn encode_const<'tcx>(
111116 // L<element-type>E as literal argument
112117
113118 // 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) ) ;
116120 }
117121
118122 // Literal arguments
@@ -232,15 +236,21 @@ fn encode_predicate<'tcx>(
232236 ty:: ExistentialPredicate :: Trait ( trait_ref) => {
233237 let name = encode_ty_name ( tcx, trait_ref. def_id ) ;
234238 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) ) ;
236240 }
237241 ty:: ExistentialPredicate :: Projection ( projection) => {
238242 let name = encode_ty_name ( tcx, projection. def_id ) ;
239243 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) ) ;
241245 match projection. term . unpack ( ) {
242246 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+ ) ) ,
244254 }
245255 }
246256 ty:: ExistentialPredicate :: AutoTrait ( def_id) => {
@@ -486,7 +496,7 @@ pub fn encode_ty<'tcx>(
486496 // <subst>, as vendor extended type.
487497 let name = encode_ty_name ( tcx, def_id) ;
488498 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) ) ;
490500 compress ( dict, DictKey :: Ty ( ty, TyQ :: None ) , & mut s) ;
491501 }
492502 typeid. push_str ( & s) ;
@@ -530,7 +540,7 @@ pub fn encode_ty<'tcx>(
530540 let mut s = String :: new ( ) ;
531541 let name = encode_ty_name ( tcx, * def_id) ;
532542 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) ) ;
534544 compress ( dict, DictKey :: Ty ( ty, TyQ :: None ) , & mut s) ;
535545 typeid. push_str ( & s) ;
536546 }
@@ -542,7 +552,7 @@ pub fn encode_ty<'tcx>(
542552 let name = encode_ty_name ( tcx, * def_id) ;
543553 let _ = write ! ( s, "u{}{}" , name. len( ) , & name) ;
544554 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) ) ;
546556 compress ( dict, DictKey :: Ty ( ty, TyQ :: None ) , & mut s) ;
547557 typeid. push_str ( & s) ;
548558 }
@@ -557,6 +567,7 @@ pub fn encode_ty<'tcx>(
557567 s. push_str ( & encode_args (
558568 tcx,
559569 tcx. mk_args ( args. as_coroutine ( ) . parent_args ( ) ) ,
570+ * def_id,
560571 dict,
561572 options,
562573 ) ) ;
0 commit comments