5
5
//! expressions) that are mostly just leftovers.
6
6
7
7
pub use crate :: def_id:: DefPathHash ;
8
- use crate :: def_id:: { CrateNum , DefIndex , LocalDefId , StableCrateId , CRATE_DEF_INDEX , LOCAL_CRATE } ;
8
+ use crate :: def_id:: {
9
+ CrateNum , DefId , DefIndex , LocalDefId , StableCrateId , CRATE_DEF_INDEX , LOCAL_CRATE ,
10
+ } ;
9
11
use crate :: def_path_hash_map:: DefPathHashMap ;
10
12
11
13
use rustc_data_structures:: fx:: FxHashMap ;
@@ -245,6 +247,17 @@ impl DefPath {
245
247
246
248
s
247
249
}
250
+
251
+ pub fn get_impl_trait_in_trait_data ( & self ) -> Option < ( DefId , Option < DefId > ) > {
252
+ if let Some ( def_path_data) = self . data . last ( )
253
+ && let DefPathData :: ImplTraitInTrait ( fn_def_id, of_trait) =
254
+ def_path_data. data
255
+ {
256
+ Some ( ( fn_def_id, of_trait) )
257
+ } else {
258
+ None
259
+ }
260
+ }
248
261
}
249
262
250
263
#[ derive( Copy , Clone , Debug , PartialEq , Eq , Hash , Encodable , Decodable ) ]
@@ -281,6 +294,10 @@ pub enum DefPathData {
281
294
AnonConst ,
282
295
/// An `impl Trait` type node.
283
296
ImplTrait ,
297
+ /// An `impl Trait` type node inside a `trait` or inside an `impl` of a `trait`.
298
+ /// On a `trait` the value is `(trait_fn_def_id, None)`.
299
+ /// On an `impl` the value is `(impl_fn_def_id, Some(trait_rpit_def_id))`.
300
+ ImplTraitInTrait ( DefId , Option < DefId > ) ,
284
301
}
285
302
286
303
impl Definitions {
@@ -404,7 +421,7 @@ impl DefPathData {
404
421
TypeNs ( name) | ValueNs ( name) | MacroNs ( name) | LifetimeNs ( name) => Some ( name) ,
405
422
406
423
Impl | ForeignMod | CrateRoot | Use | GlobalAsm | ClosureExpr | Ctor | AnonConst
407
- | ImplTrait => None ,
424
+ | ImplTrait | ImplTraitInTrait ( .. ) => None ,
408
425
}
409
426
}
410
427
@@ -424,6 +441,7 @@ impl DefPathData {
424
441
Ctor => DefPathDataName :: Anon { namespace : sym:: constructor } ,
425
442
AnonConst => DefPathDataName :: Anon { namespace : sym:: constant } ,
426
443
ImplTrait => DefPathDataName :: Anon { namespace : sym:: opaque } ,
444
+ ImplTraitInTrait ( ..) => DefPathDataName :: Anon { namespace : sym:: opaque } ,
427
445
}
428
446
}
429
447
}
0 commit comments