@@ -3,7 +3,7 @@ use rustc_hir::def_id::CrateNum;
3
3
use rustc_hir:: definitions:: DisambiguatedDefPathData ;
4
4
use rustc_middle:: ty:: {
5
5
self ,
6
- print:: { PrettyPrinter , Print , Printer } ,
6
+ print:: { PrettyPrinter , Print , PrintError , Printer } ,
7
7
GenericArg , GenericArgKind , Ty , TyCtxt ,
8
8
} ;
9
9
use std:: fmt:: Write ;
@@ -14,23 +14,15 @@ struct AbsolutePathPrinter<'tcx> {
14
14
}
15
15
16
16
impl < ' tcx > Printer < ' tcx > for AbsolutePathPrinter < ' tcx > {
17
- type Error = std:: fmt:: Error ;
18
-
19
- type Path = Self ;
20
- type Region = Self ;
21
- type Type = Self ;
22
- type DynExistential = Self ;
23
- type Const = Self ;
24
-
25
17
fn tcx ( & self ) -> TyCtxt < ' tcx > {
26
18
self . tcx
27
19
}
28
20
29
- fn print_region ( self , _region : ty:: Region < ' _ > ) -> Result < Self :: Region , Self :: Error > {
21
+ fn print_region ( self , _region : ty:: Region < ' _ > ) -> Result < Self , PrintError > {
30
22
Ok ( self )
31
23
}
32
24
33
- fn print_type ( mut self , ty : Ty < ' tcx > ) -> Result < Self :: Type , Self :: Error > {
25
+ fn print_type ( mut self , ty : Ty < ' tcx > ) -> Result < Self , PrintError > {
34
26
match * ty. kind ( ) {
35
27
// Types without identity.
36
28
ty:: Bool
@@ -68,18 +60,18 @@ impl<'tcx> Printer<'tcx> for AbsolutePathPrinter<'tcx> {
68
60
}
69
61
}
70
62
71
- fn print_const ( self , ct : ty:: Const < ' tcx > ) -> Result < Self :: Const , Self :: Error > {
63
+ fn print_const ( self , ct : ty:: Const < ' tcx > ) -> Result < Self , PrintError > {
72
64
self . pretty_print_const ( ct, false )
73
65
}
74
66
75
67
fn print_dyn_existential (
76
68
self ,
77
69
predicates : & ' tcx ty:: List < ty:: PolyExistentialPredicate < ' tcx > > ,
78
- ) -> Result < Self :: DynExistential , Self :: Error > {
70
+ ) -> Result < Self , PrintError > {
79
71
self . pretty_print_dyn_existential ( predicates)
80
72
}
81
73
82
- fn path_crate ( mut self , cnum : CrateNum ) -> Result < Self :: Path , Self :: Error > {
74
+ fn path_crate ( mut self , cnum : CrateNum ) -> Result < Self , PrintError > {
83
75
self . path . push_str ( self . tcx . crate_name ( cnum) . as_str ( ) ) ;
84
76
Ok ( self )
85
77
}
@@ -88,17 +80,17 @@ impl<'tcx> Printer<'tcx> for AbsolutePathPrinter<'tcx> {
88
80
self ,
89
81
self_ty : Ty < ' tcx > ,
90
82
trait_ref : Option < ty:: TraitRef < ' tcx > > ,
91
- ) -> Result < Self :: Path , Self :: Error > {
83
+ ) -> Result < Self , PrintError > {
92
84
self . pretty_path_qualified ( self_ty, trait_ref)
93
85
}
94
86
95
87
fn path_append_impl (
96
88
self ,
97
- print_prefix : impl FnOnce ( Self ) -> Result < Self :: Path , Self :: Error > ,
89
+ print_prefix : impl FnOnce ( Self ) -> Result < Self , PrintError > ,
98
90
_disambiguated_data : & DisambiguatedDefPathData ,
99
91
self_ty : Ty < ' tcx > ,
100
92
trait_ref : Option < ty:: TraitRef < ' tcx > > ,
101
- ) -> Result < Self :: Path , Self :: Error > {
93
+ ) -> Result < Self , PrintError > {
102
94
self . pretty_path_append_impl (
103
95
|mut cx| {
104
96
cx = print_prefix ( cx) ?;
@@ -114,9 +106,9 @@ impl<'tcx> Printer<'tcx> for AbsolutePathPrinter<'tcx> {
114
106
115
107
fn path_append (
116
108
mut self ,
117
- print_prefix : impl FnOnce ( Self ) -> Result < Self :: Path , Self :: Error > ,
109
+ print_prefix : impl FnOnce ( Self ) -> Result < Self , PrintError > ,
118
110
disambiguated_data : & DisambiguatedDefPathData ,
119
- ) -> Result < Self :: Path , Self :: Error > {
111
+ ) -> Result < Self , PrintError > {
120
112
self = print_prefix ( self ) ?;
121
113
122
114
write ! ( self . path, "::{}" , disambiguated_data. data) . unwrap ( ) ;
@@ -126,9 +118,9 @@ impl<'tcx> Printer<'tcx> for AbsolutePathPrinter<'tcx> {
126
118
127
119
fn path_generic_args (
128
120
mut self ,
129
- print_prefix : impl FnOnce ( Self ) -> Result < Self :: Path , Self :: Error > ,
121
+ print_prefix : impl FnOnce ( Self ) -> Result < Self , PrintError > ,
130
122
args : & [ GenericArg < ' tcx > ] ,
131
- ) -> Result < Self :: Path , Self :: Error > {
123
+ ) -> Result < Self , PrintError > {
132
124
self = print_prefix ( self ) ?;
133
125
let args =
134
126
args. iter ( ) . cloned ( ) . filter ( |arg| !matches ! ( arg. unpack( ) , GenericArgKind :: Lifetime ( _) ) ) ;
@@ -144,9 +136,9 @@ impl<'tcx> PrettyPrinter<'tcx> for AbsolutePathPrinter<'tcx> {
144
136
fn should_print_region ( & self , _region : ty:: Region < ' _ > ) -> bool {
145
137
false
146
138
}
147
- fn comma_sep < T > ( mut self , mut elems : impl Iterator < Item = T > ) -> Result < Self , Self :: Error >
139
+ fn comma_sep < T > ( mut self , mut elems : impl Iterator < Item = T > ) -> Result < Self , PrintError >
148
140
where
149
- T : Print < ' tcx , Self , Output = Self , Error = Self :: Error > ,
141
+ T : Print < ' tcx , Self > ,
150
142
{
151
143
if let Some ( first) = elems. next ( ) {
152
144
self = first. print ( self ) ?;
@@ -160,8 +152,8 @@ impl<'tcx> PrettyPrinter<'tcx> for AbsolutePathPrinter<'tcx> {
160
152
161
153
fn generic_delimiters (
162
154
mut self ,
163
- f : impl FnOnce ( Self ) -> Result < Self , Self :: Error > ,
164
- ) -> Result < Self , Self :: Error > {
155
+ f : impl FnOnce ( Self ) -> Result < Self , PrintError > ,
156
+ ) -> Result < Self , PrintError > {
165
157
write ! ( self , "<" ) ?;
166
158
167
159
self = f ( self ) ?;
0 commit comments