Add warn(unreachable_pub) to rustc_privacy.

This commit is contained in:
Nicholas Nethercote 2024-08-29 16:29:14 +10:00
parent 653ee7bc3a
commit 71bffef4f9
2 changed files with 11 additions and 10 deletions

View File

@ -5,7 +5,7 @@
#[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,
@ -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]
@ -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,
@ -42,7 +42,7 @@ 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,
@ -50,7 +50,7 @@ pub struct UnnamedItemIsPrivate {
#[derive(Diagnostic)]
#[diag(privacy_in_public_interface, code = E0446)]
pub struct InPublicInterface<'a> {
pub(crate) struct InPublicInterface<'a> {
#[primary_span]
#[label]
pub span: Span,
@ -63,7 +63,7 @@ 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,
@ -71,7 +71,7 @@ pub struct ReportEffectiveVisibility {
#[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,
@ -79,7 +79,7 @@ pub struct FromPrivateDependencyInPublicInterface<'a> {
#[derive(LintDiagnostic)]
#[diag(privacy_unnameable_types_lint)]
pub struct UnnameableTypesLint<'a> {
pub(crate) struct UnnameableTypesLint<'a> {
#[label]
pub span: Span,
pub kind: &'a str,
@ -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,

View File

@ -6,6 +6,7 @@
#![feature(let_chains)]
#![feature(rustdoc_internals)]
#![feature(try_blocks)]
#![warn(unreachable_pub)]
// tidy-alphabetical-end
mod errors;
@ -1497,7 +1498,7 @@ fn get(&self, def_id: LocalDefId) -> Option<EffectiveVisibility> {
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);