Rollup merge of #129732 - nnethercote:unreachable_pub-3, r=Urgau

Add `unreachable_pub`, round 3

A follow-up to #129648.

r? `@Urgau`
This commit is contained in:
Guillaume Gomez 2024-08-29 16:21:49 +02:00 committed by GitHub
commit 7e23a44495
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
56 changed files with 403 additions and 347 deletions

View File

@ -55,7 +55,7 @@ use synstructure::Structure;
///
/// See rustc dev guide for more examples on using the `#[derive(Diagnostic)]`:
/// <https://rustc-dev-guide.rust-lang.org/diagnostics/diagnostic-structs.html>
pub fn diagnostic_derive(mut s: Structure<'_>) -> TokenStream {
pub(super) fn diagnostic_derive(mut s: Structure<'_>) -> TokenStream {
s.underscore_const(true);
DiagnosticDerive::new(s).into_tokens()
}
@ -102,7 +102,7 @@ pub fn diagnostic_derive(mut s: Structure<'_>) -> TokenStream {
///
/// See rustc dev guide for more examples on using the `#[derive(LintDiagnostic)]`:
/// <https://rustc-dev-guide.rust-lang.org/diagnostics/diagnostic-structs.html#reference>
pub fn lint_diagnostic_derive(mut s: Structure<'_>) -> TokenStream {
pub(super) fn lint_diagnostic_derive(mut s: Structure<'_>) -> TokenStream {
s.underscore_const(true);
LintDiagnosticDerive::new(s).into_tokens()
}
@ -153,7 +153,7 @@ pub fn lint_diagnostic_derive(mut s: Structure<'_>) -> TokenStream {
///
/// diag.subdiagnostic(RawIdentifierSuggestion { span, applicability, ident });
/// ```
pub fn subdiagnostic_derive(mut s: Structure<'_>) -> TokenStream {
pub(super) fn subdiagnostic_derive(mut s: Structure<'_>) -> TokenStream {
s.underscore_const(true);
SubdiagnosticDerive::new().into_tokens(s)
}

View File

@ -6,6 +6,7 @@
#![feature(proc_macro_diagnostic)]
#![feature(proc_macro_span)]
#![feature(proc_macro_tracked_env)]
#![warn(unreachable_pub)]
// tidy-alphabetical-end
use proc_macro::TokenStream;

View File

@ -1,7 +1,7 @@
use quote::quote;
use syn::parse_quote;
pub fn lift_derive(mut s: synstructure::Structure<'_>) -> proc_macro2::TokenStream {
pub(super) fn lift_derive(mut s: synstructure::Structure<'_>) -> proc_macro2::TokenStream {
s.add_bounds(synstructure::AddBounds::Generics);
s.bind_with(|_| synstructure::BindStyle::Move);
s.underscore_const(true);

View File

@ -307,7 +307,7 @@ fn add_query_desc_cached_impl(
});
}
pub fn rustc_queries(input: TokenStream) -> TokenStream {
pub(super) fn rustc_queries(input: TokenStream) -> TokenStream {
let queries = parse_macro_input!(input as List<Query>);
let mut query_stream = quote! {};

View File

@ -3,7 +3,9 @@ use quote::{quote, quote_spanned};
use syn::parse_quote;
use syn::spanned::Spanned;
pub fn type_decodable_derive(mut s: synstructure::Structure<'_>) -> proc_macro2::TokenStream {
pub(super) fn type_decodable_derive(
mut s: synstructure::Structure<'_>,
) -> proc_macro2::TokenStream {
let decoder_ty = quote! { __D };
let bound = if s.ast().generics.lifetimes().any(|lt| lt.lifetime.ident == "tcx") {
quote! { <I = ::rustc_middle::ty::TyCtxt<'tcx>> }
@ -20,7 +22,9 @@ pub fn type_decodable_derive(mut s: synstructure::Structure<'_>) -> proc_macro2:
decodable_body(s, decoder_ty)
}
pub fn meta_decodable_derive(mut s: synstructure::Structure<'_>) -> proc_macro2::TokenStream {
pub(super) fn meta_decodable_derive(
mut s: synstructure::Structure<'_>,
) -> proc_macro2::TokenStream {
if !s.ast().generics.lifetimes().any(|lt| lt.lifetime.ident == "tcx") {
s.add_impl_generic(parse_quote! { 'tcx });
}
@ -32,7 +36,7 @@ pub fn meta_decodable_derive(mut s: synstructure::Structure<'_>) -> proc_macro2:
decodable_body(s, decoder_ty)
}
pub fn decodable_derive(mut s: synstructure::Structure<'_>) -> proc_macro2::TokenStream {
pub(super) fn decodable_derive(mut s: synstructure::Structure<'_>) -> proc_macro2::TokenStream {
let decoder_ty = quote! { __D };
s.add_impl_generic(parse_quote! { #decoder_ty: ::rustc_span::SpanDecoder });
s.add_bounds(synstructure::AddBounds::Generics);
@ -41,7 +45,9 @@ pub fn decodable_derive(mut s: synstructure::Structure<'_>) -> proc_macro2::Toke
decodable_body(s, decoder_ty)
}
pub fn decodable_generic_derive(mut s: synstructure::Structure<'_>) -> proc_macro2::TokenStream {
pub(super) fn decodable_generic_derive(
mut s: synstructure::Structure<'_>,
) -> proc_macro2::TokenStream {
let decoder_ty = quote! { __D };
s.add_impl_generic(parse_quote! { #decoder_ty: ::rustc_serialize::Decoder });
s.add_bounds(synstructure::AddBounds::Generics);
@ -123,7 +129,9 @@ fn decode_field(field: &syn::Field) -> proc_macro2::TokenStream {
quote_spanned! { field_span=> #decode_inner_method(#__decoder) }
}
pub fn type_encodable_derive(mut s: synstructure::Structure<'_>) -> proc_macro2::TokenStream {
pub(super) fn type_encodable_derive(
mut s: synstructure::Structure<'_>,
) -> proc_macro2::TokenStream {
let bound = if s.ast().generics.lifetimes().any(|lt| lt.lifetime.ident == "tcx") {
quote! { <I = ::rustc_middle::ty::TyCtxt<'tcx>> }
} else if s.ast().generics.type_params().any(|ty| ty.ident == "I") {
@ -140,7 +148,9 @@ pub fn type_encodable_derive(mut s: synstructure::Structure<'_>) -> proc_macro2:
encodable_body(s, encoder_ty, false)
}
pub fn meta_encodable_derive(mut s: synstructure::Structure<'_>) -> proc_macro2::TokenStream {
pub(super) fn meta_encodable_derive(
mut s: synstructure::Structure<'_>,
) -> proc_macro2::TokenStream {
if !s.ast().generics.lifetimes().any(|lt| lt.lifetime.ident == "tcx") {
s.add_impl_generic(parse_quote! { 'tcx });
}
@ -152,7 +162,7 @@ pub fn meta_encodable_derive(mut s: synstructure::Structure<'_>) -> proc_macro2:
encodable_body(s, encoder_ty, true)
}
pub fn encodable_derive(mut s: synstructure::Structure<'_>) -> proc_macro2::TokenStream {
pub(super) fn encodable_derive(mut s: synstructure::Structure<'_>) -> proc_macro2::TokenStream {
let encoder_ty = quote! { __E };
s.add_impl_generic(parse_quote! { #encoder_ty: ::rustc_span::SpanEncoder });
s.add_bounds(synstructure::AddBounds::Generics);
@ -161,7 +171,9 @@ pub fn encodable_derive(mut s: synstructure::Structure<'_>) -> proc_macro2::Toke
encodable_body(s, encoder_ty, false)
}
pub fn encodable_generic_derive(mut s: synstructure::Structure<'_>) -> proc_macro2::TokenStream {
pub(super) fn encodable_generic_derive(
mut s: synstructure::Structure<'_>,
) -> proc_macro2::TokenStream {
let encoder_ty = quote! { __E };
s.add_impl_generic(parse_quote! { #encoder_ty: ::rustc_serialize::Encoder });
s.add_bounds(synstructure::AddBounds::Generics);

View File

@ -131,7 +131,7 @@ impl Errors {
}
}
pub fn symbols(input: TokenStream) -> TokenStream {
pub(super) fn symbols(input: TokenStream) -> TokenStream {
let (mut output, errors) = symbols_with_errors(input);
// If we generated any errors, then report them as compiler_error!() macro calls.

View File

@ -1,7 +1,7 @@
use quote::{quote, ToTokens};
use syn::parse_quote;
pub fn type_foldable_derive(mut s: synstructure::Structure<'_>) -> proc_macro2::TokenStream {
pub(super) fn type_foldable_derive(mut s: synstructure::Structure<'_>) -> proc_macro2::TokenStream {
if let syn::Data::Union(_) = s.ast().data {
panic!("cannot derive on union")
}

View File

@ -1,7 +1,9 @@
use quote::quote;
use syn::parse_quote;
pub fn type_visitable_derive(mut s: synstructure::Structure<'_>) -> proc_macro2::TokenStream {
pub(super) fn type_visitable_derive(
mut s: synstructure::Structure<'_>,
) -> proc_macro2::TokenStream {
if let syn::Data::Union(_) = s.ast().data {
panic!("cannot derive on union")
}

View File

@ -16,6 +16,7 @@
#![feature(proc_macro_internals)]
#![feature(rustdoc_internals)]
#![feature(trusted_len)]
#![warn(unreachable_pub)]
// tidy-alphabetical-end
extern crate proc_macro;

View File

@ -56,13 +56,13 @@ impl std::ops::Deref for MetadataBlob {
impl MetadataBlob {
/// Runs the [`MemDecoder`] validation and if it passes, constructs a new [`MetadataBlob`].
pub fn new(slice: OwnedSlice) -> Result<Self, ()> {
pub(crate) fn new(slice: OwnedSlice) -> Result<Self, ()> {
if MemDecoder::new(&slice, 0).is_ok() { Ok(Self(slice)) } else { Err(()) }
}
/// Since this has passed the validation of [`MetadataBlob::new`], this returns bytes which are
/// known to pass the [`MemDecoder`] validation.
pub fn bytes(&self) -> &OwnedSlice {
pub(crate) fn bytes(&self) -> &OwnedSlice {
&self.0
}
}
@ -332,12 +332,12 @@ impl<'a, 'tcx> DecodeContext<'a, 'tcx> {
}
#[inline]
pub fn blob(&self) -> &'a MetadataBlob {
pub(crate) fn blob(&self) -> &'a MetadataBlob {
self.blob
}
#[inline]
pub fn cdata(&self) -> CrateMetadataRef<'a> {
fn cdata(&self) -> CrateMetadataRef<'a> {
debug_assert!(self.cdata.is_some(), "missing CrateMetadata in DecodeContext");
self.cdata.unwrap()
}
@ -377,7 +377,7 @@ impl<'a, 'tcx> DecodeContext<'a, 'tcx> {
}
#[inline]
pub fn read_raw_bytes(&mut self, len: usize) -> &[u8] {
fn read_raw_bytes(&mut self, len: usize) -> &[u8] {
self.opaque.read_raw_bytes(len)
}
}

View File

@ -17,7 +17,7 @@ parameterized_over_tcx! {
impl DefPathHashMapRef<'_> {
#[inline]
pub fn def_path_hash_to_def_index(&self, def_path_hash: &DefPathHash) -> DefIndex {
pub(crate) fn def_path_hash_to_def_index(&self, def_path_hash: &DefPathHash) -> DefIndex {
match *self {
DefPathHashMapRef::OwnedFromMetadata(ref map) => {
map.get(&def_path_hash.local_hash()).unwrap()

View File

@ -2309,7 +2309,7 @@ fn encode_root_position(mut file: &File, pos: usize) -> Result<(), std::io::Erro
Ok(())
}
pub fn provide(providers: &mut Providers) {
pub(crate) fn provide(providers: &mut Providers) {
*providers = Providers {
doc_link_resolutions: |tcx, def_id| {
tcx.resolutions(())

View File

@ -61,8 +61,9 @@ use rustc_hir::def_id::{CrateNum, DefId, LocalDefId, LocalModDefId, ModDefId, LO
use rustc_hir::definitions::DefPathHash;
use rustc_hir::{HirId, ItemLocalId, OwnerId};
pub use rustc_query_system::dep_graph::dep_node::DepKind;
pub use rustc_query_system::dep_graph::DepNode;
use rustc_query_system::dep_graph::FingerprintStyle;
pub use rustc_query_system::dep_graph::{DepContext, DepNode, DepNodeParams};
pub(crate) use rustc_query_system::dep_graph::{DepContext, DepNodeParams};
use rustc_span::symbol::Symbol;
use crate::mir::mono::MonoItem;
@ -101,7 +102,7 @@ macro_rules! define_dep_nodes {
// This checks that the discriminants of the variants have been assigned consecutively
// from 0 so that they can be used as a dense index.
pub const DEP_KIND_VARIANTS: u16 = {
pub(crate) const DEP_KIND_VARIANTS: u16 = {
let deps = &[$(dep_kinds::$variant,)*];
let mut i = 0;
while i < deps.len() {

View File

@ -62,6 +62,7 @@
#![feature(try_blocks)]
#![feature(type_alias_impl_trait)]
#![feature(yeet_expr)]
#![warn(unreachable_pub)]
// tidy-alphabetical-end
#[cfg(test)]

View File

@ -18,9 +18,9 @@ pub struct BasicBlocks<'tcx> {
}
// Typically 95%+ of basic blocks have 4 or fewer predecessors.
pub type Predecessors = IndexVec<BasicBlock, SmallVec<[BasicBlock; 4]>>;
type Predecessors = IndexVec<BasicBlock, SmallVec<[BasicBlock; 4]>>;
pub type SwitchSources = FxHashMap<(BasicBlock, BasicBlock), SmallVec<[Option<u128>; 1]>>;
type SwitchSources = FxHashMap<(BasicBlock, BasicBlock), SmallVec<[Option<u128>; 1]>>;
#[derive(Clone, Default, Debug)]
struct Cache {

View File

@ -2,7 +2,7 @@ use gsgdt::{Edge, Graph, Node, NodeStyle};
use rustc_middle::mir::*;
/// Convert an MIR function into a gsgdt Graph
pub fn mir_fn_to_generic_graph<'tcx>(tcx: TyCtxt<'tcx>, body: &Body<'_>) -> Graph {
pub(crate) fn mir_fn_to_generic_graph<'tcx>(tcx: TyCtxt<'tcx>, body: &Body<'_>) -> Graph {
let def_id = body.source.def_id();
let def_name = graphviz_safe_def_name(def_id);
let graph_name = format!("Mir_{def_name}");

View File

@ -243,7 +243,7 @@ impl hash::Hash for InitMaskMaterialized {
}
impl InitMaskMaterialized {
pub const BLOCK_SIZE: u64 = 64;
const BLOCK_SIZE: u64 = 64;
fn new(size: Size, state: bool) -> Self {
let mut m = InitMaskMaterialized { blocks: vec![] };

View File

@ -396,7 +396,7 @@ impl<'tcx> CodegenUnit<'tcx> {
// The codegen tests rely on items being process in the same order as
// they appear in the file, so for local items, we sort by node_id first
#[derive(PartialEq, Eq, PartialOrd, Ord)]
pub struct ItemSortKey<'tcx>(Option<usize>, SymbolName<'tcx>);
struct ItemSortKey<'tcx>(Option<usize>, SymbolName<'tcx>);
fn item_sort_key<'tcx>(tcx: TyCtxt<'tcx>, item: MonoItem<'tcx>) -> ItemSortKey<'tcx> {
ItemSortKey(

View File

@ -2190,7 +2190,7 @@ macro_rules! sty_debug_print {
all_infer: usize,
}
pub fn go(fmt: &mut std::fmt::Formatter<'_>, tcx: TyCtxt<'_>) -> std::fmt::Result {
pub(crate) fn go(fmt: &mut std::fmt::Formatter<'_>, tcx: TyCtxt<'_>) -> std::fmt::Result {
let mut total = DebugStat {
total: 0,
lt_infer: 0,

View File

@ -1027,7 +1027,7 @@ impl UnsafeOpKind {
}
}
pub fn check_unsafety(tcx: TyCtxt<'_>, def: LocalDefId) {
pub(crate) fn check_unsafety(tcx: TyCtxt<'_>, def: LocalDefId) {
// Closures and inline consts are handled by their owner, if it has a body
// Also, don't safety check custom MIR
if tcx.is_typeck_child(def.to_def_id()) || tcx.has_attr(def, sym::custom_mir) {

View File

@ -8,6 +8,7 @@
#![feature(if_let_guard)]
#![feature(let_chains)]
#![feature(try_blocks)]
#![warn(unreachable_pub)]
// tidy-alphabetical-end
mod build;

View File

@ -24,7 +24,7 @@ use crate::errors::{
};
use crate::framework::BitSetExt;
pub type EntrySets<'tcx, A> = IndexVec<BasicBlock, <A as AnalysisDomain<'tcx>>::Domain>;
type EntrySets<'tcx, A> = IndexVec<BasicBlock, <A as AnalysisDomain<'tcx>>::Domain>;
/// A dataflow analysis that has converged to fixpoint.
#[derive(Clone)]

View File

@ -510,7 +510,7 @@ impl<T: Idx> GenKill<T> for lattice::Dual<BitSet<T>> {
// NOTE: DO NOT CHANGE VARIANT ORDER. The derived `Ord` impls rely on the current order.
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord)]
pub enum Effect {
enum Effect {
/// The "before" effect (e.g., `apply_before_statement_effect`) for a statement (or
/// terminator).
Before,
@ -520,7 +520,7 @@ pub enum Effect {
}
impl Effect {
pub const fn at_index(self, statement_index: usize) -> EffectIndex {
const fn at_index(self, statement_index: usize) -> EffectIndex {
EffectIndex { effect: self, statement_index }
}
}

View File

@ -5,6 +5,7 @@
#![feature(exact_size_is_empty)]
#![feature(let_chains)]
#![feature(try_blocks)]
#![warn(unreachable_pub)]
// tidy-alphabetical-end
use rustc_middle::ty;

View File

@ -15,12 +15,12 @@ use rustc_middle::mir::{Local, Operand, PlaceElem, ProjectionElem};
use rustc_middle::ty::Ty;
#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
pub struct AbstractOperand;
pub(crate) struct AbstractOperand;
#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
pub struct AbstractType;
pub type AbstractElem = ProjectionElem<AbstractOperand, AbstractType>;
pub(crate) struct AbstractType;
pub(crate) type AbstractElem = ProjectionElem<AbstractOperand, AbstractType>;
pub trait Lift {
pub(crate) trait Lift {
type Abstract;
fn lift(&self) -> Self::Abstract;
}

View File

@ -242,12 +242,12 @@ use tracing::{debug, instrument, trace};
use crate::errors::{self, EncounteredErrorWhileInstantiating, NoOptimizedMir, RecursionLimit};
#[derive(PartialEq)]
pub enum MonoItemCollectionStrategy {
pub(crate) enum MonoItemCollectionStrategy {
Eager,
Lazy,
}
pub struct UsageMap<'tcx> {
pub(crate) struct UsageMap<'tcx> {
// Maps every mono item to the mono items used by it.
used_map: UnordMap<MonoItem<'tcx>, Vec<MonoItem<'tcx>>>,
@ -306,13 +306,17 @@ impl<'tcx> UsageMap<'tcx> {
assert!(self.used_map.insert(user_item, used_items).is_none());
}
pub fn get_user_items(&self, item: MonoItem<'tcx>) -> &[MonoItem<'tcx>] {
pub(crate) fn get_user_items(&self, item: MonoItem<'tcx>) -> &[MonoItem<'tcx>] {
self.user_map.get(&item).map(|items| items.as_slice()).unwrap_or(&[])
}
/// Internally iterate over all inlined items used by `item`.
pub fn for_each_inlined_used_item<F>(&self, tcx: TyCtxt<'tcx>, item: MonoItem<'tcx>, mut f: F)
where
pub(crate) fn for_each_inlined_used_item<F>(
&self,
tcx: TyCtxt<'tcx>,
item: MonoItem<'tcx>,
mut f: F,
) where
F: FnMut(MonoItem<'tcx>),
{
let used_items = self.used_map.get(&item).unwrap();
@ -1615,6 +1619,6 @@ pub(crate) fn collect_crate_mono_items<'tcx>(
(mono_items, state.usage_map.into_inner())
}
pub fn provide(providers: &mut Providers) {
pub(crate) fn provide(providers: &mut Providers) {
providers.hooks.should_codegen_locally = should_codegen_locally;
}

View File

@ -8,7 +8,7 @@ use crate::fluent_generated as fluent;
#[derive(Diagnostic)]
#[diag(monomorphize_recursion_limit)]
pub struct RecursionLimit {
pub(crate) struct RecursionLimit {
#[primary_span]
pub span: Span,
pub shrunk: String,
@ -22,13 +22,13 @@ pub struct RecursionLimit {
#[derive(Diagnostic)]
#[diag(monomorphize_no_optimized_mir)]
pub struct NoOptimizedMir {
pub(crate) struct NoOptimizedMir {
#[note]
pub span: Span,
pub crate_name: Symbol,
}
pub struct UnusedGenericParamsHint {
pub(crate) struct UnusedGenericParamsHint {
pub span: Span,
pub param_spans: Vec<Span>,
pub param_names: Vec<String>,
@ -53,7 +53,7 @@ impl<G: EmissionGuarantee> Diagnostic<'_, G> for UnusedGenericParamsHint {
#[derive(LintDiagnostic)]
#[diag(monomorphize_large_assignments)]
#[note]
pub struct LargeAssignmentsLint {
pub(crate) struct LargeAssignmentsLint {
#[label]
pub span: Span,
pub size: u64,
@ -62,7 +62,7 @@ pub struct LargeAssignmentsLint {
#[derive(Diagnostic)]
#[diag(monomorphize_symbol_already_defined)]
pub struct SymbolAlreadyDefined {
pub(crate) struct SymbolAlreadyDefined {
#[primary_span]
pub span: Option<Span>,
pub symbol: String,
@ -70,13 +70,13 @@ pub struct SymbolAlreadyDefined {
#[derive(Diagnostic)]
#[diag(monomorphize_couldnt_dump_mono_stats)]
pub struct CouldntDumpMonoStats {
pub(crate) struct CouldntDumpMonoStats {
pub error: String,
}
#[derive(Diagnostic)]
#[diag(monomorphize_encountered_error_while_instantiating)]
pub struct EncounteredErrorWhileInstantiating {
pub(crate) struct EncounteredErrorWhileInstantiating {
#[primary_span]
pub span: Span,
pub formatted_item: String,
@ -85,10 +85,10 @@ pub struct EncounteredErrorWhileInstantiating {
#[derive(Diagnostic)]
#[diag(monomorphize_start_not_found)]
#[help]
pub struct StartNotFound;
pub(crate) struct StartNotFound;
#[derive(Diagnostic)]
#[diag(monomorphize_unknown_cgu_collection_mode)]
pub struct UnknownCguCollectionMode<'a> {
pub(crate) struct UnknownCguCollectionMode<'a> {
pub mode: &'a str,
}

View File

@ -1,5 +1,6 @@
// tidy-alphabetical-start
#![feature(array_windows)]
#![warn(unreachable_pub)]
// tidy-alphabetical-end
use rustc_hir::lang_items::LangItem;

View File

@ -1300,7 +1300,7 @@ fn dump_mono_items_stats<'tcx>(
Ok(())
}
pub fn provide(providers: &mut Providers) {
pub(crate) fn provide(providers: &mut Providers) {
providers.collect_and_partition_mono_items = collect_and_partition_mono_items;
providers.is_codegened_item = |tcx, def_id| {

View File

@ -19,7 +19,7 @@ use tracing::{debug, instrument};
use crate::errors::UnusedGenericParamsHint;
/// Provide implementations of queries relating to polymorphization analysis.
pub fn provide(providers: &mut Providers) {
pub(crate) fn provide(providers: &mut Providers) {
providers.unused_generic_params = unused_generic_params;
}

View File

@ -4,6 +4,10 @@
//! but were uplifted in the process of making the new trait solver generic.
//! So if you got to this crate from the old solver, it's totally normal.
// tidy-alphabetical-start
#![warn(unreachable_pub)]
// tidy-alphabetical-end
pub mod canonicalizer;
pub mod coherence;
pub mod delegate;

View File

@ -92,7 +92,7 @@ where
#[derive(TypeVisitable_Generic, TypeFoldable_Generic, Lift_Generic)]
#[cfg_attr(feature = "nightly", derive(TyDecodable, TyEncodable, HashStable_NoContext))]
// FIXME: This can be made crate-private once `EvalCtxt` also lives in this crate.
pub struct NestedGoals<I: Interner> {
struct NestedGoals<I: Interner> {
/// These normalizes-to goals are treated specially during the evaluation
/// loop. In each iteration we take the RHS of the projection, replace it with
/// a fresh inference variable, and only after evaluating that goal do we
@ -109,11 +109,11 @@ pub struct NestedGoals<I: Interner> {
}
impl<I: Interner> NestedGoals<I> {
pub fn new() -> Self {
fn new() -> Self {
Self { normalizes_to_goals: Vec::new(), goals: Vec::new() }
}
pub fn is_empty(&self) -> bool {
fn is_empty(&self) -> bool {
self.normalizes_to_goals.is_empty() && self.goals.is_empty()
}
}

View File

@ -222,13 +222,13 @@ impl<D: SolverDelegate<Interner = I>, I: Interner> ProofTreeBuilder<D> {
self.state.as_deref_mut()
}
pub fn take_and_enter_probe(&mut self) -> ProofTreeBuilder<D> {
pub(crate) fn take_and_enter_probe(&mut self) -> ProofTreeBuilder<D> {
let mut nested = ProofTreeBuilder { state: self.state.take(), _infcx: PhantomData };
nested.enter_probe();
nested
}
pub fn finalize(self) -> Option<inspect::GoalEvaluation<I>> {
pub(crate) fn finalize(self) -> Option<inspect::GoalEvaluation<I>> {
match *self.state? {
DebugSolver::GoalEvaluation(wip_goal_evaluation) => {
Some(wip_goal_evaluation.finalize())
@ -237,22 +237,22 @@ impl<D: SolverDelegate<Interner = I>, I: Interner> ProofTreeBuilder<D> {
}
}
pub fn new_maybe_root(generate_proof_tree: GenerateProofTree) -> ProofTreeBuilder<D> {
pub(crate) fn new_maybe_root(generate_proof_tree: GenerateProofTree) -> ProofTreeBuilder<D> {
match generate_proof_tree {
GenerateProofTree::No => ProofTreeBuilder::new_noop(),
GenerateProofTree::Yes => ProofTreeBuilder::new_root(),
}
}
pub fn new_root() -> ProofTreeBuilder<D> {
fn new_root() -> ProofTreeBuilder<D> {
ProofTreeBuilder::new(DebugSolver::Root)
}
pub fn new_noop() -> ProofTreeBuilder<D> {
fn new_noop() -> ProofTreeBuilder<D> {
ProofTreeBuilder { state: None, _infcx: PhantomData }
}
pub fn is_noop(&self) -> bool {
pub(crate) fn is_noop(&self) -> bool {
self.state.is_none()
}
@ -272,7 +272,7 @@ impl<D: SolverDelegate<Interner = I>, I: Interner> ProofTreeBuilder<D> {
})
}
pub fn new_canonical_goal_evaluation(
pub(crate) fn new_canonical_goal_evaluation(
&mut self,
goal: CanonicalInput<I>,
) -> ProofTreeBuilder<D> {
@ -284,7 +284,10 @@ impl<D: SolverDelegate<Interner = I>, I: Interner> ProofTreeBuilder<D> {
})
}
pub fn canonical_goal_evaluation(&mut self, canonical_goal_evaluation: ProofTreeBuilder<D>) {
pub(crate) fn canonical_goal_evaluation(
&mut self,
canonical_goal_evaluation: ProofTreeBuilder<D>,
) {
if let Some(this) = self.as_mut() {
match (this, *canonical_goal_evaluation.state.unwrap()) {
(
@ -299,7 +302,7 @@ impl<D: SolverDelegate<Interner = I>, I: Interner> ProofTreeBuilder<D> {
}
}
pub fn canonical_goal_evaluation_overflow(&mut self) {
pub(crate) fn canonical_goal_evaluation_overflow(&mut self) {
if let Some(this) = self.as_mut() {
match this {
DebugSolver::CanonicalGoalEvaluation(canonical_goal_evaluation) => {
@ -310,7 +313,7 @@ impl<D: SolverDelegate<Interner = I>, I: Interner> ProofTreeBuilder<D> {
}
}
pub fn goal_evaluation(&mut self, goal_evaluation: ProofTreeBuilder<D>) {
pub(crate) fn goal_evaluation(&mut self, goal_evaluation: ProofTreeBuilder<D>) {
if let Some(this) = self.as_mut() {
match this {
DebugSolver::Root => *this = *goal_evaluation.state.unwrap(),
@ -322,7 +325,7 @@ impl<D: SolverDelegate<Interner = I>, I: Interner> ProofTreeBuilder<D> {
}
}
pub fn new_goal_evaluation_step(
pub(crate) fn new_goal_evaluation_step(
&mut self,
var_values: ty::CanonicalVarValues<I>,
instantiated_goal: QueryInput<I, I::Predicate>,
@ -340,7 +343,7 @@ impl<D: SolverDelegate<Interner = I>, I: Interner> ProofTreeBuilder<D> {
})
}
pub fn goal_evaluation_step(&mut self, goal_evaluation_step: ProofTreeBuilder<D>) {
pub(crate) fn goal_evaluation_step(&mut self, goal_evaluation_step: ProofTreeBuilder<D>) {
if let Some(this) = self.as_mut() {
match (this, *goal_evaluation_step.state.unwrap()) {
(
@ -354,7 +357,7 @@ impl<D: SolverDelegate<Interner = I>, I: Interner> ProofTreeBuilder<D> {
}
}
pub fn add_var_value<T: Into<I::GenericArg>>(&mut self, arg: T) {
pub(crate) fn add_var_value<T: Into<I::GenericArg>>(&mut self, arg: T) {
match self.as_mut() {
None => {}
Some(DebugSolver::CanonicalGoalEvaluationStep(state)) => {
@ -364,7 +367,7 @@ impl<D: SolverDelegate<Interner = I>, I: Interner> ProofTreeBuilder<D> {
}
}
pub fn enter_probe(&mut self) {
fn enter_probe(&mut self) {
match self.as_mut() {
None => {}
Some(DebugSolver::CanonicalGoalEvaluationStep(state)) => {
@ -381,7 +384,7 @@ impl<D: SolverDelegate<Interner = I>, I: Interner> ProofTreeBuilder<D> {
}
}
pub fn probe_kind(&mut self, probe_kind: inspect::ProbeKind<I>) {
pub(crate) fn probe_kind(&mut self, probe_kind: inspect::ProbeKind<I>) {
match self.as_mut() {
None => {}
Some(DebugSolver::CanonicalGoalEvaluationStep(state)) => {
@ -392,7 +395,11 @@ impl<D: SolverDelegate<Interner = I>, I: Interner> ProofTreeBuilder<D> {
}
}
pub fn probe_final_state(&mut self, delegate: &D, max_input_universe: ty::UniverseIndex) {
pub(crate) fn probe_final_state(
&mut self,
delegate: &D,
max_input_universe: ty::UniverseIndex,
) {
match self.as_mut() {
None => {}
Some(DebugSolver::CanonicalGoalEvaluationStep(state)) => {
@ -409,7 +416,7 @@ impl<D: SolverDelegate<Interner = I>, I: Interner> ProofTreeBuilder<D> {
}
}
pub fn add_normalizes_to_goal(
pub(crate) fn add_normalizes_to_goal(
&mut self,
delegate: &D,
max_input_universe: ty::UniverseIndex,
@ -423,7 +430,7 @@ impl<D: SolverDelegate<Interner = I>, I: Interner> ProofTreeBuilder<D> {
);
}
pub fn add_goal(
pub(crate) fn add_goal(
&mut self,
delegate: &D,
max_input_universe: ty::UniverseIndex,
@ -469,7 +476,7 @@ impl<D: SolverDelegate<Interner = I>, I: Interner> ProofTreeBuilder<D> {
}
}
pub fn make_canonical_response(&mut self, shallow_certainty: Certainty) {
pub(crate) fn make_canonical_response(&mut self, shallow_certainty: Certainty) {
match self.as_mut() {
Some(DebugSolver::CanonicalGoalEvaluationStep(state)) => {
state
@ -482,7 +489,7 @@ impl<D: SolverDelegate<Interner = I>, I: Interner> ProofTreeBuilder<D> {
}
}
pub fn finish_probe(mut self) -> ProofTreeBuilder<D> {
pub(crate) fn finish_probe(mut self) -> ProofTreeBuilder<D> {
match self.as_mut() {
None => {}
Some(DebugSolver::CanonicalGoalEvaluationStep(state)) => {
@ -497,7 +504,7 @@ impl<D: SolverDelegate<Interner = I>, I: Interner> ProofTreeBuilder<D> {
self
}
pub fn query_result(&mut self, result: QueryResult<I>) {
pub(crate) fn query_result(&mut self, result: QueryResult<I>) {
if let Some(this) = self.as_mut() {
match this {
DebugSolver::CanonicalGoalEvaluation(canonical_goal_evaluation) => {

View File

@ -97,7 +97,7 @@ where
/// Checks whether each generic argument is simply a unique generic placeholder.
///
/// FIXME: Interner argument is needed to constrain the `I` parameter.
pub fn uses_unique_placeholders_ignoring_regions<I: Interner>(
fn uses_unique_placeholders_ignoring_regions<I: Interner>(
_cx: I,
args: I::GenericArgs,
) -> Result<(), NotUniqueParam<I>> {
@ -130,7 +130,7 @@ pub fn uses_unique_placeholders_ignoring_regions<I: Interner>(
}
// FIXME: This should check for dupes and non-params first, then infer vars.
pub enum NotUniqueParam<I: Interner> {
enum NotUniqueParam<I: Interner> {
DuplicateParam(I::GenericArg),
NotParam(I::GenericArg),
}

View File

@ -260,7 +260,7 @@ pub(crate) struct NotAsNegationOperator {
}
#[derive(Subdiagnostic)]
pub enum NotAsNegationOperatorSub {
pub(crate) enum NotAsNegationOperatorSub {
#[suggestion(
parse_unexpected_token_after_not_default,
style = "verbose",
@ -424,7 +424,7 @@ pub(crate) enum IfExpressionMissingThenBlockSub {
#[derive(Diagnostic)]
#[diag(parse_ternary_operator)]
#[help]
pub struct TernaryOperator {
pub(crate) struct TernaryOperator {
#[primary_span]
pub span: Span,
}
@ -1088,7 +1088,7 @@ pub(crate) enum ExpectedIdentifierFound {
}
impl ExpectedIdentifierFound {
pub fn new(token_descr: Option<TokenDescription>, span: Span) -> Self {
pub(crate) fn new(token_descr: Option<TokenDescription>, span: Span) -> Self {
(match token_descr {
Some(TokenDescription::ReservedIdentifier) => {
ExpectedIdentifierFound::ReservedIdentifier
@ -1659,7 +1659,7 @@ pub(crate) struct SelfArgumentPointer {
#[derive(Diagnostic)]
#[diag(parse_unexpected_token_after_dot)]
pub struct UnexpectedTokenAfterDot<'a> {
pub(crate) struct UnexpectedTokenAfterDot<'a> {
#[primary_span]
pub span: Span,
pub actual: Cow<'a, str>,
@ -1928,7 +1928,7 @@ pub(crate) enum UnexpectedTokenAfterStructName {
}
impl UnexpectedTokenAfterStructName {
pub fn new(span: Span, token: Token) -> Self {
pub(crate) fn new(span: Span, token: Token) -> Self {
match TokenDescription::from_token(&token) {
Some(TokenDescription::ReservedIdentifier) => Self::ReservedIdentifier { span, token },
Some(TokenDescription::Keyword) => Self::Keyword { span, token },
@ -2006,7 +2006,7 @@ pub(crate) enum TopLevelOrPatternNotAllowed {
#[derive(Diagnostic)]
#[diag(parse_cannot_be_raw_ident)]
pub struct CannotBeRawIdent {
pub(crate) struct CannotBeRawIdent {
#[primary_span]
pub span: Span,
pub ident: Symbol,
@ -2014,14 +2014,14 @@ pub struct CannotBeRawIdent {
#[derive(Diagnostic)]
#[diag(parse_keyword_lifetime)]
pub struct KeywordLifetime {
pub(crate) struct KeywordLifetime {
#[primary_span]
pub span: Span,
}
#[derive(Diagnostic)]
#[diag(parse_invalid_label)]
pub struct InvalidLabel {
pub(crate) struct InvalidLabel {
#[primary_span]
pub span: Span,
pub name: Symbol,
@ -2029,7 +2029,7 @@ pub struct InvalidLabel {
#[derive(Diagnostic)]
#[diag(parse_cr_doc_comment)]
pub struct CrDocComment {
pub(crate) struct CrDocComment {
#[primary_span]
pub span: Span,
pub block: bool,
@ -2037,14 +2037,14 @@ pub struct CrDocComment {
#[derive(Diagnostic)]
#[diag(parse_no_digits_literal, code = E0768)]
pub struct NoDigitsLiteral {
pub(crate) struct NoDigitsLiteral {
#[primary_span]
pub span: Span,
}
#[derive(Diagnostic)]
#[diag(parse_invalid_digit_literal)]
pub struct InvalidDigitLiteral {
pub(crate) struct InvalidDigitLiteral {
#[primary_span]
pub span: Span,
pub base: u32,
@ -2052,14 +2052,14 @@ pub struct InvalidDigitLiteral {
#[derive(Diagnostic)]
#[diag(parse_empty_exponent_float)]
pub struct EmptyExponentFloat {
pub(crate) struct EmptyExponentFloat {
#[primary_span]
pub span: Span,
}
#[derive(Diagnostic)]
#[diag(parse_float_literal_unsupported_base)]
pub struct FloatLiteralUnsupportedBase {
pub(crate) struct FloatLiteralUnsupportedBase {
#[primary_span]
pub span: Span,
pub base: &'static str,
@ -2068,7 +2068,7 @@ pub struct FloatLiteralUnsupportedBase {
#[derive(Diagnostic)]
#[diag(parse_unknown_prefix)]
#[note]
pub struct UnknownPrefix<'a> {
pub(crate) struct UnknownPrefix<'a> {
#[primary_span]
#[label]
pub span: Span,
@ -2079,12 +2079,12 @@ pub struct UnknownPrefix<'a> {
#[derive(Subdiagnostic)]
#[note(parse_macro_expands_to_adt_field)]
pub struct MacroExpandsToAdtField<'a> {
pub(crate) struct MacroExpandsToAdtField<'a> {
pub adt_ty: &'a str,
}
#[derive(Subdiagnostic)]
pub enum UnknownPrefixSugg {
pub(crate) enum UnknownPrefixSugg {
#[suggestion(
parse_suggestion_br,
code = "br",
@ -2114,7 +2114,7 @@ pub enum UnknownPrefixSugg {
#[derive(Diagnostic)]
#[diag(parse_too_many_hashes)]
pub struct TooManyHashes {
pub(crate) struct TooManyHashes {
#[primary_span]
pub span: Span,
pub num: u32,
@ -2122,7 +2122,7 @@ pub struct TooManyHashes {
#[derive(Diagnostic)]
#[diag(parse_unknown_start_of_token)]
pub struct UnknownTokenStart {
pub(crate) struct UnknownTokenStart {
#[primary_span]
pub span: Span,
pub escaped: String,
@ -2135,7 +2135,7 @@ pub struct UnknownTokenStart {
}
#[derive(Subdiagnostic)]
pub enum TokenSubstitution {
pub(crate) enum TokenSubstitution {
#[suggestion(
parse_sugg_quotes,
code = "{suggestion}",
@ -2168,16 +2168,16 @@ pub enum TokenSubstitution {
#[derive(Subdiagnostic)]
#[note(parse_note_repeats)]
pub struct UnknownTokenRepeat {
pub(crate) struct UnknownTokenRepeat {
pub repeats: usize,
}
#[derive(Subdiagnostic)]
#[help(parse_help_null)]
pub struct UnknownTokenNull;
pub(crate) struct UnknownTokenNull;
#[derive(Diagnostic)]
pub enum UnescapeError {
pub(crate) enum UnescapeError {
#[diag(parse_invalid_unicode_escape)]
#[help]
InvalidUnicodeEscape {
@ -2322,7 +2322,7 @@ pub enum UnescapeError {
}
#[derive(Subdiagnostic)]
pub enum MoreThanOneCharSugg {
pub(crate) enum MoreThanOneCharSugg {
#[suggestion(
parse_consider_normalized,
code = "{normalized}",
@ -2370,7 +2370,7 @@ pub enum MoreThanOneCharSugg {
}
#[derive(Subdiagnostic)]
pub enum MoreThanOneCharNote {
pub(crate) enum MoreThanOneCharNote {
#[note(parse_followed_by)]
AllCombining {
#[primary_span]
@ -2388,7 +2388,7 @@ pub enum MoreThanOneCharNote {
}
#[derive(Subdiagnostic)]
pub enum NoBraceUnicodeSub {
pub(crate) enum NoBraceUnicodeSub {
#[suggestion(
parse_use_braces,
code = "{suggestion}",
@ -2703,7 +2703,7 @@ pub(crate) struct InvalidDynKeyword {
}
#[derive(Subdiagnostic)]
pub enum HelpUseLatestEdition {
pub(crate) enum HelpUseLatestEdition {
#[help(parse_help_set_edition_cargo)]
#[note(parse_note_edition_guide)]
Cargo { edition: Edition },
@ -2713,7 +2713,7 @@ pub enum HelpUseLatestEdition {
}
impl HelpUseLatestEdition {
pub fn new() -> Self {
pub(crate) fn new() -> Self {
let edition = LATEST_STABLE_EDITION;
if rustc_session::utils::was_invoked_from_cargo() {
Self::Cargo { edition }
@ -2725,7 +2725,7 @@ impl HelpUseLatestEdition {
#[derive(Diagnostic)]
#[diag(parse_box_syntax_removed)]
pub struct BoxSyntaxRemoved {
pub(crate) struct BoxSyntaxRemoved {
#[primary_span]
pub span: Span,
#[subdiagnostic]
@ -2738,7 +2738,7 @@ pub struct BoxSyntaxRemoved {
applicability = "machine-applicable",
style = "verbose"
)]
pub struct AddBoxNew {
pub(crate) struct AddBoxNew {
#[suggestion_part(code = "Box::new(")]
pub box_kw_and_lo: Span,
#[suggestion_part(code = ")")]
@ -3190,7 +3190,7 @@ pub(crate) struct DotDotRangeAttribute {
#[derive(Diagnostic)]
#[diag(parse_invalid_attr_unsafe)]
#[note]
pub struct InvalidAttrUnsafe {
pub(crate) struct InvalidAttrUnsafe {
#[primary_span]
#[label]
pub span: Span,
@ -3199,7 +3199,7 @@ pub struct InvalidAttrUnsafe {
#[derive(Diagnostic)]
#[diag(parse_unsafe_attr_outside_unsafe)]
pub struct UnsafeAttrOutsideUnsafe {
pub(crate) struct UnsafeAttrOutsideUnsafe {
#[primary_span]
#[label]
pub span: Span,
@ -3212,7 +3212,7 @@ pub struct UnsafeAttrOutsideUnsafe {
parse_unsafe_attr_outside_unsafe_suggestion,
applicability = "machine-applicable"
)]
pub struct UnsafeAttrOutsideUnsafeSuggestion {
pub(crate) struct UnsafeAttrOutsideUnsafeSuggestion {
#[suggestion_part(code = "unsafe(")]
pub left: Span,
#[suggestion_part(code = ")")]
@ -3221,7 +3221,7 @@ pub struct UnsafeAttrOutsideUnsafeSuggestion {
#[derive(Diagnostic)]
#[diag(parse_binder_before_modifiers)]
pub struct BinderBeforeModifiers {
pub(crate) struct BinderBeforeModifiers {
#[primary_span]
pub binder_span: Span,
#[label]
@ -3230,7 +3230,7 @@ pub struct BinderBeforeModifiers {
#[derive(Diagnostic)]
#[diag(parse_binder_and_polarity)]
pub struct BinderAndPolarity {
pub(crate) struct BinderAndPolarity {
#[primary_span]
pub polarity_span: Span,
#[label]
@ -3240,7 +3240,7 @@ pub struct BinderAndPolarity {
#[derive(Diagnostic)]
#[diag(parse_modifiers_and_polarity)]
pub struct PolarityAndModifiers {
pub(crate) struct PolarityAndModifiers {
#[primary_span]
pub polarity_span: Span,
#[label]

View File

@ -11,6 +11,7 @@
#![feature(if_let_guard)]
#![feature(iter_intersperse)]
#![feature(let_chains)]
#![warn(unreachable_pub)]
// tidy-alphabetical-end
use std::path::Path;

View File

@ -13,6 +13,7 @@
html_playground_url = "https://play.rust-lang.org/",
test(attr(deny(warnings)))
)]
#![warn(unreachable_pub)]
// tidy-alphabetical-end
use std::{iter, str, string};

View File

@ -95,6 +95,6 @@ fn debugger_visualizers(tcx: TyCtxt<'_>, _: LocalCrate) -> Vec<DebuggerVisualize
visitor.visualizers
}
pub fn provide(providers: &mut Providers) {
pub(crate) fn provide(providers: &mut Providers) {
providers.debugger_visualizers = debugger_visualizers;
}

View File

@ -90,7 +90,7 @@ fn all_diagnostic_items(tcx: TyCtxt<'_>, (): ()) -> DiagnosticItems {
items
}
pub fn provide(providers: &mut Providers) {
pub(crate) fn provide(providers: &mut Providers) {
providers.diagnostic_items = diagnostic_items;
providers.all_diagnostic_items = all_diagnostic_items;
}

File diff suppressed because it is too large Load Diff

View File

@ -359,6 +359,6 @@ impl<'ast, 'tcx> visit::Visitor<'ast> for LanguageItemCollector<'ast, 'tcx> {
}
}
pub fn provide(providers: &mut Providers) {
pub(crate) fn provide(providers: &mut Providers) {
providers.get_lang_items = get_lang_items;
}

View File

@ -12,6 +12,7 @@
#![feature(map_try_insert)]
#![feature(rustdoc_internals)]
#![feature(try_blocks)]
#![warn(unreachable_pub)]
// tidy-alphabetical-end
use rustc_middle::query::Providers;

View File

@ -16,7 +16,7 @@ use rustc_span::{sym, Span};
use crate::errors::{FeaturePreviouslyDeclared, FeatureStableTwice};
pub struct LibFeatureCollector<'tcx> {
struct LibFeatureCollector<'tcx> {
tcx: TyCtxt<'tcx>,
lib_features: LibFeatures,
}
@ -153,6 +153,6 @@ fn lib_features(tcx: TyCtxt<'_>, LocalCrate: LocalCrate) -> LibFeatures {
collector.lib_features
}
pub fn provide(providers: &mut Providers) {
pub(crate) fn provide(providers: &mut Providers) {
providers.lib_features = lib_features;
}

View File

@ -178,7 +178,7 @@ fn check_liveness(tcx: TyCtxt<'_>, def_id: LocalDefId) {
lsets.warn_about_unused_args(&body, entry_ln);
}
pub fn provide(providers: &mut Providers) {
pub(crate) fn provide(providers: &mut Providers) {
*providers = Providers { check_liveness, ..*providers };
}

View File

@ -500,6 +500,6 @@ fn reachable_set(tcx: TyCtxt<'_>, (): ()) -> LocalDefIdSet {
reachable_context.reachable_symbols
}
pub fn provide(providers: &mut Providers) {
pub(crate) fn provide(providers: &mut Providers) {
*providers = Providers { reachable_set, ..*providers };
}

View File

@ -9,7 +9,7 @@ use rustc_middle::query::Providers;
use rustc_middle::ty::TyCtxt;
use rustc_span::Span;
pub fn provide(providers: &mut Providers) {
pub(crate) fn provide(providers: &mut Providers) {
providers.upvars_mentioned = |tcx, def_id| {
if !tcx.is_closure_like(def_id) {
return None;

View File

@ -15,7 +15,11 @@ use crate::errors::{
/// Checks the crate for usage of weak lang items, returning a vector of all the
/// lang items required by this crate, but not defined yet.
pub fn check_crate(tcx: TyCtxt<'_>, items: &mut lang_items::LanguageItems, krate: &ast::Crate) {
pub(crate) fn check_crate(
tcx: TyCtxt<'_>,
items: &mut lang_items::LanguageItems,
krate: &ast::Crate,
) {
// These are never called by user code, they're generated by the compiler.
// They will never implicitly be added to the `missing` array unless we do
// so here.

View File

@ -6,6 +6,7 @@
#![allow(rustc::diagnostic_outside_of_impl)]
#![allow(rustc::untranslatable_diagnostic)]
#![cfg_attr(feature = "rustc", feature(let_chains))]
#![warn(unreachable_pub)]
// tidy-alphabetical-end
pub mod constructor;

View File

@ -5,7 +5,7 @@ use rustc_span::{Span, Symbol};
#[derive(Diagnostic)]
#[diag(privacy_field_is_private, code = E0451)]
pub struct FieldIsPrivate {
pub(crate) struct FieldIsPrivate {
#[primary_span]
pub span: Span,
pub field_name: Symbol,
@ -16,7 +16,7 @@ pub struct FieldIsPrivate {
}
#[derive(Subdiagnostic)]
pub enum FieldIsPrivateLabel {
pub(crate) enum FieldIsPrivateLabel {
#[label(privacy_field_is_private_is_update_syntax_label)]
IsUpdateSyntax {
#[primary_span]
@ -32,7 +32,7 @@ pub enum FieldIsPrivateLabel {
#[derive(Diagnostic)]
#[diag(privacy_item_is_private)]
pub struct ItemIsPrivate<'a> {
pub(crate) struct ItemIsPrivate<'a> {
#[primary_span]
#[label]
pub span: Span,
@ -42,7 +42,7 @@ pub struct ItemIsPrivate<'a> {
#[derive(Diagnostic)]
#[diag(privacy_unnamed_item_is_private)]
pub struct UnnamedItemIsPrivate {
pub(crate) struct UnnamedItemIsPrivate {
#[primary_span]
pub span: Span,
pub kind: &'static str,
@ -50,7 +50,7 @@ pub struct UnnamedItemIsPrivate {
#[derive(Diagnostic)]
#[diag(privacy_in_public_interface, code = E0446)]
pub struct InPublicInterface<'a> {
pub(crate) struct InPublicInterface<'a> {
#[primary_span]
#[label]
pub span: Span,
@ -63,7 +63,7 @@ pub struct InPublicInterface<'a> {
#[derive(Diagnostic)]
#[diag(privacy_report_effective_visibility)]
pub struct ReportEffectiveVisibility {
pub(crate) struct ReportEffectiveVisibility {
#[primary_span]
pub span: Span,
pub descr: String,
@ -71,7 +71,7 @@ pub struct ReportEffectiveVisibility {
#[derive(LintDiagnostic)]
#[diag(privacy_from_private_dep_in_public_interface)]
pub struct FromPrivateDependencyInPublicInterface<'a> {
pub(crate) struct FromPrivateDependencyInPublicInterface<'a> {
pub kind: &'a str,
pub descr: DiagArgFromDisplay<'a>,
pub krate: Symbol,
@ -79,7 +79,7 @@ pub struct FromPrivateDependencyInPublicInterface<'a> {
#[derive(LintDiagnostic)]
#[diag(privacy_unnameable_types_lint)]
pub struct UnnameableTypesLint<'a> {
pub(crate) struct UnnameableTypesLint<'a> {
#[label]
pub span: Span,
pub kind: &'a str,
@ -93,7 +93,7 @@ pub struct UnnameableTypesLint<'a> {
// See https://rust-lang.github.io/rfcs/2145-type-privacy.html for more details.
#[derive(LintDiagnostic)]
#[diag(privacy_private_interface_or_bounds_lint)]
pub struct PrivateInterfacesOrBoundsLint<'a> {
pub(crate) struct PrivateInterfacesOrBoundsLint<'a> {
#[label(privacy_item_label)]
pub item_span: Span,
pub item_kind: &'a str,

View File

@ -6,6 +6,7 @@
#![feature(let_chains)]
#![feature(rustdoc_internals)]
#![feature(try_blocks)]
#![warn(unreachable_pub)]
// tidy-alphabetical-end
mod errors;
@ -1497,7 +1498,7 @@ impl<'tcx> PrivateItemsInPublicInterfacesChecker<'tcx, '_> {
self.effective_visibilities.effective_vis(def_id).copied()
}
pub fn check_item(&mut self, id: ItemId) {
fn check_item(&mut self, id: ItemId) {
let tcx = self.tcx;
let def_id = id.owner_id.def_id;
let item_visibility = tcx.local_visibility(def_id);

View File

@ -8,6 +8,7 @@
#![feature(min_specialization)]
#![feature(rustc_attrs)]
#![feature(rustdoc_internals)]
#![warn(unreachable_pub)]
// tidy-alphabetical-end
use field_offset::offset_of;

View File

@ -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,
{
@ -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>,
@ -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>,
@ -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)*]),
@ -667,7 +669,7 @@ macro_rules! define_queries {
}
#[derive(Copy, Clone, Default)]
pub struct QueryType<'tcx> {
pub(crate) struct QueryType<'tcx> {
data: PhantomData<&'tcx ()>
}
@ -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);
@ -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),
@ -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
@ -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),
@ -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,
@ -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,
@ -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,
@ -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,
@ -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,

View File

@ -617,14 +617,14 @@ impl<D: Deps> EncoderState<D> {
}
}
pub struct GraphEncoder<D: Deps> {
pub(crate) struct GraphEncoder<D: Deps> {
profiler: SelfProfilerRef,
status: Lock<Option<EncoderState<D>>>,
record_graph: Option<Lock<DepGraphQuery>>,
}
impl<D: Deps> GraphEncoder<D> {
pub fn new(
pub(crate) fn new(
encoder: FileEncoder,
prev_node_count: usize,
record_graph: bool,
@ -723,7 +723,7 @@ impl<D: Deps> GraphEncoder<D> {
)
}
pub fn finish(&self) -> FileEncodeResult {
pub(crate) fn finish(&self) -> FileEncodeResult {
let _prof_timer = self.profiler.generic_activity("incr_comp_encode_dep_graph_finish");
self.status.lock().take().unwrap().finish(&self.profiler)

View File

@ -5,7 +5,7 @@ use rustc_span::{Span, Symbol};
#[derive(Subdiagnostic)]
#[note(query_system_cycle_stack_middle)]
pub struct CycleStack {
pub(crate) struct CycleStack {
#[primary_span]
pub span: Span,
pub desc: String,
@ -20,7 +20,7 @@ pub enum HandleCycleError {
}
#[derive(Subdiagnostic)]
pub enum StackCount {
pub(crate) enum StackCount {
#[note(query_system_cycle_stack_single)]
Single,
#[note(query_system_cycle_stack_multiple)]
@ -28,7 +28,7 @@ pub enum StackCount {
}
#[derive(Subdiagnostic)]
pub enum Alias {
pub(crate) enum Alias {
#[note(query_system_cycle_recursive_ty_alias)]
#[help(query_system_cycle_recursive_ty_alias_help1)]
#[help(query_system_cycle_recursive_ty_alias_help2)]
@ -39,7 +39,7 @@ pub enum Alias {
#[derive(Subdiagnostic)]
#[note(query_system_cycle_usage)]
pub struct CycleUsage {
pub(crate) struct CycleUsage {
#[primary_span]
pub span: Span,
pub usage: String,
@ -47,7 +47,7 @@ pub struct CycleUsage {
#[derive(Diagnostic)]
#[diag(query_system_cycle, code = E0391)]
pub struct Cycle {
pub(crate) struct Cycle {
#[primary_span]
pub span: Span,
pub stack_bottom: String,
@ -65,14 +65,14 @@ pub struct Cycle {
#[derive(Diagnostic)]
#[diag(query_system_reentrant)]
pub struct Reentrant;
pub(crate) struct Reentrant;
#[derive(Diagnostic)]
#[diag(query_system_increment_compilation)]
#[help]
#[note(query_system_increment_compilation_note1)]
#[note(query_system_increment_compilation_note2)]
pub struct IncrementCompilation {
pub(crate) struct IncrementCompilation {
pub run_cmd: String,
pub dep_node: String,
}

View File

@ -5,6 +5,7 @@
#![feature(hash_raw_entry)]
#![feature(let_chains)]
#![feature(min_specialization)]
#![warn(unreachable_pub)]
// tidy-alphabetical-end
pub mod cache;

View File

@ -21,6 +21,7 @@
#![feature(let_chains)]
#![feature(rustc_attrs)]
#![feature(rustdoc_internals)]
#![warn(unreachable_pub)]
// tidy-alphabetical-end
use std::cell::{Cell, RefCell};