@@ -40,10 +40,17 @@ use rustc::hir::svh::Svh;
40
40
use rustc:: hir;
41
41
42
42
macro_rules! provide {
43
- ( <$lt: tt> $tcx: ident, $def_id: ident, $cdata: ident $( $name: ident => $compute: block) * ) => {
43
+ ( <$lt: tt> $tcx: ident, $def_id: ident, $cdata: ident, $cnum: ident,
44
+ ByDefId {
45
+ $( $cdata_fn_name: ident => $cdata_fn_compute: block) *
46
+ }
47
+ ByCrateNum {
48
+ $( $cnum_fn_name: ident => $cnum_fn_compute: block) *
49
+ }
50
+ ) => {
44
51
pub fn provide<$lt>( providers: & mut Providers <$lt>) {
45
- $( fn $name <' a, $lt: $lt>( $tcx: TyCtxt <' a, $lt, $lt>, $def_id: DefId )
46
- -> <ty:: queries:: $name <$lt> as
52
+ $( fn $cdata_fn_name <' a, $lt: $lt>( $tcx: TyCtxt <' a, $lt, $lt>, $def_id: DefId )
53
+ -> <ty:: queries:: $cdata_fn_name <$lt> as
47
54
DepTrackingMapConfig >:: Value {
48
55
assert!( !$def_id. is_local( ) ) ;
49
56
@@ -55,82 +62,98 @@ macro_rules! provide {
55
62
let $cdata = $tcx. sess. cstore. crate_data_as_rc_any( $def_id. krate) ;
56
63
let $cdata = $cdata. downcast_ref:: <cstore:: CrateMetadata >( )
57
64
. expect( "CrateStore crated ata is not a CrateMetadata" ) ;
58
- $compute
65
+ $cdata_fn_compute
66
+ } ) *
67
+
68
+ $( fn $cnum_fn_name<' a, $lt: $lt>( $tcx: TyCtxt <' a, $lt, $lt>, $cnum: CrateNum )
69
+ -> <ty:: queries:: $cnum_fn_name<$lt> as
70
+ DepTrackingMapConfig >:: Value {
71
+ let $cdata = $tcx. sess. cstore. crate_data_as_rc_any( $cnum) ;
72
+ let $cdata = $cdata. downcast_ref:: <cstore:: CrateMetadata >( )
73
+ . expect( "CrateStore crated ata is not a CrateMetadata" ) ;
74
+ $cnum_fn_compute
59
75
} ) *
60
76
61
77
* providers = Providers {
62
- $( $name, ) *
78
+ $( $cdata_fn_name, ) *
79
+ $( $cnum_fn_name, ) *
63
80
..* providers
64
81
} ;
65
82
}
66
83
}
67
84
}
68
85
69
- provide ! { <' tcx> tcx, def_id, cdata
70
- type_of => { cdata. get_type( def_id. index, tcx) }
71
- generics_of => { tcx. alloc_generics( cdata. get_generics( def_id. index) ) }
72
- predicates_of => { cdata. get_predicates( def_id. index, tcx) }
73
- super_predicates_of => { cdata. get_super_predicates( def_id. index, tcx) }
74
- trait_def => {
75
- tcx. alloc_trait_def( cdata. get_trait_def( def_id. index) )
76
- }
77
- adt_def => { cdata. get_adt_def( def_id. index, tcx) }
78
- adt_destructor => {
79
- let _ = cdata;
80
- tcx. calculate_dtor( def_id, & mut |_, _| Ok ( ( ) ) )
81
- }
82
- variances_of => { Rc :: new( cdata. get_item_variances( def_id. index) ) }
83
- associated_item_def_ids => {
84
- let mut result = vec![ ] ;
85
- cdata. each_child_of_item( def_id. index, |child| result. push( child. def. def_id( ) ) , tcx. sess) ;
86
- Rc :: new( result)
87
- }
88
- associated_item => { cdata. get_associated_item( def_id. index) }
89
- impl_trait_ref => { cdata. get_impl_trait( def_id. index, tcx) }
90
- impl_polarity => { cdata. get_impl_polarity( def_id. index) }
91
- coerce_unsized_info => {
92
- cdata. get_coerce_unsized_info( def_id. index) . unwrap_or_else( || {
93
- bug!( "coerce_unsized_info: `{:?}` is missing its info" , def_id) ;
94
- } )
86
+ provide ! { <' tcx> tcx, def_id, cdata, cnum,
87
+ ByDefId {
88
+ type_of => { cdata. get_type( def_id. index, tcx) }
89
+ generics_of => { tcx. alloc_generics( cdata. get_generics( def_id. index) ) }
90
+ predicates_of => { cdata. get_predicates( def_id. index, tcx) }
91
+ super_predicates_of => { cdata. get_super_predicates( def_id. index, tcx) }
92
+ trait_def => {
93
+ tcx. alloc_trait_def( cdata. get_trait_def( def_id. index) )
94
+ }
95
+ adt_def => { cdata. get_adt_def( def_id. index, tcx) }
96
+ adt_destructor => {
97
+ let _ = cdata;
98
+ tcx. calculate_dtor( def_id, & mut |_, _| Ok ( ( ) ) )
99
+ }
100
+ variances_of => { Rc :: new( cdata. get_item_variances( def_id. index) ) }
101
+ associated_item_def_ids => {
102
+ let mut result = vec![ ] ;
103
+ cdata. each_child_of_item( def_id. index,
104
+ |child| result. push( child. def. def_id( ) ) , tcx. sess) ;
105
+ Rc :: new( result)
106
+ }
107
+ associated_item => { cdata. get_associated_item( def_id. index) }
108
+ impl_trait_ref => { cdata. get_impl_trait( def_id. index, tcx) }
109
+ impl_polarity => { cdata. get_impl_polarity( def_id. index) }
110
+ coerce_unsized_info => {
111
+ cdata. get_coerce_unsized_info( def_id. index) . unwrap_or_else( || {
112
+ bug!( "coerce_unsized_info: `{:?}` is missing its info" , def_id) ;
113
+ } )
114
+ }
115
+ optimized_mir => {
116
+ let mir = cdata. maybe_get_optimized_mir( tcx, def_id. index) . unwrap_or_else( || {
117
+ bug!( "get_optimized_mir: missing MIR for `{:?}`" , def_id)
118
+ } ) ;
119
+
120
+ let mir = tcx. alloc_mir( mir) ;
121
+
122
+ mir
123
+ }
124
+ mir_const_qualif => { cdata. mir_const_qualif( def_id. index) }
125
+ typeck_tables_of => { cdata. item_body_tables( def_id. index, tcx) }
126
+ closure_kind => { cdata. closure_kind( def_id. index) }
127
+ closure_type => { cdata. closure_ty( def_id. index, tcx) }
128
+ inherent_impls => { Rc :: new( cdata. get_inherent_implementations_for_type( def_id. index) ) }
129
+ is_const_fn => { cdata. is_const_fn( def_id. index) }
130
+ is_foreign_item => { cdata. is_foreign_item( def_id. index) }
131
+ is_default_impl => { cdata. is_default_impl( def_id. index) }
132
+ describe_def => { cdata. get_def( def_id. index) }
133
+ def_span => { cdata. get_span( def_id. index, & tcx. sess) }
134
+ stability => { cdata. get_stability( def_id. index) }
135
+ deprecation => { cdata. get_deprecation( def_id. index) }
136
+ item_attrs => { cdata. get_item_attrs( def_id. index, & tcx. dep_graph) }
137
+ // FIXME(#38501) We've skipped a `read` on the `HirBody` of
138
+ // a `fn` when encoding, so the dep-tracking wouldn't work.
139
+ // This is only used by rustdoc anyway, which shouldn't have
140
+ // incremental recompilation ever enabled.
141
+ fn_arg_names => { cdata. get_fn_arg_names( def_id. index) }
142
+ impl_parent => { cdata. get_parent_impl( def_id. index) }
143
+ trait_of_item => { cdata. get_trait_of_item( def_id. index) }
144
+ is_exported_symbol => {
145
+ let dep_node = cdata. metadata_dep_node( GlobalMetaDataKind :: ExportedSymbols ) ;
146
+ cdata. exported_symbols. get( & tcx. dep_graph, dep_node) . contains( & def_id. index)
147
+ }
148
+ item_body_nested_bodies => { Rc :: new( cdata. item_body_nested_bodies( def_id. index) ) }
149
+ const_is_rvalue_promotable_to_static => {
150
+ cdata. const_is_rvalue_promotable_to_static( def_id. index)
151
+ }
152
+ is_mir_available => { cdata. is_item_mir_available( def_id. index) }
95
153
}
96
- optimized_mir => {
97
- let mir = cdata. maybe_get_optimized_mir( tcx, def_id. index) . unwrap_or_else( || {
98
- bug!( "get_optimized_mir: missing MIR for `{:?}`" , def_id)
99
- } ) ;
100
154
101
- let mir = tcx. alloc_mir( mir) ;
102
-
103
- mir
104
- }
105
- mir_const_qualif => { cdata. mir_const_qualif( def_id. index) }
106
- typeck_tables_of => { cdata. item_body_tables( def_id. index, tcx) }
107
- closure_kind => { cdata. closure_kind( def_id. index) }
108
- closure_type => { cdata. closure_ty( def_id. index, tcx) }
109
- inherent_impls => { Rc :: new( cdata. get_inherent_implementations_for_type( def_id. index) ) }
110
- is_const_fn => { cdata. is_const_fn( def_id. index) }
111
- is_foreign_item => { cdata. is_foreign_item( def_id. index) }
112
- is_default_impl => { cdata. is_default_impl( def_id. index) }
113
- describe_def => { cdata. get_def( def_id. index) }
114
- def_span => { cdata. get_span( def_id. index, & tcx. sess) }
115
- stability => { cdata. get_stability( def_id. index) }
116
- deprecation => { cdata. get_deprecation( def_id. index) }
117
- item_attrs => { cdata. get_item_attrs( def_id. index, & tcx. dep_graph) }
118
- // FIXME(#38501) We've skipped a `read` on the `HirBody` of
119
- // a `fn` when encoding, so the dep-tracking wouldn't work.
120
- // This is only used by rustdoc anyway, which shouldn't have
121
- // incremental recompilation ever enabled.
122
- fn_arg_names => { cdata. get_fn_arg_names( def_id. index) }
123
- impl_parent => { cdata. get_parent_impl( def_id. index) }
124
- trait_of_item => { cdata. get_trait_of_item( def_id. index) }
125
- is_exported_symbol => {
126
- let dep_node = cdata. metadata_dep_node( GlobalMetaDataKind :: ExportedSymbols ) ;
127
- cdata. exported_symbols. get( & tcx. dep_graph, dep_node) . contains( & def_id. index)
128
- }
129
- item_body_nested_bodies => { Rc :: new( cdata. item_body_nested_bodies( def_id. index) ) }
130
- const_is_rvalue_promotable_to_static => {
131
- cdata. const_is_rvalue_promotable_to_static( def_id. index)
132
- }
133
- is_mir_available => { cdata. is_item_mir_available( def_id. index) }
155
+ ByCrateNum {
156
+ }
134
157
}
135
158
136
159
pub fn provide_local < ' tcx > ( providers : & mut Providers < ' tcx > ) {
0 commit comments