@@ -3,7 +3,7 @@ use rustc_hir::def_id::CrateNum;
33use rustc_hir:: definitions:: DisambiguatedDefPathData ;
44use rustc_middle:: ty:: {
55 self ,
6- print:: { PrettyPrinter , Print , Printer } ,
6+ print:: { PrettyPrinter , Print , PrintError , Printer } ,
77 GenericArg , GenericArgKind , Ty , TyCtxt ,
88} ;
99use std:: fmt:: Write ;
@@ -14,23 +14,15 @@ struct AbsolutePathPrinter<'tcx> {
1414}
1515
1616impl < ' 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-
2517 fn tcx ( & self ) -> TyCtxt < ' tcx > {
2618 self . tcx
2719 }
2820
29- fn print_region ( self , _region : ty:: Region < ' _ > ) -> Result < Self :: Region , Self :: Error > {
21+ fn print_region ( self , _region : ty:: Region < ' _ > ) -> Result < Self , PrintError > {
3022 Ok ( self )
3123 }
3224
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 > {
3426 match * ty. kind ( ) {
3527 // Types without identity.
3628 ty:: Bool
@@ -68,18 +60,18 @@ impl<'tcx> Printer<'tcx> for AbsolutePathPrinter<'tcx> {
6860 }
6961 }
7062
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 > {
7264 self . pretty_print_const ( ct, false )
7365 }
7466
7567 fn print_dyn_existential (
7668 self ,
7769 predicates : & ' tcx ty:: List < ty:: PolyExistentialPredicate < ' tcx > > ,
78- ) -> Result < Self :: DynExistential , Self :: Error > {
70+ ) -> Result < Self , PrintError > {
7971 self . pretty_print_dyn_existential ( predicates)
8072 }
8173
82- fn path_crate ( mut self , cnum : CrateNum ) -> Result < Self :: Path , Self :: Error > {
74+ fn path_crate ( mut self , cnum : CrateNum ) -> Result < Self , PrintError > {
8375 self . path . push_str ( self . tcx . crate_name ( cnum) . as_str ( ) ) ;
8476 Ok ( self )
8577 }
@@ -88,17 +80,17 @@ impl<'tcx> Printer<'tcx> for AbsolutePathPrinter<'tcx> {
8880 self ,
8981 self_ty : Ty < ' tcx > ,
9082 trait_ref : Option < ty:: TraitRef < ' tcx > > ,
91- ) -> Result < Self :: Path , Self :: Error > {
83+ ) -> Result < Self , PrintError > {
9284 self . pretty_path_qualified ( self_ty, trait_ref)
9385 }
9486
9587 fn path_append_impl (
9688 self ,
97- print_prefix : impl FnOnce ( Self ) -> Result < Self :: Path , Self :: Error > ,
89+ print_prefix : impl FnOnce ( Self ) -> Result < Self , PrintError > ,
9890 _disambiguated_data : & DisambiguatedDefPathData ,
9991 self_ty : Ty < ' tcx > ,
10092 trait_ref : Option < ty:: TraitRef < ' tcx > > ,
101- ) -> Result < Self :: Path , Self :: Error > {
93+ ) -> Result < Self , PrintError > {
10294 self . pretty_path_append_impl (
10395 |mut cx| {
10496 cx = print_prefix ( cx) ?;
@@ -114,9 +106,9 @@ impl<'tcx> Printer<'tcx> for AbsolutePathPrinter<'tcx> {
114106
115107 fn path_append (
116108 mut self ,
117- print_prefix : impl FnOnce ( Self ) -> Result < Self :: Path , Self :: Error > ,
109+ print_prefix : impl FnOnce ( Self ) -> Result < Self , PrintError > ,
118110 disambiguated_data : & DisambiguatedDefPathData ,
119- ) -> Result < Self :: Path , Self :: Error > {
111+ ) -> Result < Self , PrintError > {
120112 self = print_prefix ( self ) ?;
121113
122114 write ! ( self . path, "::{}" , disambiguated_data. data) . unwrap ( ) ;
@@ -126,9 +118,9 @@ impl<'tcx> Printer<'tcx> for AbsolutePathPrinter<'tcx> {
126118
127119 fn path_generic_args (
128120 mut self ,
129- print_prefix : impl FnOnce ( Self ) -> Result < Self :: Path , Self :: Error > ,
121+ print_prefix : impl FnOnce ( Self ) -> Result < Self , PrintError > ,
130122 args : & [ GenericArg < ' tcx > ] ,
131- ) -> Result < Self :: Path , Self :: Error > {
123+ ) -> Result < Self , PrintError > {
132124 self = print_prefix ( self ) ?;
133125 let args =
134126 args. iter ( ) . cloned ( ) . filter ( |arg| !matches ! ( arg. unpack( ) , GenericArgKind :: Lifetime ( _) ) ) ;
@@ -144,9 +136,9 @@ impl<'tcx> PrettyPrinter<'tcx> for AbsolutePathPrinter<'tcx> {
144136 fn should_print_region ( & self , _region : ty:: Region < ' _ > ) -> bool {
145137 false
146138 }
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 >
148140 where
149- T : Print < ' tcx , Self , Output = Self , Error = Self :: Error > ,
141+ T : Print < ' tcx , Self > ,
150142 {
151143 if let Some ( first) = elems. next ( ) {
152144 self = first. print ( self ) ?;
@@ -160,8 +152,8 @@ impl<'tcx> PrettyPrinter<'tcx> for AbsolutePathPrinter<'tcx> {
160152
161153 fn generic_delimiters (
162154 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 > {
165157 write ! ( self , "<" ) ?;
166158
167159 self = f ( self ) ?;
0 commit comments