@@ -31,9 +31,9 @@ impl<'tcx> Printer<'tcx> for AbsolutePathPrinter<'tcx> {
31
31
Ok ( self )
32
32
}
33
33
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 > {
35
35
match ty. sty {
36
- // types without identity
36
+ // Types without identity.
37
37
| ty:: Bool
38
38
| ty:: Char
39
39
| ty:: Int ( _)
@@ -48,28 +48,33 @@ impl<'tcx> Printer<'tcx> for AbsolutePathPrinter<'tcx> {
48
48
| ty:: Never
49
49
| ty:: Tuple ( _)
50
50
| 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
55
51
=> self . pretty_print_type ( ty) ,
56
- | ty :: Infer ( _ )
57
- | ty :: Bound ( _ , _ )
52
+
53
+ // Placeholders (all printed as `_` to uniformize them).
58
54
| ty:: Param ( _)
55
+ | ty:: Bound ( ..)
59
56
| 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
+ }
73
78
}
74
79
}
75
80
0 commit comments