@@ -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,17 +14,15 @@ struct AbsolutePathPrinter<'tcx> {
1414}
1515
1616impl < ' tcx > Printer < ' tcx > for AbsolutePathPrinter < ' tcx > {
17- type Error = std:: fmt:: Error ;
18-
1917 fn tcx ( & self ) -> TyCtxt < ' tcx > {
2018 self . tcx
2119 }
2220
23- fn print_region ( self , _region : ty:: Region < ' _ > ) -> Result < Self , Self :: Error > {
21+ fn print_region ( self , _region : ty:: Region < ' _ > ) -> Result < Self , PrintError > {
2422 Ok ( self )
2523 }
2624
27- fn print_type ( mut self , ty : Ty < ' tcx > ) -> Result < Self , Self :: Error > {
25+ fn print_type ( mut self , ty : Ty < ' tcx > ) -> Result < Self , PrintError > {
2826 match * ty. kind ( ) {
2927 // Types without identity.
3028 ty:: Bool
@@ -62,18 +60,18 @@ impl<'tcx> Printer<'tcx> for AbsolutePathPrinter<'tcx> {
6260 }
6361 }
6462
65- fn print_const ( self , ct : ty:: Const < ' tcx > ) -> Result < Self , Self :: Error > {
63+ fn print_const ( self , ct : ty:: Const < ' tcx > ) -> Result < Self , PrintError > {
6664 self . pretty_print_const ( ct, false )
6765 }
6866
6967 fn print_dyn_existential (
7068 self ,
7169 predicates : & ' tcx ty:: List < ty:: PolyExistentialPredicate < ' tcx > > ,
72- ) -> Result < Self , Self :: Error > {
70+ ) -> Result < Self , PrintError > {
7371 self . pretty_print_dyn_existential ( predicates)
7472 }
7573
76- fn path_crate ( mut self , cnum : CrateNum ) -> Result < Self , Self :: Error > {
74+ fn path_crate ( mut self , cnum : CrateNum ) -> Result < Self , PrintError > {
7775 self . path . push_str ( self . tcx . crate_name ( cnum) . as_str ( ) ) ;
7876 Ok ( self )
7977 }
@@ -82,17 +80,17 @@ impl<'tcx> Printer<'tcx> for AbsolutePathPrinter<'tcx> {
8280 self ,
8381 self_ty : Ty < ' tcx > ,
8482 trait_ref : Option < ty:: TraitRef < ' tcx > > ,
85- ) -> Result < Self , Self :: Error > {
83+ ) -> Result < Self , PrintError > {
8684 self . pretty_path_qualified ( self_ty, trait_ref)
8785 }
8886
8987 fn path_append_impl (
9088 self ,
91- print_prefix : impl FnOnce ( Self ) -> Result < Self , Self :: Error > ,
89+ print_prefix : impl FnOnce ( Self ) -> Result < Self , PrintError > ,
9290 _disambiguated_data : & DisambiguatedDefPathData ,
9391 self_ty : Ty < ' tcx > ,
9492 trait_ref : Option < ty:: TraitRef < ' tcx > > ,
95- ) -> Result < Self , Self :: Error > {
93+ ) -> Result < Self , PrintError > {
9694 self . pretty_path_append_impl (
9795 |mut cx| {
9896 cx = print_prefix ( cx) ?;
@@ -108,9 +106,9 @@ impl<'tcx> Printer<'tcx> for AbsolutePathPrinter<'tcx> {
108106
109107 fn path_append (
110108 mut self ,
111- print_prefix : impl FnOnce ( Self ) -> Result < Self , Self :: Error > ,
109+ print_prefix : impl FnOnce ( Self ) -> Result < Self , PrintError > ,
112110 disambiguated_data : & DisambiguatedDefPathData ,
113- ) -> Result < Self , Self :: Error > {
111+ ) -> Result < Self , PrintError > {
114112 self = print_prefix ( self ) ?;
115113
116114 write ! ( self . path, "::{}" , disambiguated_data. data) . unwrap ( ) ;
@@ -120,9 +118,9 @@ impl<'tcx> Printer<'tcx> for AbsolutePathPrinter<'tcx> {
120118
121119 fn path_generic_args (
122120 mut self ,
123- print_prefix : impl FnOnce ( Self ) -> Result < Self , Self :: Error > ,
121+ print_prefix : impl FnOnce ( Self ) -> Result < Self , PrintError > ,
124122 args : & [ GenericArg < ' tcx > ] ,
125- ) -> Result < Self , Self :: Error > {
123+ ) -> Result < Self , PrintError > {
126124 self = print_prefix ( self ) ?;
127125 let args =
128126 args. iter ( ) . cloned ( ) . filter ( |arg| !matches ! ( arg. unpack( ) , GenericArgKind :: Lifetime ( _) ) ) ;
@@ -138,9 +136,9 @@ impl<'tcx> PrettyPrinter<'tcx> for AbsolutePathPrinter<'tcx> {
138136 fn should_print_region ( & self , _region : ty:: Region < ' _ > ) -> bool {
139137 false
140138 }
141- 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 >
142140 where
143- T : Print < ' tcx , Self , Error = Self :: Error > ,
141+ T : Print < ' tcx , Self , Error = PrintError > ,
144142 {
145143 if let Some ( first) = elems. next ( ) {
146144 self = first. print ( self ) ?;
@@ -154,8 +152,8 @@ impl<'tcx> PrettyPrinter<'tcx> for AbsolutePathPrinter<'tcx> {
154152
155153 fn generic_delimiters (
156154 mut self ,
157- f : impl FnOnce ( Self ) -> Result < Self , Self :: Error > ,
158- ) -> Result < Self , Self :: Error > {
155+ f : impl FnOnce ( Self ) -> Result < Self , PrintError > ,
156+ ) -> Result < Self , PrintError > {
159157 write ! ( self , "<" ) ?;
160158
161159 self = f ( self ) ?;
0 commit comments