diff options
| author | Nicholas Nethercote <n.nethercote@gmail.com> | 2025-03-06 11:53:30 +1100 |
|---|---|---|
| committer | Nicholas Nethercote <n.nethercote@gmail.com> | 2025-03-08 08:41:09 +1100 |
| commit | beba32cebb4fb2ef8f02c4fc898a9d31f1b03c61 (patch) | |
| tree | ca3ac2faf7f66cbae78a3b32071dfec19a7436cd /src | |
| parent | a8eeb4b53b9ea3b8e67e5c6526fe04ba8e93431f (diff) | |
| download | rust-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 'src')
| -rw-r--r-- | src/bootstrap/src/core/builder/cargo.rs | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/bootstrap/src/core/builder/cargo.rs b/src/bootstrap/src/core/builder/cargo.rs index d1d52d82eaa..18154007436 100644 --- a/src/bootstrap/src/core/builder/cargo.rs +++ b/src/bootstrap/src/core/builder/cargo.rs @@ -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 { |
