Skip to content

Commit 48caf81

Browse files
authored
Rollup merge of #138084 - nnethercote:workspace-lints, r=jieyouxu
Use workspace lints for crates in `compiler/` This is nicer and hopefully less error prone than specifying lints via bootstrap. r? ``@jieyouxu``
2 parents c666287 + 8a3e033 commit 48caf81

File tree

144 files changed

+252
-90
lines changed

Some content is hidden

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

144 files changed

+252
-90
lines changed

Cargo.toml

+14
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,20 @@ exclude = [
6363
"src/tools/x",
6464
]
6565

66+
# These lints are applied to many crates in the workspace. In practice, this is
67+
# all crates under `compiler/`.
68+
#
69+
# NOTE: rustc-specific lints (e.g. `rustc::internal`) aren't supported by
70+
# Cargo. (Support for them is possibly blocked by #44690 (attributes for
71+
# tools).) Those lints are instead specified for `compiler/` crates in
72+
# `src/bootstrap/src/core/builder/cargo.rs`.
73+
[workspace.lints.rust]
74+
# FIXME(edition_2024): Change this to `-Wrust_2024_idioms` when all of the
75+
# individual lints are satisfied.
76+
keyword_idents_2024 = "warn"
77+
unreachable_pub = "warn"
78+
unsafe_op_in_unsafe_fn = "warn"
79+
6680
[profile.release.package.rustc-rayon-core]
6781
# The rustc fork of Rayon has deadlock detection code which intermittently
6882
# causes overflows in the CI (see https://github.com/rust-lang/rust/issues/90227)

compiler/rustc/Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,6 @@ llvm = ['rustc_driver_impl/llvm']
3232
max_level_info = ['rustc_driver_impl/max_level_info']
3333
rustc_randomized_layouts = ['rustc_driver_impl/rustc_randomized_layouts']
3434
# tidy-alphabetical-end
35+
36+
[lints]
37+
workspace = true

compiler/rustc_abi/Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,6 @@ nightly = [
3131
]
3232
randomize = ["dep:rand", "dep:rand_xoshiro", "nightly"]
3333
# tidy-alphabetical-end
34+
35+
[lints]
36+
workspace = true

compiler/rustc_abi/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
#![cfg_attr(feature = "nightly", feature(rustc_attrs))]
66
#![cfg_attr(feature = "nightly", feature(rustdoc_internals))]
77
#![cfg_attr(feature = "nightly", feature(step_trait))]
8-
#![warn(unreachable_pub)]
98
// tidy-alphabetical-end
109

