Skip to content

Commit 71bffef

Browse files
committed
Add warn(unreachable_pub) to rustc_privacy.
1 parent 653ee7b commit 71bffef

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

compiler/rustc_privacy/src/errors.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use rustc_span::{Span, Symbol};
55

66
#[derive(Diagnostic)]
77
#[diag(privacy_field_is_private, code = E0451)]
8-
pub struct FieldIsPrivate {
8+
pub(crate) struct FieldIsPrivate {
99
#[primary_span]
1010
pub span: Span,
1111
pub field_name: Symbol,
@@ -16,7 +16,7 @@ pub struct FieldIsPrivate {
1616
}
1717

1818
#[derive(Subdiagnostic)]
19-
pub enum FieldIsPrivateLabel {
19+
pub(crate) enum FieldIsPrivateLabel {
2020
#[label(privacy_field_is_private_is_update_syntax_label)]
2121
IsUpdateSyntax {
2222
#[primary_span]
@@ -32,7 +32,7 @@ pub enum FieldIsPrivateLabel {
3232

3333
#[derive(Diagnostic)]
3434
#[diag(privacy_item_is_private)]
35-
pub struct ItemIsPrivate<'a> {
35+
pub(crate) struct ItemIsPrivate<'a> {
3636
#[primary_span]
3737
#[label]
3838
pub span: Span,
@@ -42,15 +42,15 @@ pub struct ItemIsPrivate<'a> {
4242

4343
#[derive(Diagnostic)]
4444
#[diag(privacy_unnamed_item_is_private)]
45-
pub struct UnnamedItemIsPrivate {
45+
pub(crate) struct UnnamedItemIsPrivate {
4646
#[primary_span]
4747
pub span: Span,
4848
pub kind: &'static str,
4949
}
5050

5151
#[derive(Diagnostic)]
5252
#[diag(privacy_in_public_interface, code = E0446)]
53-
pub struct InPublicInterface<'a> {
53+
pub(crate) struct InPublicInterface<'a> {
5454
#[primary_span]
5555
#[label]
5656
pub span: Span,
@@ -63,23 +63,23 @@ pub struct InPublicInterface<'a> {
6363

6464
#[derive(Diagnostic)]
6565
#[diag(privacy_report_effective_visibility)]
66-
pub struct ReportEffectiveVisibility {
66+
pub(crate) struct ReportEffectiveVisibility {
6767
#[primary_span]
6868
pub span: Span,
6969
pub descr: String,
7070
}
7171

7272
#[derive(LintDiagnostic)]
7373
#[diag(privacy_from_private_dep_in_public_interface)]
74-
pub struct FromPrivateDependencyInPublicInterface<'a> {
74+
pub(crate) struct FromPrivateDependencyInPublicInterface<'a> {
7575
pub kind: &'a str,
7676
pub descr: DiagArgFromDisplay<'a>,
7777
pub krate: Symbol,
7878
}
7979

8080
#[derive(LintDiagnostic)]
8181
#[diag(privacy_unnameable_types_lint)]
82-
pub struct UnnameableTypesLint<'a> {
82+
pub(crate) struct UnnameableTypesLint<'a> {
8383
#[label]
8484
pub span: Span,
8585
pub kind: &'a str,
@@ -93,7 +93,7 @@ pub struct UnnameableTypesLint<'a> {
9393
// See https://rust-lang.github.io/rfcs/2145-type-privacy.html for more details.
9494
#[derive(LintDiagnostic)]
9595
#[diag(privacy_private_interface_or_bounds_lint)]
96-
pub struct PrivateInterfacesOrBoundsLint<'a> {
96+
pub(crate) struct PrivateInterfacesOrBoundsLint<'a> {
9797
#[label(privacy_item_label)]
9898
pub item_span: Span,
9999
pub item_kind: &'a str,

compiler/rustc_privacy/src/lib.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#![feature(let_chains)]
77
#![feature(rustdoc_internals)]
88
#![feature(try_blocks)]
9+
#![warn(unreachable_pub)]
910
// tidy-alphabetical-end
1011

1112
mod errors;
@@ -1497,7 +1498,7 @@ impl<'tcx> PrivateItemsInPublicInterfacesChecker<'tcx, '_> {
14971498
self.effective_visibilities.effective_vis(def_id).copied()
14981499
}
14991500

1500-
pub fn check_item(&mut self, id: ItemId) {
1501+
fn check_item(&mut self, id: ItemId) {
15011502
let tcx = self.tcx;
15021503
let def_id = id.owner_id.def_id;
15031504
let item_visibility = tcx.local_visibility(def_id);

0 commit comments

Comments
 (0)