about summary refs log tree commit diff
diff options
context:
space:
mode:
authorNicholas Nethercote <n.nethercote@gmail.com>2024-08-29 15:17:14 +1000
committerNicholas Nethercote <n.nethercote@gmail.com>2024-08-29 20:18:40 +1000
commitf77821203f73f3f71a4e92afddf17c5da8e89d9b (patch)
tree5c02cb6205e2b3dfcf57976141ae43de57047523
parent76bd802403ec5aa3e478fc628ad71529fc26417a (diff)
downloadrust-f77821203f73f3f71a4e92afddf17c5da8e89d9b.tar.gz
rust-f77821203f73f3f71a4e92afddf17c5da8e89d9b.zip
Add `warn(unreachable_pub)` to `rustc_passes`.
-rw-r--r--compiler/rustc_passes/src/debugger_visualizer.rs2
-rw-r--r--compiler/rustc_passes/src/diagnostic_items.rs2
-rw-r--r--compiler/rustc_passes/src/errors.rs366
-rw-r--r--compiler/rustc_passes/src/lang_items.rs2
-rw-r--r--compiler/rustc_passes/src/lib.rs1
-rw-r--r--compiler/rustc_passes/src/lib_features.rs4
-rw-r--r--compiler/rustc_passes/src/liveness.rs2
-rw-r--r--compiler/rustc_passes/src/reachable.rs2
-rw-r--r--compiler/rustc_passes/src/upvars.rs2
-rw-r--r--compiler/rustc_passes/src/weak_lang_items.rs6
10 files changed, 197 insertions, 192 deletions
diff --git a/compiler/rustc_passes/src/debugger_visualizer.rs b/compiler/rustc_passes/src/debugger_visualizer.rs
index 5d871bacb1d..fec149c8c43 100644
--- a/compiler/rustc_passes/src/debugger_visualizer.rs
+++ b/compiler/rustc_passes/src/debugger_visualizer.rs
@@ -95,6 +95,6 @@ fn debugger_visualizers(tcx: TyCtxt<'_>, _: LocalCrate) -> Vec<DebuggerVisualize
     visitor.visualizers
 }
 
-pub fn provide(providers: &mut Providers) {
+pub(crate) fn provide(providers: &mut Providers) {
     providers.debugger_visualizers = debugger_visualizers;
 }
diff --git a/compiler/rustc_passes/src/diagnostic_items.rs b/compiler/rustc_passes/src/diagnostic_items.rs
index 624ebb2f9f2..425e203f2b0 100644
--- a/compiler/rustc_passes/src/diagnostic_items.rs
+++ b/compiler/rustc_passes/src/diagnostic_items.rs
@@ -90,7 +90,7 @@ fn all_diagnostic_items(tcx: TyCtxt<'_>, (): ()) -> DiagnosticItems {
     items
 }
 
-pub fn provide(providers: &mut Providers) {
+pub(crate) fn provide(providers: &mut Providers) {
     providers.diagnostic_items = diagnostic_items;
     providers.all_diagnostic_items = all_diagnostic_items;
 }
diff --git a/compiler/rustc_passes/src/errors.rs b/compiler/rustc_passes/src/errors.rs
index 32db0823cf7..1e9ab7af9be 100644
--- a/compiler/rustc_passes/src/errors.rs
+++ b/compiler/rustc_passes/src/errors.rs
@@ -18,41 +18,41 @@ use crate::lang_items::Duplicate;
 
 #[derive(LintDiagnostic)]
 #[diag(passes_incorrect_do_not_recommend_location)]
-pub struct IncorrectDoNotRecommendLocation;
+pub(crate) struct IncorrectDoNotRecommendLocation;
 
 #[derive(LintDiagnostic)]
 #[diag(passes_outer_crate_level_attr)]
-pub struct OuterCrateLevelAttr;
+pub(crate) struct OuterCrateLevelAttr;
 
 #[derive(LintDiagnostic)]
 #[diag(passes_inner_crate_level_attr)]
-pub struct InnerCrateLevelAttr;
+pub(crate) struct InnerCrateLevelAttr;
 
 #[derive(LintDiagnostic)]
 #[diag(passes_ignored_attr_with_macro)]
-pub struct IgnoredAttrWithMacro<'a> {
+pub(crate) struct IgnoredAttrWithMacro<'a> {
     pub sym: &'a str,
 }
 
 #[derive(LintDiagnostic)]
 #[diag(passes_ignored_attr)]
-pub struct IgnoredAttr<'a> {
+pub(crate) struct IgnoredAttr<'a> {
     pub sym: &'a str,
 }
 
 #[derive(LintDiagnostic)]
 #[diag(passes_inline_ignored_function_prototype)]
-pub struct IgnoredInlineAttrFnProto;
+pub(crate) struct IgnoredInlineAttrFnProto;
 
 #[derive(LintDiagnostic)]
 #[diag(passes_inline_ignored_constants)]
 #[warning]
 #[note]
-pub struct IgnoredInlineAttrConstants;
+pub(crate) struct IgnoredInlineAttrConstants;
 
 #[derive(Diagnostic)]
 #[diag(passes_inline_not_fn_or_closure, code = E0518)]
