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