@@ -31,9 +31,9 @@ impl<'tcx> Printer<'tcx> for AbsolutePathPrinter<'tcx> {
3131 Ok ( self )
3232 }
3333
34- fn print_type ( self , ty : Ty < ' tcx > ) -> Result < Self :: Type , Self :: Error > {
34+ fn print_type ( mut self , ty : Ty < ' tcx > ) -> Result < Self :: Type , Self :: Error > {
3535 match ty. sty {
36- // types without identity
36+ // Types without identity.
3737 | ty:: Bool
3838 | ty:: Char
3939 | ty:: Int ( _)
@@ -48,28 +48,33 @@ impl<'tcx> Printer<'tcx> for AbsolutePathPrinter<'tcx> {
4848 | ty:: Never
4949 | ty:: Tuple ( _)
5050 | ty:: Dynamic ( _, _)
51- | ty:: Adt ( ..)
52- | ty:: Foreign ( _)
53- // should be unreachable, but there's no hurt in printing it (and better than ICEing)
54- | ty:: Error
5551 => self . pretty_print_type ( ty) ,
56- | ty :: Infer ( _ )
57- | ty :: Bound ( _ , _ )
52+
53+ // Placeholders (all printed as `_` to uniformize them).
5854 | ty:: Param ( _)
55+ | ty:: Bound ( ..)
5956 | ty:: Placeholder ( _)
60- | ty:: Projection ( _)
61- | ty:: UnnormalizedProjection ( _)
62- | ty:: GeneratorWitness ( _)
63- => bug ! (
64- "{:#?} in `type_name` should not happen because we are always monomorphized" ,
65- ty,
66- ) ,
67- // types with identity (print the module path instead)
68- | ty:: FnDef ( did, substs)
69- | ty:: Opaque ( did, substs)
70- => self . print_def_path ( did, substs) ,
71- ty:: Closure ( did, substs) => self . print_def_path ( did, substs. substs ) ,
72- ty:: Generator ( did, substs, _) => self . print_def_path ( did, substs. substs ) ,
57+ | ty:: Infer ( _)
58+ | ty:: Error
59+ => {
60+ write ! ( self , "_" ) ?;
61+ Ok ( self )
62+ }
63+
64+ // Types with identity (print the module path).
65+ | ty:: Adt ( & ty:: AdtDef { did : def_id, .. } , substs)
66+ | ty:: FnDef ( def_id, substs)
67+ | ty:: Opaque ( def_id, substs)
68+ | ty:: Projection ( ty:: ProjectionTy { item_def_id : def_id, substs } )
69+ | ty:: UnnormalizedProjection ( ty:: ProjectionTy { item_def_id : def_id, substs } )
70+ | ty:: Closure ( def_id, ty:: ClosureSubsts { substs } )
71+ | ty:: Generator ( def_id, ty:: GeneratorSubsts { substs } , _)
72+ => self . print_def_path ( def_id, substs) ,
73+ ty:: Foreign ( def_id) => self . print_def_path ( def_id, & [ ] ) ,
74+
75+ ty:: GeneratorWitness ( _) => {
76+ bug ! ( "type_name: unexpected `GeneratorWitness`" )
77+ }
7378 }
7479 }
7580
0 commit comments