-pub struct InlineNotFnOrClosure {
+pub(crate) struct InlineNotFnOrClosure {
     #[primary_span]
     pub attr_span: Span,
     #[label]
@@ -61,7 +61,7 @@ pub struct InlineNotFnOrClosure {
 
 #[derive(Diagnostic)]
 #[diag(passes_coverage_not_fn_or_closure, code = E0788)]
-pub struct CoverageNotFnOrClosure {
+pub(crate) struct CoverageNotFnOrClosure {
     #[primary_span]
     pub attr_span: Span,
     #[label]
@@ -70,11 +70,11 @@ pub struct CoverageNotFnOrClosure {
 
 #[derive(LintDiagnostic)]
 #[diag(passes_optimize_not_fn_or_closure)]
-pub struct OptimizeNotFnOrClosure;
+pub(crate) struct OptimizeNotFnOrClosure;
 
 #[derive(Diagnostic)]
 #[diag(passes_should_be_applied_to_fn)]
-pub struct AttrShouldBeAppliedToFn {
+pub(crate) struct AttrShouldBeAppliedToFn {
     #[primary_span]
     pub attr_span: Span,
     #[label]
@@ -84,7 +84,7 @@ pub struct AttrShouldBeAppliedToFn {
 
 #[derive(Diagnostic)]
 #[diag(passes_should_be_applied_to_fn_or_unit_struct)]
-pub struct AttrShouldBeAppliedToFnOrUnitStruct {
+pub(crate) struct AttrShouldBeAppliedToFnOrUnitStruct {
     #[primary_span]
     pub attr_span: Span,
     #[label]
@@ -93,7 +93,7 @@ pub struct AttrShouldBeAppliedToFnOrUnitStruct {
 
 #[derive(Diagnostic)]
 #[diag(passes_should_be_applied_to_fn, code = E0739)]
-pub struct TrackedCallerWrongLocation {
+pub(crate) struct TrackedCallerWrongLocation {
     #[primary_span]
     pub attr_span: Span,
     #[label]
@@ -103,7 +103,7 @@ pub struct TrackedCallerWrongLocation {
 
 #[derive(Diagnostic)]
 #[diag(passes_should_be_applied_to_struct_enum, code = E0701)]
-pub struct NonExhaustiveWrongLocation {
+pub(crate) struct NonExhaustiveWrongLocation {
     #[primary_span]
     pub attr_span: Span,
     #[label]
@@ -112,7 +112,7 @@ pub struct NonExhaustiveWrongLocation {
 
 #[derive(Diagnostic)]
 #[diag(passes_should_be_applied_to_trait)]
-pub struct AttrShouldBeAppliedToTrait {
+pub(crate) struct AttrShouldBeAppliedToTrait {
     #[primary_span]
     pub attr_span: Span,
     #[label]
@@ -121,11 +121,11 @@ pub struct AttrShouldBeAppliedToTrait {
 
 #[derive(LintDiagnostic)]
 #[diag(passes_target_feature_on_statement)]
-pub struct TargetFeatureOnStatement;
+pub(crate) struct TargetFeatureOnStatement;
 
 #[derive(Diagnostic)]
 #[diag(passes_should_be_applied_to_static)]
-pub struct AttrShouldBeAppliedToStatic {
+pub(crate) struct AttrShouldBeAppliedToStatic {
     #[primary_span]
     pub attr_span: Span,
     #[label]
@@ -134,7 +134,7 @@ pub struct AttrShouldBeAppliedToStatic {
 
 #[derive(Diagnostic)]
 #[diag(passes_doc_expect_str)]
-pub struct DocExpectStr<'a> {
+pub(crate) struct DocExpectStr<'a> {
     #[primary_span]
     pub attr_span: Span,
     pub attr_name: &'a str,
@@ -142,7 +142,7 @@ pub struct DocExpectStr<'a> {
 
 #[derive(Diagnostic)]
 #[diag(passes_doc_alias_empty)]
-pub struct DocAliasEmpty<'a> {
+pub(crate) struct DocAliasEmpty<'a> {
     #[primary_span]
     pub span: Span,
     pub attr_str: &'a str,
@@ -150,7 +150,7 @@ pub struct DocAliasEmpty<'a> {
 
 #[derive(Diagnostic)]
 #[diag(passes_doc_alias_bad_char)]
-pub struct DocAliasBadChar<'a> {
+pub(crate) struct DocAliasBadChar<'a> {
     #[primary_span]
     pub span: Span,
     pub attr_str: &'a str,
@@ -159,7 +159,7 @@ pub struct DocAliasBadChar<'a> {
 
 #[derive(Diagnostic)]
 #[diag(passes_doc_alias_start_end)]
-pub struct DocAliasStartEnd<'a> {
+pub(crate) struct DocAliasStartEnd<'a> {
     #[primary_span]
     pub span: Span,
     pub attr_str: &'a str,
@@ -167,7 +167,7 @@ pub struct DocAliasStartEnd<'a> {
 
 #[derive(Diagnostic)]
 #[diag(passes_doc_alias_bad_location)]
-pub struct DocAliasBadLocation<'a> {
+pub(crate) struct DocAliasBadLocation<'a> {
     #[primary_span]
     pub span: Span,
     pub attr_str: &'a str,
@@ -176,7 +176,7 @@ pub struct DocAliasBadLocation<'a> {
 
 #[derive(Diagnostic)]
 #[diag(passes_doc_alias_not_an_alias)]
-pub struct DocAliasNotAnAlias<'a> {
+pub(crate) struct DocAliasNotAnAlias<'a> {
     #[primary_span]
     pub span: Span,
     pub attr_str: &'a str,
@@ -184,42 +184,42 @@ pub struct DocAliasNotAnAlias<'a> {
 
 #[derive(LintDiagnostic)]
 #[diag(passes_doc_alias_duplicated)]
-pub struct DocAliasDuplicated {
+pub(crate) struct DocAliasDuplicated {
     #[label]
     pub first_defn: Span,
 }
 
 #[derive(Diagnostic)]
 #[diag(passes_doc_alias_not_string_literal)]
-pub struct DocAliasNotStringLiteral {
+pub(crate) struct DocAliasNotStringLiteral {
     #[primary_span]
     pub span: Span,
 }
 
 #[derive(Diagnostic)]
 #[diag(passes_doc_alias_malformed)]
-pub struct DocAliasMalformed {
+pub(crate) struct DocAliasMalformed {
     #[primary_span]
     pub span: Span,
 }
 
 #[derive(Diagnostic)]
 #[diag(passes_doc_keyword_empty_mod)]
-pub struct DocKeywordEmptyMod {
+pub(crate) struct DocKeywordEmptyMod {
     #[primary_span]
     pub span: Span,
 }
 
 #[derive(Diagnostic)]
 #[diag(passes_doc_keyword_not_mod)]
-pub struct DocKeywordNotMod {
+pub(crate) struct DocKeywordNotMod {
     #[primary_span]
     pub span: Span,
 }
 
 #[derive(Diagnostic)]
 #[diag(passes_doc_keyword_invalid_ident)]
-pub struct DocKeywordInvalidIdent {
+pub(crate) struct DocKeywordInvalidIdent {
     #[primary_span]
     pub span: Span,
     pub doc_keyword: Symbol,
@@ -227,14 +227,14 @@ pub struct DocKeywordInvalidIdent {
 
 #[derive(Diagnostic)]
 #[diag(passes_doc_fake_variadic_not_valid)]
-pub struct DocFakeVariadicNotValid {
+pub(crate) struct DocFakeVariadicNotValid {
     #[primary_span]
     pub span: Span,
 }
 
 #[derive(Diagnostic)]
 #[diag(passes_doc_keyword_only_impl)]
-pub struct DocKeywordOnlyImpl {
+pub(crate) struct DocKeywordOnlyImpl {
     #[primary_span]
     pub span: Span,
 }
@@ -242,7 +242,7 @@ pub struct DocKeywordOnlyImpl {
 #[derive(Diagnostic)]
 #[diag(passes_doc_inline_conflict)]
 #[help]
-pub struct DocKeywordConflict {
+pub(crate) struct DocKeywordConflict {
     #[primary_span]
     pub spans: MultiSpan,
 }
@@ -250,7 +250,7 @@ pub struct DocKeywordConflict {
 #[derive(LintDiagnostic)]
 #[diag(passes_doc_inline_only_use)]
 #[note]
-pub struct DocInlineOnlyUse {
+pub(crate) struct DocInlineOnlyUse {
     #[label]
     pub attr_span: Span,
     #[label(passes_not_a_use_item_label)]
@@ -260,7 +260,7 @@ pub struct DocInlineOnlyUse {
 #[derive(LintDiagnostic)]
 #[diag(passes_doc_masked_only_extern_crate)]
 #[note]
-pub struct DocMaskedOnlyExternCrate {
+pub(crate) struct DocMaskedOnlyExternCrate {
     #[label]
     pub attr_span: Span,
     #[label(passes_not_an_extern_crate_label)]
@@ -269,7 +269,7 @@ pub struct DocMaskedOnlyExternCrate {
 
 #[derive(LintDiagnostic)]
 #[diag(passes_doc_masked_not_extern_crate_self)]
-pub struct DocMaskedNotExternCrateSelf {
+pub(crate) struct DocMaskedNotExternCrateSelf {
     #[label]
     pub attr_span: Span,
     #[label(passes_extern_crate_self_label)]
@@ -278,7 +278,7 @@ pub struct DocMaskedNotExternCrateSelf {
 
 #[derive(Diagnostic)]
 #[diag(passes_doc_attr_not_crate_level)]
-pub struct DocAttrNotCrateLevel<'a> {
+pub(crate) struct DocAttrNotCrateLevel<'a> {
     #[primary_span]
     pub span: Span,
     pub attr_name: &'a str,
@@ -286,25 +286,25 @@ pub struct DocAttrNotCrateLevel<'a> {
 
 #[derive(LintDiagnostic)]
 #[diag(passes_doc_test_unknown)]
-pub struct DocTestUnknown {
+pub(crate) struct DocTestUnknown {
     pub path: String,
 }
 
 #[derive(LintDiagnostic)]
 #[diag(passes_doc_test_literal)]
-pub struct DocTestLiteral;
+pub(crate) struct DocTestLiteral;
 
 #[derive(LintDiagnostic)]
 #[diag(passes_doc_test_takes_list)]
-pub struct DocTestTakesList;
+pub(crate) struct DocTestTakesList;
 
 #[derive(LintDiagnostic)]
 #[diag(passes_doc_cfg_hide_takes_list)]
-pub struct DocCfgHideTakesList;
+pub(crate) struct DocCfgHideTakesList;
 
 #[derive(LintDiagnostic)]
 #[diag(passes_doc_test_unknown_any)]
-pub struct DocTestUnknownAny {
+pub(crate) struct DocTestUnknownAny {
     pub path: String,
 }
 
@@ -312,7 +312,7 @@ pub struct DocTestUnknownAny {
 #[diag(passes_doc_test_unknown_spotlight)]
 #[note]
 #[note(passes_no_op_note)]
-pub struct DocTestUnknownSpotlight {
+pub(crate) struct DocTestUnknownSpotlight {
     pub path: String,
     #[suggestion(style = "short", applicability = "machine-applicable", code = "notable_trait")]
     pub span: Span,
@@ -320,7 +320,7 @@ pub struct DocTestUnknownSpotlight {
 
 #[derive(LintDiagnostic)]
 #[diag(passes_doc_test_unknown_include)]
-pub struct DocTestUnknownInclude {
+pub(crate) struct DocTestUnknownInclude {
     pub path: String,
     pub value: String,
     pub inner: &'static str,
@@ -330,11 +330,11 @@ pub struct DocTestUnknownInclude {
 
 #[derive(LintDiagnostic)]
 #[diag(passes_doc_invalid)]
-pub struct DocInvalid;
+pub(crate) struct DocInvalid;
 
 #[derive(Diagnostic)]
 #[diag(passes_pass_by_value)]
-pub struct PassByValue {
+pub(crate) struct PassByValue {
     #[primary_span]
     pub attr_span: Span,
     #[label]
@@ -343,7 +343,7 @@ pub struct PassByValue {
 
 #[derive(Diagnostic)]
 #[diag(passes_allow_incoherent_impl)]
-pub struct AllowIncoherentImpl {
+pub(crate) struct AllowIncoherentImpl {
     #[primary_span]
     pub attr_span: Span,
     #[label]
@@ -352,7 +352,7 @@ pub struct AllowIncoherentImpl {
 
 #[derive(Diagnostic)]
 #[diag(passes_has_incoherent_inherent_impl)]
-pub struct HasIncoherentInherentImpl {
+pub(crate) struct HasIncoherentInherentImpl {
     #[primary_span]
     pub attr_span: Span,
     #[label]
@@ -361,35 +361,35 @@ pub struct HasIncoherentInherentImpl {
 
 #[derive(Diagnostic)]
 #[diag(passes_both_ffi_const_and_pure, code = E0757)]
-pub struct BothFfiConstAndPure {
+pub(crate) struct BothFfiConstAndPure {
     #[primary_span]
     pub attr_span: Span,
 }
 
 #[derive(Diagnostic)]
 #[diag(passes_ffi_pure_invalid_target, code = E0755)]
-pub struct FfiPureInvalidTarget {
+pub(crate) struct FfiPureInvalidTarget {
     #[primary_span]
     pub attr_span: Span,
 }
 
 #[derive(Diagnostic)]
 #[diag(passes_ffi_const_invalid_target, code = E0756)]
-pub struct FfiConstInvalidTarget {
+pub(crate) struct FfiConstInvalidTarget {
     #[primary_span]
     pub attr_span: Span,
 }
 
 #[derive(LintDiagnostic)]
 #[diag(passes_must_use_no_effect)]
-pub struct MustUseNoEffect {
+pub(crate) struct MustUseNoEffect {
     pub article: &'static str,
     pub target: rustc_hir::Target,
 }
 
 #[derive(Diagnostic)]
 #[diag(passes_must_not_suspend)]
-pub struct MustNotSuspend {
+pub(crate) struct MustNotSuspend {
     #[primary_span]
     pub attr_span: Span,
     #[label]
@@ -399,7 +399,7 @@ pub struct MustNotSuspend {
 #[derive(LintDiagnostic)]
 #[diag(passes_cold)]
 #[warning]
-pub struct Cold {
+pub(crate) struct Cold {
     #[label]
     pub span: Span,
     pub on_crate: bool,
@@ -408,7 +408,7 @@ pub struct Cold {
 #[derive(LintDiagnostic)]
 #[diag(passes_link)]
 #[warning]
-pub struct Link {
+pub(crate) struct Link {
     #[label]
     pub span: Option<Span>,
 }
@@ -416,7 +416,7 @@ pub struct Link {
 #[derive(LintDiagnostic)]
 #[diag(passes_link_name)]
 #[warning]
-pub struct LinkName<'a> {
+pub(crate) struct LinkName<'a> {
     #[help]
     pub attr_span: Option<Span>,
     #[label]
@@ -426,7 +426,7 @@ pub struct LinkName<'a> {
 
 #[derive(Diagnostic)]
 #[diag(passes_no_link)]
-pub struct NoLink {
+pub(crate) struct NoLink {
     #[primary_span]
     pub attr_span: Span,
     #[label]
@@ -435,7 +435,7 @@ pub struct NoLink {
 
 #[derive(Diagnostic)]
 #[diag(passes_export_name)]
-pub struct ExportName {
+pub(crate) struct ExportName {
     #[primary_span]
     pub attr_span: Span,
     #[label]
@@ -444,7 +444,7 @@ pub struct ExportName {
 
 #[derive(Diagnostic)]
 #[diag(passes_rustc_layout_scalar_valid_range_not_struct)]
-pub struct RustcLayoutScalarValidRangeNotStruct {
+pub(crate) struct RustcLayoutScalarValidRangeNotStruct {
     #[primary_span]
     pub attr_span: Span,
     #[label]
@@ -453,14 +453,14 @@ pub struct RustcLayoutScalarValidRangeNotStruct {
 
 #[derive(Diagnostic)]
 #[diag(passes_rustc_layout_scalar_valid_range_arg)]
-pub struct RustcLayoutScalarValidRangeArg {
+pub(crate) struct RustcLayoutScalarValidRangeArg {
     #[primary_span]
     pub attr_span: Span,
 }
 
 #[derive(Diagnostic)]
 #[diag(passes_rustc_legacy_const_generics_only)]
-pub struct RustcLegacyConstGenericsOnly {
+pub(crate) struct RustcLegacyConstGenericsOnly {
     #[primary_span]
     pub attr_span: Span,
     #[label]
@@ -469,7 +469,7 @@ pub struct RustcLegacyConstGenericsOnly {
 
 #[derive(Diagnostic)]
 #[diag(passes_rustc_legacy_const_generics_index)]
-pub struct RustcLegacyConstGenericsIndex {
+pub(crate) struct RustcLegacyConstGenericsIndex {
     #[primary_span]
     pub attr_span: Span,
     #[label]
@@ -478,7 +478,7 @@ pub struct RustcLegacyConstGenericsIndex {
 
 #[derive(Diagnostic)]
 #[diag(passes_rustc_legacy_const_generics_index_exceed)]
-pub struct RustcLegacyConstGenericsIndexExceed {
+pub(crate) struct RustcLegacyConstGenericsIndexExceed {
     #[primary_span]
     #[label]
     pub span: Span,
@@ -487,14 +487,14 @@ pub struct RustcLegacyConstGenericsIndexExceed {
 
 #[derive(Diagnostic)]
 #[diag(passes_rustc_legacy_const_generics_index_negative)]
-pub struct RustcLegacyConstGenericsIndexNegative {
+pub(crate) struct RustcLegacyConstGenericsIndexNegative {
     #[primary_span]
     pub invalid_args: Vec<Span>,
 }
 
 #[derive(Diagnostic)]
 #[diag(passes_rustc_dirty_clean)]
-pub struct RustcDirtyClean {
+pub(crate) struct RustcDirtyClean {
     #[primary_span]
     pub span: Span,
 }
@@ -502,7 +502,7 @@ pub struct RustcDirtyClean {
 #[derive(LintDiagnostic)]
 #[diag(passes_link_section)]
 #[warning]
-pub struct LinkSection {
+pub(crate) struct LinkSection {
     #[label]
     pub span: Span,
 }
@@ -511,7 +511,7 @@ pub struct LinkSection {
 #[diag(passes_no_mangle_foreign)]
 #[warning]
 #[note]
-pub struct NoMangleForeign {
+pub(crate) struct NoMangleForeign {
     #[label]
     pub span: Span,
     #[suggestion(code = "", applicability = "machine-applicable")]
@@ -522,32 +522,32 @@ pub struct NoMangleForeign {
 #[derive(LintDiagnostic)]
 #[diag(passes_no_mangle)]
 #[warning]
-pub struct NoMangle {
+pub(crate) struct NoMangle {
     #[label]
     pub span: Span,
 }
 
 #[derive(Diagnostic)]
 #[diag(passes_repr_ident, code = E0565)]
-pub struct ReprIdent {
+pub(crate) struct ReprIdent {
     #[primary_span]
     pub span: Span,
 }
 
 #[derive(Diagnostic)]
 #[diag(passes_repr_conflicting, code = E0566)]
-pub struct ReprConflicting {
+pub(crate) struct ReprConflicting {
     #[primary_span]
     pub hint_spans: Vec<Span>,
 }
 
 #[derive(LintDiagnostic)]
 #[diag(passes_repr_conflicting, code = E0566)]
-pub struct ReprConflictingLint;
+pub(crate) struct ReprConflictingLint;
 
 #[derive(Diagnostic)]
 #[diag(passes_used_static)]
-pub struct UsedStatic {
+pub(crate) struct UsedStatic {
     #[primary_span]
     pub attr_span: Span,
     #[label]
@@ -557,14 +557,14 @@ pub struct UsedStatic {
 
 #[derive(Diagnostic)]
 #[diag(passes_used_compiler_linker)]
-pub struct UsedCompilerLinker {
+pub(crate) struct UsedCompilerLinker {
     #[primary_span]
     pub spans: Vec<Span>,
 }
 
 #[derive(Diagnostic)]
 #[diag(passes_allow_internal_unstable)]
-pub struct AllowInternalUnstable {
+pub(crate) struct AllowInternalUnstable {
     #[primary_span]
     pub attr_span: Span,
     #[label]
@@ -573,7 +573,7 @@ pub struct AllowInternalUnstable {
 
 #[derive(Diagnostic)]
 #[diag(passes_debug_visualizer_placement)]
-pub struct DebugVisualizerPlacement {
+pub(crate) struct DebugVisualizerPlacement {
     #[primary_span]
     pub span: Span,
 }
@@ -583,14 +583,14 @@ pub struct DebugVisualizerPlacement {
 #[note(passes_note_1)]
 #[note(passes_note_2)]
 #[note(passes_note_3)]
-pub struct DebugVisualizerInvalid {
+pub(crate) struct DebugVisualizerInvalid {
     #[primary_span]
     pub span: Span,
 }
 
 #[derive(Diagnostic)]
 #[diag(passes_debug_visualizer_unreadable)]
-pub struct DebugVisualizerUnreadable<'a> {
+pub(crate) struct DebugVisualizerUnreadable<'a> {
     #[primary_span]
     pub span: Span,
     pub file: &'a Path,
@@ -599,7 +599,7 @@ pub struct DebugVisualizerUnreadable<'a> {
 
 #[derive(Diagnostic)]
 #[diag(passes_rustc_allow_const_fn_unstable)]
-pub struct RustcAllowConstFnUnstable {
+pub(crate) struct RustcAllowConstFnUnstable {
     #[primary_span]
     pub attr_span: Span,
     #[label]
@@ -608,7 +608,7 @@ pub struct RustcAllowConstFnUnstable {
 
 #[derive(Diagnostic)]
 #[diag(passes_rustc_safe_intrinsic)]
-pub struct RustcSafeIntrinsic {
+pub(crate) struct RustcSafeIntrinsic {
     #[primary_span]
     pub attr_span: Span,
     #[label]
@@ -617,7 +617,7 @@ pub struct RustcSafeIntrinsic {
 
 #[derive(Diagnostic)]
 #[diag(passes_rustc_std_internal_symbol)]
-pub struct RustcStdInternalSymbol {
+pub(crate) struct RustcStdInternalSymbol {
     #[primary_span]
     pub attr_span: Span,
     #[label]
@@ -626,7 +626,7 @@ pub struct RustcStdInternalSymbol {
 
 #[derive(Diagnostic)]
 #[diag(passes_rustc_pub_transparent)]
-pub struct RustcPubTransparent {
+pub(crate) struct RustcPubTransparent {
     #[primary_span]
     pub attr_span: Span,
     #[label]
@@ -635,28 +635,28 @@ pub struct RustcPubTransparent {
 
 #[derive(Diagnostic)]
 #[diag(passes_link_ordinal)]
-pub struct LinkOrdinal {
+pub(crate) struct LinkOrdinal {
     #[primary_span]
     pub attr_span: Span,
 }
 
 #[derive(Diagnostic)]
 #[diag(passes_confusables)]
-pub struct Confusables {
+pub(crate) struct Confusables {
     #[primary_span]
     pub attr_span: Span,
 }
 
 #[derive(Diagnostic)]
 #[diag(passes_coroutine_on_non_closure)]
-pub struct CoroutineOnNonClosure {
+pub(crate) struct CoroutineOnNonClosure {
     #[primary_span]
     pub span: Span,
 }
 
 #[derive(Diagnostic)]
 #[diag(passes_linkage)]
-pub struct Linkage {
+pub(crate) struct Linkage {
     #[primary_span]
     pub attr_span: Span,
     #[label]
@@ -690,23 +690,23 @@ pub(crate) struct IncorrectMetaItemSuggestion {
 
 #[derive(Diagnostic)]
 #[diag(passes_stability_promotable)]
-pub struct StabilityPromotable {
+pub(crate) struct StabilityPromotable {
     #[primary_span]
     pub attr_span: Span,
 }
 
 #[derive(LintDiagnostic)]
 #[diag(passes_deprecated)]
-pub struct Deprecated;
+pub(crate) struct Deprecated;
 
 #[derive(LintDiagnostic)]
 #[diag(passes_macro_use)]
-pub struct MacroUse {
+pub(crate) struct MacroUse {
     pub name: Symbol,
 }
 
 #[derive(LintDiagnostic)]
-pub enum MacroExport {
+pub(crate) enum MacroExport {
     #[diag(passes_macro_export)]
     Normal,
 
@@ -722,7 +722,7 @@ pub enum MacroExport {
 }
 
 #[derive(Subdiagnostic)]
-pub enum UnusedNote {
+pub(crate) enum UnusedNote {
     #[note(passes_unused_empty_lints_note)]
     EmptyList { name: Symbol },
     #[note(passes_unused_no_lints_note)]
@@ -733,7 +733,7 @@ pub enum UnusedNote {
 
 #[derive(LintDiagnostic)]
 #[diag(passes_unused)]
-pub struct Unused {
+pub(crate) struct Unused {
     #[suggestion(code = "", applicability = "machine-applicable")]
     pub attr_span: Span,
     #[subdiagnostic]
@@ -742,7 +742,7 @@ pub struct Unused {
 
 #[derive(Diagnostic)]
 #[diag(passes_non_exported_macro_invalid_attrs, code = E0518)]
-pub struct NonExportedMacroInvalidAttrs {
+pub(crate) struct NonExportedMacroInvalidAttrs {
     #[primary_span]
     #[label]
     pub attr_span: Span,
@@ -750,14 +750,14 @@ pub struct NonExportedMacroInvalidAttrs {
 
 #[derive(Diagnostic)]
 #[diag(passes_may_dangle)]
-pub struct InvalidMayDangle {
+pub(crate) struct InvalidMayDangle {
     #[primary_span]
     pub attr_span: Span,
 }
 
 #[derive(LintDiagnostic)]
 #[diag(passes_unused_duplicate)]
-pub struct UnusedDuplicate {
+pub(crate) struct UnusedDuplicate {
     #[suggestion(code = "", applicability = "machine-applicable")]
     pub this: Span,
     #[note]
@@ -768,7 +768,7 @@ pub struct UnusedDuplicate {
 
 #[derive(Diagnostic)]
 #[diag(passes_unused_multiple)]
-pub struct UnusedMultiple {
+pub(crate) struct UnusedMultiple {
     #[primary_span]
     #[suggestion(code = "", applicability = "machine-applicable")]
     pub this: Span,
@@ -779,7 +779,7 @@ pub struct UnusedMultiple {
 
 #[derive(Diagnostic)]
 #[diag(passes_rustc_lint_opt_ty)]
-pub struct RustcLintOptTy {
+pub(crate) struct RustcLintOptTy {
     #[primary_span]
     pub attr_span: Span,
     #[label]
@@ -788,7 +788,7 @@ pub struct RustcLintOptTy {
 
 #[derive(Diagnostic)]
 #[diag(passes_rustc_lint_opt_deny_field_access)]
-pub struct RustcLintOptDenyFieldAccess {
+pub(crate) struct RustcLintOptDenyFieldAccess {
     #[primary_span]
     pub attr_span: Span,
     #[label]
@@ -797,7 +797,7 @@ pub struct RustcLintOptDenyFieldAccess {
 
 #[derive(Diagnostic)]
 #[diag(passes_collapse_debuginfo)]
-pub struct CollapseDebuginfo {
+pub(crate) struct CollapseDebuginfo {
     #[primary_span]
     pub attr_span: Span,
     #[label]
@@ -806,14 +806,14 @@ pub struct CollapseDebuginfo {
 
 #[derive(LintDiagnostic)]
 #[diag(passes_deprecated_annotation_has_no_effect)]
-pub struct DeprecatedAnnotationHasNoEffect {
+pub(crate) struct DeprecatedAnnotationHasNoEffect {
     #[suggestion(applicability = "machine-applicable", code = "")]
     pub span: Span,
 }
 
 #[derive(Diagnostic)]
 #[diag(passes_unknown_external_lang_item, code = E0264)]
-pub struct UnknownExternLangItem {
+pub(crate) struct UnknownExternLangItem {
     #[primary_span]
     pub span: Span,
     pub lang_item: Symbol,
@@ -821,25 +821,25 @@ pub struct UnknownExternLangItem {
 
 #[derive(Diagnostic)]
 #[diag(passes_missing_panic_handler)]
-pub struct MissingPanicHandler;
+pub(crate) struct MissingPanicHandler;
 
 #[derive(Diagnostic)]
 #[diag(passes_panic_unwind_without_std)]
 #[help]
 #[note]
-pub struct PanicUnwindWithoutStd;
+pub(crate) struct PanicUnwindWithoutStd;
 
 #[derive(Diagnostic)]
 #[diag(passes_missing_lang_item)]
 #[note]
 #[help]
-pub struct MissingLangItem {
+pub(crate) struct MissingLangItem {
     pub name: Symbol,
 }
 
 #[derive(Diagnostic)]
 #[diag(passes_lang_item_fn_with_track_caller)]
-pub struct LangItemWithTrackCaller {
+pub(crate) struct LangItemWithTrackCaller {
     #[primary_span]
     pub attr_span: Span,
     pub name: Symbol,
@@ -849,7 +849,7 @@ pub struct LangItemWithTrackCaller {
 
 #[derive(Diagnostic)]
 #[diag(passes_lang_item_fn_with_target_feature)]
-pub struct LangItemWithTargetFeature {
+pub(crate) struct LangItemWithTargetFeature {
     #[primary_span]
     pub attr_span: Span,
     pub name: Symbol,
@@ -859,7 +859,7 @@ pub struct LangItemWithTargetFeature {
 
 #[derive(Diagnostic)]
 #[diag(passes_lang_item_on_incorrect_target, code = E0718)]
-pub struct LangItemOnIncorrectTarget {
+pub(crate) struct LangItemOnIncorrectTarget {
     #[primary_span]
     #[label]
     pub span: Span,
@@ -870,14 +870,14 @@ pub struct LangItemOnIncorrectTarget {
 
 #[derive(Diagnostic)]
 #[diag(passes_unknown_lang_item, code = E0522)]
-pub struct UnknownLangItem {
+pub(crate) struct UnknownLangItem {
     #[primary_span]
     #[label]
     pub span: Span,
     pub name: Symbol,
 }
 
-pub struct InvalidAttrAtCrateLevel {
+pub(crate) struct InvalidAttrAtCrateLevel {
     pub span: Span,
     pub sugg_span: Option<Span>,
     pub name: Symbol,
@@ -885,7 +885,7 @@ pub struct InvalidAttrAtCrateLevel {
 }
 
 #[derive(Clone, Copy)]
-pub struct ItemFollowingInnerAttr {
+pub(crate) struct ItemFollowingInnerAttr {
     pub span: Span,
     pub kind: &'static str,
 }
@@ -916,7 +916,7 @@ impl<G: EmissionGuarantee> Diagnostic<'_, G> for InvalidAttrAtCrateLevel {
 
 #[derive(Diagnostic)]
 #[diag(passes_duplicate_diagnostic_item_in_crate)]
-pub struct DuplicateDiagnosticItemInCrate {
+pub(crate) struct DuplicateDiagnosticItemInCrate {
     #[primary_span]
     pub duplicate_span: Option<Span>,
     #[note(passes_diagnostic_item_first_defined)]
@@ -930,7 +930,7 @@ pub struct DuplicateDiagnosticItemInCrate {
 
 #[derive(Diagnostic)]
 #[diag(passes_layout_abi)]
-pub struct LayoutAbi {
+pub(crate) struct LayoutAbi {
     #[primary_span]
     pub span: Span,
     pub abi: String,
@@ -938,7 +938,7 @@ pub struct LayoutAbi {
 
 #[derive(Diagnostic)]
 #[diag(passes_layout_align)]
-pub struct LayoutAlign {
+pub(crate) struct LayoutAlign {
     #[primary_span]
     pub span: Span,
     pub align: String,
@@ -946,7 +946,7 @@ pub struct LayoutAlign {
 
 #[derive(Diagnostic)]
 #[diag(passes_layout_size)]
-pub struct LayoutSize {
+pub(crate) struct LayoutSize {
     #[primary_span]
     pub span: Span,
     pub size: String,
@@ -954,7 +954,7 @@ pub struct LayoutSize {
 
 #[derive(Diagnostic)]
 #[diag(passes_layout_homogeneous_aggregate)]
-pub struct LayoutHomogeneousAggregate {
+pub(crate) struct LayoutHomogeneousAggregate {
     #[primary_span]
     pub span: Span,
     pub homogeneous_aggregate: String,
@@ -962,7 +962,7 @@ pub struct LayoutHomogeneousAggregate {
 
 #[derive(Diagnostic)]
 #[diag(passes_layout_of)]
-pub struct LayoutOf {
+pub(crate) struct LayoutOf {
     #[primary_span]
     pub span: Span,
     pub normalized_ty: String,
@@ -971,14 +971,14 @@ pub struct LayoutOf {
 
 #[derive(Diagnostic)]
 #[diag(passes_layout_invalid_attribute)]
-pub struct LayoutInvalidAttribute {
+pub(crate) struct LayoutInvalidAttribute {
     #[primary_span]
     pub span: Span,
 }
 
 #[derive(Diagnostic)]
 #[diag(passes_abi_of)]
-pub struct AbiOf {
+pub(crate) struct AbiOf {
     #[primary_span]
     pub span: Span,
     pub fn_name: Symbol,
@@ -987,7 +987,7 @@ pub struct AbiOf {
 
 #[derive(Diagnostic)]
 #[diag(passes_abi_ne)]
-pub struct AbiNe {
+pub(crate) struct AbiNe {
     #[primary_span]
     pub span: Span,
     pub left: String,
@@ -996,14 +996,14 @@ pub struct AbiNe {
 
 #[derive(Diagnostic)]
 #[diag(passes_abi_invalid_attribute)]
-pub struct AbiInvalidAttribute {
+pub(crate) struct AbiInvalidAttribute {
     #[primary_span]
     pub span: Span,
 }
 
 #[derive(Diagnostic)]
 #[diag(passes_unrecognized_field)]
-pub struct UnrecognizedField {
+pub(crate) struct UnrecognizedField {
     #[primary_span]
     pub span: Span,
     pub name: Symbol,
@@ -1011,7 +1011,7 @@ pub struct UnrecognizedField {
 
 #[derive(Diagnostic)]
 #[diag(passes_feature_stable_twice, code = E0711)]
-pub struct FeatureStableTwice {
+pub(crate) struct FeatureStableTwice {
     #[primary_span]
     pub span: Span,
     pub feature: Symbol,
@@ -1021,7 +1021,7 @@ pub struct FeatureStableTwice {
 
 #[derive(Diagnostic)]
 #[diag(passes_feature_previously_declared, code = E0711)]
-pub struct FeaturePreviouslyDeclared<'a, 'b> {
+pub(crate) struct FeaturePreviouslyDeclared<'a, 'b> {
     #[primary_span]
     pub span: Span,
     pub feature: Symbol,
@@ -1029,7 +1029,7 @@ pub struct FeaturePreviouslyDeclared<'a, 'b> {
     pub prev_declared: &'b str,
 }
 
-pub struct BreakNonLoop<'a> {
+pub(crate) struct BreakNonLoop<'a> {
     pub span: Span,
     pub head: Option<Span>,
     pub kind: &'a str,
@@ -1084,7 +1084,7 @@ impl<'a, G: EmissionGuarantee> Diagnostic<'_, G> for BreakNonLoop<'a> {
 
 #[derive(Diagnostic)]
 #[diag(passes_continue_labeled_block, code = E0696)]
-pub struct ContinueLabeledBlock {
+pub(crate) struct ContinueLabeledBlock {
     #[primary_span]
     #[label]
     pub span: Span,
@@ -1094,7 +1094,7 @@ pub struct ContinueLabeledBlock {
 
 #[derive(Diagnostic)]
 #[diag(passes_break_inside_closure, code = E0267)]
-pub struct BreakInsideClosure<'a> {
+pub(crate) struct BreakInsideClosure<'a> {
     #[primary_span]
     #[label]
     pub span: Span,
@@ -1105,7 +1105,7 @@ pub struct BreakInsideClosure<'a> {
 
 #[derive(Diagnostic)]
 #[diag(passes_break_inside_coroutine, code = E0267)]
-pub struct BreakInsideCoroutine<'a> {
+pub(crate) struct BreakInsideCoroutine<'a> {
     #[primary_span]
     #[label]
     pub span: Span,
@@ -1118,7 +1118,7 @@ pub struct BreakInsideCoroutine<'a> {
 
 #[derive(Diagnostic)]
 #[diag(passes_outside_loop, code = E0268)]
-pub struct OutsideLoop<'a> {
+pub(crate) struct OutsideLoop<'a> {
     #[primary_span]
     #[label]
     pub spans: Vec<Span>,
@@ -1129,7 +1129,7 @@ pub struct OutsideLoop<'a> {
 }
 #[derive(Subdiagnostic)]
 #[multipart_suggestion(passes_outside_loop_suggestion, applicability = "maybe-incorrect")]
-pub struct OutsideLoopSuggestion {
+pub(crate) struct OutsideLoopSuggestion {
     #[suggestion_part(code = "'block: ")]
     pub block_span: Span,
     #[suggestion_part(code = " 'block")]
@@ -1138,7 +1138,7 @@ pub struct OutsideLoopSuggestion {
 
 #[derive(Diagnostic)]
 #[diag(passes_unlabeled_in_labeled_block, code = E0695)]
-pub struct UnlabeledInLabeledBlock<'a> {
+pub(crate) struct UnlabeledInLabeledBlock<'a> {
     #[primary_span]
     #[label]
     pub span: Span,
@@ -1147,7 +1147,7 @@ pub struct UnlabeledInLabeledBlock<'a> {
 
 #[derive(Diagnostic)]
 #[diag(passes_unlabeled_cf_in_while_condition, code = E0590)]
-pub struct UnlabeledCfInWhileCondition<'a> {
+pub(crate) struct UnlabeledCfInWhileCondition<'a> {
     #[primary_span]
     #[label]
     pub span: Span,
@@ -1156,11 +1156,11 @@ pub struct UnlabeledCfInWhileCondition<'a> {
 
 #[derive(LintDiagnostic)]
 #[diag(passes_undefined_naked_function_abi)]
-pub struct UndefinedNakedFunctionAbi;
+pub(crate) struct UndefinedNakedFunctionAbi;
 
 #[derive(Diagnostic)]
 #[diag(passes_no_patterns)]
-pub struct NoPatterns {
+pub(crate) struct NoPatterns {
     #[primary_span]
     pub span: Span,
 }
@@ -1168,12 +1168,12 @@ pub struct NoPatterns {
 #[derive(Diagnostic)]
 #[diag(passes_params_not_allowed)]
 #[help]
-pub struct ParamsNotAllowed {
+pub(crate) struct ParamsNotAllowed {
     #[primary_span]
     pub span: Span,
 }
 
-pub struct NakedFunctionsAsmBlock {
+pub(crate) struct NakedFunctionsAsmBlock {
     pub span: Span,
     pub multiple_asms: Vec<Span>,
     pub non_asms: Vec<Span>,
@@ -1197,14 +1197,14 @@ impl<G: EmissionGuarantee> Diagnostic<'_, G> for NakedFunctionsAsmBlock {
 
 #[derive(Diagnostic)]
 #[diag(passes_naked_functions_operands, code = E0787)]
-pub struct NakedFunctionsOperands {
+pub(crate) struct NakedFunctionsOperands {
     #[primary_span]
     pub unsupported_operands: Vec<Span>,
 }
 
 #[derive(Diagnostic)]
 #[diag(passes_naked_functions_asm_options, code = E0787)]
-pub struct NakedFunctionsAsmOptions {
+pub(crate) struct NakedFunctionsAsmOptions {
     #[primary_span]
     pub span: Span,
     pub unsupported_options: String,
@@ -1212,7 +1212,7 @@ pub struct NakedFunctionsAsmOptions {
 
 #[derive(Diagnostic)]
 #[diag(passes_naked_functions_must_use_noreturn, code = E0787)]
-pub struct NakedFunctionsMustUseNoreturn {
+pub(crate) struct NakedFunctionsMustUseNoreturn {
     #[primary_span]
     pub span: Span,
     #[suggestion(code = ", options(noreturn)", applicability = "machine-applicable")]
@@ -1221,7 +1221,7 @@ pub struct NakedFunctionsMustUseNoreturn {
 
 #[derive(Diagnostic)]
 #[diag(passes_naked_functions_incompatible_attribute, code = E0736)]
-pub struct NakedFunctionIncompatibleAttribute {
+pub(crate) struct NakedFunctionIncompatibleAttribute {
     #[primary_span]
     #[label]
     pub span: Span,
@@ -1232,7 +1232,7 @@ pub struct NakedFunctionIncompatibleAttribute {
 
 #[derive(Diagnostic)]
 #[diag(passes_attr_only_in_functions)]
-pub struct AttrOnlyInFunctions {
+pub(crate) struct AttrOnlyInFunctions {
     #[primary_span]
     pub span: Span,
     pub attr: Symbol,
@@ -1240,7 +1240,7 @@ pub struct AttrOnlyInFunctions {
 
 #[derive(Diagnostic)]
 #[diag(passes_multiple_rustc_main, code = E0137)]
-pub struct MultipleRustcMain {
+pub(crate) struct MultipleRustcMain {
     #[primary_span]
     pub span: Span,
     #[label(passes_first)]
@@ -1251,7 +1251,7 @@ pub struct MultipleRustcMain {
 
 #[derive(Diagnostic)]
 #[diag(passes_multiple_start_functions, code = E0138)]
-pub struct MultipleStartFunctions {
+pub(crate) struct MultipleStartFunctions {
     #[primary_span]
     pub span: Span,
     #[label]
@@ -1262,12 +1262,12 @@ pub struct MultipleStartFunctions {
 
 #[derive(Diagnostic)]
 #[diag(passes_extern_main)]
-pub struct ExternMain {
+pub(crate) struct ExternMain {
     #[primary_span]
     pub span: Span,
 }
 
-pub struct NoMainErr {
+pub(crate) struct NoMainErr {
     pub sp: Span,
     pub crate_name: Symbol,
     pub has_filename: bool,
@@ -1321,7 +1321,7 @@ impl<'a, G: EmissionGuarantee> Diagnostic<'a, G> for NoMainErr {
     }
 }
 
-pub struct DuplicateLangItem {
+pub(crate) struct DuplicateLangItem {
     pub local_span: Option<Span>,
     pub lang_item_name: Symbol,
     pub crate_name: Symbol,
@@ -1386,7 +1386,7 @@ impl<G: EmissionGuarantee> Diagnostic<'_, G> for DuplicateLangItem {
 
 #[derive(Diagnostic)]
 #[diag(passes_incorrect_target, code = E0718)]
-pub struct IncorrectTarget<'a> {
+pub(crate) struct IncorrectTarget<'a> {
     #[primary_span]
     pub span: Span,
     #[label]
@@ -1400,21 +1400,21 @@ pub struct IncorrectTarget<'a> {
 
 #[derive(LintDiagnostic)]
 #[diag(passes_useless_assignment)]
-pub struct UselessAssignment<'a> {
+pub(crate) struct UselessAssignment<'a> {
     pub is_field_assign: bool,
     pub ty: Ty<'a>,
 }
 
 #[derive(LintDiagnostic)]
 #[diag(passes_only_has_effect_on)]
-pub struct OnlyHasEffectOn {
+pub(crate) struct OnlyHasEffectOn {
     pub attr_name: Symbol,
     pub target_name: String,
 }
 
 #[derive(Diagnostic)]
 #[diag(passes_object_lifetime_err)]
-pub struct ObjectLifetimeErr {
+pub(crate) struct ObjectLifetimeErr {
     #[primary_span]
     pub span: Span,
     pub repr: String,
@@ -1423,13 +1423,13 @@ pub struct ObjectLifetimeErr {
 #[derive(Diagnostic)]
 #[diag(passes_unrecognized_repr_hint, code = E0552)]
 #[help]
-pub struct UnrecognizedReprHint {
+pub(crate) struct UnrecognizedReprHint {
     #[primary_span]
     pub span: Span,
 }
 
 #[derive(Diagnostic)]
-pub enum AttrApplication {
+pub(crate) enum AttrApplication {
     #[diag(passes_attr_application_enum, code = E0517)]
     Enum {
         #[primary_span]
@@ -1469,7 +1469,7 @@ pub enum AttrApplication {
 
 #[derive(Diagnostic)]
 #[diag(passes_transparent_incompatible, code = E0692)]
-pub struct TransparentIncompatible {
+pub(crate) struct TransparentIncompatible {
     #[primary_span]
     pub hint_spans: Vec<Span>,
     pub target: String,
@@ -1477,14 +1477,14 @@ pub struct TransparentIncompatible {
 
 #[derive(Diagnostic)]
 #[diag(passes_deprecated_attribute, code = E0549)]
-pub struct DeprecatedAttribute {
+pub(crate) struct DeprecatedAttribute {
     #[primary_span]
     pub span: Span,
 }
 
 #[derive(Diagnostic)]
 #[diag(passes_useless_stability)]
-pub struct UselessStability {
+pub(crate) struct UselessStability {
     #[primary_span]
     #[label]
     pub span: Span,
@@ -1494,7 +1494,7 @@ pub struct UselessStability {
 
 #[derive(Diagnostic)]
 #[diag(passes_cannot_stabilize_deprecated)]
-pub struct CannotStabilizeDeprecated {
+pub(crate) struct CannotStabilizeDeprecated {
     #[primary_span]
     #[label]
     pub span: Span,
@@ -1504,7 +1504,7 @@ pub struct CannotStabilizeDeprecated {
 
 #[derive(Diagnostic)]
 #[diag(passes_missing_stability_attr)]
-pub struct MissingStabilityAttr<'a> {
+pub(crate) struct MissingStabilityAttr<'a> {
     #[primary_span]
     pub span: Span,
     pub descr: &'a str,
@@ -1512,7 +1512,7 @@ pub struct MissingStabilityAttr<'a> {
 
 #[derive(Diagnostic)]
 #[diag(passes_missing_const_stab_attr)]
-pub struct MissingConstStabAttr<'a> {
+pub(crate) struct MissingConstStabAttr<'a> {
     #[primary_span]
     pub span: Span,
     pub descr: &'a str,
@@ -1521,14 +1521,14 @@ pub struct MissingConstStabAttr<'a> {
 #[derive(Diagnostic)]
 #[diag(passes_trait_impl_const_stable)]
 #[note]
-pub struct TraitImplConstStable {
+pub(crate) struct TraitImplConstStable {
     #[primary_span]
     pub span: Span,
 }
 
 #[derive(Diagnostic)]
 #[diag(passes_unknown_feature, code = E0635)]
-pub struct UnknownFeature {
+pub(crate) struct UnknownFeature {
     #[primary_span]
     pub span: Span,
     pub feature: Symbol,
@@ -1536,7 +1536,7 @@ pub struct UnknownFeature {
 
 #[derive(Diagnostic)]
 #[diag(passes_implied_feature_not_exist)]
-pub struct ImpliedFeatureNotExist {
+pub(crate) struct ImpliedFeatureNotExist {
     #[primary_span]
     pub span: Span,
     pub feature: Symbol,
@@ -1545,14 +1545,14 @@ pub struct ImpliedFeatureNotExist {
 
 #[derive(Diagnostic)]
 #[diag(passes_duplicate_feature_err, code = E0636)]
-pub struct DuplicateFeatureErr {
+pub(crate) struct DuplicateFeatureErr {
     #[primary_span]
     pub span: Span,
     pub feature: Symbol,
 }
 #[derive(Diagnostic)]
 #[diag(passes_missing_const_err)]
-pub struct MissingConstErr {
+pub(crate) struct MissingConstErr {
     #[primary_span]
     #[help]
     pub fn_sig_span: Span,
@@ -1561,7 +1561,7 @@ pub struct MissingConstErr {
 }
 
 #[derive(LintDiagnostic)]
-pub enum MultipleDeadCodes<'tcx> {
+pub(crate) enum MultipleDeadCodes<'tcx> {
     #[diag(passes_dead_codes)]
     DeadCodes {
         multiple: bool,
@@ -1592,7 +1592,7 @@ pub enum MultipleDeadCodes<'tcx> {
 
 #[derive(Subdiagnostic)]
 #[label(passes_parent_info)]
-pub struct ParentInfo<'tcx> {
+pub(crate) struct ParentInfo<'tcx> {
     pub num: usize,
     pub descr: &'tcx str,
     pub parent_descr: &'tcx str,
@@ -1602,14 +1602,14 @@ pub struct ParentInfo<'tcx> {
 
 #[derive(Subdiagnostic)]
 #[note(passes_ignored_derived_impls)]
-pub struct IgnoredDerivedImpls {
+pub(crate) struct IgnoredDerivedImpls {
     pub name: Symbol,
     pub trait_list: DiagSymbolList,
     pub trait_list_len: usize,
 }
 
 #[derive(Subdiagnostic)]
-pub enum ChangeFields {
+pub(crate) enum ChangeFields {
     #[multipart_suggestion(
         passes_change_fields_to_be_of_unit_type,
         applicability = "has-placeholders"
@@ -1633,14 +1633,14 @@ pub(crate) struct ProcMacroBadSig {
 
 #[derive(Diagnostic)]
 #[diag(passes_skipping_const_checks)]
-pub struct SkippingConstChecks {
+pub(crate) struct SkippingConstChecks {
     #[primary_span]
     pub span: Span,
 }
 
 #[derive(LintDiagnostic)]
 #[diag(passes_unreachable_due_to_uninhabited)]
-pub struct UnreachableDueToUninhabited<'desc, 'tcx> {
+pub(crate) struct UnreachableDueToUninhabited<'desc, 'tcx> {
     pub descr: &'desc str,
     #[label]
     pub expr: Span,
@@ -1653,20 +1653,20 @@ pub struct UnreachableDueToUninhabited<'desc, 'tcx> {
 #[derive(LintDiagnostic)]
 #[diag(passes_unused_var_maybe_capture_ref)]
 #[help]
-pub struct UnusedVarMaybeCaptureRef {
+pub(crate) struct UnusedVarMaybeCaptureRef {
     pub name: String,
 }
 
 #[derive(LintDiagnostic)]
 #[diag(passes_unused_capture_maybe_capture_ref)]
 #[help]
-pub struct UnusedCaptureMaybeCaptureRef {
+pub(crate) struct UnusedCaptureMaybeCaptureRef {
     pub name: String,
 }
 
 #[derive(LintDiagnostic)]
 #[diag(passes_unused_var_remove_field)]
-pub struct UnusedVarRemoveField {
+pub(crate) struct UnusedVarRemoveField {
     pub name: String,
     #[subdiagnostic]
     pub sugg: UnusedVarRemoveFieldSugg,
@@ -1677,7 +1677,7 @@ pub struct UnusedVarRemoveField {
     passes_unused_var_remove_field_suggestion,
     applicability = "machine-applicable"
 )]
-pub struct UnusedVarRemoveFieldSugg {
+pub(crate) struct UnusedVarRemoveFieldSugg {
     #[suggestion_part(code = "")]
     pub spans: Vec<Span>,
 }
@@ -1685,20 +1685,20 @@ pub struct UnusedVarRemoveFieldSugg {
 #[derive(LintDiagnostic)]
 #[diag(passes_unused_var_assigned_only)]
 #[note]
-pub struct UnusedVarAssignedOnly {
+pub(crate) struct UnusedVarAssignedOnly {
     pub name: String,
 }
 
 #[derive(LintDiagnostic)]
 #[diag(passes_unnecessary_stable_feature)]
-pub struct UnnecessaryStableFeature {
+pub(crate) struct UnnecessaryStableFeature {
     pub feature: Symbol,
     pub since: Symbol,
 }
 
 #[derive(LintDiagnostic)]
 #[diag(passes_unnecessary_partial_stable_feature)]
-pub struct UnnecessaryPartialStableFeature {
+pub(crate) struct UnnecessaryPartialStableFeature {
     #[suggestion(code = "{implies}", applicability = "maybe-incorrect")]
     pub span: Span,
     #[suggestion(passes_suggestion_remove, code = "", applicability = "maybe-incorrect")]
@@ -1711,25 +1711,25 @@ pub struct UnnecessaryPartialStableFeature {
 #[derive(LintDiagnostic)]
 #[diag(passes_ineffective_unstable_impl)]
 #[note]
-pub struct IneffectiveUnstableImpl;
+pub(crate) struct IneffectiveUnstableImpl;
 
 #[derive(LintDiagnostic)]
 #[diag(passes_unused_assign)]
 #[help]
-pub struct UnusedAssign {
+pub(crate) struct UnusedAssign {
     pub name: String,
 }
 
 #[derive(LintDiagnostic)]
 #[diag(passes_unused_assign_passed)]
 #[help]
-pub struct UnusedAssignPassed {
+pub(crate) struct UnusedAssignPassed {
     pub name: String,
 }
 
 #[derive(LintDiagnostic)]
 #[diag(passes_unused_variable_try_prefix)]
-pub struct UnusedVariableTryPrefix {
+pub(crate) struct UnusedVariableTryPrefix {
     #[label]
     pub label: Option<Span>,
     #[subdiagnostic]
@@ -1740,7 +1740,7 @@ pub struct UnusedVariableTryPrefix {
 }
 
 #[derive(Subdiagnostic)]
-pub enum UnusedVariableSugg {
+pub(crate) enum UnusedVariableSugg {
     #[multipart_suggestion(passes_suggestion, applicability = "maybe-incorrect")]
     TryPrefixSugg {
         #[suggestion_part(code = "_{name}")]
@@ -1755,7 +1755,7 @@ pub enum UnusedVariableSugg {
     },
 }
 
-pub struct UnusedVariableStringInterp {
+pub(crate) struct UnusedVariableStringInterp {
     pub lit: Span,
     pub lo: Span,
     pub hi: Span,
@@ -1778,14 +1778,14 @@ impl Subdiagnostic for UnusedVariableStringInterp {
 
 #[derive(LintDiagnostic)]
 #[diag(passes_unused_variable_try_ignore)]
-pub struct UnusedVarTryIgnore {
+pub(crate) struct UnusedVarTryIgnore {
     #[subdiagnostic]
     pub sugg: UnusedVarTryIgnoreSugg,
 }
 
 #[derive(Subdiagnostic)]
 #[multipart_suggestion(passes_suggestion, applicability = "maybe-incorrect")]
-pub struct UnusedVarTryIgnoreSugg {
+pub(crate) struct UnusedVarTryIgnoreSugg {
     #[suggestion_part(code = "{name}: _")]
     pub shorthands: Vec<Span>,
     #[suggestion_part(code = "_")]
@@ -1796,14 +1796,14 @@ pub struct UnusedVarTryIgnoreSugg {
 #[derive(LintDiagnostic)]
 #[diag(passes_attr_crate_level)]
 #[note]
-pub struct AttrCrateLevelOnly {
+pub(crate) struct AttrCrateLevelOnly {
     #[subdiagnostic]
     pub sugg: Option<AttrCrateLevelOnlySugg>,
 }
 
 #[derive(Subdiagnostic)]
 #[suggestion(passes_suggestion, applicability = "maybe-incorrect", code = "!", style = "verbose")]
-pub struct AttrCrateLevelOnlySugg {
+pub(crate) struct AttrCrateLevelOnlySugg {
     #[primary_span]
     pub attr: Span,
 }
diff --git a/compiler/rustc_passes/src/lang_items.rs b/compiler/rustc_passes/src/lang_items.rs
index 71b0ebb0e21..8038afb955e 100644
--- a/compiler/rustc_passes/src/lang_items.rs
+++ b/compiler/rustc_passes/src/lang_items.rs
@@ -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;
 }
diff --git a/compiler/rustc_passes/src/lib.rs b/compiler/rustc_passes/src/lib.rs
index a0f5f98aafc..664da65068d 100644
--- a/compiler/rustc_passes/src/lib.rs
+++ b/compiler/rustc_passes/src/lib.rs
@@ -12,6 +12,7 @@
 #![feature(map_try_insert)]
 #![feature(rustdoc_internals)]
 #![feature(try_blocks)]
+#![warn(unreachable_pub)]
 // tidy-alphabetical-end
 
 use rustc_middle::query::Providers;
diff --git a/compiler/rustc_passes/src/lib_features.rs b/compiler/rustc_passes/src/lib_features.rs
index e60985ba16f..9d5766865c7 100644
--- a/compiler/rustc_passes/src/lib_features.rs
+++ b/compiler/rustc_passes/src/lib_features.rs
@@ -16,7 +16,7 @@ use rustc_span::{sym, Span};
 
 use crate::errors::{FeaturePreviouslyDeclared, FeatureStableTwice};
 
-pub struct LibFeatureCollector<'tcx> {
+struct LibFeatureCollector<'tcx> {
     tcx: TyCtxt<'tcx>,
     lib_features: LibFeatures,
 }
@@ -153,6 +153,6 @@ fn lib_features(tcx: TyCtxt<'_>, LocalCrate: LocalCrate) -> LibFeatures {
     collector.lib_features
 }
 
-pub fn provide(providers: &mut Providers) {
+pub(crate) fn provide(providers: &mut Providers) {
     providers.lib_features = lib_features;
 }
diff --git a/compiler/rustc_passes/src/liveness.rs b/compiler/rustc_passes/src/liveness.rs
index d3b85da4630..db3eaea68b5 100644
--- a/compiler/rustc_passes/src/liveness.rs
+++ b/compiler/rustc_passes/src/liveness.rs
@@ -178,7 +178,7 @@ fn check_liveness(tcx: TyCtxt<'_>, def_id: LocalDefId) {
     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 };
 }
 
diff --git a/compiler/rustc_passes/src/reachable.rs b/compiler/rustc_passes/src/reachable.rs
index dee8ba7e87d..8d9e00b9f3c 100644
--- a/compiler/rustc_passes/src/reachable.rs
+++ b/compiler/rustc_passes/src/reachable.rs
@@ -500,6 +500,6 @@ fn reachable_set(tcx: TyCtxt<'_>, (): ()) -> LocalDefIdSet {
     reachable_context.reachable_symbols
 }
 
-pub fn provide(providers: &mut Providers) {
+pub(crate) fn provide(providers: &mut Providers) {
     *providers = Providers { reachable_set, ..*providers };
 }
diff --git a/compiler/rustc_passes/src/upvars.rs b/compiler/rustc_passes/src/upvars.rs
index f2454514e4d..0544d08f5b1 100644
--- a/compiler/rustc_passes/src/upvars.rs
+++ b/compiler/rustc_passes/src/upvars.rs
@@ -9,7 +9,7 @@ use rustc_middle::query::Providers;
 use rustc_middle::ty::TyCtxt;
 use rustc_span::Span;
 
-pub fn provide(providers: &mut Providers) {
+pub(crate) fn provide(providers: &mut Providers) {
     providers.upvars_mentioned = |tcx, def_id| {
         if !tcx.is_closure_like(def_id) {
             return None;
diff --git a/compiler/rustc_passes/src/weak_lang_items.rs b/compiler/rustc_passes/src/weak_lang_items.rs
index 90691ca1790..020128f29c5 100644
--- a/compiler/rustc_passes/src/weak_lang_items.rs
+++ b/compiler/rustc_passes/src/weak_lang_items.rs
@@ -15,7 +15,11 @@ use crate::errors::{
 
 /// 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.
-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.
     // They will never implicitly be added to the `missing` array unless we do
     // so here.