Skip to content

Commit

Permalink
Add warn(unreachable_pub) to rustc_query_impl.
Browse files Browse the repository at this point in the history
  • Loading branch information
nnethercote committed Aug 29, 2024
1 parent 71bffef commit 2eea2d2
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 18 deletions.
1 change: 1 addition & 0 deletions compiler/rustc_query_impl/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#![feature(min_specialization)]
#![feature(rustc_attrs)]
#![feature(rustdoc_internals)]
#![warn(unreachable_pub)]
// tidy-alphabetical-end

use field_offset::offset_of;
Expand Down
44 changes: 26 additions & 18 deletions compiler/rustc_query_impl/src/plumbing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ macro_rules! expand_if_cached {
/// Don't show the backtrace for query system by default
/// use `RUST_BACKTRACE=full` to show all the backtraces
#[inline(never)]
pub fn __rust_begin_short_backtrace<F, T>(f: F) -> T
pub(crate) fn __rust_begin_short_backtrace<F, T>(f: F) -> T
where
F: FnOnce() -> T,
{
Expand All @@ -557,17 +557,17 @@ macro_rules! define_queries {
$($(#[$attr:meta])*
[$($modifiers:tt)*] fn $name:ident($($K:tt)*) -> $V:ty,)*) => {

pub(crate) mod query_impl { $(pub mod $name {
pub(crate) mod query_impl { $(pub(crate) mod $name {
use super::super::*;
use std::marker::PhantomData;

pub mod get_query_incr {
pub(crate) mod get_query_incr {
use super::*;

// Adding `__rust_end_short_backtrace` marker to backtraces so that we emit the frames
// when `RUST_BACKTRACE=1`, add a new mod with `$name` here is to allow duplicate naming
#[inline(never)]
pub fn __rust_end_short_backtrace<'tcx>(
pub(crate) fn __rust_end_short_backtrace<'tcx>(
tcx: TyCtxt<'tcx>,
span: Span,
key: queries::$name::Key<'tcx>,
Expand All @@ -585,11 +585,11 @@ macro_rules! define_queries {
}
}

pub mod get_query_non_incr {
pub(crate) mod get_query_non_incr {
use super::*;

#[inline(never)]
pub fn __rust_end_short_backtrace<'tcx>(
pub(crate) fn __rust_end_short_backtrace<'tcx>(
tcx: TyCtxt<'tcx>,
span: Span,
key: queries::$name::Key<'tcx>,
Expand All @@ -604,7 +604,9 @@ macro_rules! define_queries {
}
}

pub fn dynamic_query<'tcx>() -> DynamicQuery<'tcx, queries::$name::Storage<'tcx>> {
pub(crate) fn dynamic_query<'tcx>()
-> DynamicQuery<'tcx, queries::$name::Storage<'tcx>>
{
DynamicQuery {
name: stringify!($name),
eval_always: is_eval_always!([$($modifiers)*]),
Expand Down Expand Up @@ -667,7 +669,7 @@ macro_rules! define_queries {
}

#[derive(Copy, Clone, Default)]
pub struct QueryType<'tcx> {
pub(crate) struct QueryType<'tcx> {
data: PhantomData<&'tcx ()>
}

Expand Down Expand Up @@ -696,7 +698,7 @@ macro_rules! define_queries {
}
}

pub fn try_collect_active_jobs<'tcx>(tcx: TyCtxt<'tcx>, qmap: &mut QueryMap) {
pub(crate) fn try_collect_active_jobs<'tcx>(tcx: TyCtxt<'tcx>, qmap: &mut QueryMap) {
let make_query = |tcx, key| {
let kind = rustc_middle::dep_graph::dep_kinds::$name;
let name = stringify!($name);
Expand All @@ -711,11 +713,17 @@ macro_rules! define_queries {
// don't `unwrap()` here, just manually check for `None` and do best-effort error
// reporting.
if res.is_none() {
tracing::warn!("Failed to collect active jobs for query with name `{}`!", stringify!($name));
tracing::warn!(
"Failed to collect active jobs for query with name `{}`!",
stringify!($name)
);
}
}

pub fn alloc_self_profile_query_strings<'tcx>(tcx: TyCtxt<'tcx>, string_cache: &mut QueryKeyStringCache) {
pub(crate) fn alloc_self_profile_query_strings<'tcx>(
tcx: TyCtxt<'tcx>,
string_cache: &mut QueryKeyStringCache
) {
$crate::profiling_support::alloc_self_profile_query_strings_for_query_cache(
tcx,
stringify!($name),
Expand All @@ -725,7 +733,7 @@ macro_rules! define_queries {
}

item_if_cached! { [$($modifiers)*] {
pub fn encode_query_results<'tcx>(
pub(crate) fn encode_query_results<'tcx>(
tcx: TyCtxt<'tcx>,
encoder: &mut CacheEncoder<'_, 'tcx>,
query_result_index: &mut EncodedDepNodeIndex
Expand All @@ -739,7 +747,7 @@ macro_rules! define_queries {
}
}}

pub fn query_key_hash_verify<'tcx>(tcx: TyCtxt<'tcx>) {
pub(crate) fn query_key_hash_verify<'tcx>(tcx: TyCtxt<'tcx>) {
$crate::plumbing::query_key_hash_verify(
query_impl::$name::QueryType::config(tcx),
QueryCtxt::new(tcx),
Expand Down Expand Up @@ -795,7 +803,7 @@ macro_rules! define_queries {
use rustc_query_system::dep_graph::FingerprintStyle;

// We use this for most things when incr. comp. is turned off.
pub fn Null<'tcx>() -> DepKindStruct<'tcx> {
pub(crate) fn Null<'tcx>() -> DepKindStruct<'tcx> {
DepKindStruct {
is_anon: false,
is_eval_always: false,
Expand All @@ -807,7 +815,7 @@ macro_rules! define_queries {
}

// We use this for the forever-red node.
pub fn Red<'tcx>() -> DepKindStruct<'tcx> {
pub(crate) fn Red<'tcx>() -> DepKindStruct<'tcx> {
DepKindStruct {
is_anon: false,
is_eval_always: false,
Expand All @@ -818,7 +826,7 @@ macro_rules! define_queries {
}
}

pub fn TraitSelect<'tcx>() -> DepKindStruct<'tcx> {
pub(crate) fn TraitSelect<'tcx>() -> DepKindStruct<'tcx> {
DepKindStruct {
is_anon: true,
is_eval_always: false,
Expand All @@ -829,7 +837,7 @@ macro_rules! define_queries {
}
}

pub fn CompileCodegenUnit<'tcx>() -> DepKindStruct<'tcx> {
pub(crate) fn CompileCodegenUnit<'tcx>() -> DepKindStruct<'tcx> {
DepKindStruct {
is_anon: false,
is_eval_always: false,
Expand All @@ -840,7 +848,7 @@ macro_rules! define_queries {
}
}

pub fn CompileMonoItem<'tcx>() -> DepKindStruct<'tcx> {
pub(crate) fn CompileMonoItem<'tcx>() -> DepKindStruct<'tcx> {
DepKindStruct {
is_anon: false,
is_eval_always: false,
Expand Down

0 comments on commit 2eea2d2

Please sign in to comment.