mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-21 22:34:05 +00:00
Add warn(unreachable_pub)
to rustc_privacy
.
This commit is contained in:
parent
653ee7bc3a
commit
71bffef4f9
@ -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,
|
||||
@ -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,
|
||||
|
@ -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 @@ 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);
|
||||
|
Loading…
Reference in New Issue
Block a user