Skip to content

Commit 2eea2d2

Browse files
committed
Add warn(unreachable_pub) to rustc_query_impl.
1 parent 71bffef commit 2eea2d2

File tree

2 files changed

+27
-18
lines changed

2 files changed

+27
-18
lines changed

compiler/rustc_query_impl/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#![feature(min_specialization)]
99
#![feature(rustc_attrs)]
1010
#![feature(rustdoc_internals)]
11+
#![warn(unreachable_pub)]
1112
// tidy-alphabetical-end
1213

1314
use field_offset::offset_of;

compiler/rustc_query_impl/src/plumbing.rs

+26-18
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,7 @@ macro_rules! expand_if_cached {
541541
/// Don't show the backtrace for query system by default
542542
/// use `RUST_BACKTRACE=full` to show all the backtraces
543543
#[inline(never)]
544-
pub fn __rust_begin_short_backtrace<F, T>(f: F) -> T
544+
pub(crate) fn __rust_begin_short_backtrace<F, T>(f: F) -> T
545545
where
546546
F: FnOnce() -> T,
547547
{
@@ -557,17 +557,17 @@ macro_rules! define_queries {
557557
$($(#[$attr:meta])*
558558
[$($modifiers:tt)*] fn $name:ident($($K:tt)*) -> $V:ty,)*) => {
559559

560-
pub(crate) mod query_impl { $(pub mod $name {
560+
pub(crate) mod query_impl { $(pub(crate) mod $name {
561561
use super::super::*;
562562
use std::marker::PhantomData;
563563

564-
pub mod get_query_incr {
564+
pub(crate) mod get_query_incr {
565565
use super::*;
566566

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

588-
pub mod get_query_non_incr {
588+
pub(crate) mod get_query_non_incr {
589589
use super::*;
590590

591591
#[inline(never)]
592-
pub fn __rust_end_short_backtrace<'tcx>(
592+
pub(crate) fn __rust_end_short_backtrace<'tcx>(
593593
tcx: TyCtxt<'tcx>,
594594
span: Span,
595595
key: queries::$name::Key<'tcx>,
@@ -604,7 +604,9 @@ macro_rules! define_queries {
604604
}
605605
}
606606

607-
pub fn dynamic_query<'tcx>() -> DynamicQuery<'tcx, queries::$name::Storage<'tcx>> {
607+
pub(crate) fn dynamic_query<'tcx>()
608+
-> DynamicQuery<'tcx, queries::$name::Storage<'tcx>>
609+
{
608610
DynamicQuery {
609611
name: stringify!($name),
610612
eval_always: is_eval_always!([$($modifiers)*]),
@@ -667,7 +669,7 @@ macro_rules! define_queries {
667669
}
668670

669671
#[derive(Copy, Clone, Default)]
670-
pub struct QueryType<'tcx> {
672+
pub(crate) struct QueryType<'tcx> {
671673
data: PhantomData<&'tcx ()>
672674
}
673675

@@ -696,7 +698,7 @@ macro_rules! define_queries {
696698
}
697699
}
698700

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

718-
pub fn alloc_self_profile_query_strings<'tcx>(tcx: TyCtxt<'tcx>, string_cache: &mut QueryKeyStringCache) {
723+
pub(crate) fn alloc_self_profile_query_strings<'tcx>(
724+
tcx: TyCtxt<'tcx>,
725+
string_cache: &mut QueryKeyStringCache
726+
) {
719727
$crate::profiling_support::alloc_self_profile_query_strings_for_query_cache(
720728
tcx,
721729
stringify!($name),
@@ -725,7 +733,7 @@ macro_rules! define_queries {
725733
}
726734

727735
item_if_cached! { [$($modifiers)*] {
728-
pub fn encode_query_results<'tcx>(
736+
pub(crate) fn encode_query_results<'tcx>(
729737
tcx: TyCtxt<'tcx>,
730738
encoder: &mut CacheEncoder<'_, 'tcx>,
731739
query_result_index: &mut EncodedDepNodeIndex
@@ -739,7 +747,7 @@ macro_rules! define_queries {
739747
}
740748
}}
741749

742-
pub fn query_key_hash_verify<'tcx>(tcx: TyCtxt<'tcx>) {
750+
pub(crate) fn query_key_hash_verify<'tcx>(tcx: TyCtxt<'tcx>) {
743751
$crate::plumbing::query_key_hash_verify(
744752
query_impl::$name::QueryType::config(tcx),
745753
QueryCtxt::new(tcx),
@@ -795,7 +803,7 @@ macro_rules! define_queries {
795803
use rustc_query_system::dep_graph::FingerprintStyle;
796804

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

809817
// We use this for the forever-red node.
810-
pub fn Red<'tcx>() -> DepKindStruct<'tcx> {
818+
pub(crate) fn Red<'tcx>() -> DepKindStruct<'tcx> {
811819
DepKindStruct {
812820
is_anon: false,
813821
is_eval_always: false,
@@ -818,7 +826,7 @@ macro_rules! define_queries {
818826
}
819827
}
820828

821-
pub fn TraitSelect<'tcx>() -> DepKindStruct<'tcx> {
829+
pub(crate) fn TraitSelect<'tcx>() -> DepKindStruct<'tcx> {
822830
DepKindStruct {
823831
is_anon: true,
824832
is_eval_always: false,
@@ -829,7 +837,7 @@ macro_rules! define_queries {
829837
}
830838
}
831839

832-
pub fn CompileCodegenUnit<'tcx>() -> DepKindStruct<'tcx> {
840+
pub(crate) fn CompileCodegenUnit<'tcx>() -> DepKindStruct<'tcx> {
833841
DepKindStruct {
834842
is_anon: false,
835843
is_eval_always: false,
@@ -840,7 +848,7 @@ macro_rules! define_queries {
840848
}
841849
}
842850

843-
pub fn CompileMonoItem<'tcx>() -> DepKindStruct<'tcx> {
851+
pub(crate) fn CompileMonoItem<'tcx>() -> DepKindStruct<'tcx> {
844852
DepKindStruct {
845853
is_anon: false,
846854
is_eval_always: false,

0 commit comments

Comments
 (0)