@@ -24,10 +24,10 @@ use if_chain::if_chain;
24
24
use matches:: matches;
25
25
use rustc:: hir;
26
26
use rustc:: hir:: def:: Def ;
27
- use rustc:: hir:: map:: DisambiguatedDefPathData ;
28
27
use rustc:: hir:: def_id:: CrateNum ;
29
28
use rustc:: hir:: def_id:: { DefId , CRATE_DEF_INDEX , LOCAL_CRATE } ;
30
29
use rustc:: hir:: intravisit:: { NestedVisitorMap , Visitor } ;
30
+ use rustc:: hir:: map:: DisambiguatedDefPathData ;
31
31
use rustc:: hir:: Node ;
32
32
use rustc:: hir:: * ;
33
33
use rustc:: lint:: { LateContext , Level , Lint , LintContext } ;
@@ -43,7 +43,7 @@ use rustc_errors::Applicability;
43
43
use syntax:: ast:: { self , LitKind } ;
44
44
use syntax:: attr;
45
45
use syntax:: source_map:: { Span , DUMMY_SP } ;
46
- use syntax:: symbol:: { keywords, Symbol , LocalInternedString } ;
46
+ use syntax:: symbol:: { keywords, LocalInternedString , Symbol } ;
47
47
48
48
use crate :: reexport:: * ;
49
49
@@ -116,39 +116,30 @@ impl<'tcx> Printer<'tcx, 'tcx> for AbsolutePathPrinter<'_, 'tcx> {
116
116
self . tcx
117
117
}
118
118
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 > {
123
120
Ok ( ( ) )
124
121
}
125
122
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 > {
130
124
Ok ( ( ) )
131
125
}
132
126
133
127
fn print_dyn_existential (
134
128
self ,
135
129
_predicates : & ' tcx ty:: List < ty:: ExistentialPredicate < ' tcx > > ,
136
- ) -> Result < Self :: DynExistential , Self :: Error > {
130
+ ) -> Result < Self :: DynExistential , Self :: Error > {
137
131
Ok ( ( ) )
138
132
}
139
133
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 > {
144
135
Ok ( vec ! [ self . tcx. original_crate_name( cnum) . as_str( ) ] )
145
136
}
146
137
147
138
fn path_qualified (
148
139
self ,
149
140
self_ty : Ty < ' tcx > ,
150
141
trait_ref : Option < ty:: TraitRef < ' tcx > > ,
151
- ) -> Result < Self :: Path , Self :: Error > {
142
+ ) -> Result < Self :: Path , Self :: Error > {
152
143
// This shouldn't ever be needed, but just in case:
153
144
Ok ( vec ! [ match trait_ref {
154
145
Some ( trait_ref) => Symbol :: intern( & format!( "{:?}" , trait_ref) ) . as_str( ) ,
@@ -162,14 +153,12 @@ impl<'tcx> Printer<'tcx, 'tcx> for AbsolutePathPrinter<'_, 'tcx> {
162
153
_disambiguated_data : & DisambiguatedDefPathData ,
163
154
self_ty : Ty < ' tcx > ,
164
155
trait_ref : Option < ty:: TraitRef < ' tcx > > ,
165
- ) -> Result < Self :: Path , Self :: Error > {
156
+ ) -> Result < Self :: Path , Self :: Error > {
166
157
let mut path = print_prefix ( self ) ?;
167
158
168
159
// This shouldn't ever be needed, but just in case:
169
160
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 ( ) ,
173
162
None => Symbol :: intern ( & format ! ( "<impl {}>" , self_ty) ) . as_str ( ) ,
174
163
} ) ;
175
164
@@ -180,7 +169,7 @@ impl<'tcx> Printer<'tcx, 'tcx> for AbsolutePathPrinter<'_, 'tcx> {
180
169
self ,
181
170
print_prefix : impl FnOnce ( Self ) -> Result < Self :: Path , Self :: Error > ,
182
171
disambiguated_data : & DisambiguatedDefPathData ,
183
- ) -> Result < Self :: Path , Self :: Error > {
172
+ ) -> Result < Self :: Path , Self :: Error > {
184
173
let mut path = print_prefix ( self ) ?;
185
174
path. push ( disambiguated_data. data . as_interned_str ( ) . as_str ( ) ) ;
186
175
Ok ( path)
@@ -190,7 +179,7 @@ impl<'tcx> Printer<'tcx, 'tcx> for AbsolutePathPrinter<'_, 'tcx> {
190
179
self ,
191
180
print_prefix : impl FnOnce ( Self ) -> Result < Self :: Path , Self :: Error > ,
192
181
_args : & [ Kind < ' tcx > ] ,
193
- ) -> Result < Self :: Path , Self :: Error > {
182
+ ) -> Result < Self :: Path , Self :: Error > {
194
183
print_prefix ( self )
195
184
}
196
185
}
@@ -219,7 +208,12 @@ pub fn match_def_path<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId, path
219
208
/// };
220
209
/// ```
221
210
pub 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 ( )
223
217
}
224
218
225
219
/// Checks if type is struct, enum or union type with the given def path.
0 commit comments