Add warn(unreachable_pub) to rustc_infer.

This commit is contained in:
Nicholas Nethercote 2024-08-27 14:47:56 +10:00
parent 46fe09f3f3
commit 688792715b
10 changed files with 12 additions and 11 deletions

View File

@ -3,7 +3,7 @@ use rustc_span::Span;
#[derive(Diagnostic)]
#[diag(infer_opaque_hidden_type)]
pub struct OpaqueHiddenTypeDiag {
pub(crate) struct OpaqueHiddenTypeDiag {
#[primary_span]
#[label]
pub span: Span,

View File

@ -18,11 +18,11 @@ pub(crate) struct RegionRelations<'a, 'tcx> {
}
impl<'a, 'tcx> RegionRelations<'a, 'tcx> {
pub fn new(tcx: TyCtxt<'tcx>, free_regions: &'a FreeRegionMap<'tcx>) -> Self {
pub(crate) fn new(tcx: TyCtxt<'tcx>, free_regions: &'a FreeRegionMap<'tcx>) -> Self {
Self { tcx, free_regions }
}
pub fn lub_param_regions(&self, r_a: Region<'tcx>, r_b: Region<'tcx>) -> Region<'tcx> {
pub(crate) fn lub_param_regions(&self, r_a: Region<'tcx>, r_b: Region<'tcx>) -> Region<'tcx> {
self.free_regions.lub_param_regions(self.tcx, r_a, r_b)
}
}
@ -80,7 +80,7 @@ impl<'tcx> FreeRegionMap<'tcx> {
/// cases, this is more conservative than necessary, in order to
/// avoid making arbitrary choices. See
/// `TransitiveRelation::postdom_upper_bound` for more details.
pub fn lub_param_regions(
pub(crate) fn lub_param_regions(
&self,
tcx: TyCtxt<'tcx>,
r_a: Region<'tcx>,

View File

@ -43,7 +43,7 @@ pub(crate) fn resolve<'tcx>(
/// Contains the result of lexical region resolution. Offers methods
/// to lookup up the final value of a region variable.
#[derive(Clone)]
pub struct LexicalRegionResolutions<'tcx> {
pub(crate) struct LexicalRegionResolutions<'tcx> {
pub(crate) values: IndexVec<RegionVid, VarValue<'tcx>>,
}

View File

@ -705,7 +705,7 @@ impl<'tcx> TypeRelation<TyCtxt<'tcx>> for Generalizer<'_, 'tcx> {
/// not only the generalized type, but also a bool flag
/// indicating whether further WF checks are needed.
#[derive(Debug)]
pub struct Generalization<T> {
struct Generalization<T> {
/// When generalizing `<?0 as Trait>::Assoc` or
/// `<T as Bar<<?0 as Foo>::Assoc>>::Assoc`
/// for `?0` generalization returns an inference

View File

@ -29,7 +29,7 @@ use crate::traits::ObligationCause;
///
/// GLB moves "down" the lattice (to smaller values); LUB moves
/// "up" the lattice (to bigger values).
pub trait LatticeDir<'f, 'tcx>: PredicateEmittingRelation<InferCtxt<'tcx>> {
pub(crate) trait LatticeDir<'f, 'tcx>: PredicateEmittingRelation<InferCtxt<'tcx>> {
fn infcx(&self) -> &'f InferCtxt<'tcx>;
fn cause(&self) -> &ObligationCause<'tcx>;

View File

@ -170,7 +170,7 @@ impl<'tcx> InferCtxt<'tcx> {
}
}
pub struct InferenceFudger<'a, 'tcx> {
struct InferenceFudger<'a, 'tcx> {
infcx: &'a InferCtxt<'tcx>,
type_vars: (Range<TyVid>, Vec<TypeVariableOrigin>),
int_vars: Range<IntVid>,

View File

@ -158,7 +158,7 @@ impl<'tcx> InferCtxtInner<'tcx> {
}
impl<'tcx> InferCtxtUndoLogs<'tcx> {
pub fn start_snapshot(&mut self) -> Snapshot<'tcx> {
pub(crate) fn start_snapshot(&mut self) -> Snapshot<'tcx> {
self.num_open_snapshots += 1;
Snapshot { undo_len: self.logs.len(), _marker: PhantomData }
}

View File

@ -28,6 +28,7 @@
#![feature(let_chains)]
#![feature(rustdoc_internals)]
#![recursion_limit = "512"] // For rustdoc
#![warn(unreachable_pub)]
// tidy-alphabetical-end
#[macro_use]

View File

@ -22,7 +22,7 @@ pub use self::engine::{FromSolverError, ScrubbedTraitError, TraitEngine};
pub(crate) use self::project::UndoLog;
pub use self::project::{
MismatchedProjectionTypes, Normalized, NormalizedTerm, ProjectionCache, ProjectionCacheEntry,
ProjectionCacheKey, ProjectionCacheStorage, Reveal,
ProjectionCacheKey, ProjectionCacheStorage,
};
pub use self::ImplSource::*;
pub use self::SelectionError::*;

View File

@ -2,7 +2,7 @@
use rustc_data_structures::snapshot_map::{self, SnapshotMapRef, SnapshotMapStorage};
use rustc_data_structures::undo_log::Rollback;
pub use rustc_middle::traits::{EvaluationResult, Reveal};
use rustc_middle::traits::EvaluationResult;
use rustc_middle::ty;
use super::PredicateObligation;