Add warn(unreachable_pub) to rustc_incremental.

This commit is contained in:
Nicholas Nethercote 2024-08-27 14:30:20 +10:00
parent 7fc0444340
commit 37becf7bdc
7 changed files with 50 additions and 49 deletions

View File

@ -55,7 +55,7 @@
use crate::errors; use crate::errors;
#[allow(missing_docs)] #[allow(missing_docs)]
pub fn assert_dep_graph(tcx: TyCtxt<'_>) { pub(crate) fn assert_dep_graph(tcx: TyCtxt<'_>) {
tcx.dep_graph.with_ignore(|| { tcx.dep_graph.with_ignore(|| {
if tcx.sess.opts.unstable_opts.dump_dep_graph { if tcx.sess.opts.unstable_opts.dump_dep_graph {
tcx.dep_graph.with_query(dump_graph); tcx.dep_graph.with_query(dump_graph);
@ -261,7 +261,7 @@ fn dump_graph(query: &DepGraphQuery) {
} }
#[allow(missing_docs)] #[allow(missing_docs)]
pub struct GraphvizDepGraph(FxIndexSet<DepKind>, Vec<(DepKind, DepKind)>); struct GraphvizDepGraph(FxIndexSet<DepKind>, Vec<(DepKind, DepKind)>);
impl<'a> dot::GraphWalk<'a> for GraphvizDepGraph { impl<'a> dot::GraphWalk<'a> for GraphvizDepGraph {
type Node = DepKind; type Node = DepKind;

View File

@ -6,7 +6,7 @@
#[derive(Diagnostic)] #[derive(Diagnostic)]
#[diag(incremental_unrecognized_depnode)] #[diag(incremental_unrecognized_depnode)]
pub struct UnrecognizedDepNode { pub(crate) struct UnrecognizedDepNode {
#[primary_span] #[primary_span]
pub span: Span, pub span: Span,
pub name: Symbol, pub name: Symbol,
@ -14,28 +14,28 @@ pub struct UnrecognizedDepNode {
#[derive(Diagnostic)] #[derive(Diagnostic)]
#[diag(incremental_missing_depnode)] #[diag(incremental_missing_depnode)]
pub struct MissingDepNode { pub(crate) struct MissingDepNode {
#[primary_span] #[primary_span]
pub span: Span, pub span: Span,
} }
#[derive(Diagnostic)] #[derive(Diagnostic)]
#[diag(incremental_missing_if_this_changed)] #[diag(incremental_missing_if_this_changed)]
pub struct MissingIfThisChanged { pub(crate) struct MissingIfThisChanged {
#[primary_span] #[primary_span]
pub span: Span, pub span: Span,
} }
#[derive(Diagnostic)] #[derive(Diagnostic)]
#[diag(incremental_ok)] #[diag(incremental_ok)]
pub struct Ok { pub(crate) struct Ok {
#[primary_span] #[primary_span]
pub span: Span, pub span: Span,
} }
#[derive(Diagnostic)] #[derive(Diagnostic)]
#[diag(incremental_no_path)] #[diag(incremental_no_path)]
pub struct NoPath { pub(crate) struct NoPath {
#[primary_span] #[primary_span]
pub span: Span, pub span: Span,
pub target: Symbol, pub target: Symbol,
@ -44,7 +44,7 @@ pub struct NoPath {
#[derive(Diagnostic)] #[derive(Diagnostic)]
#[diag(incremental_assertion_auto)] #[diag(incremental_assertion_auto)]
pub struct AssertionAuto<'a> { pub(crate) struct AssertionAuto<'a> {
#[primary_span] #[primary_span]
pub span: Span, pub span: Span,
pub name: &'a str, pub name: &'a str,
@ -53,7 +53,7 @@ pub struct AssertionAuto<'a> {
#[derive(Diagnostic)] #[derive(Diagnostic)]
#[diag(incremental_undefined_clean_dirty_assertions_item)] #[diag(incremental_undefined_clean_dirty_assertions_item)]
pub struct UndefinedCleanDirtyItem { pub(crate) struct UndefinedCleanDirtyItem {
#[primary_span] #[primary_span]
pub span: Span, pub span: Span,
pub kind: String, pub kind: String,
@ -61,7 +61,7 @@ pub struct UndefinedCleanDirtyItem {
#[derive(Diagnostic)] #[derive(Diagnostic)]
#[diag(incremental_undefined_clean_dirty_assertions)] #[diag(incremental_undefined_clean_dirty_assertions)]
pub struct UndefinedCleanDirty { pub(crate) struct UndefinedCleanDirty {
#[primary_span] #[primary_span]
pub span: Span, pub span: Span,
pub kind: String, pub kind: String,
@ -69,7 +69,7 @@ pub struct UndefinedCleanDirty {
#[derive(Diagnostic)] #[derive(Diagnostic)]
#[diag(incremental_repeated_depnode_label)] #[diag(incremental_repeated_depnode_label)]
pub struct RepeatedDepNodeLabel<'a> { pub(crate) struct RepeatedDepNodeLabel<'a> {
#[primary_span] #[primary_span]
pub span: Span, pub span: Span,
pub label: &'a str, pub label: &'a str,
@ -77,7 +77,7 @@ pub struct RepeatedDepNodeLabel<'a> {
#[derive(Diagnostic)] #[derive(Diagnostic)]
#[diag(incremental_unrecognized_depnode_label)] #[diag(incremental_unrecognized_depnode_label)]
pub struct UnrecognizedDepNodeLabel<'a> { pub(crate) struct UnrecognizedDepNodeLabel<'a> {
#[primary_span] #[primary_span]
pub span: Span, pub span: Span,
pub label: &'a str, pub label: &'a str,
@ -85,7 +85,7 @@ pub struct UnrecognizedDepNodeLabel<'a> {
#[derive(Diagnostic)] #[derive(Diagnostic)]
#[diag(incremental_not_dirty)] #[diag(incremental_not_dirty)]
pub struct NotDirty<'a> { pub(crate) struct NotDirty<'a> {
#[primary_span] #[primary_span]
pub span: Span, pub span: Span,
pub dep_node_str: &'a str, pub dep_node_str: &'a str,
@ -93,7 +93,7 @@ pub struct NotDirty<'a> {
#[derive(Diagnostic)] #[derive(Diagnostic)]
#[diag(incremental_not_clean)] #[diag(incremental_not_clean)]
pub struct NotClean<'a> { pub(crate) struct NotClean<'a> {
#[primary_span] #[primary_span]
pub span: Span, pub span: Span,
pub dep_node_str: &'a str, pub dep_node_str: &'a str,
@ -101,7 +101,7 @@ pub struct NotClean<'a> {
#[derive(Diagnostic)] #[derive(Diagnostic)]
#[diag(incremental_not_loaded)] #[diag(incremental_not_loaded)]
pub struct NotLoaded<'a> { pub(crate) struct NotLoaded<'a> {
#[primary_span] #[primary_span]
pub span: Span, pub span: Span,
pub dep_node_str: &'a str, pub dep_node_str: &'a str,
@ -109,7 +109,7 @@ pub struct NotLoaded<'a> {
#[derive(Diagnostic)] #[derive(Diagnostic)]
#[diag(incremental_unknown_item)] #[diag(incremental_unknown_item)]
pub struct UnknownItem { pub(crate) struct UnknownItem {
#[primary_span] #[primary_span]
pub span: Span, pub span: Span,
pub name: Symbol, pub name: Symbol,
@ -117,14 +117,14 @@ pub struct UnknownItem {
#[derive(Diagnostic)] #[derive(Diagnostic)]
#[diag(incremental_no_cfg)] #[diag(incremental_no_cfg)]
pub struct NoCfg { pub(crate) struct NoCfg {
#[primary_span] #[primary_span]
pub span: Span, pub span: Span,
} }
#[derive(Diagnostic)] #[derive(Diagnostic)]
#[diag(incremental_associated_value_expected_for)] #[diag(incremental_associated_value_expected_for)]
pub struct AssociatedValueExpectedFor { pub(crate) struct AssociatedValueExpectedFor {
#[primary_span] #[primary_span]
pub span: Span, pub span: Span,
pub ident: Ident, pub ident: Ident,
@ -132,21 +132,21 @@ pub struct AssociatedValueExpectedFor {
#[derive(Diagnostic)] #[derive(Diagnostic)]
#[diag(incremental_associated_value_expected)] #[diag(incremental_associated_value_expected)]
pub struct AssociatedValueExpected { pub(crate) struct AssociatedValueExpected {
#[primary_span] #[primary_span]
pub span: Span, pub span: Span,
} }
#[derive(Diagnostic)] #[derive(Diagnostic)]
#[diag(incremental_unchecked_clean)] #[diag(incremental_unchecked_clean)]
pub struct UncheckedClean { pub(crate) struct UncheckedClean {
#[primary_span] #[primary_span]
pub span: Span, pub span: Span,
} }
#[derive(Diagnostic)] #[derive(Diagnostic)]
#[diag(incremental_delete_old)] #[diag(incremental_delete_old)]
pub struct DeleteOld<'a> { pub(crate) struct DeleteOld<'a> {
pub name: &'a str, pub name: &'a str,
pub path: PathBuf, pub path: PathBuf,
pub err: std::io::Error, pub err: std::io::Error,
@ -154,7 +154,7 @@ pub struct DeleteOld<'a> {
#[derive(Diagnostic)] #[derive(Diagnostic)]
#[diag(incremental_create_new)] #[diag(incremental_create_new)]
pub struct CreateNew<'a> { pub(crate) struct CreateNew<'a> {
pub name: &'a str, pub name: &'a str,
pub path: PathBuf, pub path: PathBuf,
pub err: std::io::Error, pub err: std::io::Error,
@ -162,7 +162,7 @@ pub struct CreateNew<'a> {
#[derive(Diagnostic)] #[derive(Diagnostic)]
#[diag(incremental_write_new)] #[diag(incremental_write_new)]
pub struct WriteNew<'a> { pub(crate) struct WriteNew<'a> {
pub name: &'a str, pub name: &'a str,
pub path: PathBuf, pub path: PathBuf,
pub err: std::io::Error, pub err: std::io::Error,
@ -170,14 +170,14 @@ pub struct WriteNew<'a> {
#[derive(Diagnostic)] #[derive(Diagnostic)]
#[diag(incremental_canonicalize_path)] #[diag(incremental_canonicalize_path)]
pub struct CanonicalizePath { pub(crate) struct CanonicalizePath {
pub path: PathBuf, pub path: PathBuf,
pub err: std::io::Error, pub err: std::io::Error,
} }
#[derive(Diagnostic)] #[derive(Diagnostic)]
#[diag(incremental_create_incr_comp_dir)] #[diag(incremental_create_incr_comp_dir)]
pub struct CreateIncrCompDir<'a> { pub(crate) struct CreateIncrCompDir<'a> {
pub tag: &'a str, pub tag: &'a str,
pub path: &'a Path, pub path: &'a Path,
pub err: std::io::Error, pub err: std::io::Error,
@ -185,7 +185,7 @@ pub struct CreateIncrCompDir<'a> {
#[derive(Diagnostic)] #[derive(Diagnostic)]
#[diag(incremental_create_lock)] #[diag(incremental_create_lock)]
pub struct CreateLock<'a> { pub(crate) struct CreateLock<'a> {
pub lock_err: std::io::Error, pub lock_err: std::io::Error,
pub session_dir: &'a Path, pub session_dir: &'a Path,
#[note(incremental_lock_unsupported)] #[note(incremental_lock_unsupported)]
@ -197,84 +197,84 @@ pub struct CreateLock<'a> {
#[derive(Diagnostic)] #[derive(Diagnostic)]
#[diag(incremental_delete_lock)] #[diag(incremental_delete_lock)]
pub struct DeleteLock<'a> { pub(crate) struct DeleteLock<'a> {
pub path: &'a Path, pub path: &'a Path,
pub err: std::io::Error, pub err: std::io::Error,
} }
#[derive(Diagnostic)] #[derive(Diagnostic)]
#[diag(incremental_hard_link_failed)] #[diag(incremental_hard_link_failed)]
pub struct HardLinkFailed<'a> { pub(crate) struct HardLinkFailed<'a> {
pub path: &'a Path, pub path: &'a Path,
} }
#[derive(Diagnostic)] #[derive(Diagnostic)]
#[diag(incremental_delete_partial)] #[diag(incremental_delete_partial)]
pub struct DeletePartial<'a> { pub(crate) struct DeletePartial<'a> {
pub path: &'a Path, pub path: &'a Path,
pub err: std::io::Error, pub err: std::io::Error,
} }
#[derive(Diagnostic)] #[derive(Diagnostic)]
#[diag(incremental_delete_full)] #[diag(incremental_delete_full)]
pub struct DeleteFull<'a> { pub(crate) struct DeleteFull<'a> {
pub path: &'a Path, pub path: &'a Path,
pub err: std::io::Error, pub err: std::io::Error,
} }
#[derive(Diagnostic)] #[derive(Diagnostic)]
#[diag(incremental_finalize)] #[diag(incremental_finalize)]
pub struct Finalize<'a> { pub(crate) struct Finalize<'a> {
pub path: &'a Path, pub path: &'a Path,
pub err: std::io::Error, pub err: std::io::Error,
} }
#[derive(Diagnostic)] #[derive(Diagnostic)]
#[diag(incremental_invalid_gc_failed)] #[diag(incremental_invalid_gc_failed)]
pub struct InvalidGcFailed<'a> { pub(crate) struct InvalidGcFailed<'a> {
pub path: &'a Path, pub path: &'a Path,
pub err: std::io::Error, pub err: std::io::Error,
} }
#[derive(Diagnostic)] #[derive(Diagnostic)]
#[diag(incremental_finalized_gc_failed)] #[diag(incremental_finalized_gc_failed)]
pub struct FinalizedGcFailed<'a> { pub(crate) struct FinalizedGcFailed<'a> {
pub path: &'a Path, pub path: &'a Path,
pub err: std::io::Error, pub err: std::io::Error,
} }
#[derive(Diagnostic)] #[derive(Diagnostic)]
#[diag(incremental_session_gc_failed)] #[diag(incremental_session_gc_failed)]
pub struct SessionGcFailed<'a> { pub(crate) struct SessionGcFailed<'a> {
pub path: &'a Path, pub path: &'a Path,
pub err: std::io::Error, pub err: std::io::Error,
} }
#[derive(Diagnostic)] #[derive(Diagnostic)]
#[diag(incremental_assert_not_loaded)] #[diag(incremental_assert_not_loaded)]
pub struct AssertNotLoaded; pub(crate) struct AssertNotLoaded;
#[derive(Diagnostic)] #[derive(Diagnostic)]
#[diag(incremental_assert_loaded)] #[diag(incremental_assert_loaded)]
pub struct AssertLoaded; pub(crate) struct AssertLoaded;
#[derive(Diagnostic)] #[derive(Diagnostic)]
#[diag(incremental_delete_incompatible)] #[diag(incremental_delete_incompatible)]
pub struct DeleteIncompatible { pub(crate) struct DeleteIncompatible {
pub path: PathBuf, pub path: PathBuf,
pub err: std::io::Error, pub err: std::io::Error,
} }
#[derive(Diagnostic)] #[derive(Diagnostic)]
#[diag(incremental_load_dep_graph)] #[diag(incremental_load_dep_graph)]
pub struct LoadDepGraph { pub(crate) struct LoadDepGraph {
pub path: PathBuf, pub path: PathBuf,
pub err: std::io::Error, pub err: std::io::Error,
} }
#[derive(Diagnostic)] #[derive(Diagnostic)]
#[diag(incremental_move_dep_graph)] #[diag(incremental_move_dep_graph)]
pub struct MoveDepGraph<'a> { pub(crate) struct MoveDepGraph<'a> {
pub from: &'a Path, pub from: &'a Path,
pub to: &'a Path, pub to: &'a Path,
pub err: std::io::Error, pub err: std::io::Error,
@ -282,14 +282,14 @@ pub struct MoveDepGraph<'a> {
#[derive(Diagnostic)] #[derive(Diagnostic)]
#[diag(incremental_create_dep_graph)] #[diag(incremental_create_dep_graph)]
pub struct CreateDepGraph<'a> { pub(crate) struct CreateDepGraph<'a> {
pub path: &'a Path, pub path: &'a Path,
pub err: std::io::Error, pub err: std::io::Error,
} }
#[derive(Diagnostic)] #[derive(Diagnostic)]
#[diag(incremental_copy_workproduct_to_cache)] #[diag(incremental_copy_workproduct_to_cache)]
pub struct CopyWorkProductToCache<'a> { pub(crate) struct CopyWorkProductToCache<'a> {
pub from: &'a Path, pub from: &'a Path,
pub to: &'a Path, pub to: &'a Path,
pub err: std::io::Error, pub err: std::io::Error,
@ -297,13 +297,13 @@ pub struct CopyWorkProductToCache<'a> {
#[derive(Diagnostic)] #[derive(Diagnostic)]
#[diag(incremental_delete_workproduct)] #[diag(incremental_delete_workproduct)]
pub struct DeleteWorkProduct<'a> { pub(crate) struct DeleteWorkProduct<'a> {
pub path: &'a Path, pub path: &'a Path,
pub err: std::io::Error, pub err: std::io::Error,
} }
#[derive(Diagnostic)] #[derive(Diagnostic)]
#[diag(incremental_corrupt_file)] #[diag(incremental_corrupt_file)]
pub struct CorruptFile<'a> { pub(crate) struct CorruptFile<'a> {
pub path: &'a Path, pub path: &'a Path,
} }

View File

@ -6,6 +6,7 @@
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")] #![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
#![doc(rust_logo)] #![doc(rust_logo)]
#![feature(rustdoc_internals)] #![feature(rustdoc_internals)]
#![warn(unreachable_pub)]
// tidy-alphabetical-end // tidy-alphabetical-end
mod assert_dep_graph; mod assert_dep_graph;

View File

@ -4,7 +4,7 @@
use rustc_middle::dep_graph::{WorkProduct, WorkProductId}; use rustc_middle::dep_graph::{WorkProduct, WorkProductId};
#[derive(Debug, Encodable, Decodable)] #[derive(Debug, Encodable, Decodable)]
pub struct SerializedWorkProduct { pub(crate) struct SerializedWorkProduct {
/// node that produced the work-product /// node that produced the work-product
pub id: WorkProductId, pub id: WorkProductId,

View File

@ -133,7 +133,7 @@ struct Assertion {
loaded_from_disk: Labels, loaded_from_disk: Labels,
} }
pub fn check_dirty_clean_annotations(tcx: TyCtxt<'_>) { pub(crate) fn check_dirty_clean_annotations(tcx: TyCtxt<'_>) {
if !tcx.sess.opts.unstable_opts.query_dep_graph { if !tcx.sess.opts.unstable_opts.query_dep_graph {
return; return;
} }
@ -174,7 +174,7 @@ pub fn check_dirty_clean_annotations(tcx: TyCtxt<'_>) {
}) })
} }
pub struct DirtyCleanVisitor<'tcx> { struct DirtyCleanVisitor<'tcx> {
tcx: TyCtxt<'tcx>, tcx: TyCtxt<'tcx>,
checked_attrs: FxHashSet<ast::AttrId>, checked_attrs: FxHashSet<ast::AttrId>,
} }
@ -429,7 +429,7 @@ fn expect_associated_value(tcx: TyCtxt<'_>, item: &NestedMetaItem) -> Symbol {
/// A visitor that collects all `#[rustc_clean]` attributes from /// A visitor that collects all `#[rustc_clean]` attributes from
/// the HIR. It is used to verify that we really ran checks for all annotated /// the HIR. It is used to verify that we really ran checks for all annotated
/// nodes. /// nodes.
pub struct FindAllAttrs<'tcx> { struct FindAllAttrs<'tcx> {
tcx: TyCtxt<'tcx>, tcx: TyCtxt<'tcx>,
found_attrs: Vec<&'tcx Attribute>, found_attrs: Vec<&'tcx Attribute>,
} }

View File

@ -89,7 +89,7 @@ pub(crate) fn save_in<F>(sess: &Session, path_buf: PathBuf, name: &str, encode:
/// incompatible version of the compiler. /// incompatible version of the compiler.
/// - Returns `Err(..)` if some kind of IO error occurred while reading the /// - Returns `Err(..)` if some kind of IO error occurred while reading the
/// file. /// file.
pub fn read_file( pub(crate) fn read_file(
path: &Path, path: &Path,
report_incremental_info: bool, report_incremental_info: bool,
is_nightly_build: bool, is_nightly_build: bool,

View File

@ -157,7 +157,7 @@ pub(crate) fn work_products_path(sess: &Session) -> PathBuf {
} }
/// Returns the path to a session's query cache. /// Returns the path to a session's query cache.
pub fn query_cache_path(sess: &Session) -> PathBuf { pub(crate) fn query_cache_path(sess: &Session) -> PathBuf {
in_incr_comp_dir_sess(sess, QUERY_CACHE_FILENAME) in_incr_comp_dir_sess(sess, QUERY_CACHE_FILENAME)
} }