@@ -128,7 +128,7 @@ impl DefKind {
128
128
}
129
129
130
130
#[ derive( Clone , Copy , PartialEq , Eq , RustcEncodable , RustcDecodable , Hash , Debug , HashStable ) ]
131
- pub enum Def < Id = hir:: HirId > {
131
+ pub enum Res < Id = hir:: HirId > {
132
132
Def ( DefKind , DefId ) ,
133
133
134
134
// Type namespace
@@ -152,38 +152,38 @@ pub enum Def<Id = hir::HirId> {
152
152
}
153
153
154
154
/// The result of resolving a path before lowering to HIR.
155
- /// `base_def ` is definition of resolved part of the
155
+ /// `base_res ` is the resolution of the resolved part of the
156
156
/// path, `unresolved_segments` is the number of unresolved
157
157
/// segments.
158
158
///
159
159
/// ```text
160
160
/// module::Type::AssocX::AssocY::MethodOrAssocType
161
161
/// ^~~~~~~~~~~~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
162
- /// base_def unresolved_segments = 3
162
+ /// base_res unresolved_segments = 3
163
163
///
164
164
/// <T as Trait>::AssocX::AssocY::MethodOrAssocType
165
165
/// ^~~~~~~~~~~~~~ ^~~~~~~~~~~~~~~~~~~~~~~~~
166
- /// base_def unresolved_segments = 2
166
+ /// base_res unresolved_segments = 2
167
167
/// ```
168
168
#[ derive( Copy , Clone , Debug ) ]
169
169
pub struct PathResolution {
170
- base_def : Def < NodeId > ,
170
+ base_res : Res < NodeId > ,
171
171
unresolved_segments : usize ,
172
172
}
173
173
174
174
impl PathResolution {
175
- pub fn new ( def : Def < NodeId > ) -> Self {
176
- PathResolution { base_def : def , unresolved_segments : 0 }
175
+ pub fn new ( res : Res < NodeId > ) -> Self {
176
+ PathResolution { base_res : res , unresolved_segments : 0 }
177
177
}
178
178
179
- pub fn with_unresolved_segments ( def : Def < NodeId > , mut unresolved_segments : usize ) -> Self {
180
- if def == Def :: Err { unresolved_segments = 0 }
181
- PathResolution { base_def : def , unresolved_segments : unresolved_segments }
179
+ pub fn with_unresolved_segments ( res : Res < NodeId > , mut unresolved_segments : usize ) -> Self {
180
+ if res == Res :: Err { unresolved_segments = 0 }
181
+ PathResolution { base_res : res , unresolved_segments : unresolved_segments }
182
182
}
183
183
184
184
#[ inline]
185
- pub fn base_def ( & self ) -> Def < NodeId > {
186
- self . base_def
185
+ pub fn base_res ( & self ) -> Res < NodeId > {
186
+ self . base_res
187
187
}
188
188
189
189
#[ inline]
@@ -270,7 +270,7 @@ impl<T> PerNS<Option<T>> {
270
270
}
271
271
272
272
/// Definition mapping
273
- pub type DefMap = NodeMap < PathResolution > ;
273
+ pub type ResMap = NodeMap < PathResolution > ;
274
274
275
275
/// This is the replacement export map. It maps a module to all of the exports
276
276
/// within.
@@ -284,9 +284,9 @@ pub type ImportMap = NodeMap<PerNS<Option<PathResolution>>>;
284
284
pub struct Export < Id > {
285
285
/// The name of the target.
286
286
pub ident : ast:: Ident ,
287
- /// The definition of the target.
288
- pub def : Def < Id > ,
289
- /// The span of the target definition .
287
+ /// The resolution of the target.
288
+ pub res : Res < Id > ,
289
+ /// The span of the target.
290
290
pub span : Span ,
291
291
/// The visibility of the export.
292
292
/// We include non-`pub` exports for hygienic macros that get used from extern crates.
@@ -297,7 +297,7 @@ impl<Id> Export<Id> {
297
297
pub fn map_id < R > ( self , map : impl FnMut ( Id ) -> R ) -> Export < R > {
298
298
Export {
299
299
ident : self . ident ,
300
- def : self . def . map_id ( map) ,
300
+ res : self . res . map_id ( map) ,
301
301
span : self . span ,
302
302
vis : self . vis ,
303
303
}
@@ -334,85 +334,85 @@ impl NonMacroAttrKind {
334
334
}
335
335
}
336
336
337
- impl < Id > Def < Id > {
337
+ impl < Id > Res < Id > {
338
338
/// Return the `DefId` of this `Def` if it has an id, else panic.
339
339
pub fn def_id ( & self ) -> DefId
340
340
where
341
341
Id : Debug ,
342
342
{
343
343
self . opt_def_id ( ) . unwrap_or_else ( || {
344
- bug ! ( "attempted .def_id() on invalid def : {:?}" , self )
344
+ bug ! ( "attempted .def_id() on invalid res : {:?}" , self )
345
345
} )
346
346
}
347
347
348
- /// Return `Some(..)` with the `DefId` of this `Def ` if it has a id, else `None`.
348
+ /// Return `Some(..)` with the `DefId` of this `Res ` if it has a id, else `None`.
349
349
pub fn opt_def_id ( & self ) -> Option < DefId > {
350
350
match * self {
351
- Def :: Def ( _, id) => Some ( id) ,
352
-
353
- Def :: Local ( ..) |
354
- Def :: Upvar ( ..) |
355
- Def :: Label ( ..) |
356
- Def :: PrimTy ( ..) |
357
- Def :: SelfTy ( ..) |
358
- Def :: SelfCtor ( ..) |
359
- Def :: ToolMod |
360
- Def :: NonMacroAttr ( ..) |
361
- Def :: Err => {
351
+ Res :: Def ( _, id) => Some ( id) ,
352
+
353
+ Res :: Local ( ..) |
354
+ Res :: Upvar ( ..) |
355
+ Res :: Label ( ..) |
356
+ Res :: PrimTy ( ..) |
357
+ Res :: SelfTy ( ..) |
358
+ Res :: SelfCtor ( ..) |
359
+ Res :: ToolMod |
360
+ Res :: NonMacroAttr ( ..) |
361
+ Res :: Err => {
362
362
None
363
363
}
364
364
}
365
365
}
366
366
367
- /// Return the `DefId` of this `Def ` if it represents a module.
367
+ /// Return the `DefId` of this `Res ` if it represents a module.
368
368
pub fn mod_def_id ( & self ) -> Option < DefId > {
369
369
match * self {
370
- Def :: Def ( DefKind :: Mod , id) => Some ( id) ,
370
+ Res :: Def ( DefKind :: Mod , id) => Some ( id) ,
371
371
_ => None ,
372
372
}
373
373
}
374
374
375
- /// A human readable name for the def kind ("function", "module", etc.).
375
+ /// A human readable name for the res kind ("function", "module", etc.).
376
376
pub fn kind_name ( & self ) -> & ' static str {
377
377
match * self {
378
- Def :: Def ( kind, _) => kind. descr ( ) ,
379
- Def :: SelfCtor ( ..) => "self constructor" ,
380
- Def :: PrimTy ( ..) => "builtin type" ,
381
- Def :: Local ( ..) => "local variable" ,
382
- Def :: Upvar ( ..) => "closure capture" ,
383
- Def :: Label ( ..) => "label" ,
384
- Def :: SelfTy ( ..) => "self type" ,
385
- Def :: ToolMod => "tool module" ,
386
- Def :: NonMacroAttr ( attr_kind) => attr_kind. descr ( ) ,
387
- Def :: Err => "unresolved item" ,
378
+ Res :: Def ( kind, _) => kind. descr ( ) ,
379
+ Res :: SelfCtor ( ..) => "self constructor" ,
380
+ Res :: PrimTy ( ..) => "builtin type" ,
381
+ Res :: Local ( ..) => "local variable" ,
382
+ Res :: Upvar ( ..) => "closure capture" ,
383
+ Res :: Label ( ..) => "label" ,
384
+ Res :: SelfTy ( ..) => "self type" ,
385
+ Res :: ToolMod => "tool module" ,
386
+ Res :: NonMacroAttr ( attr_kind) => attr_kind. descr ( ) ,
387
+ Res :: Err => "unresolved item" ,
388
388
}
389
389
}
390
390
391
- /// An English article for the def .
391
+ /// An English article for the res .
392
392
pub fn article ( & self ) -> & ' static str {
393
393
match * self {
394
- Def :: Def ( kind, _) => kind. article ( ) ,
395
- Def :: Err => "an" ,
394
+ Res :: Def ( kind, _) => kind. article ( ) ,
395
+ Res :: Err => "an" ,
396
396
_ => "a" ,
397
397
}
398
398
}
399
399
400
- pub fn map_id < R > ( self , mut map : impl FnMut ( Id ) -> R ) -> Def < R > {
400
+ pub fn map_id < R > ( self , mut map : impl FnMut ( Id ) -> R ) -> Res < R > {
401
401
match self {
402
- Def :: Def ( kind, id) => Def :: Def ( kind, id) ,
403
- Def :: SelfCtor ( id) => Def :: SelfCtor ( id) ,
404
- Def :: PrimTy ( id) => Def :: PrimTy ( id) ,
405
- Def :: Local ( id) => Def :: Local ( map ( id) ) ,
406
- Def :: Upvar ( id, index, closure) => Def :: Upvar (
402
+ Res :: Def ( kind, id) => Res :: Def ( kind, id) ,
403
+ Res :: SelfCtor ( id) => Res :: SelfCtor ( id) ,
404
+ Res :: PrimTy ( id) => Res :: PrimTy ( id) ,
405
+ Res :: Local ( id) => Res :: Local ( map ( id) ) ,
406
+ Res :: Upvar ( id, index, closure) => Res :: Upvar (
407
407
map ( id) ,
408
408
index,
409
409
closure
410
410
) ,
411
- Def :: Label ( id) => Def :: Label ( id) ,
412
- Def :: SelfTy ( a, b) => Def :: SelfTy ( a, b) ,
413
- Def :: ToolMod => Def :: ToolMod ,
414
- Def :: NonMacroAttr ( attr_kind) => Def :: NonMacroAttr ( attr_kind) ,
415
- Def :: Err => Def :: Err ,
411
+ Res :: Label ( id) => Res :: Label ( id) ,
412
+ Res :: SelfTy ( a, b) => Res :: SelfTy ( a, b) ,
413
+ Res :: ToolMod => Res :: ToolMod ,
414
+ Res :: NonMacroAttr ( attr_kind) => Res :: NonMacroAttr ( attr_kind) ,
415
+ Res :: Err => Res :: Err ,
416
416
}
417
417
}
418
418
}
0 commit comments