@@ -24,10 +24,10 @@ use if_chain::if_chain;
2424use matches:: matches;
2525use rustc:: hir;
2626use rustc:: hir:: def:: Def ;
27- use rustc:: hir:: map:: DisambiguatedDefPathData ;
2827use rustc:: hir:: def_id:: CrateNum ;
2928use rustc:: hir:: def_id:: { DefId , CRATE_DEF_INDEX , LOCAL_CRATE } ;
3029use rustc:: hir:: intravisit:: { NestedVisitorMap , Visitor } ;
30+ use rustc:: hir:: map:: DisambiguatedDefPathData ;
3131use rustc:: hir:: Node ;
3232use rustc:: hir:: * ;
3333use rustc:: lint:: { LateContext , Level , Lint , LintContext } ;
@@ -43,7 +43,7 @@ use rustc_errors::Applicability;
4343use syntax:: ast:: { self , LitKind } ;
4444use syntax:: attr;
4545use syntax:: source_map:: { Span , DUMMY_SP } ;
46- use syntax:: symbol:: { keywords, Symbol , LocalInternedString } ;
46+ use syntax:: symbol:: { keywords, LocalInternedString , Symbol } ;
4747
4848use crate :: reexport:: * ;
4949
@@ -116,39 +116,30 @@ impl<'tcx> Printer<'tcx, 'tcx> for AbsolutePathPrinter<'_, 'tcx> {
116116 self . tcx
117117 }
118118
119- fn print_region (
120- self ,
121- _region : ty:: Region < ' _ > ,
122- ) -> Result < Self :: Region , Self :: Error > {
119+ fn print_region ( self , _region : ty:: Region < ' _ > ) -> Result < Self :: Region , Self :: Error > {
123120 Ok ( ( ) )
124121 }
125122
126- fn print_type (
127- self ,
128- _ty : Ty < ' tcx > ,
129- ) -> Result < Self :: Type , Self :: Error > {
123+ fn print_type ( self , _ty : Ty < ' tcx > ) -> Result < Self :: Type , Self :: Error > {
130124 Ok ( ( ) )
131125 }
132126
133127 fn print_dyn_existential (
134128 self ,
135129 _predicates : & ' tcx ty:: List < ty:: ExistentialPredicate < ' tcx > > ,
136- ) -> Result < Self :: DynExistential , Self :: Error > {
130+ ) -> Result < Self :: DynExistential , Self :: Error > {
137131 Ok ( ( ) )
138132 }
139133
140- fn path_crate (
141- self ,
142- cnum : CrateNum ,
143- ) -> Result < Self :: Path , Self :: Error > {
134+ fn path_crate ( self , cnum : CrateNum ) -> Result < Self :: Path , Self :: Error > {
144135 Ok ( vec ! [ self . tcx. original_crate_name( cnum) . as_str( ) ] )
145136 }
146137
147138 fn path_qualified (
148139 self ,
149140 self_ty : Ty < ' tcx > ,
150141 trait_ref : Option < ty:: TraitRef < ' tcx > > ,
151- ) -> Result < Self :: Path , Self :: Error > {
142+ ) -> Result < Self :: Path , Self :: Error > {
152143 // This shouldn't ever be needed, but just in case:
153144 Ok ( vec ! [ match trait_ref {
154145 Some ( trait_ref) => Symbol :: intern( & format!( "{:?}" , trait_ref) ) . as_str( ) ,
@@ -162,14 +153,12 @@ impl<'tcx> Printer<'tcx, 'tcx> for AbsolutePathPrinter<'_, 'tcx> {
162153 _disambiguated_data : & DisambiguatedDefPathData ,
163154 self_ty : Ty < ' tcx > ,
164155 trait_ref : Option < ty:: TraitRef < ' tcx > > ,
165- ) -> Result < Self :: Path , Self :: Error > {
156+ ) -> Result < Self :: Path , Self :: Error > {
166157 let mut path = print_prefix ( self ) ?;
167158
168159 // This shouldn't ever be needed, but just in case:
169160 path. push ( match trait_ref {
170- Some ( trait_ref) => {
171- Symbol :: intern ( & format ! ( "<impl {} for {}>" , trait_ref, self_ty) ) . as_str ( )
172- }
161+ Some ( trait_ref) => Symbol :: intern ( & format ! ( "<impl {} for {}>" , trait_ref, self_ty) ) . as_str ( ) ,
173162 None => Symbol :: intern ( & format ! ( "<impl {}>" , self_ty) ) . as_str ( ) ,
174163 } ) ;
175164
@@ -180,7 +169,7 @@ impl<'tcx> Printer<'tcx, 'tcx> for AbsolutePathPrinter<'_, 'tcx> {
180169 self ,
181170 print_prefix : impl FnOnce ( Self ) -> Result < Self :: Path , Self :: Error > ,
182171 disambiguated_data : & DisambiguatedDefPathData ,
183- ) -> Result < Self :: Path , Self :: Error > {
172+ ) -> Result < Self :: Path , Self :: Error > {
184173 let mut path = print_prefix ( self ) ?;
185174 path. push ( disambiguated_data. data . as_interned_str ( ) . as_str ( ) ) ;
186175 Ok ( path)
@@ -190,7 +179,7 @@ impl<'tcx> Printer<'tcx, 'tcx> for AbsolutePathPrinter<'_, 'tcx> {
190179 self ,
191180 print_prefix : impl FnOnce ( Self ) -> Result < Self :: Path , Self :: Error > ,
192181 _args : & [ Kind < ' tcx > ] ,
193- ) -> Result < Self :: Path , Self :: Error > {
182+ ) -> Result < Self :: Path , Self :: Error > {
194183 print_prefix ( self )
195184 }
196185}
@@ -219,7 +208,12 @@ pub fn match_def_path<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId, path
219208/// };
220209/// ```
221210pub fn get_def_path < ' a , ' tcx > ( tcx : TyCtxt < ' a , ' tcx , ' tcx > , def_id : DefId ) -> Vec < & ' static str > {
222- AbsolutePathPrinter { tcx } . print_def_path ( def_id, & [ ] ) . unwrap ( ) . iter ( ) . map ( LocalInternedString :: get) . collect ( )
211+ AbsolutePathPrinter { tcx }
212+ . print_def_path ( def_id, & [ ] )
213+ . unwrap ( )
214+ . iter ( )
215+ . map ( LocalInternedString :: get)
216+ . collect ( )
223217}
224218
225219/// Checks if type is struct, enum or union type with the given def path.
0 commit comments