@@ -14,8 +14,8 @@ use dep_graph::DepGraph;
1414use errors:: DiagnosticBuilder ;
1515use session:: Session ;
1616use middle;
17- use hir:: { TraitMap } ;
18- use hir:: def:: { Def , ExportMap } ;
17+ use hir:: { TraitCandidate , HirId } ;
18+ use hir:: def:: { Def , Export } ;
1919use hir:: def_id:: { CrateNum , DefId , LOCAL_CRATE } ;
2020use hir:: map as hir_map;
2121use hir:: map:: DefPathHash ;
@@ -817,10 +817,10 @@ pub struct GlobalCtxt<'tcx> {
817817
818818 /// Map indicating what traits are in scope for places where this
819819 /// is relevant; generated by resolve.
820- pub trait_map : TraitMap ,
820+ trait_map : FxHashMap < HirId , Rc < Vec < TraitCandidate > > > ,
821821
822822 /// Export map produced by name resolution.
823- pub export_map : ExportMap ,
823+ export_map : FxHashMap < HirId , Rc < Vec < Export > > > ,
824824
825825 pub named_region_map : resolve_lifetime:: NamedRegionMap ,
826826
@@ -1075,8 +1075,12 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
10751075 dep_graph : dep_graph. clone ( ) ,
10761076 types : common_types,
10771077 named_region_map,
1078- trait_map : resolutions. trait_map ,
1079- export_map : resolutions. export_map ,
1078+ trait_map : resolutions. trait_map . into_iter ( ) . map ( |( k, v) | {
1079+ ( hir. node_to_hir_id ( k) , Rc :: new ( v) )
1080+ } ) . collect ( ) ,
1081+ export_map : resolutions. export_map . into_iter ( ) . map ( |( k, v) | {
1082+ ( hir. node_to_hir_id ( k) , Rc :: new ( v) )
1083+ } ) . collect ( ) ,
10801084 hir,
10811085 def_path_hash_to_def_id,
10821086 maps : maps:: Maps :: new ( providers) ,
@@ -1994,3 +1998,20 @@ impl<T, R, E> InternIteratorElement<T, R> for Result<T, E> {
19941998 Ok ( f ( & iter. collect :: < Result < AccumulateVec < [ _ ; 8 ] > , _ > > ( ) ?) )
19951999 }
19962000}
2001+
2002+ fn in_scope_traits < ' a , ' tcx > ( tcx : TyCtxt < ' a , ' tcx , ' tcx > , id : HirId )
2003+ -> Option < Rc < Vec < TraitCandidate > > >
2004+ {
2005+ tcx. gcx . trait_map . get ( & id) . cloned ( )
2006+ }
2007+
2008+ fn module_exports < ' a , ' tcx > ( tcx : TyCtxt < ' a , ' tcx , ' tcx > , id : HirId )
2009+ -> Option < Rc < Vec < Export > > >
2010+ {
2011+ tcx. gcx . export_map . get ( & id) . cloned ( )
2012+ }
2013+
2014+ pub fn provide ( providers : & mut ty:: maps:: Providers ) {
2015+ providers. in_scope_traits = in_scope_traits;
2016+ providers. module_exports = module_exports;
2017+ }
0 commit comments