Skip to content

Commit 9212e31

Browse files
committed
Add unreachable_pub to the default lints for compiler/ crates.
And fix the new errors in the handful of crates that didn't have a `#![warn(unreachable_pub)]`.
1 parent beba32c commit 9212e31

File tree

9 files changed

+16
-15
lines changed

9 files changed

+16
-15
lines changed

Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ exclude = [
7474
# FIXME(edition_2024): Change this to `-Wrust_2024_idioms` when all of the
7575
# individual lints are satisfied.
7676
keyword_idents_2024 = "warn"
77+
unreachable_pub = "warn"
7778
unsafe_op_in_unsafe_fn = "warn"
7879

7980
[profile.release.package.rustc-rayon-core]

compiler/rustc_baked_icu_data/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@
2323
// tidy-alphabetical-start
2424
#![allow(elided_lifetimes_in_paths)]
2525
#![allow(internal_features)]
26+
#![allow(unreachable_pub)] // because this crate is mostly generated code
2627
#![doc(rust_logo)]
2728
#![feature(rustdoc_internals)]
28-
// #![warn(unreachable_pub)] // don't use because this crate is mostly generated code
2929
// tidy-alphabetical-end
3030

3131
mod data {

compiler/rustc_data_structures/src/graph/tests.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@ use std::cmp::max;
33
use super::*;
44
use crate::fx::FxHashMap;
55

6-
pub struct TestGraph {
6+
pub(super) struct TestGraph {
77
num_nodes: usize,
88
start_node: usize,
99
successors: FxHashMap<usize, Vec<usize>>,
1010
predecessors: FxHashMap<usize, Vec<usize>>,
1111
}
1212

1313
impl TestGraph {
14-
pub fn new(start_node: usize, edges: &[(usize, usize)]) -> Self {
14+
pub(super) fn new(start_node: usize, edges: &[(usize, usize)]) -> Self {
1515
let mut graph = TestGraph {
1616
num_nodes: start_node + 1,
1717
start_node,

compiler/rustc_data_structures/src/obligation_forest/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ pub struct Error<O, E> {
313313

314314
mod helper {
315315
use super::*;
316-
pub type ObligationTreeIdGenerator = impl Iterator<Item = ObligationTreeId>;
316+
pub(super) type ObligationTreeIdGenerator = impl Iterator<Item = ObligationTreeId>;
317317
impl<O: ForestObligation> ObligationForest<O> {
318318
pub fn new() -> ObligationForest<O> {
319319
ObligationForest {

compiler/rustc_data_structures/src/sync.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ mod mode {
8888

8989
// Whether thread safety might be enabled.
9090
#[inline]
91-
pub fn might_be_dyn_thread_safe() -> bool {
91+
pub(super) fn might_be_dyn_thread_safe() -> bool {
9292
DYN_THREAD_SAFE_MODE.load(Ordering::Relaxed) != DYN_NOT_THREAD_SAFE
9393
}
9494

compiler/rustc_data_structures/src/sync/parallel.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ pub fn parallel_guard<R>(f: impl FnOnce(&ParallelGuard) -> R) -> R {
4646
ret
4747
}
4848

49-
pub fn serial_join<A, B, RA, RB>(oper_a: A, oper_b: B) -> (RA, RB)
49+
fn serial_join<A, B, RA, RB>(oper_a: A, oper_b: B) -> (RA, RB)
5050
where
5151
A: FnOnce() -> RA,
5252
B: FnOnce() -> RB,

compiler/rustc_data_structures/src/tagged_ptr/tests.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use crate::stable_hasher::{HashStable, StableHasher};
77

88
/// A tag type used in [`TaggedRef`] tests.
99
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
10-
pub enum Tag2 {
10+
enum Tag2 {
1111
B00 = 0b00,
1212
B01 = 0b01,
1313
B10 = 0b10,

compiler/rustc_index_macros/src/newtype.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ impl Parse for Newtype {
305305
}
306306
}
307307

308-
pub fn newtype(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
308+
pub(crate) fn newtype(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
309309
let input = parse_macro_input!(input as Newtype);
310310
input.0.into()
311311
}

compiler/rustc_pattern_analysis/tests/common/mod.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use rustc_pattern_analysis::usefulness::{PlaceValidity, UsefulnessReport};
55
use rustc_pattern_analysis::{MatchArm, PatCx, PrivateUninhabitedField};
66

77
/// Sets up `tracing` for easier debugging. Tries to look like the `rustc` setup.
8-
pub fn init_tracing() {
8+
fn init_tracing() {
99
use tracing_subscriber::Layer;
1010
use tracing_subscriber::layer::SubscriberExt;
1111
use tracing_subscriber::util::SubscriberInitExt;
@@ -24,7 +24,7 @@ pub fn init_tracing() {
2424
/// A simple set of types.
2525
#[allow(dead_code)]
2626
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
27-
pub enum Ty {
27+
pub(super) enum Ty {
2828
/// Booleans
2929
Bool,
3030
/// 8-bit unsigned integers
@@ -41,7 +41,7 @@ pub enum Ty {
4141

4242
/// The important logic.
4343
impl Ty {
44-
pub fn sub_tys(&self, ctor: &Constructor<Cx>) -> Vec<Self> {
44+
pub(super) fn sub_tys(&self, ctor: &Constructor<Cx>) -> Vec<Self> {
4545
use Constructor::*;
4646
match (ctor, *self) {
4747
(Struct, Ty::Tuple(tys)) => tys.iter().copied().collect(),
@@ -63,7 +63,7 @@ impl Ty {
6363
}
6464
}
6565

66-
pub fn ctor_set(&self) -> ConstructorSet<Cx> {
66+
fn ctor_set(&self) -> ConstructorSet<Cx> {
6767
match *self {
6868
Ty::Bool => ConstructorSet::Bool,
6969
Ty::U8 => ConstructorSet::Integers {
@@ -104,7 +104,7 @@ impl Ty {
104104
}
105105
}
106106

107-
pub fn write_variant_name(
107+
fn write_variant_name(
108108
&self,
109109
f: &mut std::fmt::Formatter<'_>,
110110
ctor: &Constructor<Cx>,
@@ -120,7 +120,7 @@ impl Ty {
120120
}
121121

122122
/// Compute usefulness in our simple context (and set up tracing for easier debugging).
123-
pub fn compute_match_usefulness<'p>(
123+
pub(super) fn compute_match_usefulness<'p>(
124124
arms: &[MatchArm<'p, Cx>],
125125
ty: Ty,
126126
scrut_validity: PlaceValidity,
@@ -137,7 +137,7 @@ pub fn compute_match_usefulness<'p>(
137137
}
138138

139139
#[derive(Debug)]
140-
pub struct Cx;
140+
pub(super) struct Cx;
141141

142142
/// The context for pattern analysis. Forwards anything interesting to `Ty` methods.
143143
impl PatCx for Cx {

0 commit comments

Comments
 (0)