Repository: rust-lang/rust
File: compiler/rustc_query_impl/src/plumbing.rs (Rust)

Code before:
                    tcx: TyCtxt<'tcx>,
                    encoder: &mut CacheEncoder<'_, 'tcx>,
                    query_result_index: &mut EncodedDepNodeIndex
                ) {
                    $crate::plumbing::encode_query_results::<
                        query_impl::$name::QueryType<'tcx>,
                        _,
                        _
                    > (
                        query_impl::$name::QueryType::query_dispatcher(tcx),
                        tcx,
                        encoder,
                        query_result_index,
                    )
                }
            }

            pub(crate) fn query_key_hash_verify<'tcx>(tcx: TyCtxt<'tcx>) {
                $crate::plumbing::query_key_hash_verify(
                    query_impl::$name::QueryType::query_dispatcher(tcx),
                    tcx,
                )
            }
        })*}

        pub fn make_query_vtables<'tcx>(incremental: bool) -> queries::PerQueryVTables<'tcx> {
            queries::PerQueryVTables {
                $(
                    $name: query_impl::$name::make_query_vtable(incremental),
                )*
            }
        }

        // These arrays are used for iteration and can't be indexed by `DepKind`.

        /// Used by `collect_active_jobs_from_all_queries` to iterate over all
        /// queries, and gather the active jobs for each query.
        ///
        /// (We arbitrarily use the word "gather" when collecting the jobs for
        /// each individual query, so that we have distinct function names to
        /// grep for.)
        const PER_QUERY_GATHER_ACTIVE_JOBS_FNS: &[
            for<'tcx> fn(
                tcx: TyCtxt<'tcx>,
                require_complete: bool,
                job_map_out: &mut QueryJobMap<'tcx>,
            ) -> Option<()>
        ] = &[
            $( $crate::query_impl::$name::gather_active_jobs ),*
        ];


Review comment (suggestion):
If you want to take this opportunity to also rename `PerQueryVTables` back to `QueryVTables`, feel free. The more verbose name did its job at a more confusing time, but the simpler `QueryVTables` should be fine now.

Code after:
                require_complete: bool,
                job_map_out: &mut QueryJobMap<'tcx>,
            ) -> Option<()>
        ] = &[
            $( $crate::query_impl::$name::gather_active_jobs ),*
        ];

        const ALLOC_SELF_PROFILE_QUERY_STRINGS: &[
            for<'tcx> fn(TyCtxt<'tcx>, &mut QueryKeyStringCache)
        ] = &[$(query_impl::$name::alloc_self_profile_query_strings),*];

        const ENCODE_QUERY_RESULTS: &[
            Option<for<'tcx> fn(
                TyCtxt<'tcx>,
                &mut CacheEncoder<'_, 'tcx>,
                &mut EncodedDepNodeIndex)
            >
        ] = &[
            $(
                if_cache_on_disk!([$($modifiers)*] {
                    Some(query_impl::$name::encode_query_results)
                } {
                    None
                })
            ),*
        ];

        const QUERY_KEY_HASH_VERIFY: &[
            for<'tcx> fn(TyCtxt<'tcx>)
        ] = &[$(query_impl::$name::query_key_hash_verify),*];

        /// Declares a dep-kind vtable constructor for each query.
        mod _dep_kind_vtable_ctors_for_queries {
            use ::rustc_middle::dep_graph::DepKindVTable;
            use $crate::dep_kind_vtables::make_dep_kind_vtable_for_query;

            $(
                /// `DepKindVTable` constructor for this query.
                pub(crate) fn $name<'tcx>() -> DepKindVTable<'tcx> {
                    use $crate::query_impl::$name::VTableGetter;
                    make_dep_kind_vtable_for_query::<VTableGetter>(
                        is_anon!([$($modifiers)*]),
                        is_eval_always!([$($modifiers)*]),
                    )
                }
            )*
        }
    }
}