]>
Commit | Line | Data |
---|---|---|
ea8adc8c XL |
1 | // Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT |
2 | // file at the top-level directory of this distribution and at | |
3 | // http://rust-lang.org/COPYRIGHT. | |
4 | // | |
5 | // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | |
6 | // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | |
7 | // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | |
8 | // option. This file may not be copied, modified, or distributed | |
9 | // except according to those terms. | |
10 | ||
abe05a73 | 11 | use dep_graph::SerializedDepNodeIndex; |
83c7162d | 12 | use dep_graph::DepNode; |
ea8adc8c | 13 | use hir::def_id::{CrateNum, DefId, DefIndex}; |
8faf50e0 | 14 | use mir::interpret::GlobalId; |
0bf4aa26 | 15 | use traits; |
8faf50e0 | 16 | use traits::query::{ |
0bf4aa26 XL |
17 | CanonicalPredicateGoal, CanonicalProjectionGoal, CanonicalTyGoal, |
18 | CanonicalTypeOpAscribeUserTypeGoal, CanonicalTypeOpEqGoal, CanonicalTypeOpNormalizeGoal, | |
19 | CanonicalTypeOpProvePredicateGoal, CanonicalTypeOpSubtypeGoal, | |
8faf50e0 | 20 | }; |
0531ce1d | 21 | use ty::{self, ParamEnvAnd, Ty, TyCtxt}; |
ea8adc8c | 22 | use ty::subst::Substs; |
94b46f34 XL |
23 | use ty::query::queries; |
24 | use ty::query::Query; | |
25 | use ty::query::QueryCache; | |
b7449926 | 26 | use util::profiling::ProfileCategory; |
ea8adc8c | 27 | |
0bf4aa26 | 28 | use std::borrow::Cow; |
ea8adc8c | 29 | use std::hash::Hash; |
83c7162d | 30 | use std::fmt::Debug; |
ea8adc8c | 31 | use syntax_pos::symbol::InternedString; |
83c7162d XL |
32 | use rustc_data_structures::sync::Lock; |
33 | use rustc_data_structures::stable_hasher::HashStable; | |
34 | use ich::StableHashingContext; | |
ea8adc8c | 35 | |
94b46f34 | 36 | // Query configuration and description traits. |
ea8adc8c | 37 | |
83c7162d XL |
38 | pub trait QueryConfig<'tcx> { |
39 | const NAME: &'static str; | |
b7449926 | 40 | const CATEGORY: ProfileCategory; |
83c7162d XL |
41 | |
42 | type Key: Eq + Hash + Clone + Debug; | |
43 | type Value: Clone + for<'a> HashStable<StableHashingContext<'a>>; | |
94b46f34 | 44 | } |
83c7162d | 45 | |
94b46f34 | 46 | pub(super) trait QueryAccessors<'tcx>: QueryConfig<'tcx> { |
83c7162d XL |
47 | fn query(key: Self::Key) -> Query<'tcx>; |
48 | ||
49 | // Don't use this method to access query results, instead use the methods on TyCtxt | |
94b46f34 | 50 | fn query_cache<'a>(tcx: TyCtxt<'a, 'tcx, '_>) -> &'a Lock<QueryCache<'tcx, Self>>; |
83c7162d XL |
51 | |
52 | fn to_dep_node(tcx: TyCtxt<'_, 'tcx, '_>, key: &Self::Key) -> DepNode; | |
53 | ||
54 | // Don't use this method to compute query results, instead use the methods on TyCtxt | |
55 | fn compute(tcx: TyCtxt<'_, 'tcx, '_>, key: Self::Key) -> Self::Value; | |
56 | ||
57 | fn handle_cycle_error(tcx: TyCtxt<'_, 'tcx, '_>) -> Self::Value; | |
ea8adc8c XL |
58 | } |
59 | ||
94b46f34 | 60 | pub(super) trait QueryDescription<'tcx>: QueryAccessors<'tcx> { |
0bf4aa26 | 61 | fn describe(tcx: TyCtxt<'_, '_, '_>, key: Self::Key) -> Cow<'static, str>; |
abe05a73 | 62 | |
ff7c6d11 | 63 | #[inline] |
abe05a73 XL |
64 | fn cache_on_disk(_: Self::Key) -> bool { |
65 | false | |
66 | } | |
67 | ||
ff7c6d11 | 68 | fn try_load_from_disk(_: TyCtxt<'_, 'tcx, 'tcx>, |
abe05a73 | 69 | _: SerializedDepNodeIndex) |
ff7c6d11 XL |
70 | -> Option<Self::Value> { |
71 | bug!("QueryDescription::load_from_disk() called for an unsupported query.") | |
abe05a73 | 72 | } |
ea8adc8c XL |
73 | } |
74 | ||
94b46f34 | 75 | impl<'tcx, M: QueryAccessors<'tcx, Key=DefId>> QueryDescription<'tcx> for M { |
0bf4aa26 | 76 | default fn describe(tcx: TyCtxt<'_, '_, '_>, def_id: DefId) -> Cow<'static, str> { |
abe05a73 | 77 | if !tcx.sess.verbose() { |
0bf4aa26 | 78 | format!("processing `{}`", tcx.item_path_str(def_id)).into() |
abe05a73 XL |
79 | } else { |
80 | let name = unsafe { ::std::intrinsics::type_name::<M>() }; | |
0bf4aa26 | 81 | format!("processing `{}` applied to `{:?}`", name, def_id).into() |
abe05a73 | 82 | } |
ea8adc8c XL |
83 | } |
84 | } | |
85 | ||
0531ce1d XL |
86 | impl<'tcx> QueryDescription<'tcx> for queries::normalize_projection_ty<'tcx> { |
87 | fn describe( | |
0bf4aa26 | 88 | _tcx: TyCtxt<'_, '_, '_>, |
0531ce1d | 89 | goal: CanonicalProjectionGoal<'tcx>, |
0bf4aa26 XL |
90 | ) -> Cow<'static, str> { |
91 | format!("normalizing `{:?}`", goal).into() | |
0531ce1d XL |
92 | } |
93 | } | |
94 | ||
8faf50e0 | 95 | impl<'tcx> QueryDescription<'tcx> for queries::implied_outlives_bounds<'tcx> { |
0bf4aa26 XL |
96 | fn describe(_tcx: TyCtxt<'_, '_, '_>, goal: CanonicalTyGoal<'tcx>) -> Cow<'static, str> { |
97 | format!("computing implied outlives bounds for `{:?}`", goal).into() | |
8faf50e0 XL |
98 | } |
99 | } | |
100 | ||
0531ce1d | 101 | impl<'tcx> QueryDescription<'tcx> for queries::dropck_outlives<'tcx> { |
0bf4aa26 XL |
102 | fn describe(_tcx: TyCtxt<'_, '_, '_>, goal: CanonicalTyGoal<'tcx>) -> Cow<'static, str> { |
103 | format!("computing dropck types for `{:?}`", goal).into() | |
0531ce1d XL |
104 | } |
105 | } | |
106 | ||
107 | impl<'tcx> QueryDescription<'tcx> for queries::normalize_ty_after_erasing_regions<'tcx> { | |
0bf4aa26 XL |
108 | fn describe(_tcx: TyCtxt<'_, '_, '_>, goal: ParamEnvAnd<'tcx, Ty<'tcx>>) -> Cow<'static, str> { |
109 | format!("normalizing `{:?}`", goal).into() | |
0531ce1d XL |
110 | } |
111 | } | |
112 | ||
83c7162d | 113 | impl<'tcx> QueryDescription<'tcx> for queries::evaluate_obligation<'tcx> { |
0bf4aa26 XL |
114 | fn describe(_tcx: TyCtxt<'_, '_, '_>, goal: CanonicalPredicateGoal<'tcx>) -> Cow<'static, str> { |
115 | format!("evaluating trait selection obligation `{}`", goal.value.value).into() | |
116 | } | |
117 | } | |
118 | ||
119 | impl<'tcx> QueryDescription<'tcx> for queries::type_op_ascribe_user_type<'tcx> { | |
120 | fn describe( | |
121 | _tcx: TyCtxt<'_, '_, '_>, | |
122 | goal: CanonicalTypeOpAscribeUserTypeGoal<'tcx>, | |
123 | ) -> Cow<'static, str> { | |
124 | format!("evaluating `type_op_ascribe_user_type` `{:?}`", goal).into() | |
83c7162d XL |
125 | } |
126 | } | |
127 | ||
8faf50e0 | 128 | impl<'tcx> QueryDescription<'tcx> for queries::type_op_eq<'tcx> { |
0bf4aa26 XL |
129 | fn describe(_tcx: TyCtxt<'_, '_, '_>, goal: CanonicalTypeOpEqGoal<'tcx>) -> Cow<'static, str> { |
130 | format!("evaluating `type_op_eq` `{:?}`", goal).into() | |
8faf50e0 XL |
131 | } |
132 | } | |
133 | ||
134 | impl<'tcx> QueryDescription<'tcx> for queries::type_op_subtype<'tcx> { | |
0bf4aa26 XL |
135 | fn describe(_tcx: TyCtxt<'_, '_, '_>, goal: CanonicalTypeOpSubtypeGoal<'tcx>) |
136 | -> Cow<'static, str> { | |
137 | format!("evaluating `type_op_subtype` `{:?}`", goal).into() | |
8faf50e0 XL |
138 | } |
139 | } | |
140 | ||
141 | impl<'tcx> QueryDescription<'tcx> for queries::type_op_prove_predicate<'tcx> { | |
0bf4aa26 XL |
142 | fn describe(_tcx: TyCtxt<'_, '_, '_>, goal: CanonicalTypeOpProvePredicateGoal<'tcx>) |
143 | -> Cow<'static, str> { | |
144 | format!("evaluating `type_op_prove_predicate` `{:?}`", goal).into() | |
8faf50e0 XL |
145 | } |
146 | } | |
147 | ||
148 | impl<'tcx> QueryDescription<'tcx> for queries::type_op_normalize_ty<'tcx> { | |
0bf4aa26 XL |
149 | fn describe(_tcx: TyCtxt<'_, '_, '_>, |
150 | goal: CanonicalTypeOpNormalizeGoal<'tcx, Ty<'tcx>>) -> Cow<'static, str> { | |
151 | format!("normalizing `{:?}`", goal).into() | |
8faf50e0 XL |
152 | } |
153 | } | |
154 | ||
155 | impl<'tcx> QueryDescription<'tcx> for queries::type_op_normalize_predicate<'tcx> { | |
156 | fn describe( | |
0bf4aa26 | 157 | _tcx: TyCtxt<'_, '_, '_>, |
8faf50e0 | 158 | goal: CanonicalTypeOpNormalizeGoal<'tcx, ty::Predicate<'tcx>>, |
0bf4aa26 XL |
159 | ) -> Cow<'static, str> { |
160 | format!("normalizing `{:?}`", goal).into() | |
8faf50e0 XL |
161 | } |
162 | } | |
163 | ||
164 | impl<'tcx> QueryDescription<'tcx> for queries::type_op_normalize_poly_fn_sig<'tcx> { | |
165 | fn describe( | |
0bf4aa26 | 166 | _tcx: TyCtxt<'_, '_, '_>, |
8faf50e0 | 167 | goal: CanonicalTypeOpNormalizeGoal<'tcx, ty::PolyFnSig<'tcx>>, |
0bf4aa26 XL |
168 | ) -> Cow<'static, str> { |
169 | format!("normalizing `{:?}`", goal).into() | |
8faf50e0 XL |
170 | } |
171 | } | |
172 | ||
173 | impl<'tcx> QueryDescription<'tcx> for queries::type_op_normalize_fn_sig<'tcx> { | |
0bf4aa26 XL |
174 | fn describe(_tcx: TyCtxt<'_, '_, '_>, |
175 | goal: CanonicalTypeOpNormalizeGoal<'tcx, ty::FnSig<'tcx>>) -> Cow<'static, str> { | |
176 | format!("normalizing `{:?}`", goal).into() | |
8faf50e0 XL |
177 | } |
178 | } | |
179 | ||
abe05a73 | 180 | impl<'tcx> QueryDescription<'tcx> for queries::is_copy_raw<'tcx> { |
0bf4aa26 XL |
181 | fn describe(_tcx: TyCtxt<'_, '_, '_>, env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) |
182 | -> Cow<'static, str> { | |
183 | format!("computing whether `{}` is `Copy`", env.value).into() | |
ea8adc8c XL |
184 | } |
185 | } | |
186 | ||
abe05a73 | 187 | impl<'tcx> QueryDescription<'tcx> for queries::is_sized_raw<'tcx> { |
0bf4aa26 XL |
188 | fn describe(_tcx: TyCtxt<'_, '_, '_>, env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) |
189 | -> Cow<'static, str> { | |
190 | format!("computing whether `{}` is `Sized`", env.value).into() | |
ea8adc8c XL |
191 | } |
192 | } | |
193 | ||
abe05a73 | 194 | impl<'tcx> QueryDescription<'tcx> for queries::is_freeze_raw<'tcx> { |
0bf4aa26 XL |
195 | fn describe(_tcx: TyCtxt<'_, '_, '_>, env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) |
196 | -> Cow<'static, str> { | |
197 | format!("computing whether `{}` is freeze", env.value).into() | |
ea8adc8c XL |
198 | } |
199 | } | |
200 | ||
abe05a73 | 201 | impl<'tcx> QueryDescription<'tcx> for queries::needs_drop_raw<'tcx> { |
0bf4aa26 XL |
202 | fn describe(_tcx: TyCtxt<'_, '_, '_>, env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) |
203 | -> Cow<'static, str> { | |
204 | format!("computing whether `{}` needs drop", env.value).into() | |
ea8adc8c XL |
205 | } |
206 | } | |
207 | ||
abe05a73 | 208 | impl<'tcx> QueryDescription<'tcx> for queries::layout_raw<'tcx> { |
0bf4aa26 XL |
209 | fn describe(_tcx: TyCtxt<'_, '_, '_>, env: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) |
210 | -> Cow<'static, str> { | |
211 | format!("computing layout of `{}`", env.value).into() | |
ea8adc8c XL |
212 | } |
213 | } | |
214 | ||
abe05a73 | 215 | impl<'tcx> QueryDescription<'tcx> for queries::super_predicates_of<'tcx> { |
0bf4aa26 | 216 | fn describe(tcx: TyCtxt<'_, '_, '_>, def_id: DefId) -> Cow<'static, str> { |
ea8adc8c | 217 | format!("computing the supertraits of `{}`", |
0bf4aa26 | 218 | tcx.item_path_str(def_id)).into() |
ea8adc8c XL |
219 | } |
220 | } | |
221 | ||
abe05a73 | 222 | impl<'tcx> QueryDescription<'tcx> for queries::erase_regions_ty<'tcx> { |
0bf4aa26 XL |
223 | fn describe(_tcx: TyCtxt<'_, '_, '_>, ty: Ty<'tcx>) -> Cow<'static, str> { |
224 | format!("erasing regions from `{:?}`", ty).into() | |
abe05a73 XL |
225 | } |
226 | } | |
227 | ||
228 | impl<'tcx> QueryDescription<'tcx> for queries::type_param_predicates<'tcx> { | |
0bf4aa26 | 229 | fn describe(tcx: TyCtxt<'_, '_, '_>, (_, def_id): (DefId, DefId)) -> Cow<'static, str> { |
ea8adc8c XL |
230 | let id = tcx.hir.as_local_node_id(def_id).unwrap(); |
231 | format!("computing the bounds for type parameter `{}`", | |
0bf4aa26 | 232 | tcx.hir.ty_param_name(id)).into() |
ea8adc8c XL |
233 | } |
234 | } | |
235 | ||
abe05a73 | 236 | impl<'tcx> QueryDescription<'tcx> for queries::coherent_trait<'tcx> { |
0bf4aa26 | 237 | fn describe(tcx: TyCtxt<'_, '_, '_>, def_id: DefId) -> Cow<'static, str> { |
ea8adc8c | 238 | format!("coherence checking all impls of trait `{}`", |
0bf4aa26 | 239 | tcx.item_path_str(def_id)).into() |
ea8adc8c XL |
240 | } |
241 | } | |
242 | ||
83c7162d | 243 | impl<'tcx> QueryDescription<'tcx> for queries::upstream_monomorphizations<'tcx> { |
0bf4aa26 XL |
244 | fn describe(_: TyCtxt<'_, '_, '_>, k: CrateNum) -> Cow<'static, str> { |
245 | format!("collecting available upstream monomorphizations `{:?}`", k).into() | |
83c7162d XL |
246 | } |
247 | } | |
248 | ||
abe05a73 | 249 | impl<'tcx> QueryDescription<'tcx> for queries::crate_inherent_impls<'tcx> { |
0bf4aa26 XL |
250 | fn describe(_: TyCtxt<'_, '_, '_>, k: CrateNum) -> Cow<'static, str> { |
251 | format!("all inherent impls defined in crate `{:?}`", k).into() | |
ea8adc8c XL |
252 | } |
253 | } | |
254 | ||
abe05a73 | 255 | impl<'tcx> QueryDescription<'tcx> for queries::crate_inherent_impls_overlap_check<'tcx> { |
0bf4aa26 XL |
256 | fn describe(_: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { |
257 | "check for overlap between inherent impls defined in this crate".into() | |
ea8adc8c XL |
258 | } |
259 | } | |
260 | ||
abe05a73 | 261 | impl<'tcx> QueryDescription<'tcx> for queries::crate_variances<'tcx> { |
0bf4aa26 XL |
262 | fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { |
263 | "computing the variances for items in this crate".into() | |
ea8adc8c XL |
264 | } |
265 | } | |
266 | ||
83c7162d | 267 | impl<'tcx> QueryDescription<'tcx> for queries::inferred_outlives_crate<'tcx> { |
0bf4aa26 XL |
268 | fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { |
269 | "computing the inferred outlives predicates for items in this crate".into() | |
83c7162d XL |
270 | } |
271 | } | |
272 | ||
abe05a73 | 273 | impl<'tcx> QueryDescription<'tcx> for queries::mir_shims<'tcx> { |
0bf4aa26 | 274 | fn describe(tcx: TyCtxt<'_, '_, '_>, def: ty::InstanceDef<'tcx>) -> Cow<'static, str> { |
ea8adc8c | 275 | format!("generating MIR shim for `{}`", |
0bf4aa26 | 276 | tcx.item_path_str(def.def_id())).into() |
ea8adc8c XL |
277 | } |
278 | } | |
279 | ||
abe05a73 | 280 | impl<'tcx> QueryDescription<'tcx> for queries::privacy_access_levels<'tcx> { |
0bf4aa26 XL |
281 | fn describe(_: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { |
282 | "privacy access levels".into() | |
ea8adc8c XL |
283 | } |
284 | } | |
285 | ||
abe05a73 | 286 | impl<'tcx> QueryDescription<'tcx> for queries::typeck_item_bodies<'tcx> { |
0bf4aa26 XL |
287 | fn describe(_: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { |
288 | "type-checking all item bodies".into() | |
ea8adc8c XL |
289 | } |
290 | } | |
291 | ||
abe05a73 | 292 | impl<'tcx> QueryDescription<'tcx> for queries::reachable_set<'tcx> { |
0bf4aa26 XL |
293 | fn describe(_: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { |
294 | "reachability".into() | |
ea8adc8c XL |
295 | } |
296 | } | |
297 | ||
abe05a73 | 298 | impl<'tcx> QueryDescription<'tcx> for queries::const_eval<'tcx> { |
0bf4aa26 XL |
299 | fn describe(tcx: TyCtxt<'_, '_, '_>, key: ty::ParamEnvAnd<'tcx, GlobalId<'tcx>>) |
300 | -> Cow<'static, str> | |
301 | { | |
302 | format!("const-evaluating `{}`", tcx.item_path_str(key.value.instance.def.def_id())).into() | |
0531ce1d XL |
303 | } |
304 | ||
305 | #[inline] | |
306 | fn cache_on_disk(_key: Self::Key) -> bool { | |
307 | true | |
308 | } | |
309 | ||
310 | #[inline] | |
311 | fn try_load_from_disk<'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>, | |
312 | id: SerializedDepNodeIndex) | |
313 | -> Option<Self::Value> { | |
94b46f34 | 314 | tcx.queries.on_disk_cache.try_load_query_result(tcx, id).map(Ok) |
ea8adc8c XL |
315 | } |
316 | } | |
317 | ||
abe05a73 | 318 | impl<'tcx> QueryDescription<'tcx> for queries::mir_keys<'tcx> { |
0bf4aa26 XL |
319 | fn describe(_: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { |
320 | "getting a list of all mir_keys".into() | |
ea8adc8c XL |
321 | } |
322 | } | |
323 | ||
abe05a73 | 324 | impl<'tcx> QueryDescription<'tcx> for queries::symbol_name<'tcx> { |
0bf4aa26 XL |
325 | fn describe(_tcx: TyCtxt<'_, '_, '_>, instance: ty::Instance<'tcx>) -> Cow<'static, str> { |
326 | format!("computing the symbol for `{}`", instance).into() | |
ea8adc8c | 327 | } |
ff7c6d11 XL |
328 | |
329 | #[inline] | |
330 | fn cache_on_disk(_: Self::Key) -> bool { | |
331 | true | |
332 | } | |
333 | ||
334 | #[inline] | |
335 | fn try_load_from_disk<'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>, | |
336 | id: SerializedDepNodeIndex) | |
337 | -> Option<Self::Value> { | |
94b46f34 | 338 | tcx.queries.on_disk_cache.try_load_query_result(tcx, id) |
ff7c6d11 | 339 | } |
ea8adc8c XL |
340 | } |
341 | ||
abe05a73 | 342 | impl<'tcx> QueryDescription<'tcx> for queries::describe_def<'tcx> { |
0bf4aa26 | 343 | fn describe(_: TyCtxt<'_, '_, '_>, _: DefId) -> Cow<'static, str> { |
ea8adc8c XL |
344 | bug!("describe_def") |
345 | } | |
346 | } | |
347 | ||
abe05a73 | 348 | impl<'tcx> QueryDescription<'tcx> for queries::def_span<'tcx> { |
0bf4aa26 | 349 | fn describe(_: TyCtxt<'_, '_, '_>, _: DefId) -> Cow<'static, str> { |
ea8adc8c XL |
350 | bug!("def_span") |
351 | } | |
352 | } | |
353 | ||
354 | ||
abe05a73 | 355 | impl<'tcx> QueryDescription<'tcx> for queries::lookup_stability<'tcx> { |
0bf4aa26 | 356 | fn describe(_: TyCtxt<'_, '_, '_>, _: DefId) -> Cow<'static, str> { |
ea8adc8c XL |
357 | bug!("stability") |
358 | } | |
359 | } | |
360 | ||
abe05a73 | 361 | impl<'tcx> QueryDescription<'tcx> for queries::lookup_deprecation_entry<'tcx> { |
0bf4aa26 | 362 | fn describe(_: TyCtxt<'_, '_, '_>, _: DefId) -> Cow<'static, str> { |
ea8adc8c XL |
363 | bug!("deprecation") |
364 | } | |
365 | } | |
366 | ||
abe05a73 | 367 | impl<'tcx> QueryDescription<'tcx> for queries::item_attrs<'tcx> { |
0bf4aa26 | 368 | fn describe(_: TyCtxt<'_, '_, '_>, _: DefId) -> Cow<'static, str> { |
ea8adc8c XL |
369 | bug!("item_attrs") |
370 | } | |
371 | } | |
372 | ||
0531ce1d | 373 | impl<'tcx> QueryDescription<'tcx> for queries::is_reachable_non_generic<'tcx> { |
0bf4aa26 | 374 | fn describe(_: TyCtxt<'_, '_, '_>, _: DefId) -> Cow<'static, str> { |
0531ce1d | 375 | bug!("is_reachable_non_generic") |
ea8adc8c XL |
376 | } |
377 | } | |
378 | ||
abe05a73 | 379 | impl<'tcx> QueryDescription<'tcx> for queries::fn_arg_names<'tcx> { |
0bf4aa26 | 380 | fn describe(_: TyCtxt<'_, '_, '_>, _: DefId) -> Cow<'static, str> { |
ea8adc8c XL |
381 | bug!("fn_arg_names") |
382 | } | |
383 | } | |
384 | ||
abe05a73 | 385 | impl<'tcx> QueryDescription<'tcx> for queries::impl_parent<'tcx> { |
0bf4aa26 | 386 | fn describe(_: TyCtxt<'_, '_, '_>, _: DefId) -> Cow<'static, str> { |
ea8adc8c XL |
387 | bug!("impl_parent") |
388 | } | |
389 | } | |
390 | ||
abe05a73 | 391 | impl<'tcx> QueryDescription<'tcx> for queries::trait_of_item<'tcx> { |
0bf4aa26 | 392 | fn describe(_: TyCtxt<'_, '_, '_>, _: DefId) -> Cow<'static, str> { |
ea8adc8c XL |
393 | bug!("trait_of_item") |
394 | } | |
395 | } | |
396 | ||
abe05a73 | 397 | impl<'tcx> QueryDescription<'tcx> for queries::const_is_rvalue_promotable_to_static<'tcx> { |
0bf4aa26 | 398 | fn describe(tcx: TyCtxt<'_, '_, '_>, def_id: DefId) -> Cow<'static, str> { |
ea8adc8c | 399 | format!("const checking if rvalue is promotable to static `{}`", |
0bf4aa26 | 400 | tcx.item_path_str(def_id)).into() |
ea8adc8c | 401 | } |
ff7c6d11 XL |
402 | |
403 | #[inline] | |
404 | fn cache_on_disk(_: Self::Key) -> bool { | |
405 | true | |
406 | } | |
407 | ||
408 | #[inline] | |
409 | fn try_load_from_disk<'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>, | |
0bf4aa26 XL |
410 | id: SerializedDepNodeIndex) |
411 | -> Option<Self::Value> { | |
94b46f34 | 412 | tcx.queries.on_disk_cache.try_load_query_result(tcx, id) |
ff7c6d11 | 413 | } |
ea8adc8c XL |
414 | } |
415 | ||
abe05a73 | 416 | impl<'tcx> QueryDescription<'tcx> for queries::rvalue_promotable_map<'tcx> { |
0bf4aa26 | 417 | fn describe(tcx: TyCtxt<'_, '_, '_>, def_id: DefId) -> Cow<'static, str> { |
abe05a73 | 418 | format!("checking which parts of `{}` are promotable to static", |
0bf4aa26 | 419 | tcx.item_path_str(def_id)).into() |
abe05a73 XL |
420 | } |
421 | } | |
422 | ||
423 | impl<'tcx> QueryDescription<'tcx> for queries::is_mir_available<'tcx> { | |
0bf4aa26 | 424 | fn describe(tcx: TyCtxt<'_, '_, '_>, def_id: DefId) -> Cow<'static, str> { |
ea8adc8c | 425 | format!("checking if item is mir available: `{}`", |
0bf4aa26 | 426 | tcx.item_path_str(def_id)).into() |
ea8adc8c XL |
427 | } |
428 | } | |
429 | ||
94b46f34 | 430 | impl<'tcx> QueryDescription<'tcx> for queries::codegen_fulfill_obligation<'tcx> { |
0bf4aa26 XL |
431 | fn describe(tcx: TyCtxt<'_, '_, '_>, |
432 | key: (ty::ParamEnv<'tcx>, ty::PolyTraitRef<'tcx>)) -> Cow<'static, str> { | |
abe05a73 | 433 | format!("checking if `{}` fulfills its obligations", tcx.item_path_str(key.1.def_id())) |
0bf4aa26 | 434 | .into() |
abe05a73 | 435 | } |
ff7c6d11 XL |
436 | |
437 | #[inline] | |
438 | fn cache_on_disk(_: Self::Key) -> bool { | |
439 | true | |
440 | } | |
441 | ||
442 | #[inline] | |
443 | fn try_load_from_disk<'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>, | |
444 | id: SerializedDepNodeIndex) | |
445 | -> Option<Self::Value> { | |
94b46f34 | 446 | tcx.queries.on_disk_cache.try_load_query_result(tcx, id) |
ff7c6d11 | 447 | } |
abe05a73 XL |
448 | } |
449 | ||
450 | impl<'tcx> QueryDescription<'tcx> for queries::trait_impls_of<'tcx> { | |
0bf4aa26 XL |
451 | fn describe(tcx: TyCtxt<'_, '_, '_>, def_id: DefId) -> Cow<'static, str> { |
452 | format!("trait impls of `{}`", tcx.item_path_str(def_id)).into() | |
ea8adc8c XL |
453 | } |
454 | } | |
455 | ||
abe05a73 | 456 | impl<'tcx> QueryDescription<'tcx> for queries::is_object_safe<'tcx> { |
0bf4aa26 XL |
457 | fn describe(tcx: TyCtxt<'_, '_, '_>, def_id: DefId) -> Cow<'static, str> { |
458 | format!("determine object safety of trait `{}`", tcx.item_path_str(def_id)).into() | |
ea8adc8c XL |
459 | } |
460 | } | |
461 | ||
0bf4aa26 XL |
462 | impl<'tcx> QueryDescription<'tcx> for queries::is_const_fn_raw<'tcx> { |
463 | fn describe(tcx: TyCtxt<'_, '_, '_>, def_id: DefId) -> Cow<'static, str> { | |
464 | format!("checking if item is const fn: `{}`", tcx.item_path_str(def_id)).into() | |
ea8adc8c XL |
465 | } |
466 | } | |
467 | ||
abe05a73 | 468 | impl<'tcx> QueryDescription<'tcx> for queries::dylib_dependency_formats<'tcx> { |
0bf4aa26 XL |
469 | fn describe(_: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { |
470 | "dylib dependency formats of crate".into() | |
ea8adc8c XL |
471 | } |
472 | } | |
473 | ||
abe05a73 | 474 | impl<'tcx> QueryDescription<'tcx> for queries::is_panic_runtime<'tcx> { |
0bf4aa26 XL |
475 | fn describe(_: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { |
476 | "checking if the crate is_panic_runtime".into() | |
ea8adc8c XL |
477 | } |
478 | } | |
479 | ||
abe05a73 | 480 | impl<'tcx> QueryDescription<'tcx> for queries::is_compiler_builtins<'tcx> { |
0bf4aa26 XL |
481 | fn describe(_: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { |
482 | "checking if the crate is_compiler_builtins".into() | |
ea8adc8c XL |
483 | } |
484 | } | |
485 | ||
abe05a73 | 486 | impl<'tcx> QueryDescription<'tcx> for queries::has_global_allocator<'tcx> { |
0bf4aa26 XL |
487 | fn describe(_: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { |
488 | "checking if the crate has_global_allocator".into() | |
ea8adc8c XL |
489 | } |
490 | } | |
491 | ||
b7449926 | 492 | impl<'tcx> QueryDescription<'tcx> for queries::has_panic_handler<'tcx> { |
0bf4aa26 XL |
493 | fn describe(_: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { |
494 | "checking if the crate has_panic_handler".into() | |
b7449926 XL |
495 | } |
496 | } | |
497 | ||
abe05a73 | 498 | impl<'tcx> QueryDescription<'tcx> for queries::extern_crate<'tcx> { |
0bf4aa26 XL |
499 | fn describe(_: TyCtxt<'_, '_, '_>, _: DefId) -> Cow<'static, str> { |
500 | "getting crate's ExternCrateData".into() | |
ea8adc8c XL |
501 | } |
502 | } | |
503 | ||
abe05a73 | 504 | impl<'tcx> QueryDescription<'tcx> for queries::lint_levels<'tcx> { |
0bf4aa26 XL |
505 | fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { |
506 | "computing the lint levels for items in this crate".into() | |
ea8adc8c XL |
507 | } |
508 | } | |
509 | ||
abe05a73 | 510 | impl<'tcx> QueryDescription<'tcx> for queries::specializes<'tcx> { |
0bf4aa26 XL |
511 | fn describe(_tcx: TyCtxt<'_, '_, '_>, _: (DefId, DefId)) -> Cow<'static, str> { |
512 | "computing whether impls specialize one another".into() | |
ea8adc8c XL |
513 | } |
514 | } | |
515 | ||
abe05a73 | 516 | impl<'tcx> QueryDescription<'tcx> for queries::in_scope_traits_map<'tcx> { |
0bf4aa26 XL |
517 | fn describe(_tcx: TyCtxt<'_, '_, '_>, _: DefIndex) -> Cow<'static, str> { |
518 | "traits in scope at a block".into() | |
ea8adc8c XL |
519 | } |
520 | } | |
521 | ||
abe05a73 | 522 | impl<'tcx> QueryDescription<'tcx> for queries::is_no_builtins<'tcx> { |
0bf4aa26 XL |
523 | fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { |
524 | "test whether a crate has #![no_builtins]".into() | |
ea8adc8c XL |
525 | } |
526 | } | |
527 | ||
abe05a73 | 528 | impl<'tcx> QueryDescription<'tcx> for queries::panic_strategy<'tcx> { |
0bf4aa26 XL |
529 | fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { |
530 | "query a crate's configured panic strategy".into() | |
ea8adc8c XL |
531 | } |
532 | } | |
533 | ||
abe05a73 | 534 | impl<'tcx> QueryDescription<'tcx> for queries::is_profiler_runtime<'tcx> { |
0bf4aa26 XL |
535 | fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { |
536 | "query a crate is #![profiler_runtime]".into() | |
ea8adc8c XL |
537 | } |
538 | } | |
539 | ||
abe05a73 | 540 | impl<'tcx> QueryDescription<'tcx> for queries::is_sanitizer_runtime<'tcx> { |
0bf4aa26 XL |
541 | fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { |
542 | "query a crate is #![sanitizer_runtime]".into() | |
ea8adc8c XL |
543 | } |
544 | } | |
545 | ||
0531ce1d | 546 | impl<'tcx> QueryDescription<'tcx> for queries::reachable_non_generics<'tcx> { |
0bf4aa26 XL |
547 | fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { |
548 | "looking up the exported symbols of a crate".into() | |
ea8adc8c XL |
549 | } |
550 | } | |
551 | ||
abe05a73 | 552 | impl<'tcx> QueryDescription<'tcx> for queries::native_libraries<'tcx> { |
0bf4aa26 XL |
553 | fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { |
554 | "looking up the native libraries of a linked crate".into() | |
ea8adc8c XL |
555 | } |
556 | } | |
557 | ||
0531ce1d | 558 | impl<'tcx> QueryDescription<'tcx> for queries::foreign_modules<'tcx> { |
0bf4aa26 XL |
559 | fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { |
560 | "looking up the foreign modules of a linked crate".into() | |
0531ce1d XL |
561 | } |
562 | } | |
563 | ||
abe05a73 | 564 | impl<'tcx> QueryDescription<'tcx> for queries::plugin_registrar_fn<'tcx> { |
0bf4aa26 XL |
565 | fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { |
566 | "looking up the plugin registrar for a crate".into() | |
ea8adc8c XL |
567 | } |
568 | } | |
569 | ||
abe05a73 | 570 | impl<'tcx> QueryDescription<'tcx> for queries::derive_registrar_fn<'tcx> { |
0bf4aa26 XL |
571 | fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { |
572 | "looking up the derive registrar for a crate".into() | |
ea8adc8c XL |
573 | } |
574 | } | |
575 | ||
abe05a73 | 576 | impl<'tcx> QueryDescription<'tcx> for queries::crate_disambiguator<'tcx> { |
0bf4aa26 XL |
577 | fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { |
578 | "looking up the disambiguator a crate".into() | |
ea8adc8c XL |
579 | } |
580 | } | |
581 | ||
abe05a73 | 582 | impl<'tcx> QueryDescription<'tcx> for queries::crate_hash<'tcx> { |
0bf4aa26 XL |
583 | fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { |
584 | "looking up the hash a crate".into() | |
ea8adc8c XL |
585 | } |
586 | } | |
587 | ||
abe05a73 | 588 | impl<'tcx> QueryDescription<'tcx> for queries::original_crate_name<'tcx> { |
0bf4aa26 XL |
589 | fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { |
590 | "looking up the original name a crate".into() | |
ea8adc8c XL |
591 | } |
592 | } | |
593 | ||
83c7162d | 594 | impl<'tcx> QueryDescription<'tcx> for queries::extra_filename<'tcx> { |
0bf4aa26 XL |
595 | fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { |
596 | "looking up the extra filename for a crate".into() | |
83c7162d XL |
597 | } |
598 | } | |
599 | ||
abe05a73 | 600 | impl<'tcx> QueryDescription<'tcx> for queries::implementations_of_trait<'tcx> { |
0bf4aa26 XL |
601 | fn describe(_tcx: TyCtxt<'_, '_, '_>, _: (CrateNum, DefId)) -> Cow<'static, str> { |
602 | "looking up implementations of a trait in a crate".into() | |
ea8adc8c XL |
603 | } |
604 | } | |
605 | ||
abe05a73 | 606 | impl<'tcx> QueryDescription<'tcx> for queries::all_trait_implementations<'tcx> { |
0bf4aa26 XL |
607 | fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { |
608 | "looking up all (?) trait implementations".into() | |
ea8adc8c XL |
609 | } |
610 | } | |
611 | ||
abe05a73 | 612 | impl<'tcx> QueryDescription<'tcx> for queries::link_args<'tcx> { |
0bf4aa26 XL |
613 | fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { |
614 | "looking up link arguments for a crate".into() | |
ea8adc8c XL |
615 | } |
616 | } | |
617 | ||
ff7c6d11 | 618 | impl<'tcx> QueryDescription<'tcx> for queries::resolve_lifetimes<'tcx> { |
0bf4aa26 XL |
619 | fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { |
620 | "resolving lifetimes".into() | |
ff7c6d11 XL |
621 | } |
622 | } | |
623 | ||
abe05a73 | 624 | impl<'tcx> QueryDescription<'tcx> for queries::named_region_map<'tcx> { |
0bf4aa26 XL |
625 | fn describe(_tcx: TyCtxt<'_, '_, '_>, _: DefIndex) -> Cow<'static, str> { |
626 | "looking up a named region".into() | |
ea8adc8c XL |
627 | } |
628 | } | |
629 | ||
abe05a73 | 630 | impl<'tcx> QueryDescription<'tcx> for queries::is_late_bound_map<'tcx> { |
0bf4aa26 XL |
631 | fn describe(_tcx: TyCtxt<'_, '_, '_>, _: DefIndex) -> Cow<'static, str> { |
632 | "testing if a region is late bound".into() | |
ea8adc8c XL |
633 | } |
634 | } | |
635 | ||
abe05a73 | 636 | impl<'tcx> QueryDescription<'tcx> for queries::object_lifetime_defaults_map<'tcx> { |
0bf4aa26 XL |
637 | fn describe(_tcx: TyCtxt<'_, '_, '_>, _: DefIndex) -> Cow<'static, str> { |
638 | "looking up lifetime defaults for a region".into() | |
ea8adc8c XL |
639 | } |
640 | } | |
641 | ||
abe05a73 | 642 | impl<'tcx> QueryDescription<'tcx> for queries::dep_kind<'tcx> { |
0bf4aa26 XL |
643 | fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { |
644 | "fetching what a dependency looks like".into() | |
ea8adc8c XL |
645 | } |
646 | } | |
647 | ||
abe05a73 | 648 | impl<'tcx> QueryDescription<'tcx> for queries::crate_name<'tcx> { |
0bf4aa26 XL |
649 | fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { |
650 | "fetching what a crate is named".into() | |
ea8adc8c XL |
651 | } |
652 | } | |
653 | ||
b7449926 | 654 | impl<'tcx> QueryDescription<'tcx> for queries::get_lib_features<'tcx> { |
0bf4aa26 XL |
655 | fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { |
656 | "calculating the lib features map".into() | |
b7449926 XL |
657 | } |
658 | } | |
659 | ||
660 | impl<'tcx> QueryDescription<'tcx> for queries::defined_lib_features<'tcx> { | |
0bf4aa26 XL |
661 | fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { |
662 | "calculating the lib features defined in a crate".into() | |
b7449926 XL |
663 | } |
664 | } | |
665 | ||
abe05a73 | 666 | impl<'tcx> QueryDescription<'tcx> for queries::get_lang_items<'tcx> { |
0bf4aa26 XL |
667 | fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { |
668 | "calculating the lang items map".into() | |
ea8adc8c XL |
669 | } |
670 | } | |
671 | ||
abe05a73 | 672 | impl<'tcx> QueryDescription<'tcx> for queries::defined_lang_items<'tcx> { |
0bf4aa26 XL |
673 | fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { |
674 | "calculating the lang items defined in a crate".into() | |
ea8adc8c XL |
675 | } |
676 | } | |
677 | ||
abe05a73 | 678 | impl<'tcx> QueryDescription<'tcx> for queries::missing_lang_items<'tcx> { |
0bf4aa26 XL |
679 | fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { |
680 | "calculating the missing lang items in a crate".into() | |
ea8adc8c XL |
681 | } |
682 | } | |
683 | ||
abe05a73 | 684 | impl<'tcx> QueryDescription<'tcx> for queries::visible_parent_map<'tcx> { |
0bf4aa26 XL |
685 | fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { |
686 | "calculating the visible parent map".into() | |
ea8adc8c XL |
687 | } |
688 | } | |
689 | ||
abe05a73 | 690 | impl<'tcx> QueryDescription<'tcx> for queries::missing_extern_crate_item<'tcx> { |
0bf4aa26 XL |
691 | fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { |
692 | "seeing if we're missing an `extern crate` item for this crate".into() | |
ea8adc8c XL |
693 | } |
694 | } | |
695 | ||
abe05a73 | 696 | impl<'tcx> QueryDescription<'tcx> for queries::used_crate_source<'tcx> { |
0bf4aa26 XL |
697 | fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { |
698 | "looking at the source for a crate".into() | |
ea8adc8c XL |
699 | } |
700 | } | |
701 | ||
abe05a73 | 702 | impl<'tcx> QueryDescription<'tcx> for queries::postorder_cnums<'tcx> { |
0bf4aa26 XL |
703 | fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { |
704 | "generating a postorder list of CrateNums".into() | |
ea8adc8c XL |
705 | } |
706 | } | |
707 | ||
abe05a73 | 708 | impl<'tcx> QueryDescription<'tcx> for queries::maybe_unused_extern_crates<'tcx> { |
0bf4aa26 XL |
709 | fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { |
710 | "looking up all possibly unused extern crates".into() | |
ea8adc8c XL |
711 | } |
712 | } | |
713 | ||
abe05a73 | 714 | impl<'tcx> QueryDescription<'tcx> for queries::stability_index<'tcx> { |
0bf4aa26 XL |
715 | fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { |
716 | "calculating the stability index for the local crate".into() | |
ea8adc8c XL |
717 | } |
718 | } | |
719 | ||
83c7162d | 720 | impl<'tcx> QueryDescription<'tcx> for queries::all_traits<'tcx> { |
0bf4aa26 XL |
721 | fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { |
722 | "fetching all foreign and local traits".into() | |
83c7162d XL |
723 | } |
724 | } | |
725 | ||
abe05a73 | 726 | impl<'tcx> QueryDescription<'tcx> for queries::all_crate_nums<'tcx> { |
0bf4aa26 XL |
727 | fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { |
728 | "fetching all foreign CrateNum instances".into() | |
ea8adc8c XL |
729 | } |
730 | } | |
731 | ||
abe05a73 | 732 | impl<'tcx> QueryDescription<'tcx> for queries::exported_symbols<'tcx> { |
0bf4aa26 XL |
733 | fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { |
734 | "exported_symbols".into() | |
ea8adc8c XL |
735 | } |
736 | } | |
737 | ||
94b46f34 | 738 | impl<'tcx> QueryDescription<'tcx> for queries::collect_and_partition_mono_items<'tcx> { |
0bf4aa26 XL |
739 | fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { |
740 | "collect_and_partition_mono_items".into() | |
ea8adc8c XL |
741 | } |
742 | } | |
743 | ||
abe05a73 | 744 | impl<'tcx> QueryDescription<'tcx> for queries::codegen_unit<'tcx> { |
0bf4aa26 XL |
745 | fn describe(_tcx: TyCtxt<'_, '_, '_>, _: InternedString) -> Cow<'static, str> { |
746 | "codegen_unit".into() | |
ea8adc8c XL |
747 | } |
748 | } | |
749 | ||
abe05a73 | 750 | impl<'tcx> QueryDescription<'tcx> for queries::output_filenames<'tcx> { |
0bf4aa26 XL |
751 | fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { |
752 | "output_filenames".into() | |
ea8adc8c XL |
753 | } |
754 | } | |
755 | ||
abe05a73 | 756 | impl<'tcx> QueryDescription<'tcx> for queries::vtable_methods<'tcx> { |
0bf4aa26 XL |
757 | fn describe(tcx: TyCtxt<'_, '_, '_>, key: ty::PolyTraitRef<'tcx> ) -> Cow<'static, str> { |
758 | format!("finding all methods for trait {}", tcx.item_path_str(key.def_id())).into() | |
abe05a73 XL |
759 | } |
760 | } | |
761 | ||
0531ce1d | 762 | impl<'tcx> QueryDescription<'tcx> for queries::features_query<'tcx> { |
0bf4aa26 XL |
763 | fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { |
764 | "looking up enabled feature gates".into() | |
abe05a73 XL |
765 | } |
766 | } | |
767 | ||
768 | impl<'tcx> QueryDescription<'tcx> for queries::typeck_tables_of<'tcx> { | |
769 | #[inline] | |
770 | fn cache_on_disk(def_id: Self::Key) -> bool { | |
771 | def_id.is_local() | |
772 | } | |
773 | ||
ff7c6d11 | 774 | fn try_load_from_disk(tcx: TyCtxt<'_, 'tcx, 'tcx>, |
abe05a73 | 775 | id: SerializedDepNodeIndex) |
ff7c6d11 XL |
776 | -> Option<Self::Value> { |
777 | let typeck_tables: Option<ty::TypeckTables<'tcx>> = tcx | |
94b46f34 | 778 | .queries.on_disk_cache |
ff7c6d11 XL |
779 | .try_load_query_result(tcx, id); |
780 | ||
781 | typeck_tables.map(|tables| tcx.alloc_tables(tables)) | |
abe05a73 XL |
782 | } |
783 | } | |
784 | ||
ff7c6d11 XL |
785 | impl<'tcx> QueryDescription<'tcx> for queries::optimized_mir<'tcx> { |
786 | #[inline] | |
787 | fn cache_on_disk(def_id: Self::Key) -> bool { | |
788 | def_id.is_local() | |
789 | } | |
790 | ||
791 | fn try_load_from_disk<'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>, | |
2c00a5a8 XL |
792 | id: SerializedDepNodeIndex) |
793 | -> Option<Self::Value> { | |
94b46f34 | 794 | let mir: Option<::mir::Mir<'tcx>> = tcx.queries.on_disk_cache |
ff7c6d11 XL |
795 | .try_load_query_result(tcx, id); |
796 | mir.map(|x| tcx.alloc_mir(x)) | |
797 | } | |
798 | } | |
799 | ||
2c00a5a8 | 800 | impl<'tcx> QueryDescription<'tcx> for queries::substitute_normalize_and_test_predicates<'tcx> { |
0bf4aa26 XL |
801 | fn describe(tcx: TyCtxt<'_, '_, '_>, key: (DefId, &'tcx Substs<'tcx>)) -> Cow<'static, str> { |
802 | format!("testing substituted normalized predicates:`{}`", tcx.item_path_str(key.0)).into() | |
2c00a5a8 XL |
803 | } |
804 | } | |
805 | ||
806 | impl<'tcx> QueryDescription<'tcx> for queries::target_features_whitelist<'tcx> { | |
0bf4aa26 XL |
807 | fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { |
808 | "looking up the whitelist of target features".into() | |
2c00a5a8 XL |
809 | } |
810 | } | |
811 | ||
812 | impl<'tcx> QueryDescription<'tcx> for queries::instance_def_size_estimate<'tcx> { | |
0bf4aa26 XL |
813 | fn describe(tcx: TyCtxt<'_, '_, '_>, def: ty::InstanceDef<'tcx>) -> Cow<'static, str> { |
814 | format!("estimating size for `{}`", tcx.item_path_str(def.def_id())).into() | |
2c00a5a8 XL |
815 | } |
816 | } | |
817 | ||
818 | impl<'tcx> QueryDescription<'tcx> for queries::generics_of<'tcx> { | |
819 | #[inline] | |
820 | fn cache_on_disk(def_id: Self::Key) -> bool { | |
821 | def_id.is_local() | |
822 | } | |
823 | ||
824 | fn try_load_from_disk<'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>, | |
825 | id: SerializedDepNodeIndex) | |
826 | -> Option<Self::Value> { | |
94b46f34 | 827 | let generics: Option<ty::Generics> = tcx.queries.on_disk_cache |
2c00a5a8 XL |
828 | .try_load_query_result(tcx, id); |
829 | generics.map(|x| tcx.alloc_generics(x)) | |
830 | } | |
831 | } | |
832 | ||
0531ce1d | 833 | impl<'tcx> QueryDescription<'tcx> for queries::program_clauses_for<'tcx> { |
0bf4aa26 XL |
834 | fn describe(_tcx: TyCtxt<'_, '_, '_>, _: DefId) -> Cow<'static, str> { |
835 | "generating chalk-style clauses".into() | |
0531ce1d XL |
836 | } |
837 | } | |
838 | ||
83c7162d | 839 | impl<'tcx> QueryDescription<'tcx> for queries::program_clauses_for_env<'tcx> { |
0bf4aa26 XL |
840 | fn describe(_tcx: TyCtxt<'_, '_, '_>, _: traits::Environment<'tcx>) -> Cow<'static, str> { |
841 | "generating chalk-style clauses for environment".into() | |
842 | } | |
843 | } | |
844 | ||
845 | impl<'tcx> QueryDescription<'tcx> for queries::environment<'tcx> { | |
846 | fn describe(_tcx: TyCtxt<'_, '_, '_>, _: DefId) -> Cow<'static, str> { | |
847 | "return a chalk-style environment".into() | |
83c7162d XL |
848 | } |
849 | } | |
850 | ||
0531ce1d | 851 | impl<'tcx> QueryDescription<'tcx> for queries::wasm_import_module_map<'tcx> { |
0bf4aa26 XL |
852 | fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { |
853 | "wasm import module map".into() | |
0531ce1d XL |
854 | } |
855 | } | |
856 | ||
857 | impl<'tcx> QueryDescription<'tcx> for queries::dllimport_foreign_items<'tcx> { | |
0bf4aa26 XL |
858 | fn describe(_tcx: TyCtxt<'_, '_, '_>, _: CrateNum) -> Cow<'static, str> { |
859 | "wasm import module map".into() | |
0531ce1d XL |
860 | } |
861 | } | |
862 | ||
ff7c6d11 XL |
863 | macro_rules! impl_disk_cacheable_query( |
864 | ($query_name:ident, |$key:tt| $cond:expr) => { | |
865 | impl<'tcx> QueryDescription<'tcx> for queries::$query_name<'tcx> { | |
866 | #[inline] | |
867 | fn cache_on_disk($key: Self::Key) -> bool { | |
868 | $cond | |
869 | } | |
870 | ||
871 | #[inline] | |
872 | fn try_load_from_disk<'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>, | |
873 | id: SerializedDepNodeIndex) | |
874 | -> Option<Self::Value> { | |
94b46f34 | 875 | tcx.queries.on_disk_cache.try_load_query_result(tcx, id) |
ff7c6d11 XL |
876 | } |
877 | } | |
878 | } | |
879 | ); | |
880 | ||
881 | impl_disk_cacheable_query!(unsafety_check_result, |def_id| def_id.is_local()); | |
882 | impl_disk_cacheable_query!(borrowck, |def_id| def_id.is_local()); | |
883 | impl_disk_cacheable_query!(mir_borrowck, |def_id| def_id.is_local()); | |
884 | impl_disk_cacheable_query!(mir_const_qualif, |def_id| def_id.is_local()); | |
885 | impl_disk_cacheable_query!(check_match, |def_id| def_id.is_local()); | |
ff7c6d11 | 886 | impl_disk_cacheable_query!(def_symbol_name, |_| true); |
2c00a5a8 XL |
887 | impl_disk_cacheable_query!(type_of, |def_id| def_id.is_local()); |
888 | impl_disk_cacheable_query!(predicates_of, |def_id| def_id.is_local()); | |
889 | impl_disk_cacheable_query!(used_trait_imports, |def_id| def_id.is_local()); | |
94b46f34 | 890 | impl_disk_cacheable_query!(codegen_fn_attrs, |_| true); |
0531ce1d | 891 | impl_disk_cacheable_query!(specialization_graph_of, |_| true); |