1
Fork 0

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)] #[derive(Diagnostic)]
#[diag(infer_opaque_hidden_type)] #[diag(infer_opaque_hidden_type)]
pub struct OpaqueHiddenTypeDiag { pub(crate) struct OpaqueHiddenTypeDiag {
#[primary_span] #[primary_span]
#[label] #[label]
pub span: Span, pub span: Span,

View file

@ -18,11 +18,11 @@ pub(crate) struct RegionRelations<'a, 'tcx> {
} }
impl<'a, 'tcx> 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 } 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) 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 /// cases, this is more conservative than necessary, in order to
/// avoid making arbitrary choices. See /// avoid making arbitrary choices. See
/// `TransitiveRelation::postdom_upper_bound` for more details. /// `TransitiveRelation::postdom_upper_bound` for more details.
pub fn lub_param_regions( pub(crate) fn lub_param_regions(
&self, &self,
tcx: TyCtxt<'tcx>, tcx: TyCtxt<'tcx>,
r_a: Region<'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 /// Contains the result of lexical region resolution. Offers methods
/// to lookup up the final value of a region variable. /// to lookup up the final value of a region variable.
#[derive(Clone)] #[derive(Clone)]
pub struct LexicalRegionResolutions<'tcx> { pub(crate) struct LexicalRegionResolutions<'tcx> {
pub(crate) values: IndexVec<RegionVid, VarValue<'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 /// not only the generalized type, but also a bool flag
/// indicating whether further WF checks are needed. /// indicating whether further WF checks are needed.
#[derive(Debug)] #[derive(Debug)]
pub struct Generalization<T> { struct Generalization<T> {
/// When generalizing `<?0 as Trait>::Assoc` or /// When generalizing `<?0 as Trait>::Assoc` or
/// `<T as Bar<<?0 as Foo>::Assoc>>::Assoc` /// `<T as Bar<<?0 as Foo>::Assoc>>::Assoc`
/// for `?0` generalization returns an inference /// 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 /// GLB moves "down" the lattice (to smaller values); LUB moves
/// "up" the lattice (to bigger values). /// "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 infcx(&self) -> &'f InferCtxt<'tcx>;
fn cause(&self) -> &ObligationCause<'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>, infcx: &'a InferCtxt<'tcx>,
type_vars: (Range<TyVid>, Vec<TypeVariableOrigin>), type_vars: (Range<TyVid>, Vec<TypeVariableOrigin>),
int_vars: Range<IntVid>, int_vars: Range<IntVid>,

View file

@ -158,7 +158,7 @@ impl<'tcx> InferCtxtInner<'tcx> {
} }
impl<'tcx> InferCtxtUndoLogs<'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; self.num_open_snapshots += 1;
Snapshot { undo_len: self.logs.len(), _marker: PhantomData } Snapshot { undo_len: self.logs.len(), _marker: PhantomData }
} }

View file

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

View file

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

View file

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