Skip to content

Commit

Permalink
Add warn(unreachable_pub) to rustc_trait_selection.
Browse files Browse the repository at this point in the history
  • Loading branch information
nnethercote committed Sep 2, 2024
1 parent c4f6f52 commit 2e358e6
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 16 deletions.
1 change: 1 addition & 0 deletions compiler/rustc_trait_selection/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#![feature(unwrap_infallible)]
#![feature(yeet_expr)]
#![recursion_limit = "512"] // For rustdoc
#![warn(unreachable_pub)] // For rustdoc
// tidy-alphabetical-end

pub mod error_reporting;
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_trait_selection/src/traits/coherence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ pub fn add_placeholder_note<G: EmissionGuarantee>(err: &mut Diag<'_, G>) {
);
}

pub fn suggest_increasing_recursion_limit<'tcx, G: EmissionGuarantee>(
pub(crate) fn suggest_increasing_recursion_limit<'tcx, G: EmissionGuarantee>(
tcx: TyCtxt<'tcx>,
err: &mut Diag<'_, G>,
overflowing_predicates: &[ty::Predicate<'tcx>],
Expand Down
10 changes: 5 additions & 5 deletions compiler/rustc_trait_selection/src/traits/object_safety.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ use tracing::{debug, instrument};
use super::elaborate;
use crate::infer::TyCtxtInferExt;
use crate::traits::query::evaluate_obligation::InferCtxtExt;
use crate::traits::{util, Obligation, ObligationCause};
pub use crate::traits::{MethodViolationCode, ObjectSafetyViolation};
pub use crate::traits::ObjectSafetyViolation;
use crate::traits::{util, MethodViolationCode, Obligation, ObligationCause};

/// Returns the object safety violations that affect HIR ty lowering.
///
Expand Down Expand Up @@ -512,7 +512,7 @@ fn virtual_call_violations_for_method<'tcx>(
///
/// This check is outlined from the object safety check to avoid cycles with
/// layout computation, which relies on knowing whether methods are object safe.
pub fn check_receiver_correct<'tcx>(tcx: TyCtxt<'tcx>, trait_def_id: DefId, method: ty::AssocItem) {
fn check_receiver_correct<'tcx>(tcx: TyCtxt<'tcx>, trait_def_id: DefId, method: ty::AssocItem) {
if !is_vtable_safe_method(tcx, trait_def_id, method) {
return;
}
Expand Down Expand Up @@ -906,7 +906,7 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for EraseEscapingBoundRegions<'tcx> {
}
}

pub fn contains_illegal_impl_trait_in_trait<'tcx>(
fn contains_illegal_impl_trait_in_trait<'tcx>(
tcx: TyCtxt<'tcx>,
fn_def_id: DefId,
ty: ty::Binder<'tcx, Ty<'tcx>>,
Expand All @@ -930,7 +930,7 @@ pub fn contains_illegal_impl_trait_in_trait<'tcx>(
})
}

pub fn provide(providers: &mut Providers) {
pub(crate) fn provide(providers: &mut Providers) {
*providers = Providers {
object_safety_violations,
is_object_safe,
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_trait_selection/src/traits/select/_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ use tracing::instrument;
/// Like subtyping, matching is really a binary relation, so the only
/// important thing about the result is Ok/Err. Also, matching never
/// affects any type variables or unification state.
pub struct MatchAgainstFreshVars<'tcx> {
pub(crate) struct MatchAgainstFreshVars<'tcx> {
tcx: TyCtxt<'tcx>,
}

impl<'tcx> MatchAgainstFreshVars<'tcx> {
pub fn new(tcx: TyCtxt<'tcx>) -> MatchAgainstFreshVars<'tcx> {
pub(crate) fn new(tcx: TyCtxt<'tcx>) -> MatchAgainstFreshVars<'tcx> {
MatchAgainstFreshVars { tcx }
}
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_trait_selection/src/traits/select/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3127,7 +3127,7 @@ impl<'o, 'tcx> fmt::Debug for TraitObligationStack<'o, 'tcx> {
}
}

pub enum ProjectionMatchesProjection {
pub(crate) enum ProjectionMatchesProjection {
Yes,
Ambiguous,
No,
Expand Down
14 changes: 7 additions & 7 deletions compiler/rustc_trait_selection/src/traits/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ impl<'tcx> Iterator for TraitAliasExpander<'tcx> {
/// Instantiate all bound parameters of the impl subject with the given args,
/// returning the resulting subject and all obligations that arise.
/// The obligations are closed under normalization.
pub fn impl_subject_and_oblig<'a, 'tcx>(
pub(crate) fn impl_subject_and_oblig<'a, 'tcx>(
selcx: &SelectionContext<'a, 'tcx>,
param_env: ty::ParamEnv<'tcx>,
impl_def_id: DefId,
Expand Down Expand Up @@ -209,7 +209,7 @@ pub fn upcast_choices<'tcx>(
supertraits(tcx, source_trait_ref).filter(|r| r.def_id() == target_trait_def_id).collect()
}

pub fn closure_trait_ref_and_return_type<'tcx>(
pub(crate) fn closure_trait_ref_and_return_type<'tcx>(
tcx: TyCtxt<'tcx>,
fn_trait_def_id: DefId,
self_ty: Ty<'tcx>,
Expand Down Expand Up @@ -238,7 +238,7 @@ pub fn closure_trait_ref_and_return_type<'tcx>(
sig.map_bound(|sig| (trait_ref, sig.output()))
}

pub fn coroutine_trait_ref_and_outputs<'tcx>(
pub(crate) fn coroutine_trait_ref_and_outputs<'tcx>(
tcx: TyCtxt<'tcx>,
fn_trait_def_id: DefId,
self_ty: Ty<'tcx>,
Expand All @@ -249,7 +249,7 @@ pub fn coroutine_trait_ref_and_outputs<'tcx>(
(trait_ref, sig.yield_ty, sig.return_ty)
}

pub fn future_trait_ref_and_outputs<'tcx>(
pub(crate) fn future_trait_ref_and_outputs<'tcx>(
tcx: TyCtxt<'tcx>,
fn_trait_def_id: DefId,
self_ty: Ty<'tcx>,
Expand All @@ -260,7 +260,7 @@ pub fn future_trait_ref_and_outputs<'tcx>(
(trait_ref, sig.return_ty)
}

pub fn iterator_trait_ref_and_outputs<'tcx>(
pub(crate) fn iterator_trait_ref_and_outputs<'tcx>(
tcx: TyCtxt<'tcx>,
iterator_def_id: DefId,
self_ty: Ty<'tcx>,
Expand All @@ -271,7 +271,7 @@ pub fn iterator_trait_ref_and_outputs<'tcx>(
(trait_ref, sig.yield_ty)
}

pub fn async_iterator_trait_ref_and_outputs<'tcx>(
pub(crate) fn async_iterator_trait_ref_and_outputs<'tcx>(
tcx: TyCtxt<'tcx>,
async_iterator_def_id: DefId,
self_ty: Ty<'tcx>,
Expand All @@ -287,7 +287,7 @@ pub fn impl_item_is_final(tcx: TyCtxt<'_>, assoc_item: &ty::AssocItem) -> bool {
&& tcx.defaultness(assoc_item.container_id(tcx)).is_final()
}

pub enum TupleArgumentsFlag {
pub(crate) enum TupleArgumentsFlag {
Yes,
No,
}
Expand Down

0 comments on commit 2e358e6

Please sign in to comment.