Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Wunused-crate-dependencies for the compiler #137930

Merged
merged 2 commits into from
Mar 20, 2025

Conversation

nnethercote
Copy link
Contributor

@nnethercote nnethercote commented Mar 3, 2025

An implementation of rust-lang/compiler-team#844.

r? @jieyouxu

@rustbot rustbot added A-attributes Area: Attributes (`#[…]`, `#![…]`) A-query-system Area: The rustc query system (https://rustc-dev-guide.rust-lang.org/query.html) PG-exploit-mitigations Project group: Exploit mitigations S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Mar 3, 2025
@rust-log-analyzer

This comment has been minimized.

@nnethercote nnethercote force-pushed the use-Wunused-crate-dependencies branch from 9c4840f to fe01d30 Compare March 3, 2025 19:17
@rust-log-analyzer

This comment has been minimized.

@nnethercote nnethercote force-pushed the use-Wunused-crate-dependencies branch 2 times, most recently from 0ede122 to d73f6e5 Compare March 4, 2025 00:02
@jieyouxu jieyouxu self-assigned this Mar 4, 2025
@bors
Copy link
Contributor

bors commented Mar 9, 2025

☔ The latest upstream changes (presumably #138267) made this pull request unmergeable. Please resolve the merge conflicts.

@nnethercote nnethercote force-pushed the use-Wunused-crate-dependencies branch from d73f6e5 to 8650d11 Compare March 9, 2025 23:36
@bors
Copy link
Contributor

bors commented Mar 10, 2025

☔ The latest upstream changes (presumably #138310) made this pull request unmergeable. Please resolve the merge conflicts.

@jieyouxu jieyouxu added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 12, 2025
@nnethercote nnethercote force-pushed the use-Wunused-crate-dependencies branch from 8650d11 to 2e213f8 Compare March 13, 2025 00:39
@rustbot
Copy link
Collaborator

rustbot commented Mar 13, 2025

Could not assign reviewer from: jieyouxu.
User(s) jieyouxu are either the PR author, already assigned, or on vacation. Please use r? to specify someone else to assign.

@nnethercote nnethercote marked this pull request as ready for review March 13, 2025 00:40
@rustbot
Copy link
Collaborator

rustbot commented Mar 13, 2025

Some changes occurred in compiler/rustc_codegen_ssa

cc @WaffleLapkin

Some changes occurred in exhaustiveness checking

cc @Nadrieril

These commits modify the Cargo.lock file. Unintentional changes to Cargo.lock can be introduced when switching branches and rebasing PRs.

If this was unintentional then you should revert the changes before this PR is merged.
Otherwise, you can ignore this comment.

Some changes occurred in compiler/rustc_attr_parsing

cc @jdonszelmann

Some changes occurred in compiler/rustc_sanitizers

cc @rust-lang/project-exploit-mitigations, @rcvalle

@nnethercote
Copy link
Contributor Author

rust-lang/compiler-team#844 has hit 10 days after seconding without objection, so is approved. And we have established RUSTC_LINT_FLAGS as the best way to handle new lints for compiler crates. So this is ready to go.

@bors rollup

Comment on lines 22 to 24
#[cfg(test)]
mod tests;

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this change and why merge all the modules into a single file? Please at least leave the files separated like they were, and overall I'd prefer if this crate was structured like a normal crate, i.e. with usage tests in tests/.

Copy link
Member

@Nadrieril Nadrieril Mar 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I saw the commit description, I don't agree that "the rest of the compiler does it" is a good reason: this is a librarified crate, meant to be used outside of the compiler and compiled on its own (on stable even). In an ideal future this crate would be published to crates.io. These tests are meant to play with its public API surface, hence why they were integration tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like having a "dual status" crate like this. I think it should either be a compiler crate and treated like other compiler crates, or be on crates.io (like the ena crate, for example) and then it can do things differently.

Nonetheless, the third commit it not integral and can be removed. Some level of false positive workaround is necessary for the first commit, such as the #![allow(unused_crate_dependencies)] attributes.

Copy link
Member

@Nadrieril Nadrieril Mar 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It still evolves sufficiently in sync with the compiler that moving out-of-tree wouldn't make sense. I expect other librarified parts of the compiler to behave similarly, how do they behave? The only other one I know of is rustc_type_ir tho.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rustc_transmute also has a rustc feature.

rustc_abi, rustc_next_trait_solver, rustc_index, rustc_ast_ir, rustc_transmute, rustc_type_ir all have a nightly feature.

I don't have a sense of whether rustc and nightly are doing the same thing. I wonder if some of these crates could be split into the "base" part (typically shared with rust-analyzer) and the rustc-specific part.

Copy link
Member

@Nadrieril Nadrieril Mar 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rustc_pattern_analysis could easily be split in that way. Looking at these other crates, I see:

  • actual nightly features (e.g. Rc::new_zeroed or Extend::extend_one);
  • implementing Encodable/Decodable;
  • whole submodules cfged-out;
  • internal features like rustc_pass_by_value or rustc_lint_query_instability (only in rustc_type_ir).

My guess is that we could split most of them if we had the orphan rules escape hatch that RfL wants.

@jieyouxu
Copy link
Member

Commit 1 LGTM. I'll hand the review over to @Nadrieril who has a stronger preference on the test organizations.

r? @Nadrieril

@rustbot rustbot assigned Nadrieril and unassigned jieyouxu Mar 15, 2025
@bors
Copy link
Contributor

bors commented Mar 15, 2025

☔ The latest upstream changes (presumably #138464) made this pull request unmergeable. Please resolve the merge conflicts.

@bors bors added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Mar 19, 2025
@nnethercote nnethercote force-pushed the use-Wunused-crate-dependencies branch from 1fa77ca to f84fd39 Compare March 19, 2025 20:29
@nnethercote
Copy link
Contributor Author

I rebased again, and again removed a couple of new unnecessary dependencies that had crept in.

@bors r=jieyouxu,Nadrieril p=1

Bumping priority because this is conflict-prone.

@bors
Copy link
Contributor

bors commented Mar 19, 2025

📌 Commit f84fd39 has been approved by jieyouxu,Nadrieril

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Mar 19, 2025
@nnethercote
Copy link
Contributor Author

@bors rollup=never

bors added a commit to rust-lang-ci/rust that referenced this pull request Mar 19, 2025
…encies, r=jieyouxu,Nadrieril

Use `Wunused-crate-dependencies` for the compiler

An implementation of rust-lang/compiler-team#844.

r? `@jieyouxu`
@bors
Copy link
Contributor

bors commented Mar 19, 2025

⌛ Testing commit f84fd39 with merge cea7074...

@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Contributor

bors commented Mar 19, 2025

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Mar 19, 2025
It's very useful. There are some false positives involving integration
tests in `rustc_pattern_analysis` and `rustc_serialize`. There is also a
false positive involving `rustc_driver_impl`'s
`rustc_randomized_layouts` feature. And I removed a `rustc_span` mention
in a doc comment in `rustc_log` because it wasn't integral to the
comment but caused a dev-dependency.
Because (a) the vast majority of compiler tests are unit tests, and (b)
this works better with `unused_crate_dependencies`.
@nnethercote nnethercote force-pushed the use-Wunused-crate-dependencies branch from f84fd39 to e2320b3 Compare March 19, 2025 22:00
@nnethercote
Copy link
Contributor Author

@bors r=jieyouxu,Nadrieril p=1

@bors
Copy link
Contributor

bors commented Mar 20, 2025

📌 Commit e2320b3 has been approved by jieyouxu,Nadrieril

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 20, 2025
@jieyouxu
Copy link
Member

@bors p=10 (or else this will get rollup-raced)

@bors
Copy link
Contributor

bors commented Mar 20, 2025

⌛ Testing commit e2320b3 with merge 4e2b096...

@bors
Copy link
Contributor

bors commented Mar 20, 2025

☀️ Test successful - checks-actions
Approved by: jieyouxu,Nadrieril
Pushing 4e2b096 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Mar 20, 2025
@bors bors merged commit 4e2b096 into rust-lang:master Mar 20, 2025
7 checks passed
@rustbot rustbot added this to the 1.87.0 milestone Mar 20, 2025
Copy link

What is this? This is an experimental post-merge analysis report that shows differences in test outcomes between the merged PR and its parent PR.

Comparing 70237a8 (parent) -> 4e2b096 (this PR)

Test differences

Show 68 test diffs
  • leb128::tests::test_i128_leb128 (stage 1): [missing] -> pass (J0)
  • leb128::tests::test_i16_leb128 (stage 1): [missing] -> pass (J0)
  • leb128::tests::test_i32_leb128 (stage 1): [missing] -> pass (J0)
  • leb128::tests::test_i64_leb128 (stage 1): [missing] -> pass (J0)
  • leb128::tests::test_isize_leb128 (stage 1): [missing] -> pass (J0)
  • leb128::tests::test_u128_leb128 (stage 1): [missing] -> pass (J0)
  • leb128::tests::test_u16_leb128 (stage 1): [missing] -> pass (J0)
  • leb128::tests::test_u32_leb128 (stage 1): [missing] -> pass (J0)
  • leb128::tests::test_u64_leb128 (stage 1): [missing] -> pass (J0)
  • leb128::tests::test_usize_leb128 (stage 1): [missing] -> pass (J0)
  • opaque::tests::test_bool (stage 1): [missing] -> pass (J0)
  • opaque::tests::test_box (stage 1): [missing] -> pass (J0)
  • opaque::tests::test_cell (stage 1): [missing] -> pass (J0)
  • opaque::tests::test_char (stage 1): [missing] -> pass (J0)
  • opaque::tests::test_enum (stage 1): [missing] -> pass (J0)
  • opaque::tests::test_hash_map (stage 1): [missing] -> pass (J0)
  • opaque::tests::test_i16 (stage 1): [missing] -> pass (J0)
  • opaque::tests::test_i32 (stage 1): [missing] -> pass (J0)
  • opaque::tests::test_i64 (stage 1): [missing] -> pass (J0)
  • opaque::tests::test_i8 (stage 1): [missing] -> pass (J0)
  • opaque::tests::test_isize (stage 1): [missing] -> pass (J0)
  • opaque::tests::test_option (stage 1): [missing] -> pass (J0)
  • opaque::tests::test_sequence (stage 1): [missing] -> pass (J0)
  • opaque::tests::test_string (stage 1): [missing] -> pass (J0)
  • opaque::tests::test_struct (stage 1): [missing] -> pass (J0)
  • opaque::tests::test_tuples (stage 1): [missing] -> pass (J0)
  • opaque::tests::test_u16 (stage 1): [missing] -> pass (J0)
  • opaque::tests::test_u32 (stage 1): [missing] -> pass (J0)
  • opaque::tests::test_u64 (stage 1): [missing] -> pass (J0)
  • opaque::tests::test_u8 (stage 1): [missing] -> pass (J0)
  • opaque::tests::test_unit (stage 1): [missing] -> pass (J0)
  • opaque::tests::test_unit_like_struct (stage 1): [missing] -> pass (J0)
  • opaque::tests::test_usize (stage 1): [missing] -> pass (J0)
  • test_bool (stage 1): pass -> [missing] (J0)
  • test_box (stage 1): pass -> [missing] (J0)
  • test_cell (stage 1): pass -> [missing] (J0)
  • test_char (stage 1): pass -> [missing] (J0)
  • test_enum (stage 1): pass -> [missing] (J0)
  • test_hash_map (stage 1): pass -> [missing] (J0)
  • test_i128_leb128 (stage 1): pass -> [missing] (J0)
  • test_i16 (stage 1): pass -> [missing] (J0)
  • test_i16_leb128 (stage 1): pass -> [missing] (J0)
  • test_i32 (stage 1): pass -> [missing] (J0)
  • test_i32_leb128 (stage 1): pass -> [missing] (J0)
  • test_i64 (stage 1): pass -> [missing] (J0)
  • test_i64_leb128 (stage 1): pass -> [missing] (J0)
  • test_i8 (stage 1): pass -> [missing] (J0)
  • test_isize (stage 1): pass -> [missing] (J0)
  • test_isize_leb128 (stage 1): pass -> [missing] (J0)
  • test_option (stage 1): pass -> [missing] (J0)
  • test_sequence (stage 1): pass -> [missing] (J0)
  • test_string (stage 1): pass -> [missing] (J0)
  • test_struct (stage 1): pass -> [missing] (J0)
  • test_tuples (stage 1): pass -> [missing] (J0)
  • test_u128_leb128 (stage 1): pass -> [missing] (J0)
  • test_u16 (stage 1): pass -> [missing] (J0)
  • test_u16_leb128 (stage 1): pass -> [missing] (J0)
  • test_u32 (stage 1): pass -> [missing] (J0)
  • test_u32_leb128 (stage 1): pass -> [missing] (J0)
  • test_u64 (stage 1): pass -> [missing] (J0)
  • test_u64_leb128 (stage 1): pass -> [missing] (J0)
  • test_u8 (stage 1): pass -> [missing] (J0)
  • test_unit (stage 1): pass -> [missing] (J0)
  • test_unit_like_struct (stage 1): pass -> [missing] (J0)
  • test_usize (stage 1): pass -> [missing] (J0)
  • test_usize_leb128 (stage 1): pass -> [missing] (J0)

Additionally, 2 doctest diffs were found. These are ignored, as they are noisy.

Job group index

  • J0: aarch64-apple, aarch64-gnu, i686-gnu-2, i686-gnu-nopt-2, i686-mingw-2, i686-mingw-3, i686-msvc-2, x86_64-apple-1, x86_64-gnu, x86_64-gnu-llvm-18-3, x86_64-gnu-llvm-19-3, x86_64-gnu-nopt, x86_64-gnu-stable, x86_64-mingw-2, x86_64-msvc-2

@nnethercote nnethercote deleted the use-Wunused-crate-dependencies branch March 20, 2025 08:21
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (4e2b096): comparison URL.

Overall result: no relevant changes - no action needed

@rustbot label: -perf-regression

Instruction count

This benchmark run did not return any relevant results for this metric.

Max RSS (memory usage)

This benchmark run did not return any relevant results for this metric.

Cycles

Results (primary -3.0%)

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-3.0% [-3.0%, -3.0%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -3.0% [-3.0%, -3.0%] 1

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 773.52s -> 773.468s (-0.01%)
Artifact size: 365.50 MiB -> 365.48 MiB (-0.01%)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-attributes Area: Attributes (`#[…]`, `#![…]`) A-query-system Area: The rustc query system (https://rustc-dev-guide.rust-lang.org/query.html) merged-by-bors This PR was explicitly merged by bors. PG-exploit-mitigations Project group: Exploit mitigations S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants