Skip to content

Commit ad76c6f

Browse files
authored
Unrolled build for rust-lang#126013
Rollup merge of rust-lang#126013 - nnethercote:unreachable_pub, r=Urgau Add `#[warn(unreachable_pub)]` to a bunch of compiler crates By default `unreachable_pub` identifies things that need not be `pub` and tells you to make them `pub(crate)`. But sometimes those things don't need any kind of visibility. So they way I did these was to remove the visibility entirely for each thing the lint identifies, and then add `pub(crate)` back in everywhere the compiler said it was necessary. (Or occasionally `pub(super)` when context suggested that was appropriate.) Tedious, but results in more `pub` removal. There are plenty more crates to do but this seems like enough for a first PR. r? `@compiler-errors`
2 parents 515395a + cc84442 commit ad76c6f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+503
-464
lines changed

compiler/rustc_abi/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#![cfg_attr(feature = "nightly", doc(rust_logo))]
44
#![cfg_attr(feature = "nightly", feature(rustdoc_internals))]
55
#![cfg_attr(feature = "nightly", feature(step_trait))]
6+
#![warn(unreachable_pub)]
67
// tidy-alphabetical-end
78

89
use std::fmt;

compiler/rustc_arena/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#![feature(rustc_attrs)]
2626
#![feature(rustdoc_internals)]
2727
#![feature(strict_provenance)]
28+
#![warn(unreachable_pub)]
2829
// tidy-alphabetical-end
2930

3031
use std::alloc::Layout;

compiler/rustc_arena/src/tests.rs

+11-11
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ impl<T> TypedArena<T> {
3232
}
3333

3434
#[test]
35-
pub fn test_unused() {
35+
fn test_unused() {
3636
let arena: TypedArena<Point> = TypedArena::default();
3737
assert!(arena.chunks.borrow().is_empty());
3838
}
@@ -75,7 +75,7 @@ fn test_arena_alloc_nested() {
7575
}
7676

7777
#[test]
78-
pub fn test_copy() {
78+
fn test_copy() {
7979
let arena = TypedArena::default();
8080
#[cfg(not(miri))]
8181
const N: usize = 100000;
@@ -87,13 +87,13 @@ pub fn test_copy() {
8787
}
8888

8989
#[bench]
90-
pub fn bench_copy(b: &mut Bencher) {
90+
fn bench_copy(b: &mut Bencher) {
9191
let arena = TypedArena::default();
9292
b.iter(|| arena.alloc(Point { x: 1, y: 2, z: 3 }))
9393
}
9494

9595
#[bench]
96-
pub fn bench_copy_nonarena(b: &mut Bencher) {
96+
fn bench_copy_nonarena(b: &mut Bencher) {
9797
b.iter(|| {
9898
let _: Box<_> = Box::new(Point { x: 1, y: 2, z: 3 });
9999
})
@@ -106,7 +106,7 @@ struct Noncopy {
106106
}
107107

108108
#[test]
109-
pub fn test_noncopy() {
109+
fn test_noncopy() {
110110
let arena = TypedArena::default();
111111
#[cfg(not(miri))]
112112
const N: usize = 100000;
@@ -118,7 +118,7 @@ pub fn test_noncopy() {
118118
}
119119

120120
#[test]
121-
pub fn test_typed_arena_zero_sized() {
121+
fn test_typed_arena_zero_sized() {
122122
let arena = TypedArena::default();
123123
#[cfg(not(miri))]
124124
const N: usize = 100000;
@@ -130,7 +130,7 @@ pub fn test_typed_arena_zero_sized() {
130130
}
131131

132132
#[test]
133-
pub fn test_typed_arena_clear() {
133+
fn test_typed_arena_clear() {
134134
let mut arena = TypedArena::default();
135135
for _ in 0..10 {
136136
arena.clear();
@@ -145,7 +145,7 @@ pub fn test_typed_arena_clear() {
145145
}
146146

147147
#[bench]
148-
pub fn bench_typed_arena_clear(b: &mut Bencher) {
148+
fn bench_typed_arena_clear(b: &mut Bencher) {
149149
let mut arena = TypedArena::default();
150150
b.iter(|| {
151151
arena.alloc(Point { x: 1, y: 2, z: 3 });
@@ -154,7 +154,7 @@ pub fn bench_typed_arena_clear(b: &mut Bencher) {
154154
}
155155

156156
#[bench]
157-
pub fn bench_typed_arena_clear_100(b: &mut Bencher) {
157+
fn bench_typed_arena_clear_100(b: &mut Bencher) {
158158
let mut arena = TypedArena::default();
159159
b.iter(|| {
160160
for _ in 0..100 {
@@ -230,15 +230,15 @@ fn test_typed_arena_drop_small_count() {
230230
}
231231

232232
#[bench]
233-
pub fn bench_noncopy(b: &mut Bencher) {
233+
fn bench_noncopy(b: &mut Bencher) {
234234
let arena = TypedArena::default();
235235
b.iter(|| {
236236
arena.alloc(Noncopy { string: "hello world".to_string(), array: vec![1, 2, 3, 4, 5] })
237237
})
238238
}
239239

240240
#[bench]
241-
pub fn bench_noncopy_nonarena(b: &mut Bencher) {
241+
fn bench_noncopy_nonarena(b: &mut Bencher) {
242242
b.iter(|| {
243243
let _: Box<_> =
244244
Box::new(Noncopy { string: "hello world".to_string(), array: vec![1, 2, 3, 4, 5] });

compiler/rustc_ast/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#![feature(never_type)]
2020
#![feature(rustdoc_internals)]
2121
#![feature(stmt_expr_attributes)]
22+
#![warn(unreachable_pub)]
2223
// tidy-alphabetical-end
2324

2425
pub mod util {

compiler/rustc_ast_ir/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#![cfg_attr(feature = "nightly", allow(internal_features))]
33
#![cfg_attr(feature = "nightly", feature(never_type))]
44
#![cfg_attr(feature = "nightly", feature(rustc_attrs))]
5+
#![warn(unreachable_pub)]
56
// tidy-alphabetical-end
67

78
#[cfg(feature = "nightly")]

0 commit comments

Comments
 (0)