99// except according to those terms.
1010
1111use dep_graph:: { DepGraph , DepNode , DepTrackingMap , DepTrackingMapConfig } ;
12- use hir:: def_id:: { CrateNum , DefId } ;
12+ use hir:: def_id:: { CrateNum , DefId , LOCAL_CRATE } ;
1313use middle:: const_val:: ConstVal ;
1414use mir;
1515use ty:: { self , Ty , TyCtxt } ;
@@ -24,6 +24,16 @@ trait Key {
2424 fn default_span ( & self , tcx : TyCtxt ) -> Span ;
2525}
2626
27+ impl < ' tcx > Key for ty:: InstanceDef < ' tcx > {
28+ fn map_crate ( & self ) -> CrateNum {
29+ LOCAL_CRATE
30+ }
31+
32+ fn default_span ( & self , tcx : TyCtxt ) -> Span {
33+ tcx. def_span ( self . def_id ( ) )
34+ }
35+ }
36+
2737impl Key for CrateNum {
2838 fn map_crate ( & self ) -> CrateNum {
2939 * self
@@ -83,9 +93,9 @@ impl<'tcx> Value<'tcx> for Ty<'tcx> {
8393 }
8494}
8595
86- pub struct CycleError < ' a > {
96+ pub struct CycleError < ' a , ' tcx : ' a > {
8797 span : Span ,
88- cycle : RefMut < ' a , [ ( Span , Query ) ] > ,
98+ cycle : RefMut < ' a , [ ( Span , Query < ' tcx > ) ] > ,
8999}
90100
91101impl < ' a , ' gcx , ' tcx > TyCtxt < ' a , ' gcx , ' tcx > {
@@ -110,8 +120,8 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
110120 err. emit ( ) ;
111121 }
112122
113- fn cycle_check < F , R > ( self , span : Span , query : Query , compute : F )
114- -> Result < R , CycleError < ' a > >
123+ fn cycle_check < F , R > ( self , span : Span , query : Query < ' gcx > , compute : F )
124+ -> Result < R , CycleError < ' a , ' gcx > >
115125 where F : FnOnce ( ) -> R
116126 {
117127 {
@@ -172,13 +182,20 @@ impl<'tcx> QueryDescription for queries::coherent_inherent_impls<'tcx> {
172182 }
173183}
174184
185+ impl < ' tcx > QueryDescription for queries:: mir_shims < ' tcx > {
186+ fn describe ( tcx : TyCtxt , def : ty:: InstanceDef < ' tcx > ) -> String {
187+ format ! ( "generating MIR shim for `{}`" ,
188+ tcx. item_path_str( def. def_id( ) ) )
189+ }
190+ }
191+
175192macro_rules! define_maps {
176193 ( <$tcx: tt>
177194 $( $( #[ $attr: meta] ) *
178195 pub $name: ident: $node: ident( $K: ty) -> $V: ty) ,* ) => {
179196 pub struct Maps <$tcx> {
180197 providers: IndexVec <CrateNum , Providers <$tcx>>,
181- query_stack: RefCell <Vec <( Span , Query ) >>,
198+ query_stack: RefCell <Vec <( Span , Query <$tcx> ) >>,
182199 $( $( #[ $attr] ) * pub $name: RefCell <DepTrackingMap <queries:: $name<$tcx>>>) ,*
183200 }
184201
@@ -196,11 +213,11 @@ macro_rules! define_maps {
196213
197214 #[ allow( bad_style) ]
198215 #[ derive( Copy , Clone , Debug , PartialEq , Eq ) ]
199- pub enum Query {
216+ pub enum Query <$tcx> {
200217 $( $( #[ $attr] ) * $name( $K) ) ,*
201218 }
202219
203- impl Query {
220+ impl <$tcx> Query <$tcx> {
204221 pub fn describe( & self , tcx: TyCtxt ) -> String {
205222 match * self {
206223 $( Query :: $name( key) => queries:: $name:: describe( tcx, key) ) ,*
@@ -233,7 +250,7 @@ macro_rules! define_maps {
233250 mut span: Span ,
234251 key: $K,
235252 f: F )
236- -> Result <R , CycleError <' a>>
253+ -> Result <R , CycleError <' a, $tcx >>
237254 where F : FnOnce ( & $V) -> R
238255 {
239256 if let Some ( result) = tcx. maps. $name. borrow( ) . get( & key) {
@@ -256,7 +273,7 @@ macro_rules! define_maps {
256273 }
257274
258275 pub fn try_get( tcx: TyCtxt <' a, $tcx, ' lcx>, span: Span , key: $K)
259- -> Result <$V, CycleError <' a>> {
276+ -> Result <$V, CycleError <' a, $tcx >> {
260277 Self :: try_get_with( tcx, span, key, Clone :: clone)
261278 }
262279
@@ -387,7 +404,9 @@ define_maps! { <'tcx>
387404
388405 /// Results of evaluating monomorphic constants embedded in
389406 /// other items, such as enum variant explicit discriminants.
390- pub monomorphic_const_eval: MonomorphicConstEval ( DefId ) -> Result <ConstVal <' tcx>, ( ) >
407+ pub monomorphic_const_eval: MonomorphicConstEval ( DefId ) -> Result <ConstVal <' tcx>, ( ) >,
408+
409+ pub mir_shims: mir_shim( ty:: InstanceDef <' tcx>) -> & ' tcx RefCell <mir:: Mir <' tcx>>
391410}
392411
393412fn coherent_trait_dep_node ( ( _, def_id) : ( CrateNum , DefId ) ) -> DepNode < DefId > {
@@ -397,3 +416,7 @@ fn coherent_trait_dep_node((_, def_id): (CrateNum, DefId)) -> DepNode<DefId> {
397416fn coherent_inherent_impls_dep_node ( _: CrateNum ) -> DepNode < DefId > {
398417 DepNode :: Coherence
399418}
419+
420+ fn mir_shim ( instance : ty:: InstanceDef ) -> DepNode < DefId > {
421+ instance. dep_node ( )
422+ }
0 commit comments