1110
/*! ABI handling for rustc

compiler/rustc_arena/Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,6 @@ edition = "2024"
77
# tidy-alphabetical-start
88
smallvec = { version = "1.8.1", features = ["union", "may_dangle"] }
99
# tidy-alphabetical-end
10+
11+
[lints]
12+
workspace = true

compiler/rustc_arena/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
#![feature(maybe_uninit_slice)]
2424
#![feature(rustc_attrs)]
2525
#![feature(rustdoc_internals)]
26-
#![warn(unreachable_pub)]
2726
// tidy-alphabetical-end
2827

2928
use std::alloc::Layout;

compiler/rustc_ast/Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,6 @@ smallvec = { version = "1.8.1", features = ["union", "may_dangle"] }
1818
thin-vec = "0.2.12"
1919
tracing = "0.1"
2020
# tidy-alphabetical-end
21+
22+
[lints]
23+
workspace = true

compiler/rustc_ast/src/lib.rs

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

2524
pub mod util {

compiler/rustc_ast_ir/Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,6 @@ nightly = [
1919
"dep:rustc_macros",
2020
"dep:rustc_span",
2121
]
22+
23+
[lints]
24+
workspace = true

compiler/rustc_ast_ir/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
#![cfg_attr(feature = "nightly", allow(internal_features))]
1010
#![cfg_attr(feature = "nightly", feature(never_type))]
1111
#![cfg_attr(feature = "nightly", feature(rustc_attrs))]
12-
#![warn(unreachable_pub)]
1312
// tidy-alphabetical-end
1413

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

compiler/rustc_ast_lowering/Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,6 @@ smallvec = { version = "1.8.1", features = ["union", "may_dangle"] }
2828
thin-vec = "0.2.12"
2929
tracing = "0.1"
3030
# tidy-alphabetical-end
31+
32+
[lints]
33+
workspace = true

compiler/rustc_ast_lowering/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
#![feature(if_let_guard)]
3939
#![feature(let_chains)]
4040
#![feature(rustdoc_internals)]
41-
#![warn(unreachable_pub)]
4241
// tidy-alphabetical-end
4342

4443
use std::sync::Arc;

compiler/rustc_ast_passes/Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,6 @@ rustc_session = { path = "../rustc_session" }
2020
rustc_span = { path = "../rustc_span" }
2121
thin-vec = "0.2.12"
2222
# tidy-alphabetical-end
23+
24+
[lints]
25+
workspace = true

compiler/rustc_ast_passes/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#![feature(iter_is_partitioned)]
1111
#![feature(let_chains)]
1212
#![feature(rustdoc_internals)]
13-
#![warn(unreachable_pub)]
1413
// tidy-alphabetical-end
1514

1615
pub mod ast_validation;

compiler/rustc_ast_pretty/Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,6 @@ rustc_lexer = { path = "../rustc_lexer" }
1212
rustc_span = { path = "../rustc_span" }
1313
thin-vec = "0.2.12"
1414
# tidy-alphabetical-end
15+
16+
[lints]
17+
workspace = true

compiler/rustc_ast_pretty/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
#![doc(rust_logo)]
44
#![feature(box_patterns)]
55
#![feature(rustdoc_internals)]
6-
#![warn(unreachable_pub)]
76
// tidy-alphabetical-end
87

98
mod helpers;

compiler/rustc_attr_data_structures/Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,6 @@ rustc_serialize = {path = "../rustc_serialize"}
1414
rustc_span = {path = "../rustc_span"}
1515
thin-vec = "0.2.12"
1616
# tidy-alphabetical-end
17+
18+
[lints]
19+
workspace = true

compiler/rustc_attr_data_structures/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
#![doc(rust_logo)]
44
#![feature(let_chains)]
55
#![feature(rustdoc_internals)]
6-
#![warn(unreachable_pub)]
76
// tidy-alphabetical-end
87

98
mod attributes;

compiler/rustc_attr_parsing/Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,6 @@ rustc_session = { path = "../rustc_session" }
2121
rustc_span = { path = "../rustc_span" }
2222
thin-vec = "0.2.12"
2323
# tidy-alphabetical-end
24+
25+
[lints]
26+
workspace = true

compiler/rustc_attr_parsing/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@
8080
#![doc(rust_logo)]
8181
#![feature(let_chains)]
8282
#![feature(rustdoc_internals)]
83-
#![warn(unreachable_pub)]
8483
// tidy-alphabetical-end
8584

8685
#[macro_use]

compiler/rustc_baked_icu_data/Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,6 @@ icu_locid_transform = "1.3.2"
1111
icu_provider = { version = "1.2", features = ["sync"] }
1212
zerovec = "0.10.0"
1313
# tidy-alphabetical-end
14+
15+
[lints]
16+
workspace = true

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_borrowck/Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,6 @@ rustc_traits = { path = "../rustc_traits" }
2727
smallvec = { version = "1.8.1", features = ["union", "may_dangle"] }
2828
tracing = "0.1"
2929
# tidy-alphabetical-end
30+
31+
[lints]
32+
workspace = true

compiler/rustc_borrowck/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
#![feature(rustdoc_internals)]
1414
#![feature(stmt_expr_attributes)]
1515
#![feature(try_blocks)]
16-
#![warn(unreachable_pub)]
1716
// tidy-alphabetical-end
1817

1918
use std::borrow::Cow;

compiler/rustc_builtin_macros/Cargo.toml

+3-4
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@ name = "rustc_builtin_macros"
33
version = "0.0.0"
44
edition = "2024"
55

6-
7-
[lints.rust]
8-
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(llvm_enzyme)'] }
9-
106
[lib]
117
doctest = false
128

@@ -34,3 +30,6 @@ smallvec = { version = "1.8.1", features = ["union", "may_dangle"] }
3430
thin-vec = "0.2.12"
3531
tracing = "0.1"
3632
# tidy-alphabetical-end
33+
34+
[lints]
35+
workspace = true

compiler/rustc_builtin_macros/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
#![feature(rustdoc_internals)]
1919
#![feature(string_from_utf8_lossy_owned)]
2020
#![feature(try_blocks)]
21-
#![warn(unreachable_pub)]
2221
// tidy-alphabetical-end
2322

2423
extern crate proc_macro;

compiler/rustc_codegen_llvm/Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,6 @@ serde_json = "1"
4343
smallvec = { version = "1.8.1", features = ["union", "may_dangle"] }
4444
tracing = "0.1"
4545
# tidy-alphabetical-end
46+
47+
[lints]
48+
workspace = true

compiler/rustc_codegen_llvm/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
#![feature(rustdoc_internals)]
2020
#![feature(slice_as_array)]
2121
#![feature(try_blocks)]
22-
#![warn(unreachable_pub)]
2322
// tidy-alphabetical-end
2423

2524
use std::any::Any;

compiler/rustc_codegen_ssa/Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,6 @@ features = ["read_core", "elf", "macho", "pe", "xcoff", "unaligned", "archive",
6363
[target.'cfg(windows)'.dependencies.windows]
6464
version = "0.59.0"
6565
features = ["Win32_Globalization"]
66+
67+
[lints]
68+
workspace = true

compiler/rustc_codegen_ssa/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
#![feature(rustdoc_internals)]
1515
#![feature(trait_alias)]
1616
#![feature(try_blocks)]
17-
#![warn(unreachable_pub)]
1817
// tidy-alphabetical-end
1918

2019
//! This crate contains codegen code that is used by all codegen backends (LLVM and others).

compiler/rustc_const_eval/Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,6 @@ rustc_trait_selection = { path = "../rustc_trait_selection" }
2626
rustc_type_ir = { path = "../rustc_type_ir" }
2727
tracing = "0.1"
2828
# tidy-alphabetical-end
29+
30+
[lints]
31+
workspace = true

compiler/rustc_const_eval/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
#![feature(unqualified_local_imports)]
1717
#![feature(yeet_expr)]
1818
#![warn(unqualified_local_imports)]
19-
#![warn(unreachable_pub)]
2019
// tidy-alphabetical-end
2120

2221
pub mod check_consts;

compiler/rustc_data_structures/Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,6 @@ memmap2 = "0.2.1"
5454

5555
[target.'cfg(not(target_has_atomic = "64"))'.dependencies]
5656
portable-atomic = "1.5.1"
57+
58+
[lints]
59+
workspace = true

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_driver/Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,6 @@ crate-type = ["dylib"]
1010
# tidy-alphabetical-start
1111
rustc_driver_impl = { path = "../rustc_driver_impl" }
1212
# tidy-alphabetical-end
13+
14+
[lints]
15+
workspace = true

compiler/rustc_driver_impl/Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,6 @@ rustc_randomized_layouts = [
7979
'rustc_middle/rustc_randomized_layouts'
8080
]
8181
# tidy-alphabetical-end
82+
83+
[lints]
84+
workspace = true

compiler/rustc_driver_impl/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
#![feature(result_flattening)]
1717
#![feature(rustdoc_internals)]
1818
#![feature(try_blocks)]
19-
#![warn(unreachable_pub)]
2019
// tidy-alphabetical-end
2120

2221
use std::cmp::max;

compiler/rustc_error_codes/Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,6 @@ edition = "2024"
66
[dependencies]
77
# tidy-alphabetical-start
88
# tidy-alphabetical-end
9+
10+
[lints]
11+
workspace = true

compiler/rustc_error_codes/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
#![deny(rustdoc::invalid_codeblock_attributes)]
77
#![doc(rust_logo)]
88
#![feature(rustdoc_internals)]
9-
#![warn(unreachable_pub)]
109
// tidy-alphabetical-end
1110

1211
// This higher-order macro defines the error codes that are in use. It is used

compiler/rustc_error_messages/Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,6 @@ rustc_span = { path = "../rustc_span" }
1919
tracing = "0.1"
2020
unic-langid = { version = "0.9.0", features = ["macros"] }
2121
# tidy-alphabetical-end
22+
23+
[lints]
24+
workspace = true

compiler/rustc_error_messages/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
#![feature(rustc_attrs)]
55
#![feature(rustdoc_internals)]
66
#![feature(type_alias_impl_trait)]
7-
#![warn(unreachable_pub)]
87
// tidy-alphabetical-end
98

109
use std::borrow::Cow;

compiler/rustc_errors/Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,6 @@ features = [
3939
"Win32_Security",
4040
"Win32_System_Threading",
4141
]
42+
43+
[lints]
44+
workspace = true

compiler/rustc_errors/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
#![feature(trait_alias)]
2626
#![feature(try_blocks)]
2727
#![feature(yeet_expr)]
28-
#![warn(unreachable_pub)]
2928
// tidy-alphabetical-end
3029

3130
extern crate self as rustc_errors;

0 commit comments

Comments
 (0)