]> git.lizzy.rs Git - rust.git/blob - src/librustc/ty/maps/plumbing.rs
959f11a89bd01586447f89fcea009fa305988a2e
[rust.git] / src / librustc / ty / maps / plumbing.rs
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
11 //! The implementation of the query system itself. Defines the macros
12 //! that generate the actual methods on tcx which find and execute the
13 //! provider, manage the caches, and so forth.
14
15 use dep_graph::{DepNodeIndex, DepNode, DepKind};
16 use errors::{Diagnostic, DiagnosticBuilder};
17 use ty::{TyCtxt};
18 use ty::maps::Query; // NB: actually generated by the macros in this file
19 use ty::maps::config::QueryDescription;
20 use ty::item_path;
21
22 use rustc_data_structures::fx::{FxHashMap};
23 use std::cell::{RefMut, Cell};
24 use std::marker::PhantomData;
25 use std::mem;
26 use syntax_pos::Span;
27
28 pub(super) struct QueryMap<D: QueryDescription> {
29     phantom: PhantomData<D>,
30     pub(super) map: FxHashMap<D::Key, QueryValue<D::Value>>,
31 }
32
33 pub(super) struct QueryValue<T> {
34     pub(super) value: T,
35     pub(super) index: DepNodeIndex,
36     pub(super) diagnostics: Option<Box<QueryDiagnostics>>,
37 }
38
39 impl<T> QueryValue<T> {
40     pub(super) fn new(value: T,
41                       dep_node_index: DepNodeIndex,
42                       diagnostics: Vec<Diagnostic>)
43                       -> QueryValue<T> {
44         QueryValue {
45             value,
46             index: dep_node_index,
47             diagnostics: if diagnostics.len() == 0 {
48                 None
49             } else {
50                 Some(Box::new(QueryDiagnostics {
51                     diagnostics,
52                     emitted_diagnostics: Cell::new(true),
53                 }))
54             },
55         }
56     }
57 }
58
59 pub(super) struct QueryDiagnostics {
60     pub(super) diagnostics: Vec<Diagnostic>,
61     pub(super) emitted_diagnostics: Cell<bool>,
62 }
63
64 impl<M: QueryDescription> QueryMap<M> {
65     pub(super) fn new() -> QueryMap<M> {
66         QueryMap {
67             phantom: PhantomData,
68             map: FxHashMap(),
69         }
70     }
71 }
72
73 pub(super) struct CycleError<'a, 'tcx: 'a> {
74     span: Span,
75     cycle: RefMut<'a, [(Span, Query<'tcx>)]>,
76 }
77
78 impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
79     pub(super) fn report_cycle(self, CycleError { span, cycle }: CycleError)
80         -> DiagnosticBuilder<'a>
81     {
82         // Subtle: release the refcell lock before invoking `describe()`
83         // below by dropping `cycle`.
84         let stack = cycle.to_vec();
85         mem::drop(cycle);
86
87         assert!(!stack.is_empty());
88
89         // Disable naming impls with types in this path, since that
90         // sometimes cycles itself, leading to extra cycle errors.
91         // (And cycle errors around impls tend to occur during the
92         // collect/coherence phases anyhow.)
93         item_path::with_forced_impl_filename_line(|| {
94             let mut err =
95                 struct_span_err!(self.sess, span, E0391,
96                                  "unsupported cyclic reference between types/traits detected");
97             err.span_label(span, "cyclic reference");
98
99             err.span_note(stack[0].0, &format!("the cycle begins when {}...",
100                                                stack[0].1.describe(self)));
101
102             for &(span, ref query) in &stack[1..] {
103                 err.span_note(span, &format!("...which then requires {}...",
104                                              query.describe(self)));
105             }
106
107             err.note(&format!("...which then again requires {}, completing the cycle.",
108                               stack[0].1.describe(self)));
109
110             return err
111         })
112     }
113
114     pub(super) fn cycle_check<F, R>(self, span: Span, query: Query<'gcx>, compute: F)
115                                     -> Result<R, CycleError<'a, 'gcx>>
116         where F: FnOnce() -> R
117     {
118         {
119             let mut stack = self.maps.query_stack.borrow_mut();
120             if let Some((i, _)) = stack.iter().enumerate().rev()
121                                        .find(|&(_, &(_, ref q))| *q == query) {
122                 return Err(CycleError {
123                     span,
124                     cycle: RefMut::map(stack, |stack| &mut stack[i..])
125                 });
126             }
127             stack.push((span, query));
128         }
129
130         let result = compute();
131
132         self.maps.query_stack.borrow_mut().pop();
133
134         Ok(result)
135     }
136 }
137
138 // If enabled, send a message to the profile-queries thread
139 macro_rules! profq_msg {
140     ($tcx:expr, $msg:expr) => {
141         if cfg!(debug_assertions) {
142             if  $tcx.sess.profile_queries() {
143                 profq_msg($msg)
144             }
145         }
146     }
147 }
148
149 // If enabled, format a key using its debug string, which can be
150 // expensive to compute (in terms of time).
151 macro_rules! profq_key {
152     ($tcx:expr, $key:expr) => {
153         if cfg!(debug_assertions) {
154             if $tcx.sess.profile_queries_and_keys() {
155                 Some(format!("{:?}", $key))
156             } else { None }
157         } else { None }
158     }
159 }
160
161 macro_rules! define_maps {
162     (<$tcx:tt>
163      $($(#[$attr:meta])*
164        [$($modifiers:tt)*] fn $name:ident: $node:ident($K:ty) -> $V:ty,)*) => {
165
166         use dep_graph::DepNodeIndex;
167         use std::cell::RefCell;
168
169         define_map_struct! {
170             tcx: $tcx,
171             input: ($(([$($modifiers)*] [$($attr)*] [$name]))*)
172         }
173
174         impl<$tcx> Maps<$tcx> {
175             pub fn new(providers: IndexVec<CrateNum, Providers<$tcx>>)
176                        -> Self {
177                 Maps {
178                     providers,
179                     query_stack: RefCell::new(vec![]),
180                     $($name: RefCell::new(QueryMap::new())),*
181                 }
182             }
183         }
184
185         #[allow(bad_style)]
186         #[derive(Copy, Clone, Debug, PartialEq, Eq)]
187         pub enum Query<$tcx> {
188             $($(#[$attr])* $name($K)),*
189         }
190
191         #[allow(bad_style)]
192         #[derive(Clone, Debug, PartialEq, Eq)]
193         pub enum QueryMsg {
194             $($name(Option<String>)),*
195         }
196
197         impl<$tcx> Query<$tcx> {
198             pub fn describe(&self, tcx: TyCtxt) -> String {
199                 let (r, name) = match *self {
200                     $(Query::$name(key) => {
201                         (queries::$name::describe(tcx, key), stringify!($name))
202                     })*
203                 };
204                 if tcx.sess.verbose() {
205                     format!("{} [{}]", r, name)
206                 } else {
207                     r
208                 }
209             }
210         }
211
212         pub mod queries {
213             use std::marker::PhantomData;
214
215             $(#[allow(bad_style)]
216             pub struct $name<$tcx> {
217                 data: PhantomData<&$tcx ()>
218             })*
219         }
220
221         $(impl<$tcx> QueryConfig for queries::$name<$tcx> {
222             type Key = $K;
223             type Value = $V;
224         }
225
226         impl<'a, $tcx, 'lcx> queries::$name<$tcx> {
227
228             #[allow(unused)]
229             fn to_dep_node(tcx: TyCtxt<'a, $tcx, 'lcx>, key: &$K) -> DepNode {
230                 use dep_graph::DepConstructor::*;
231
232                 DepNode::new(tcx, $node(*key))
233             }
234
235             fn try_get_with(tcx: TyCtxt<'a, $tcx, 'lcx>,
236                             mut span: Span,
237                             key: $K)
238                             -> Result<$V, CycleError<'a, $tcx>>
239             {
240                 debug!("ty::queries::{}::try_get_with(key={:?}, span={:?})",
241                        stringify!($name),
242                        key,
243                        span);
244
245                 profq_msg!(tcx,
246                     ProfileQueriesMsg::QueryBegin(
247                         span.data(),
248                         QueryMsg::$name(profq_key!(tcx, key))
249                     )
250                 );
251
252                 if let Some(value) = tcx.maps.$name.borrow().map.get(&key) {
253                     if let Some(ref d) = value.diagnostics {
254                         if !d.emitted_diagnostics.get() {
255                             d.emitted_diagnostics.set(true);
256                             let handle = tcx.sess.diagnostic();
257                             for diagnostic in d.diagnostics.iter() {
258                                 DiagnosticBuilder::new_diagnostic(handle, diagnostic.clone())
259                                     .emit();
260                             }
261                         }
262                     }
263                     profq_msg!(tcx, ProfileQueriesMsg::CacheHit);
264                     tcx.dep_graph.read_index(value.index);
265                     return Ok((&value.value).clone());
266                 }
267
268                 // FIXME(eddyb) Get more valid Span's on queries.
269                 // def_span guard is necessary to prevent a recursive loop,
270                 // default_span calls def_span query internally.
271                 if span == DUMMY_SP && stringify!($name) != "def_span" {
272                     span = key.default_span(tcx)
273                 }
274
275                 // Fast path for when incr. comp. is off. `to_dep_node` is
276                 // expensive for some DepKinds.
277                 if !tcx.dep_graph.is_fully_enabled() {
278                     let null_dep_node = DepNode::new_no_params(::dep_graph::DepKind::Null);
279                     return Self::force(tcx, key, span, null_dep_node)
280                                 .map(|(v, _)| v);
281                 }
282
283                 let dep_node = Self::to_dep_node(tcx, &key);
284
285                 if dep_node.kind.is_anon() {
286                     profq_msg!(tcx, ProfileQueriesMsg::ProviderBegin);
287
288                     let res = tcx.cycle_check(span, Query::$name(key), || {
289                         tcx.sess.diagnostic().track_diagnostics(|| {
290                             tcx.dep_graph.with_anon_task(dep_node.kind, || {
291                                 Self::compute_result(tcx.global_tcx(), key)
292                             })
293                         })
294                     })?;
295
296                     profq_msg!(tcx, ProfileQueriesMsg::ProviderEnd);
297                     let ((result, dep_node_index), diagnostics) = res;
298
299                     tcx.dep_graph.read_index(dep_node_index);
300                     let value = QueryValue::new(result, dep_node_index, diagnostics);
301
302                     return Ok((&tcx.maps
303                                     .$name
304                                     .borrow_mut()
305                                     .map
306                                     .entry(key)
307                                     .or_insert(value)
308                                     .value).clone());
309                 }
310
311                 if !dep_node.kind.is_input() {
312                     use dep_graph::DepNodeColor;
313                     if let Some(DepNodeColor::Green(dep_node_index)) = tcx.dep_graph
314                                                                           .node_color(&dep_node) {
315                         profq_msg!(tcx, ProfileQueriesMsg::CacheHit);
316                         tcx.dep_graph.read_index(dep_node_index);
317                         return Self::load_from_disk_and_cache_in_memory(tcx,
318                                                                         key,
319                                                                         span,
320                                                                         dep_node_index)
321                     }
322
323                     if let Some(dep_node_index) = tcx.dep_graph.try_mark_green(tcx, &dep_node) {
324                         debug_assert!(tcx.dep_graph.is_green(dep_node_index));
325                         profq_msg!(tcx, ProfileQueriesMsg::CacheHit);
326                         tcx.dep_graph.read_index(dep_node_index);
327                         return Self::load_from_disk_and_cache_in_memory(tcx,
328                                                                         key,
329                                                                         span,
330                                                                         dep_node_index)
331                     }
332                 }
333
334                 match Self::force(tcx, key, span, dep_node) {
335                     Ok((result, dep_node_index)) => {
336                         tcx.dep_graph.read_index(dep_node_index);
337                         Ok(result)
338                     }
339                     Err(e) => Err(e)
340                 }
341             }
342
343             fn compute_result(tcx: TyCtxt<'a, $tcx, 'lcx>, key: $K) -> $V {
344                 let provider = tcx.maps.providers[key.map_crate()].$name;
345                 provider(tcx.global_tcx(), key)
346             }
347
348             fn load_from_disk_and_cache_in_memory(tcx: TyCtxt<'a, $tcx, 'lcx>,
349                                                   key: $K,
350                                                   span: Span,
351                                                   dep_node_index: DepNodeIndex)
352                                                   -> Result<$V, CycleError<'a, $tcx>>
353             {
354                 debug_assert!(tcx.dep_graph.is_green(dep_node_index));
355
356                 // We don't do any caching yet, so recompute
357                 let (result, diagnostics) = tcx.cycle_check(span, Query::$name(key), || {
358                     tcx.sess.diagnostic().track_diagnostics(|| {
359                         // The dep-graph for this computation is already in place
360                         tcx.dep_graph.with_ignore(|| {
361                             Self::compute_result(tcx, key)
362                         })
363                     })
364                 })?;
365
366                 let value = QueryValue::new(result, dep_node_index, diagnostics);
367
368                 Ok((&tcx.maps
369                          .$name
370                          .borrow_mut()
371                          .map
372                          .entry(key)
373                          .or_insert(value)
374                          .value).clone())
375             }
376
377             fn force(tcx: TyCtxt<'a, $tcx, 'lcx>,
378                      key: $K,
379                      span: Span,
380                      dep_node: DepNode)
381                      -> Result<($V, DepNodeIndex), CycleError<'a, $tcx>> {
382                 debug_assert!(tcx.dep_graph.node_color(&dep_node).is_none());
383
384                 profq_msg!(tcx, ProfileQueriesMsg::ProviderBegin);
385                 let res = tcx.cycle_check(span, Query::$name(key), || {
386                     tcx.sess.diagnostic().track_diagnostics(|| {
387                         tcx.dep_graph.with_task(dep_node,
388                                                 tcx,
389                                                 key,
390                                                 Self::compute_result)
391                     })
392                 })?;
393                 profq_msg!(tcx, ProfileQueriesMsg::ProviderEnd);
394
395                 let ((result, dep_node_index), diagnostics) = res;
396
397                 let value = QueryValue::new(result, dep_node_index, diagnostics);
398
399                 Ok(((&tcx.maps
400                          .$name
401                          .borrow_mut()
402                          .map
403                          .entry(key)
404                          .or_insert(value)
405                          .value).clone(),
406                    dep_node_index))
407             }
408
409
410
411             pub fn try_get(tcx: TyCtxt<'a, $tcx, 'lcx>, span: Span, key: $K)
412                            -> Result<$V, DiagnosticBuilder<'a>> {
413                 match Self::try_get_with(tcx, span, key) {
414                     Ok(e) => Ok(e),
415                     Err(e) => Err(tcx.report_cycle(e)),
416                 }
417             }
418         })*
419
420         #[derive(Copy, Clone)]
421         pub struct TyCtxtAt<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
422             pub tcx: TyCtxt<'a, 'gcx, 'tcx>,
423             pub span: Span,
424         }
425
426         impl<'a, 'gcx, 'tcx> Deref for TyCtxtAt<'a, 'gcx, 'tcx> {
427             type Target = TyCtxt<'a, 'gcx, 'tcx>;
428             fn deref(&self) -> &Self::Target {
429                 &self.tcx
430             }
431         }
432
433         impl<'a, $tcx, 'lcx> TyCtxt<'a, $tcx, 'lcx> {
434             /// Return a transparent wrapper for `TyCtxt` which uses
435             /// `span` as the location of queries performed through it.
436             pub fn at(self, span: Span) -> TyCtxtAt<'a, $tcx, 'lcx> {
437                 TyCtxtAt {
438                     tcx: self,
439                     span
440                 }
441             }
442
443             $($(#[$attr])*
444             pub fn $name(self, key: $K) -> $V {
445                 self.at(DUMMY_SP).$name(key)
446             })*
447         }
448
449         impl<'a, $tcx, 'lcx> TyCtxtAt<'a, $tcx, 'lcx> {
450             $($(#[$attr])*
451             pub fn $name(self, key: $K) -> $V {
452                 queries::$name::try_get(self.tcx, self.span, key).unwrap_or_else(|mut e| {
453                     e.emit();
454                     Value::from_cycle_error(self.global_tcx())
455                 })
456             })*
457         }
458
459         define_provider_struct! {
460             tcx: $tcx,
461             input: ($(([$($modifiers)*] [$name] [$K] [$V]))*),
462             output: ()
463         }
464
465         impl<$tcx> Copy for Providers<$tcx> {}
466         impl<$tcx> Clone for Providers<$tcx> {
467             fn clone(&self) -> Self { *self }
468         }
469     }
470 }
471
472 macro_rules! define_map_struct {
473     // Initial state
474     (tcx: $tcx:tt,
475      input: $input:tt) => {
476         define_map_struct! {
477             tcx: $tcx,
478             input: $input,
479             output: ()
480         }
481     };
482
483     // Final output
484     (tcx: $tcx:tt,
485      input: (),
486      output: ($($output:tt)*)) => {
487         pub struct Maps<$tcx> {
488             providers: IndexVec<CrateNum, Providers<$tcx>>,
489             query_stack: RefCell<Vec<(Span, Query<$tcx>)>>,
490             $($output)*
491         }
492     };
493
494     // Field recognized and ready to shift into the output
495     (tcx: $tcx:tt,
496      ready: ([$($pub:tt)*] [$($attr:tt)*] [$name:ident]),
497      input: $input:tt,
498      output: ($($output:tt)*)) => {
499         define_map_struct! {
500             tcx: $tcx,
501             input: $input,
502             output: ($($output)*
503                      $(#[$attr])* $($pub)* $name: RefCell<QueryMap<queries::$name<$tcx>>>,)
504         }
505     };
506
507     // No modifiers left? This is a private item.
508     (tcx: $tcx:tt,
509      input: (([] $attrs:tt $name:tt) $($input:tt)*),
510      output: $output:tt) => {
511         define_map_struct! {
512             tcx: $tcx,
513             ready: ([] $attrs $name),
514             input: ($($input)*),
515             output: $output
516         }
517     };
518
519     // Skip other modifiers
520     (tcx: $tcx:tt,
521      input: (([$other_modifier:tt $($modifiers:tt)*] $($fields:tt)*) $($input:tt)*),
522      output: $output:tt) => {
523         define_map_struct! {
524             tcx: $tcx,
525             input: (([$($modifiers)*] $($fields)*) $($input)*),
526             output: $output
527         }
528     };
529 }
530
531 macro_rules! define_provider_struct {
532     // Initial state:
533     (tcx: $tcx:tt, input: $input:tt) => {
534         define_provider_struct! {
535             tcx: $tcx,
536             input: $input,
537             output: ()
538         }
539     };
540
541     // Final state:
542     (tcx: $tcx:tt,
543      input: (),
544      output: ($(([$name:ident] [$K:ty] [$R:ty]))*)) => {
545         pub struct Providers<$tcx> {
546             $(pub $name: for<'a> fn(TyCtxt<'a, $tcx, $tcx>, $K) -> $R,)*
547         }
548
549         impl<$tcx> Default for Providers<$tcx> {
550             fn default() -> Self {
551                 $(fn $name<'a, $tcx>(_: TyCtxt<'a, $tcx, $tcx>, key: $K) -> $R {
552                     bug!("tcx.maps.{}({:?}) unsupported by its crate",
553                          stringify!($name), key);
554                 })*
555                 Providers { $($name),* }
556             }
557         }
558     };
559
560     // Something ready to shift:
561     (tcx: $tcx:tt,
562      ready: ($name:tt $K:tt $V:tt),
563      input: $input:tt,
564      output: ($($output:tt)*)) => {
565         define_provider_struct! {
566             tcx: $tcx,
567             input: $input,
568             output: ($($output)* ($name $K $V))
569         }
570     };
571
572     // Regular queries produce a `V` only.
573     (tcx: $tcx:tt,
574      input: (([] $name:tt $K:tt $V:tt) $($input:tt)*),
575      output: $output:tt) => {
576         define_provider_struct! {
577             tcx: $tcx,
578             ready: ($name $K $V),
579             input: ($($input)*),
580             output: $output
581         }
582     };
583
584     // Skip modifiers.
585     (tcx: $tcx:tt,
586      input: (([$other_modifier:tt $($modifiers:tt)*] $($fields:tt)*) $($input:tt)*),
587      output: $output:tt) => {
588         define_provider_struct! {
589             tcx: $tcx,
590             input: (([$($modifiers)*] $($fields)*) $($input)*),
591             output: $output
592         }
593     };
594 }
595
596 pub fn force_from_dep_node<'a, 'gcx, 'lcx>(tcx: TyCtxt<'a, 'gcx, 'lcx>,
597                                            dep_node: &DepNode)
598                                            -> bool {
599     use ty::maps::keys::Key;
600     use hir::def_id::LOCAL_CRATE;
601
602     // We should never get into the situation of having to force this from the DepNode.
603     // Since we cannot reconstruct the query key, we would always end up having to evaluate
604     // the first caller of this query that *is* reconstructible. This might very well be
605     // compile_codegen_unit() in which case we'd lose all re-use.
606     debug_assert!(dep_node.kind != DepKind::CodegenUnit,
607                   "calling force_from_dep_node() on DepKind::CodegenUnit");
608
609     if !dep_node.kind.can_reconstruct_query_key() {
610         return false
611     }
612
613     macro_rules! def_id {
614         () => {
615             if let Some(def_id) = dep_node.extract_def_id(tcx) {
616                 def_id
617             } else {
618                 // return from the whole function
619                 return false
620             }
621         }
622     };
623
624     macro_rules! krate {
625         () => { (def_id!()).krate }
626     };
627
628     macro_rules! force {
629         ($query:ident, $key:expr) => {
630             {
631                 use $crate::util::common::{ProfileQueriesMsg, profq_msg};
632
633                 // FIXME(eddyb) Get more valid Span's on queries.
634                 // def_span guard is necessary to prevent a recursive loop,
635                 // default_span calls def_span query internally.
636                 let span = if stringify!($query) != "def_span" {
637                     $key.default_span(tcx)
638                 } else {
639                     ::syntax_pos::DUMMY_SP
640                 };
641
642                 profq_msg!(tcx,
643                     ProfileQueriesMsg::QueryBegin(
644                         span.clone(),
645                         ::ty::maps::QueryMsg::$query(profq_key!(tcx, $key))
646                     )
647                 );
648
649                 match ::ty::maps::queries::$query::force(tcx, $key, span, *dep_node) {
650                     Ok(_) => {},
651                     Err(e) => {
652                         tcx.report_cycle(e).emit();
653                     }
654                 }
655             }
656         }
657     };
658
659     match dep_node.kind {
660         // These are inputs that are expected to be pre-allocated and that
661         // should therefore always be red or green already
662         DepKind::AllLocalTraitImpls |
663         DepKind::Krate |
664         DepKind::CrateMetadata |
665         DepKind::HirBody |
666         DepKind::Hir |
667
668         // This are anonymous nodes
669         DepKind::IsCopy |
670         DepKind::IsSized |
671         DepKind::IsFreeze |
672         DepKind::NeedsDrop |
673         DepKind::Layout |
674         DepKind::TraitSelect |
675         DepKind::ConstEval |
676
677         // We don't have enough information to reconstruct the query key of
678         // these
679         DepKind::InstanceSymbolName |
680         DepKind::MirShim |
681         DepKind::BorrowCheckKrate |
682         DepKind::Specializes |
683         DepKind::ImplementationsOfTrait |
684         DepKind::TypeParamPredicates |
685         DepKind::CodegenUnit |
686         DepKind::CompileCodegenUnit |
687
688         // This one is just odd
689         DepKind::Null |
690         DepKind::WorkProduct => {
691             bug!("force_from_dep_node() - Encountered {:?}", dep_node.kind)
692         }
693
694         // These is not a queries
695         DepKind::CoherenceCheckTrait |
696         DepKind::ItemVarianceConstraints => {
697             return false
698         }
699
700         DepKind::RegionScopeTree => { force!(region_scope_tree, def_id!()); }
701
702         DepKind::Coherence => { force!(crate_inherent_impls, LOCAL_CRATE); }
703         DepKind::CoherenceInherentImplOverlapCheck => {
704             force!(crate_inherent_impls_overlap_check, LOCAL_CRATE)
705         },
706         DepKind::PrivacyAccessLevels => { force!(privacy_access_levels, LOCAL_CRATE); }
707         DepKind::MirConstQualif => { force!(mir_const_qualif, def_id!()); }
708         DepKind::MirConst => { force!(mir_const, def_id!()); }
709         DepKind::MirValidated => { force!(mir_validated, def_id!()); }
710         DepKind::MirOptimized => { force!(optimized_mir, def_id!()); }
711
712         DepKind::BorrowCheck => { force!(borrowck, def_id!()); }
713         DepKind::MirBorrowCheck => { force!(mir_borrowck, def_id!()); }
714         DepKind::UnsafetyViolations => { force!(unsafety_violations, def_id!()); }
715         DepKind::Reachability => { force!(reachable_set, LOCAL_CRATE); }
716         DepKind::MirKeys => { force!(mir_keys, LOCAL_CRATE); }
717         DepKind::CrateVariances => { force!(crate_variances, LOCAL_CRATE); }
718         DepKind::AssociatedItems => { force!(associated_item, def_id!()); }
719         DepKind::TypeOfItem => { force!(type_of, def_id!()); }
720         DepKind::GenericsOfItem => { force!(generics_of, def_id!()); }
721         DepKind::PredicatesOfItem => { force!(predicates_of, def_id!()); }
722         DepKind::SuperPredicatesOfItem => { force!(super_predicates_of, def_id!()); }
723         DepKind::TraitDefOfItem => { force!(trait_def, def_id!()); }
724         DepKind::AdtDefOfItem => { force!(adt_def, def_id!()); }
725         DepKind::IsDefaultImpl => { force!(is_default_impl, def_id!()); }
726         DepKind::ImplTraitRef => { force!(impl_trait_ref, def_id!()); }
727         DepKind::ImplPolarity => { force!(impl_polarity, def_id!()); }
728         DepKind::ClosureKind => { force!(closure_kind, def_id!()); }
729         DepKind::FnSignature => { force!(fn_sig, def_id!()); }
730         DepKind::GenSignature => { force!(generator_sig, def_id!()); }
731         DepKind::CoerceUnsizedInfo => { force!(coerce_unsized_info, def_id!()); }
732         DepKind::ItemVariances => { force!(variances_of, def_id!()); }
733         DepKind::IsConstFn => { force!(is_const_fn, def_id!()); }
734         DepKind::IsForeignItem => { force!(is_foreign_item, def_id!()); }
735         DepKind::SizedConstraint => { force!(adt_sized_constraint, def_id!()); }
736         DepKind::DtorckConstraint => { force!(adt_dtorck_constraint, def_id!()); }
737         DepKind::AdtDestructor => { force!(adt_destructor, def_id!()); }
738         DepKind::AssociatedItemDefIds => { force!(associated_item_def_ids, def_id!()); }
739         DepKind::InherentImpls => { force!(inherent_impls, def_id!()); }
740         DepKind::TypeckBodiesKrate => { force!(typeck_item_bodies, LOCAL_CRATE); }
741         DepKind::TypeckTables => { force!(typeck_tables_of, def_id!()); }
742         DepKind::HasTypeckTables => { force!(has_typeck_tables, def_id!()); }
743         DepKind::SymbolName => { force!(def_symbol_name, def_id!()); }
744         DepKind::SpecializationGraph => { force!(specialization_graph_of, def_id!()); }
745         DepKind::ObjectSafety => { force!(is_object_safe, def_id!()); }
746         DepKind::TraitImpls => { force!(trait_impls_of, def_id!()); }
747
748         DepKind::ParamEnv => { force!(param_env, def_id!()); }
749         DepKind::DescribeDef => { force!(describe_def, def_id!()); }
750         DepKind::DefSpan => { force!(def_span, def_id!()); }
751         DepKind::LookupStability => { force!(lookup_stability, def_id!()); }
752         DepKind::LookupDeprecationEntry => {
753             force!(lookup_deprecation_entry, def_id!());
754         }
755         DepKind::ItemBodyNestedBodies => { force!(item_body_nested_bodies, def_id!()); }
756         DepKind::ConstIsRvaluePromotableToStatic => {
757             force!(const_is_rvalue_promotable_to_static, def_id!());
758         }
759         DepKind::ImplParent => { force!(impl_parent, def_id!()); }
760         DepKind::TraitOfItem => { force!(trait_of_item, def_id!()); }
761         DepKind::IsExportedSymbol => { force!(is_exported_symbol, def_id!()); }
762         DepKind::IsMirAvailable => { force!(is_mir_available, def_id!()); }
763         DepKind::ItemAttrs => { force!(item_attrs, def_id!()); }
764         DepKind::FnArgNames => { force!(fn_arg_names, def_id!()); }
765         DepKind::DylibDepFormats => { force!(dylib_dependency_formats, krate!()); }
766         DepKind::IsPanicRuntime => { force!(is_panic_runtime, krate!()); }
767         DepKind::IsCompilerBuiltins => { force!(is_compiler_builtins, krate!()); }
768         DepKind::HasGlobalAllocator => { force!(has_global_allocator, krate!()); }
769         DepKind::ExternCrate => { force!(extern_crate, def_id!()); }
770         DepKind::LintLevels => { force!(lint_levels, LOCAL_CRATE); }
771         DepKind::InScopeTraits => { force!(in_scope_traits_map, def_id!().index); }
772         DepKind::ModuleExports => { force!(module_exports, def_id!()); }
773         DepKind::IsSanitizerRuntime => { force!(is_sanitizer_runtime, krate!()); }
774         DepKind::IsProfilerRuntime => { force!(is_profiler_runtime, krate!()); }
775         DepKind::GetPanicStrategy => { force!(panic_strategy, krate!()); }
776         DepKind::IsNoBuiltins => { force!(is_no_builtins, krate!()); }
777         DepKind::ImplDefaultness => { force!(impl_defaultness, def_id!()); }
778         DepKind::ExportedSymbolIds => { force!(exported_symbol_ids, krate!()); }
779         DepKind::NativeLibraries => { force!(native_libraries, krate!()); }
780         DepKind::PluginRegistrarFn => { force!(plugin_registrar_fn, krate!()); }
781         DepKind::DeriveRegistrarFn => { force!(derive_registrar_fn, krate!()); }
782         DepKind::CrateDisambiguator => { force!(crate_disambiguator, krate!()); }
783         DepKind::CrateHash => { force!(crate_hash, krate!()); }
784         DepKind::OriginalCrateName => { force!(original_crate_name, krate!()); }
785
786         DepKind::AllTraitImplementations => {
787             force!(all_trait_implementations, krate!());
788         }
789
790         DepKind::IsDllimportForeignItem => {
791             force!(is_dllimport_foreign_item, def_id!());
792         }
793         DepKind::IsStaticallyIncludedForeignItem => {
794             force!(is_statically_included_foreign_item, def_id!());
795         }
796         DepKind::NativeLibraryKind => { force!(native_library_kind, def_id!()); }
797         DepKind::LinkArgs => { force!(link_args, LOCAL_CRATE); }
798
799         DepKind::NamedRegion => { force!(named_region_map, def_id!().index); }
800         DepKind::IsLateBound => { force!(is_late_bound_map, def_id!().index); }
801         DepKind::ObjectLifetimeDefaults => {
802             force!(object_lifetime_defaults_map, def_id!().index);
803         }
804
805         DepKind::Visibility => { force!(visibility, def_id!()); }
806         DepKind::DepKind => { force!(dep_kind, krate!()); }
807         DepKind::CrateName => { force!(crate_name, krate!()); }
808         DepKind::ItemChildren => { force!(item_children, def_id!()); }
809         DepKind::ExternModStmtCnum => { force!(extern_mod_stmt_cnum, def_id!()); }
810         DepKind::GetLangItems => { force!(get_lang_items, LOCAL_CRATE); }
811         DepKind::DefinedLangItems => { force!(defined_lang_items, krate!()); }
812         DepKind::MissingLangItems => { force!(missing_lang_items, krate!()); }
813         DepKind::ExternConstBody => { force!(extern_const_body, def_id!()); }
814         DepKind::VisibleParentMap => { force!(visible_parent_map, LOCAL_CRATE); }
815         DepKind::MissingExternCrateItem => {
816             force!(missing_extern_crate_item, krate!());
817         }
818         DepKind::UsedCrateSource => { force!(used_crate_source, krate!()); }
819         DepKind::PostorderCnums => { force!(postorder_cnums, LOCAL_CRATE); }
820         DepKind::HasCloneClosures => { force!(has_clone_closures, krate!()); }
821         DepKind::HasCopyClosures => { force!(has_copy_closures, krate!()); }
822
823         DepKind::Freevars => { force!(freevars, def_id!()); }
824         DepKind::MaybeUnusedTraitImport => {
825             force!(maybe_unused_trait_import, def_id!());
826         }
827         DepKind::MaybeUnusedExternCrates => { force!(maybe_unused_extern_crates, LOCAL_CRATE); }
828         DepKind::StabilityIndex => { force!(stability_index, LOCAL_CRATE); }
829         DepKind::AllCrateNums => { force!(all_crate_nums, LOCAL_CRATE); }
830         DepKind::ExportedSymbols => { force!(exported_symbols, krate!()); }
831         DepKind::CollectAndPartitionTranslationItems => {
832             force!(collect_and_partition_translation_items, LOCAL_CRATE);
833         }
834         DepKind::ExportName => { force!(export_name, def_id!()); }
835         DepKind::ContainsExternIndicator => {
836             force!(contains_extern_indicator, def_id!());
837         }
838         DepKind::IsTranslatedFunction => { force!(is_translated_function, def_id!()); }
839         DepKind::OutputFilenames => { force!(output_filenames, LOCAL_CRATE); }
840     }
841
842     true
843 }
844