Add warn(unreachable_pub) to rustc_passes.

This commit is contained in:
Nicholas Nethercote 2024-08-29 15:17:14 +10:00
parent 76bd802403
commit f77821203f
10 changed files with 197 additions and 192 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -9,7 +9,7 @@ use rustc_middle::query::Providers;
use rustc_middle::ty::TyCtxt; use rustc_middle::ty::TyCtxt;
use rustc_span::Span; use rustc_span::Span;
pub fn provide(providers: &mut Providers) { pub(crate) fn provide(providers: &mut Providers) {
providers.upvars_mentioned = |tcx, def_id| { providers.upvars_mentioned = |tcx, def_id| {
if !tcx.is_closure_like(def_id) { if !tcx.is_closure_like(def_id) {
return None; 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 /// 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. /// 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. // 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 // They will never implicitly be added to the `missing` array unless we do
// so here. // so here.