9
9
// except according to those terms.
10
10
11
11
use dep_graph:: { DepGraph , DepNode , DepTrackingMap , DepTrackingMapConfig } ;
12
- use hir:: def_id:: { CrateNum , DefId } ;
12
+ use hir:: def_id:: { CrateNum , DefId , LOCAL_CRATE } ;
13
13
use middle:: const_val:: ConstVal ;
14
14
use mir;
15
15
use ty:: { self , Ty , TyCtxt } ;
@@ -24,6 +24,16 @@ trait Key {
24
24
fn default_span ( & self , tcx : TyCtxt ) -> Span ;
25
25
}
26
26
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
+
27
37
impl Key for CrateNum {
28
38
fn map_crate ( & self ) -> CrateNum {
29
39
* self
@@ -83,9 +93,9 @@ impl<'tcx> Value<'tcx> for Ty<'tcx> {
83
93
}
84
94
}
85
95
86
- pub struct CycleError < ' a > {
96
+ pub struct CycleError < ' a , ' tcx : ' a > {
87
97
span : Span ,
88
- cycle : RefMut < ' a , [ ( Span , Query ) ] > ,
98
+ cycle : RefMut < ' a , [ ( Span , Query < ' tcx > ) ] > ,
89
99
}
90
100
91
101
impl < ' a , ' gcx , ' tcx > TyCtxt < ' a , ' gcx , ' tcx > {
@@ -110,8 +120,8 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
110
120
err. emit ( ) ;
111
121
}
112
122
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 > >
115
125
where F : FnOnce ( ) -> R
116
126
{
117
127
{
@@ -172,13 +182,20 @@ impl<'tcx> QueryDescription for queries::coherent_inherent_impls<'tcx> {
172
182
}
173
183
}
174
184
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
+
175
192
macro_rules! define_maps {
176
193
( <$tcx: tt>
177
194
$( $( #[ $attr: meta] ) *
178
195
pub $name: ident: $node: ident( $K: ty) -> $V: ty) ,* ) => {
179
196
pub struct Maps <$tcx> {
180
197
providers: IndexVec <CrateNum , Providers <$tcx>>,
181
- query_stack: RefCell <Vec <( Span , Query ) >>,
198
+ query_stack: RefCell <Vec <( Span , Query <$tcx> ) >>,
182
199
$( $( #[ $attr] ) * pub $name: RefCell <DepTrackingMap <queries:: $name<$tcx>>>) ,*
183
200
}
184
201
@@ -196,11 +213,11 @@ macro_rules! define_maps {
196
213
197
214
#[ allow( bad_style) ]
198
215
#[ derive( Copy , Clone , Debug , PartialEq , Eq ) ]
199
- pub enum Query {
216
+ pub enum Query <$tcx> {
200
217
$( $( #[ $attr] ) * $name( $K) ) ,*
201
218
}
202
219
203
- impl Query {
220
+ impl <$tcx> Query <$tcx> {
204
221
pub fn describe( & self , tcx: TyCtxt ) -> String {
205
222
match * self {
206
223
$( Query :: $name( key) => queries:: $name:: describe( tcx, key) ) ,*
@@ -233,7 +250,7 @@ macro_rules! define_maps {
233
250
mut span: Span ,
234
251
key: $K,
235
252
f: F )
236
- -> Result <R , CycleError <' a>>
253
+ -> Result <R , CycleError <' a, $tcx >>
237
254
where F : FnOnce ( & $V) -> R
238
255
{
239
256
if let Some ( result) = tcx. maps. $name. borrow( ) . get( & key) {
@@ -256,7 +273,7 @@ macro_rules! define_maps {
256
273
}
257
274
258
275
pub fn try_get( tcx: TyCtxt <' a, $tcx, ' lcx>, span: Span , key: $K)
259
- -> Result <$V, CycleError <' a>> {
276
+ -> Result <$V, CycleError <' a, $tcx >> {
260
277
Self :: try_get_with( tcx, span, key, Clone :: clone)
261
278
}
262
279
@@ -387,7 +404,9 @@ define_maps! { <'tcx>
387
404
388
405
/// Results of evaluating monomorphic constants embedded in
389
406
/// 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>>
391
410
}
392
411
393
412
fn 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> {
397
416
fn coherent_inherent_impls_dep_node ( _: CrateNum ) -> DepNode < DefId > {
398
417
DepNode :: Coherence
399
418
}
419
+
420
+ fn mir_shim ( instance : ty:: InstanceDef ) -> DepNode < DefId > {
421
+ instance. dep_node ( )
422
+ }
0 commit comments