55//! expressions) that are mostly just leftovers.
66
77pub 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+ } ;
911use crate :: def_path_hash_map:: DefPathHashMap ;
1012
1113use rustc_data_structures:: fx:: FxHashMap ;
@@ -245,6 +247,17 @@ impl DefPath {
245247
246248 s
247249 }
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+ }
248261}
249262
250263#[ derive( Copy , Clone , Debug , PartialEq , Eq , Hash , Encodable , Decodable ) ]
@@ -281,6 +294,10 @@ pub enum DefPathData {
281294 AnonConst ,
282295 /// An `impl Trait` type node.
283296 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 > ) ,
284301}
285302
286303impl Definitions {
@@ -404,7 +421,7 @@ impl DefPathData {
404421 TypeNs ( name) | ValueNs ( name) | MacroNs ( name) | LifetimeNs ( name) => Some ( name) ,
405422
406423 Impl | ForeignMod | CrateRoot | Use | GlobalAsm | ClosureExpr | Ctor | AnonConst
407- | ImplTrait => None ,
424+ | ImplTrait | ImplTraitInTrait ( .. ) => None ,
408425 }
409426 }
410427
@@ -424,6 +441,7 @@ impl DefPathData {
424441 Ctor => DefPathDataName :: Anon { namespace : sym:: constructor } ,
425442 AnonConst => DefPathDataName :: Anon { namespace : sym:: constant } ,
426443 ImplTrait => DefPathDataName :: Anon { namespace : sym:: opaque } ,
444+ ImplTraitInTrait ( ..) => DefPathDataName :: Anon { namespace : sym:: opaque } ,
427445 }
428446 }
429447}
0 commit comments