Skip to content

Commit

Permalink
Add warn(unreachable_pub) to rustc_privacy.
Browse files Browse the repository at this point in the history
  • Loading branch information
nnethercote committed Aug 29, 2024
1 parent 653ee7b commit 71bffef
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
18 changes: 9 additions & 9 deletions compiler/rustc_privacy/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use rustc_span::{Span, Symbol};

#[derive(Diagnostic)]
#[diag(privacy_field_is_private, code = E0451)]
pub struct FieldIsPrivate {
pub(crate) struct FieldIsPrivate {
#[primary_span]
pub span: Span,
pub field_name: Symbol,
Expand All @@ -16,7 +16,7 @@ pub struct FieldIsPrivate {
}

#[derive(Subdiagnostic)]
pub enum FieldIsPrivateLabel {
pub(crate) enum FieldIsPrivateLabel {
#[label(privacy_field_is_private_is_update_syntax_label)]
IsUpdateSyntax {
#[primary_span]
Expand All @@ -32,7 +32,7 @@ pub enum FieldIsPrivateLabel {

#[derive(Diagnostic)]
#[diag(privacy_item_is_private)]
pub struct ItemIsPrivate<'a> {
pub(crate) struct ItemIsPrivate<'a> {
#[primary_span]
#[label]
pub span: Span,
Expand All @@ -42,15 +42,15 @@ pub struct ItemIsPrivate<'a> {

#[derive(Diagnostic)]
#[diag(privacy_unnamed_item_is_private)]
pub struct UnnamedItemIsPrivate {
pub(crate) struct UnnamedItemIsPrivate {
#[primary_span]
pub span: Span,
pub kind: &'static str,
}

#[derive(Diagnostic)]
#[diag(privacy_in_public_interface, code = E0446)]
pub struct InPublicInterface<'a> {
pub(crate) struct InPublicInterface<'a> {
#[primary_span]
#[label]
pub span: Span,
Expand All @@ -63,23 +63,23 @@ pub struct InPublicInterface<'a> {

#[derive(Diagnostic)]
#[diag(privacy_report_effective_visibility)]
pub struct ReportEffectiveVisibility {
pub(crate) struct ReportEffectiveVisibility {
#[primary_span]
pub span: Span,
pub descr: String,
}

#[derive(LintDiagnostic)]
#[diag(privacy_from_private_dep_in_public_interface)]
pub struct FromPrivateDependencyInPublicInterface<'a> {
pub(crate) struct FromPrivateDependencyInPublicInterface<'a> {
pub kind: &'a str,
pub descr: DiagArgFromDisplay<'a>,
pub krate: Symbol,
}

#[derive(LintDiagnostic)]
#[diag(privacy_unnameable_types_lint)]
pub struct UnnameableTypesLint<'a> {
pub(crate) struct UnnameableTypesLint<'a> {
#[label]
pub span: Span,
pub kind: &'a str,
Expand All @@ -93,7 +93,7 @@ pub struct UnnameableTypesLint<'a> {
// See https://rust-lang.github.io/rfcs/2145-type-privacy.html for more details.
#[derive(LintDiagnostic)]
#[diag(privacy_private_interface_or_bounds_lint)]
pub struct PrivateInterfacesOrBoundsLint<'a> {
pub(crate) struct PrivateInterfacesOrBoundsLint<'a> {
#[label(privacy_item_label)]
pub item_span: Span,
pub item_kind: &'a str,
Expand Down
3 changes: 2 additions & 1 deletion compiler/rustc_privacy/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#![feature(let_chains)]
#![feature(rustdoc_internals)]
#![feature(try_blocks)]
#![warn(unreachable_pub)]
// tidy-alphabetical-end

mod errors;
Expand Down Expand Up @@ -1497,7 +1498,7 @@ impl<'tcx> PrivateItemsInPublicInterfacesChecker<'tcx, '_> {
self.effective_visibilities.effective_vis(def_id).copied()
}

pub fn check_item(&mut self, id: ItemId) {
fn check_item(&mut self, id: ItemId) {
let tcx = self.tcx;
let def_id = id.owner_id.def_id;
let item_visibility = tcx.local_visibility(def_id);
Expand Down

0 comments on commit 71bffef

Please sign in to comment.