@@ -109,14 +109,14 @@ fn push_debuginfo_type_name<'tcx>(
109109 ty_and_layout,
110110 & |output, visited| {
111111 push_item_name ( tcx, def. did ( ) , true , output) ;
112- push_generic_params_internal ( tcx, args, output, visited) ;
112+ push_generic_args_internal ( tcx, args, output, visited) ;
113113 } ,
114114 output,
115115 visited,
116116 ) ;
117117 } else {
118118 push_item_name ( tcx, def. did ( ) , qualified, output) ;
119- push_generic_params_internal ( tcx, args, output, visited) ;
119+ push_generic_args_internal ( tcx, args, output, visited) ;
120120 }
121121 }
122122 ty:: Tuple ( component_types) => {
@@ -253,19 +253,18 @@ fn push_debuginfo_type_name<'tcx>(
253253 ) ;
254254 push_item_name ( tcx, principal. def_id , qualified, output) ;
255255 let principal_has_generic_params =
256- push_generic_params_internal ( tcx, principal. args , output, visited) ;
256+ push_generic_args_internal ( tcx, principal. args , output, visited) ;
257257
258258 let projection_bounds: SmallVec < [ _ ; 4 ] > = trait_data
259259 . projection_bounds ( )
260260 . map ( |bound| {
261261 let ExistentialProjection { def_id : item_def_id, term, .. } =
262262 tcx. instantiate_bound_regions_with_erased ( bound) ;
263- // FIXME(mgca): allow for consts here
264- ( item_def_id, term. expect_type ( ) )
263+ ( item_def_id, term)
265264 } )
266265 . collect ( ) ;
267266
268- if projection_bounds. len ( ) != 0 {
267+ if ! projection_bounds. is_empty ( ) {
269268 if principal_has_generic_params {
270269 // push_generic_params_internal() above added a `>` but we actually
271270 // want to add more items to that list, so remove that again...
@@ -279,17 +278,17 @@ fn push_debuginfo_type_name<'tcx>(
279278 output. push ( '<' ) ;
280279 }
281280
282- for ( item_def_id, ty ) in projection_bounds {
281+ for ( item_def_id, term ) in projection_bounds {
283282 if cpp_like_debuginfo {
284283 output. push_str ( "assoc$<" ) ;
285284 push_item_name ( tcx, item_def_id, false , output) ;
286285 push_arg_separator ( cpp_like_debuginfo, output) ;
287- push_debuginfo_type_name ( tcx, ty , true , output, visited) ;
286+ push_debuginfo_term_name ( tcx, term , true , output, visited) ;
288287 push_close_angle_bracket ( cpp_like_debuginfo, output) ;
289288 } else {
290289 push_item_name ( tcx, item_def_id, false , output) ;
291290 output. push ( '=' ) ;
292- push_debuginfo_type_name ( tcx, ty , true , output, visited) ;
291+ push_debuginfo_term_name ( tcx, term , true , output, visited) ;
293292 }
294293 push_arg_separator ( cpp_like_debuginfo, output) ;
295294 }
@@ -533,7 +532,7 @@ pub fn compute_debuginfo_vtable_name<'tcx>(
533532 tcx. normalize_erasing_regions ( ty:: TypingEnv :: fully_monomorphized ( ) , trait_ref) ;
534533 push_item_name ( tcx, trait_ref. def_id , true , & mut vtable_name) ;
535534 visited. clear ( ) ;
536- push_generic_params_internal ( tcx, trait_ref. args , & mut vtable_name, & mut visited) ;
535+ push_generic_args_internal ( tcx, trait_ref. args , & mut vtable_name, & mut visited) ;
537536 } else {
538537 vtable_name. push ( '_' ) ;
539538 }
@@ -631,7 +630,13 @@ fn push_unqualified_item_name(
631630 } ;
632631}
633632
634- fn push_generic_params_internal < ' tcx > (
633+ pub fn push_generic_args < ' tcx > ( tcx : TyCtxt < ' tcx > , args : GenericArgsRef < ' tcx > , output : & mut String ) {
634+ let _prof = tcx. prof . generic_activity ( "compute_debuginfo_type_name" ) ;
635+ let mut visited = FxHashSet :: default ( ) ;
636+ push_generic_args_internal ( tcx, args, output, & mut visited) ;
637+ }
638+
639+ fn push_generic_args_internal < ' tcx > (
635640 tcx : TyCtxt < ' tcx > ,
636641 args : GenericArgsRef < ' tcx > ,
637642 output : & mut String ,
@@ -646,14 +651,10 @@ fn push_generic_params_internal<'tcx>(
646651
647652 output. push ( '<' ) ;
648653
649- for type_parameter in args {
650- match type_parameter {
651- GenericArgKind :: Type ( type_parameter) => {
652- push_debuginfo_type_name ( tcx, type_parameter, true , output, visited) ;
653- }
654- GenericArgKind :: Const ( ct) => {
655- push_const_param ( tcx, ct, output) ;
656- }
654+ for arg in args {
655+ match arg {
656+ GenericArgKind :: Type ( ty) => push_debuginfo_type_name ( tcx, ty, true , output, visited) ,
657+ GenericArgKind :: Const ( ct) => push_debuginfo_const_name ( tcx, ct, output) ,
657658 other => bug ! ( "Unexpected non-erasable generic: {:?}" , other) ,
658659 }
659660
@@ -665,7 +666,20 @@ fn push_generic_params_internal<'tcx>(
665666 true
666667}
667668
668- fn push_const_param < ' tcx > ( tcx : TyCtxt < ' tcx > , ct : ty:: Const < ' tcx > , output : & mut String ) {
669+ fn push_debuginfo_term_name < ' tcx > (
670+ tcx : TyCtxt < ' tcx > ,
671+ term : ty:: Term < ' tcx > ,
672+ qualified : bool ,
673+ output : & mut String ,
674+ visited : & mut FxHashSet < Ty < ' tcx > > ,
675+ ) {
676+ match term. kind ( ) {
677+ ty:: TermKind :: Ty ( ty) => push_debuginfo_type_name ( tcx, ty, qualified, output, visited) ,
678+ ty:: TermKind :: Const ( ct) => push_debuginfo_const_name ( tcx, ct, output) ,
679+ }
680+ }
681+
682+ fn push_debuginfo_const_name < ' tcx > ( tcx : TyCtxt < ' tcx > , ct : ty:: Const < ' tcx > , output : & mut String ) {
669683 match ct. kind ( ) {
670684 ty:: ConstKind :: Param ( param) => {
671685 write ! ( output, "{}" , param. name)
@@ -715,16 +729,6 @@ fn push_const_param<'tcx>(tcx: TyCtxt<'tcx>, ct: ty::Const<'tcx>, output: &mut S
715729 . unwrap ( ) ;
716730}
717731
718- pub fn push_generic_params < ' tcx > (
719- tcx : TyCtxt < ' tcx > ,
720- args : GenericArgsRef < ' tcx > ,
721- output : & mut String ,
722- ) {
723- let _prof = tcx. prof . generic_activity ( "compute_debuginfo_type_name" ) ;
724- let mut visited = FxHashSet :: default ( ) ;
725- push_generic_params_internal ( tcx, args, output, & mut visited) ;
726- }
727-
728732fn push_closure_or_coroutine_name < ' tcx > (
729733 tcx : TyCtxt < ' tcx > ,
730734 def_id : DefId ,
@@ -767,7 +771,7 @@ fn push_closure_or_coroutine_name<'tcx>(
767771 // FIXME(async_closures): This is probably not going to be correct w.r.t.
768772 // multiple coroutine flavors. Maybe truncate to (parent + 1)?
769773 let args = args. truncate_to ( tcx, generics) ;
770- push_generic_params_internal ( tcx, args, output, visited) ;
774+ push_generic_args_internal ( tcx, args, output, visited) ;
771775}
772776
773777fn push_close_angle_bracket ( cpp_like_debuginfo : bool , output : & mut String ) {
0 commit comments