Add warn(unreachable_pub) to rustc_trait_selection.

This commit is contained in:
Nicholas Nethercote 2024-08-30 15:53:47 +10:00
parent c4f6f52139
commit 2e358e633d
6 changed files with 17 additions and 16 deletions

View File

@ -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;

View File

@ -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>],

View File

@ -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.
///
@ -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;
}
@ -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>>,
@ -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,

View File

@ -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 }
}
}

View File

@ -3127,7 +3127,7 @@ impl<'o, 'tcx> fmt::Debug for TraitObligationStack<'o, 'tcx> {
}
}
pub enum ProjectionMatchesProjection {
pub(crate) enum ProjectionMatchesProjection {
Yes,
Ambiguous,
No,

View File

@ -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,
@ -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>,
@ -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>,
@ -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>,
@ -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>,
@ -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>,
@ -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,
}