Use workspace lints for crates in compiler/#138084
Conversation
|
Maybe add a tidy check making sure that every |
There was a problem hiding this comment.
This approach seems reasonable to me. I opened #138106 to track an cleanup follow-up to handle them consistently, but is not a blocker for this PR.
EDIT: bootstrap thread: https://rust-lang.zulipchat.com/#narrow/channel/326414-t-infra.2Fbootstrap/topic/Consistent.20handling.20of.20compiler.2F*.20RUSTFLAGs.20and.20lints
| # NOTE: rustc-specific lints (e.g. `rustc::internal`) aren't supported by | ||
| # Cargo. They are specified for `compiler/` crates in | ||
| # `src/bootstrap/src/core/builder/cargo.rs`. |
There was a problem hiding this comment.
Question: do you know if we have a cargo issue to link to? Even if this isn't going to be implemented for a long time.
| // NOTE: these flags are added to RUSTFLAGS, which is ignored when | ||
| // compiling proc macro crates such as `rustc_macros`, | ||
| // unfortunately. |
There was a problem hiding this comment.
Discussion: yeah this is unfortunate.
One way to do this is by unconditionally passing an arbitrary flag and asserting its presence in each compiler crate. Ugly, but it could work I think.
We should probably investigate if we want to switch over to that approach to make sure the lints get consistently applied to all compiler crates.
There was a problem hiding this comment.
But for this PR, it's not a blocker. I find the workspace lints approach for non-internal lints still less "magical" than doing all of them here.
|
Marking as S-waiting-on-team for discussion in https://rust-lang.zulipchat.com/#narrow/channel/326414-t-infra.2Fbootstrap/topic/Consistent.20handling.20of.20compiler.2F*.20RUSTFLAGs.20and.20lints. |
2b691ff to
3d2113f
Compare
It was added in rust-lang#129523 to enable building on stable when there were `cfg(bootstrap)` occurrences in the crate. But those are gone now, so the section can be removed.
`llvm_enzyme` is now in the extra `check-cfg` list in bootstrap, so it doesn't need to be handled explicitly here.
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.
And fix the new errors in the handful of crates that didn't have a `#![warn(unreachable_pub)]`.
(Except for `rustc_codegen_cranelift`.) It's no longer necessary now that `unreachable_pub` is in the workspace lints.
3d2113f to
8a3e033
Compare
|
Some changes occurred to the CTFE machinery Some changes occurred in compiler/rustc_sanitizers cc @rust-lang/project-exploit-mitigations, @rcvalle Some changes occurred in compiler/rustc_attr_parsing Some changes occurred in exhaustiveness checking cc @Nadrieril This PR changes Stable MIR cc @oli-obk, @celinval, @ouz-a Some changes occurred to MIR optimizations cc @rust-lang/wg-mir-opt
cc @davidtwco, @compiler-errors, @TaKO8Ki Some changes occurred in compiler/rustc_attr_data_structures Some changes occurred in compiler/rustc_codegen_ssa Some changes occurred in diagnostic error codes |
|
@jieyouxu: I think this is ready to go.
|
|
Yes, I think the tidy check isn't a blocker and can be done separately. I'll file an issue so we don't forgor. @rustbot label: -S-waiting-on-team +S-waiting-on-review |
|
@bors r+ |
…youxu Use workspace lints for crates in `compiler/` This is nicer and hopefully less error prone than specifying lints via bootstrap. r? `@jieyouxu`
Rollup of 16 pull requests Successful merges: - rust-lang#122790 (Apply dllimport in ThinLTO) - rust-lang#136127 (Allow `*const W<dyn A> -> *const dyn A` ptr cast) - rust-lang#136968 (Turn order dependent trait objects future incompat warning into a hard error) - rust-lang#137147 (Add exclude to config.toml) - rust-lang#137319 (Stabilize `const_vec_string_slice`) - rust-lang#137885 (tidy: add triagebot checks) - rust-lang#138040 (compiler: Use `size_of` from the prelude instead of imported) - rust-lang#138052 (strip `-Wlinker-messages` wrappers from `rust-lld` rmake test) - rust-lang#138084 (Use workspace lints for crates in `compiler/`) - rust-lang#138158 (Move more layouting logic to `rustc_abi`) - rust-lang#138160 (depend more on attr_data_structures and move find_attr! there) - rust-lang#138192 (crashes: couple more tests) - rust-lang#138216 (bootstrap: Fix stack printing when a step cycle is detected) - rust-lang#138232 (Reduce verbosity of GCC build log) - rust-lang#138233 (Windows: Don't link std (and run-make) against advapi32, except on win7) - rust-lang#138242 (Revert "Don't test new error messages with the stage 0 compiler") r? `@ghost` `@rustbot` modify labels: rollup
…iaskrgr Rollup of 12 pull requests Successful merges: - rust-lang#136127 (Allow `*const W<dyn A> -> *const dyn A` ptr cast) - rust-lang#136968 (Turn order dependent trait objects future incompat warning into a hard error) - rust-lang#137319 (Stabilize `const_vec_string_slice`) - rust-lang#137885 (tidy: add triagebot checks) - rust-lang#138040 (compiler: Use `size_of` from the prelude instead of imported) - rust-lang#138084 (Use workspace lints for crates in `compiler/`) - rust-lang#138158 (Move more layouting logic to `rustc_abi`) - rust-lang#138160 (depend more on attr_data_structures and move find_attr! there) - rust-lang#138192 (crashes: couple more tests) - rust-lang#138216 (bootstrap: Fix stack printing when a step cycle is detected) - rust-lang#138232 (Reduce verbosity of GCC build log) - rust-lang#138242 (Revert "Don't test new error messages with the stage 0 compiler") r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#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``
Revert <rust-lang#138084> to buy time to consider options that avoids breaking downstream usages of cargo on distributed `rustc-src` artifacts, where such cargo invocations fail due to inability to inherit `lints` from workspace root manifest's `workspace.lints` (this is only valid for the source rust-lang/rust workspace, but not really the distributed `rustc-src` artifacts). This breakage was reported in <rust-lang#138304>. This reverts commit 48caf81, reversing changes made to c666287.
…=Noratrieb Revert "Use workspace lints for crates in `compiler/` rust-lang#138084" Revert <rust-lang#138084> to buy time to consider options that avoids breaking downstream usages of cargo on distributed `rustc-src` artifacts, where such cargo invocations fail due to inability to inherit `lints` from workspace root manifest's `workspace.lints` (this is only valid for the source rust-lang/rust workspace, but not really the distributed `rustc-src` artifacts). The problem is that the `rustc-src` component doesn't include the root `Cargo.toml` manifest. This breakage was reported in rust-lang#138304. This reverts commit 48caf81, reversing changes made to c666287. cc `@RalfJung` r? `@nnethercote` (sorry, I didn't consider this being a thing 💀)
…iaskrgr Rollup of 8 pull requests Successful merges: - rust-lang#137931 (Add remark for missing `llvm-tools` component re. `rustc_private` linker failures related to not finding LLVM libraries) - rust-lang#138138 (Pass `InferCtxt` to `InlineAsmCtxt` to properly taint on error) - rust-lang#138223 (Fix post-merge workflow) - rust-lang#138268 (Handle empty test suites in GitHub job summary report) - rust-lang#138278 (Delegation: fix ICE with invalid `MethodCall` generation) - rust-lang#138281 (Fix O(tests) stack usage in edition 2024 mergeable doctests) - rust-lang#138305 (Subtree update of `rust-analyzer`) - rust-lang#138306 (Revert "Use workspace lints for crates in `compiler/` rust-lang#138084") r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#138306 - jieyouxu:revert-workspace-lints, r=Noratrieb Revert "Use workspace lints for crates in `compiler/` rust-lang#138084" Revert <rust-lang#138084> to buy time to consider options that avoids breaking downstream usages of cargo on distributed `rustc-src` artifacts, where such cargo invocations fail due to inability to inherit `lints` from workspace root manifest's `workspace.lints` (this is only valid for the source rust-lang/rust workspace, but not really the distributed `rustc-src` artifacts). The problem is that the `rustc-src` component doesn't include the root `Cargo.toml` manifest. This breakage was reported in rust-lang#138304. This reverts commit 48caf81, reversing changes made to c666287. cc `@RalfJung` r? `@nnethercote` (sorry, I didn't consider this being a thing 💀)
…ore, r=onur-ozkan,jieyouxu Use `RUSTC_LINT_FLAGS` more An alternative to the failed rust-lang#138084. Fixes rust-lang#138106. r? `@jieyouxu`
…ore, r=onur-ozkan,jieyouxu Use `RUSTC_LINT_FLAGS` more An alternative to the failed rust-lang#138084. Fixes rust-lang#138106. r? ``@jieyouxu``
…ore, r=onur-ozkan,jieyouxu Use `RUSTC_LINT_FLAGS` more An alternative to the failed rust-lang#138084. Fixes rust-lang#138106. r? ```@jieyouxu```
…ore, r=onur-ozkan,jieyouxu Use `RUSTC_LINT_FLAGS` more An alternative to the failed rust-lang#138084. Fixes rust-lang#138106. r? ````@jieyouxu````
…ore, r=onur-ozkan,jieyouxu Use `RUSTC_LINT_FLAGS` more An alternative to the failed rust-lang#138084. Fixes rust-lang#138106. r? `````@jieyouxu`````
Rollup merge of rust-lang#138331 - nnethercote:use-RUSTC_LINT_FLAGS-more, r=onur-ozkan,jieyouxu Use `RUSTC_LINT_FLAGS` more An alternative to the failed rust-lang#138084. Fixes rust-lang#138106. r? ````@jieyouxu````
Revert "Use workspace lints for crates in `compiler/` #138084" Revert <rust-lang/rust#138084> to buy time to consider options that avoids breaking downstream usages of cargo on distributed `rustc-src` artifacts, where such cargo invocations fail due to inability to inherit `lints` from workspace root manifest's `workspace.lints` (this is only valid for the source rust-lang/rust workspace, but not really the distributed `rustc-src` artifacts). The problem is that the `rustc-src` component doesn't include the root `Cargo.toml` manifest. This breakage was reported in rust-lang/rust#138304. This reverts commit 48caf81, reversing changes made to c666287. cc `@RalfJung` r? `@nnethercote` (sorry, I didn't consider this being a thing 💀)
This is nicer and hopefully less error prone than specifying lints via bootstrap.
r? @jieyouxu