about summary refs log tree commit diff
path: root/Cargo.toml
diff options
context:
space:
mode:
authorNicholas Nethercote <n.nethercote@gmail.com>2025-03-06 11:53:30 +1100
committerNicholas Nethercote <n.nethercote@gmail.com>2025-03-08 08:41:09 +1100
commitbeba32cebb4fb2ef8f02c4fc898a9d31f1b03c61 (patch)
treeca3ac2faf7f66cbae78a3b32071dfec19a7436cd /Cargo.toml
parenta8eeb4b53b9ea3b8e67e5c6526fe04ba8e93431f (diff)
downloadrust-beba32cebb4fb2ef8f02c4fc898a9d31f1b03c61.tar.gz
rust-beba32cebb4fb2ef8f02c4fc898a9d31f1b03c61.zip
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.
Diffstat (limited to 'Cargo.toml')
-rw-r--r--Cargo.toml13
1 files changed, 13 insertions, 0 deletions
diff --git a/Cargo.toml b/Cargo.toml
index 20a43aaaeeb..4e952ccfc73 100644
--- a/Cargo.toml
+++ b/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)