mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-13 20:46:48 +00:00
Specify rust lints for compiler/
crates via Cargo.
By naming them in `[workspace.lints.rust]` in the top-level `Cargo.toml`, and then making all `compiler/` crates inherit them with `[lints] workspace = true`. (I omitted `rustc_codegen_{cranelift,gcc}`, because they're a bit different.) The advantages of this over the current approach: - It uses a standard Cargo feature, rather than special handling in bootstrap. So, easier to understand, and less likely to get accidentally broken in the future. - It works for proc macro crates. It's a shame it doesn't work for rustc-specific lints, as the comments explain.
This commit is contained in:
parent
a8eeb4b53b
commit
beba32cebb
13
Cargo.toml
13
Cargo.toml
@ -63,6 +63,19 @@ exclude = [
|
||||
"src/tools/x",
|
||||
]
|
||||
|
||||
# These lints are applied to many crates in the workspace. In practice, this is
|
||||
# all crates under `compiler/`.
|
||||
#
|
||||
# NOTE: rustc-specific lints (e.g. `rustc::internal`) aren't supported by
|
||||
# Cargo. (Support for them is possibly blocked by #44690 (attributes for
|
||||
# tools).) Those lints are instead specified for `compiler/` crates in
|
||||
# `src/bootstrap/src/core/builder/cargo.rs`.
|
||||
[workspace.lints.rust]
|
||||
# FIXME(edition_2024): Change this to `-Wrust_2024_idioms` when all of the
|
||||
# individual lints are satisfied.
|
||||
keyword_idents_2024 = "warn"
|
||||
unsafe_op_in_unsafe_fn = "warn"
|
||||
|
||||
[profile.release.package.rustc-rayon-core]
|
||||
# The rustc fork of Rayon has deadlock detection code which intermittently
|
||||
# causes overflows in the CI (see https://github.com/rust-lang/rust/issues/90227)
|
||||
|
@ -32,3 +32,6 @@ llvm = ['rustc_driver_impl/llvm']
|
||||
max_level_info = ['rustc_driver_impl/max_level_info']
|
||||
rustc_randomized_layouts = ['rustc_driver_impl/rustc_randomized_layouts']
|
||||
# tidy-alphabetical-end
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
@ -31,3 +31,6 @@ nightly = [
|
||||
]
|
||||
randomize = ["dep:rand", "dep:rand_xoshiro", "nightly"]
|
||||
# tidy-alphabetical-end
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
@ -7,3 +7,6 @@ edition = "2024"
|
||||
# tidy-alphabetical-start
|
||||
smallvec = { version = "1.8.1", features = ["union", "may_dangle"] }
|
||||
# tidy-alphabetical-end
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
@ -18,3 +18,6 @@ smallvec = { version = "1.8.1", features = ["union", "may_dangle"] }
|
||||
thin-vec = "0.2.12"
|
||||
tracing = "0.1"
|
||||
# tidy-alphabetical-end
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
@ -19,3 +19,6 @@ nightly = [
|
||||
"dep:rustc_macros",
|
||||
"dep:rustc_span",
|
||||
]
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
@ -28,3 +28,6 @@ smallvec = { version = "1.8.1", features = ["union", "may_dangle"] }
|
||||
thin-vec = "0.2.12"
|
||||
tracing = "0.1"
|
||||
# tidy-alphabetical-end
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
@ -20,3 +20,6 @@ rustc_session = { path = "../rustc_session" }
|
||||
rustc_span = { path = "../rustc_span" }
|
||||
thin-vec = "0.2.12"
|
||||
# tidy-alphabetical-end
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
@ -12,3 +12,6 @@ rustc_lexer = { path = "../rustc_lexer" }
|
||||
rustc_span = { path = "../rustc_span" }
|
||||
thin-vec = "0.2.12"
|
||||
# tidy-alphabetical-end
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
@ -14,3 +14,6 @@ rustc_serialize = {path = "../rustc_serialize"}
|
||||
rustc_span = {path = "../rustc_span"}
|
||||
thin-vec = "0.2.12"
|
||||
# tidy-alphabetical-end
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
@ -21,3 +21,6 @@ rustc_session = { path = "../rustc_session" }
|
||||
rustc_span = { path = "../rustc_span" }
|
||||
thin-vec = "0.2.12"
|
||||
# tidy-alphabetical-end
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
@ -11,3 +11,6 @@ icu_locid_transform = "1.3.2"
|
||||
icu_provider = { version = "1.2", features = ["sync"] }
|
||||
zerovec = "0.10.0"
|
||||
# tidy-alphabetical-end
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
@ -27,3 +27,6 @@ rustc_traits = { path = "../rustc_traits" }
|
||||
smallvec = { version = "1.8.1", features = ["union", "may_dangle"] }
|
||||
tracing = "0.1"
|
||||
# tidy-alphabetical-end
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
@ -30,3 +30,6 @@ smallvec = { version = "1.8.1", features = ["union", "may_dangle"] }
|
||||
thin-vec = "0.2.12"
|
||||
tracing = "0.1"
|
||||
# tidy-alphabetical-end
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
@ -43,3 +43,6 @@ serde_json = "1"
|
||||
smallvec = { version = "1.8.1", features = ["union", "may_dangle"] }
|
||||
tracing = "0.1"
|
||||
# tidy-alphabetical-end
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
@ -63,3 +63,6 @@ features = ["read_core", "elf", "macho", "pe", "xcoff", "unaligned", "archive",
|
||||
[target.'cfg(windows)'.dependencies.windows]
|
||||
version = "0.59.0"
|
||||
features = ["Win32_Globalization"]
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
@ -26,3 +26,6 @@ rustc_trait_selection = { path = "../rustc_trait_selection" }
|
||||
rustc_type_ir = { path = "../rustc_type_ir" }
|
||||
tracing = "0.1"
|
||||
# tidy-alphabetical-end
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
@ -54,3 +54,6 @@ memmap2 = "0.2.1"
|
||||
|
||||
[target.'cfg(not(target_has_atomic = "64"))'.dependencies]
|
||||
portable-atomic = "1.5.1"
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
@ -10,3 +10,6 @@ crate-type = ["dylib"]
|
||||
# tidy-alphabetical-start
|
||||
rustc_driver_impl = { path = "../rustc_driver_impl" }
|
||||
# tidy-alphabetical-end
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
@ -79,3 +79,6 @@ rustc_randomized_layouts = [
|
||||
'rustc_middle/rustc_randomized_layouts'
|
||||
]
|
||||
# tidy-alphabetical-end
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
@ -6,3 +6,6 @@ edition = "2024"
|
||||
[dependencies]
|
||||
# tidy-alphabetical-start
|
||||
# tidy-alphabetical-end
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
@ -19,3 +19,6 @@ rustc_span = { path = "../rustc_span" }
|
||||
tracing = "0.1"
|
||||
unic-langid = { version = "0.9.0", features = ["macros"] }
|
||||
# tidy-alphabetical-end
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
@ -39,3 +39,6 @@ features = [
|
||||
"Win32_Security",
|
||||
"Win32_System_Threading",
|
||||
]
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
@ -29,3 +29,6 @@ smallvec = { version = "1.8.1", features = ["union", "may_dangle"] }
|
||||
thin-vec = "0.2.12"
|
||||
tracing = "0.1"
|
||||
# tidy-alphabetical-end
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
@ -10,3 +10,6 @@ rustc_span = { path = "../rustc_span" }
|
||||
serde = { version = "1.0.125", features = [ "derive" ] }
|
||||
serde_json = "1.0.59"
|
||||
# tidy-alphabetical-end
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
@ -16,3 +16,6 @@ quote = "1"
|
||||
syn = { version = "2", features = ["full"] }
|
||||
unic-langid = { version = "0.9.0", features = ["macros"] }
|
||||
# tidy-alphabetical-end
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
@ -6,3 +6,6 @@ edition = "2024"
|
||||
[dependencies]
|
||||
# tidy-alphabetical-start
|
||||
# tidy-alphabetical-end
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
@ -6,3 +6,6 @@ edition = "2024"
|
||||
[dependencies]
|
||||
# tidy-alphabetical-start
|
||||
# tidy-alphabetical-end
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
@ -7,3 +7,6 @@ edition = "2024"
|
||||
# tidy-alphabetical-start
|
||||
rustc-stable-hash = { version = "0.1.0" }
|
||||
# tidy-alphabetical-end
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
@ -21,3 +21,6 @@ smallvec = { version = "1.8.1", features = ["union", "may_dangle"] }
|
||||
thin-vec = "0.2.12"
|
||||
tracing = "0.1"
|
||||
# tidy-alphabetical-end
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
@ -32,3 +32,6 @@ rustc_type_ir = { path = "../rustc_type_ir" }
|
||||
smallvec = { version = "1.8.1", features = ["union", "may_dangle"] }
|
||||
tracing = "0.1"
|
||||
# tidy-alphabetical-end
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
@ -12,3 +12,6 @@ rustc_attr_parsing = { path = "../rustc_attr_parsing" }
|
||||
rustc_hir = { path = "../rustc_hir" }
|
||||
rustc_span = { path = "../rustc_span" }
|
||||
# tidy-alphabetical-end
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
@ -27,3 +27,6 @@ rustc_type_ir = { path = "../rustc_type_ir" }
|
||||
smallvec = { version = "1.8.1", features = ["union", "may_dangle"] }
|
||||
tracing = "0.1"
|
||||
# tidy-alphabetical-end
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
@ -22,3 +22,6 @@ rustc_span = { path = "../rustc_span" }
|
||||
thin-vec = "0.2.12"
|
||||
tracing = "0.1"
|
||||
# tidy-alphabetical-end
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
@ -21,3 +21,6 @@ nightly = [
|
||||
]
|
||||
rustc_randomized_layouts = []
|
||||
# tidy-alphabetical-end
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
@ -13,3 +13,6 @@ quote = "1"
|
||||
|
||||
[features]
|
||||
nightly = []
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
@ -21,3 +21,6 @@ smallvec = { version = "1.8.1", features = ["union", "may_dangle"] }
|
||||
thin-vec = "0.2.12"
|
||||
tracing = "0.1"
|
||||
# tidy-alphabetical-end
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
@ -56,3 +56,6 @@ tracing = "0.1"
|
||||
# tidy-alphabetical-start
|
||||
llvm = ['dep:rustc_codegen_llvm']
|
||||
# tidy-alphabetical-end
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
@ -24,3 +24,6 @@ features = ["emoji"]
|
||||
|
||||
[dev-dependencies]
|
||||
expect-test = "1.4.0"
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
@ -28,3 +28,6 @@ smallvec = { version = "1.8.1", features = ["union", "may_dangle"] }
|
||||
tracing = "0.1"
|
||||
unicode-security = "0.1.0"
|
||||
# tidy-alphabetical-end
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
@ -15,3 +15,6 @@ rustc_serialize = { path = "../rustc_serialize" }
|
||||
rustc_span = { path = "../rustc_span" }
|
||||
serde = { version = "1.0.125", features = ["derive"] }
|
||||
# tidy-alphabetical-end
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
@ -14,3 +14,6 @@ libc = "0.2.73"
|
||||
# pinned `cc` in `rustc_codegen_ssa` if you update `cc` here.
|
||||
cc = "=1.2.16"
|
||||
# tidy-alphabetical-end
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
@ -20,3 +20,6 @@ rustc_span = { path = "../rustc_span" }
|
||||
# tidy-alphabetical-start
|
||||
max_level_info = ['tracing/max_level_info']
|
||||
# tidy-alphabetical-end
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
@ -13,3 +13,6 @@ quote = "1"
|
||||
syn = { version = "2.0.9", features = ["full"] }
|
||||
synstructure = "0.13.0"
|
||||
# tidy-alphabetical-end
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
@ -31,3 +31,6 @@ rustc_type_ir = { path = "../rustc_type_ir" }
|
||||
tempfile = "3.2"
|
||||
tracing = "0.1"
|
||||
# tidy-alphabetical-end
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
@ -42,3 +42,6 @@ tracing = "0.1"
|
||||
# tidy-alphabetical-start
|
||||
rustc_randomized_layouts = []
|
||||
# tidy-alphabetical-end
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
@ -28,3 +28,6 @@ rustc_span = { path = "../rustc_span" }
|
||||
rustc_trait_selection = { path = "../rustc_trait_selection" }
|
||||
tracing = "0.1"
|
||||
# tidy-alphabetical-end
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
@ -21,3 +21,6 @@ rustc_span = { path = "../rustc_span" }
|
||||
smallvec = { version = "1.8.1", features = ["union", "may_dangle"] }
|
||||
tracing = "0.1"
|
||||
# tidy-alphabetical-end
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
@ -30,3 +30,6 @@ rustc_type_ir = { path = "../rustc_type_ir" }
|
||||
smallvec = { version = "1.8.1", features = ["union", "may_dangle"] }
|
||||
tracing = "0.1"
|
||||
# tidy-alphabetical-end
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
@ -22,3 +22,6 @@ serde = "1"
|
||||
serde_json = "1"
|
||||
tracing = "0.1"
|
||||
# tidy-alphabetical-end
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
@ -24,3 +24,6 @@ nightly = [
|
||||
"rustc_index/nightly",
|
||||
"rustc_type_ir/nightly",
|
||||
]
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
@ -26,3 +26,5 @@ unicode-width = "0.2.0"
|
||||
[dev-dependencies]
|
||||
termcolor = "1.2"
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
@ -8,3 +8,6 @@ edition = "2024"
|
||||
rustc_index = { path = "../rustc_index", default-features = false }
|
||||
rustc_lexer = { path = "../rustc_lexer" }
|
||||
# tidy-alphabetical-end
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
@ -26,3 +26,6 @@ rustc_target = { path = "../rustc_target" }
|
||||
rustc_trait_selection = { path = "../rustc_trait_selection" }
|
||||
tracing = "0.1"
|
||||
# tidy-alphabetical-end
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
@ -43,3 +43,6 @@ rustc = [
|
||||
"smallvec/may_dangle",
|
||||
"rustc_index/nightly",
|
||||
]
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
@ -18,3 +18,6 @@ rustc_span = { path = "../rustc_span" }
|
||||
rustc_ty_utils = { path = "../rustc_ty_utils" }
|
||||
tracing = "0.1"
|
||||
# tidy-alphabetical-end
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
@ -20,3 +20,6 @@ rustc_span = { path = "../rustc_span" }
|
||||
thin-vec = "0.2.12"
|
||||
tracing = "0.1"
|
||||
# tidy-alphabetical-end
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
@ -25,3 +25,6 @@ smallvec = { version = "1.8.1", features = ["union", "may_dangle"] }
|
||||
thin-vec = "0.2.12"
|
||||
tracing = "0.1"
|
||||
# tidy-alphabetical-end
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
@ -28,3 +28,6 @@ smallvec = { version = "1.8.1", features = ["union", "may_dangle"] }
|
||||
thin-vec = "0.2.12"
|
||||
tracing = "0.1"
|
||||
# tidy-alphabetical-end
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
@ -15,3 +15,6 @@ rustc_middle = { path = "../rustc_middle" }
|
||||
rustc_span = { path = "../rustc_span" }
|
||||
rustc_target = { path = "../rustc_target" }
|
||||
rustc_trait_selection = { path = "../rustc_trait_selection" }
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
@ -16,3 +16,6 @@ thin-vec = "0.2.12"
|
||||
rustc_macros = { path = "../rustc_macros" }
|
||||
tempfile = "3.2"
|
||||
# tidy-alphabetical-end
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
@ -37,3 +37,6 @@ features = [
|
||||
"Win32_Foundation",
|
||||
"Win32_System_LibraryLoader",
|
||||
]
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
@ -18,3 +18,6 @@ scoped-tls = "1.0"
|
||||
stable_mir = {path = "../stable_mir" }
|
||||
tracing = "0.1"
|
||||
# tidy-alphabetical-end
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
@ -22,3 +22,6 @@ sha2 = "0.10.1"
|
||||
tracing = "0.1"
|
||||
unicode-width = "0.2.0"
|
||||
# tidy-alphabetical-end
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
@ -19,3 +19,6 @@ rustc_session = { path = "../rustc_session" }
|
||||
rustc_span = { path = "../rustc_span" }
|
||||
tracing = "0.1"
|
||||
# tidy-alphabetical-end
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
@ -22,3 +22,6 @@ default-features = false
|
||||
features = ["elf", "macho"]
|
||||
version = "0.36.2"
|
||||
# tidy-alphabetical-end
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
@ -26,3 +26,6 @@ smallvec = { version = "1.8.1", features = ["union", "may_dangle"] }
|
||||
thin-vec = "0.2"
|
||||
tracing = "0.1"
|
||||
# tidy-alphabetical-end
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
@ -13,3 +13,6 @@ rustc_span = { path = "../rustc_span" }
|
||||
rustc_trait_selection = { path = "../rustc_trait_selection" }
|
||||
tracing = "0.1"
|
||||
# tidy-alphabetical-end
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
@ -25,3 +25,6 @@ rustc = [
|
||||
# tidy-alphabetical-start
|
||||
itertools = "0.12"
|
||||
# tidy-alphabetical-end
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
@ -23,3 +23,6 @@ rustc_trait_selection = { path = "../rustc_trait_selection" }
|
||||
rustc_type_ir = { path = "../rustc_type_ir" }
|
||||
tracing = "0.1"
|
||||
# tidy-alphabetical-end
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
@ -33,3 +33,6 @@ nightly = [
|
||||
"rustc_index/nightly",
|
||||
"rustc_ast_ir/nightly",
|
||||
]
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
@ -13,3 +13,6 @@ quote = "1"
|
||||
syn = { version = "2.0.9", features = ["full"] }
|
||||
synstructure = "0.13.0"
|
||||
# tidy-alphabetical-end
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
@ -6,3 +6,6 @@ edition = "2024"
|
||||
[dependencies]
|
||||
scoped-tls = "1.0"
|
||||
serde = { version = "1.0.125", features = [ "derive" ] }
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
@ -1072,12 +1072,17 @@ impl Builder<'_> {
|
||||
}
|
||||
|
||||
if mode == Mode::Rustc {
|
||||
// NOTE: rustc-specific lints are specified here. Normal rust lints
|
||||
// are specified in the `[workspace.lints.rust]` section in the
|
||||
// top-level `Cargo.toml`. If/when tool lints are supported by
|
||||
// Cargo, these lints can be move to a `[workspace.lints.rustc]`
|
||||
// section in the top-level `Cargo.toml`.
|
||||
//
|
||||
// NOTE: these flags are added to RUSTFLAGS, which is ignored when
|
||||
// compiling proc macro crates such as `rustc_macros`,
|
||||
// unfortunately.
|
||||
rustflags.arg("-Wrustc::internal");
|
||||
rustflags.arg("-Drustc::symbol_intern_string_literal");
|
||||
// FIXME(edition_2024): Change this to `-Wrust_2024_idioms` when all
|
||||
// of the individual lints are satisfied.
|
||||
rustflags.arg("-Wkeyword_idents_2024");
|
||||
rustflags.arg("-Wunsafe_op_in_unsafe_fn");
|
||||
}
|
||||
|
||||
if self.config.rust_frame_pointers {
|
||||
|
Loading…
Reference in New Issue
Block a user