GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Lint unused pub items in binary crates by mu001999 · Pull Request #149509 · rust-lang/rust

Conversation

@mu001999

@mu001999 mu001999 commented Dec 1, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

View all comments

This PR adds a new unstable flag -Ztreat-pub-as-pub-crate as @Kobzol suggested.
When compiling binary crates with this flag, the seed worklist will only contain the entry fn and won't contain other reachable items. Then we can do the dead code analysis for pub items just like they are pub(crate).

Related zulip thread #general > pub/pub(crate) within a binary is a footgun.


Updated:

Adds a new lint dead_code_pub_in_binary (crate-level, default allow for now) instead of the previous unstable flag to lint unused pub items for binary crates.

See more details of implementation in #149509 (comment).

This lint is allowed by default, but I believe this has been better than the unstable flag. Making it warn-by-default will lead to a lot of noise for this PR (like bless many tests). So I'd like to make it warn-by-default in a separate PR in the future.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Kobzol, JosiahParry, and AnthonyMikh reacted with heart emoji GrigorenkoPV reacted with eyes emoji
All reactions
  • ❤️ 3 reactions
  • 👀 1 reaction
@rustbot rustbot assigned jdonszelmann Dec 1, 2025
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Dec 1, 2025
@rustbot

rustbot commented Dec 1, 2025

Copy link
Copy Markdown
Collaborator

r? @jdonszelmann

rustbot has assigned @jdonszelmann.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mu001999 mu001999 changed the title Add new unstable flag -Ztreat-pub-as-pub-crate Add new unstable flag -Ztreat-pub-as-pub-crate Dec 1, 2025
@mu001999 mu001999 changed the title Add new unstable flag -Ztreat-pub-as-pub-crate Add a new unstable flag -Ztreat-pub-as-pub-crate Dec 1, 2025
@mu001999 mu001999 mentioned this pull request Dec 1, 2025
Consider pub items in binary crates dead code if not used in the crate (i.e., treating it like pub(crate)) #74970
Open
@Noratrieb

Noratrieb commented Dec 1, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

What are the plans for this flag? Being made the default? As just a flag, it's essentially useless, because no one will know about it. So I'd be opposed to just adding it without any plan for making it useful for everyone.

jyn514, GrantGryczan, iago-lito, jieyouxu, Expurple, jdonszelmann, Kobzol, and kamulos reacted with thumbs up emoji
All reactions
  • 👍 8 reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mu001999
mu001999 marked this pull request as draft December 2, 2025 01:13
@rustbot rustbot 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 Dec 2, 2025
@mu001999
mu001999 force-pushed the flag/pub-as-pub-crate branch 2 times, most recently from 6541f80 to 8ac52ba Compare December 2, 2025 02:12
@mu001999
mu001999 marked this pull request as ready for review December 2, 2025 02:13
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Dec 2, 2025
@mu001999

mu001999 commented Dec 2, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member Author

Maybe this could be a separate lint, I haven't thought too clearly yet

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jdonszelmann

jdonszelmann commented Dec 3, 2025

Copy link
Copy Markdown
Contributor

Yea I do agree with nora here, maybe open a (specific) zulip thread to make a proper plan for this?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jdonszelmann

jdonszelmann commented Dec 3, 2025

Copy link
Copy Markdown
Contributor

I guess I'd prefer this as a lint (attribute at the crate root) myself

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jdonszelmann

jdonszelmann commented Dec 3, 2025

Copy link
Copy Markdown
Contributor

@rustbot author

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@rustbot rustbot 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 Dec 3, 2025
@rustbot

rustbot commented Dec 3, 2025

Copy link
Copy Markdown
Collaborator

Reminder, once the PR becomes ready for a review, use @rustbot ready.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mu001999
mu001999 marked this pull request as draft December 3, 2025 14:34
@Kobzol

Kobzol commented Dec 3, 2025

Copy link
Copy Markdown
Member

I guess that the use-case that I'm envisioning is to have an opt-in way to treat pub stuff as pub(crate) in binary crates. If it was an allow-by-default lint, which could be manually denied, that would serve that use-case, I think.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@GrantGryczan

GrantGryczan commented Dec 4, 2025

Copy link
Copy Markdown

Why would the end goal be for this to be opt-in? I and others want to see #74970 become a default. I wouldn't opt into this, because that would make my codebase less idiomatic, diverging from how everyone else who hasn't opted in uses pub.

The reason this is useful as a default is because it doesn't semantically make sense to distinguish between pub and pub(crate) in binary crates. This creates a footgun because, for example, pub items can't receive dead_code warnings. If it's just opt-in, then that doesn't remove the footgun for anyone who hasn't opted in, and I don't see a benefit to pub and pub(crate) being distinct in binary crates.

The only reason I can see that someone might not want to opt into this is that one might use pub to prevent dead_code warnings as opposed to pub(crate). But I think this intent might be better communicated using #[expect(dead_code)] rather than the implicit behavior of pub. Dead code detection is useful as a default. (The only downside to that is that you then have to remove the #[expect(dead_code)] if you later use it, but I'll leave it to others to decide if that coupling is an important consideration.)

jyn514 and Noratrieb reacted with thumbs up emoji
All reactions
  • 👍 2 reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mu001999
mu001999 force-pushed the flag/pub-as-pub-crate branch from 8ac52ba to 923596e Compare December 28, 2025 15:22
@mu001999
mu001999 force-pushed the flag/pub-as-pub-crate branch from 923596e to 1d89354 Compare March 19, 2026 12:06
@rust-log-analyzer

This comment has been minimized.

Sign in to view
@mu001999
mu001999 force-pushed the flag/pub-as-pub-crate branch from 1d89354 to e116866 Compare March 19, 2026 13:41
@rust-bors

rust-bors Bot commented May 6, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 93abcca has been approved by jdonszelmann

It is now in the queue for this repository.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@JonathanBrouwer JonathanBrouwer mentioned this pull request May 6, 2026
Rollup of 8 pull requests #156232
Closed
@JonathanBrouwer

JonathanBrouwer commented May 6, 2026

Copy link
Copy Markdown
Member

@bors r-
https://github.com/rust-lang/rust/actions/runs/25429503795/job/74591817259#step:28:1

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@rust-bors

rust-bors Bot commented May 6, 2026

Copy link
Copy Markdown
Contributor

This pull request was unapproved.

This PR was contained in a rollup (#156232), which was unapproved.

View changes since this unapproval

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

mu001999 added 3 commits May 6, 2026 19:33
@mu001999
Refactor dead code liveness plumbing
c44e922
@mu001999
Implement unused_pub_items_in_binary lint
27a8bb6
@mu001999
Rename unused_pub_items_in_binary to dead_code_pub_in_binary
26bfcf3
@rustbot

rustbot commented May 6, 2026

Copy link
Copy Markdown
Collaborator

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mu001999

mu001999 commented May 6, 2026

Copy link
Copy Markdown
Member Author

@bors r=jdonszelmann

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@rust-bors

rust-bors Bot commented May 6, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 26bfcf3 has been approved by jdonszelmann

It is now in the queue for this repository.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

This was referenced May 6, 2026
Rollup of 7 pull requests #156249
Closed
Rollup of 9 pull requests #156254
Closed
This was referenced May 7, 2026
Rollup of 11 pull requests #156261
Closed
Rollup of 11 pull requests #156262
Closed
Rollup of 14 pull requests #156263
Closed
@rust-bors

This comment has been minimized.

Sign in to view
@rust-bors

rust-bors Bot commented May 7, 2026

Copy link
Copy Markdown
Contributor

☀️ Test successful - CI
Approved by: jdonszelmann
Duration: 3h 9m 40s
Pushing 0e5924a to main...

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions

github-actions Bot commented May 7, 2026

Copy link
Copy Markdown
Contributor
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 4ddd453 (parent) -> 0e5924a (this PR)

Test differences

Show 814 test diffs

Stage 1

  • [ui] tests/ui/lint/dead-code-pub-in-binary/allow-dead-code-transitive.rs: [missing] -> pass (J1)
  • [ui] tests/ui/lint/dead-code-pub-in-binary/allow-lint.rs: [missing] -> pass (J1)
  • [ui] tests/ui/lint/dead-code-pub-in-binary/basic.rs: [missing] -> pass (J1)
  • [ui] tests/ui/lint/dead-code-pub-in-binary/deny-lint.rs: [missing] -> pass (J1)
  • [ui] tests/ui/lint/dead-code-pub-in-binary/interaction-allow-dead-code.rs: [missing] -> pass (J1)
  • [ui] tests/ui/lint/dead-code-pub-in-binary/interaction-allow-unused-pub.rs: [missing] -> pass (J1)
  • [ui] tests/ui/lint/dead-code-pub-in-binary/interaction-deny-dead-code-only.rs: [missing] -> pass (J1)
  • [ui] tests/ui/lint/dead-code-pub-in-binary/library.rs: [missing] -> pass (J1)
  • [ui] tests/ui/lint/dead-code-pub-in-binary/no-mangle-items.rs: [missing] -> pass (J1)

Stage 2

  • [ui] tests/ui/lint/dead-code-pub-in-binary/allow-dead-code-transitive.rs: [missing] -> pass (J0)
  • [ui] tests/ui/lint/dead-code-pub-in-binary/allow-lint.rs: [missing] -> pass (J0)
  • [ui] tests/ui/lint/dead-code-pub-in-binary/basic.rs: [missing] -> pass (J0)
  • [ui] tests/ui/lint/dead-code-pub-in-binary/deny-lint.rs: [missing] -> pass (J0)
  • [ui] tests/ui/lint/dead-code-pub-in-binary/interaction-allow-dead-code.rs: [missing] -> pass (J0)
  • [ui] tests/ui/lint/dead-code-pub-in-binary/interaction-allow-unused-pub.rs: [missing] -> pass (J0)
  • [ui] tests/ui/lint/dead-code-pub-in-binary/interaction-deny-dead-code-only.rs: [missing] -> pass (J0)
  • [ui] tests/ui/lint/dead-code-pub-in-binary/library.rs: [missing] -> pass (J0)
  • [ui] tests/ui/lint/dead-code-pub-in-binary/no-mangle-items.rs: [missing] -> pass (J0)

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

Job group index

  • J0: aarch64-apple, aarch64-gnu, aarch64-gnu-llvm-21-1, aarch64-msvc-1, arm-android, armhf-gnu, dist-i586-gnu-i586-i686-musl, i686-gnu-1, i686-gnu-nopt-1, i686-msvc-1, optional-x86_64-gnu-parallel-frontend, test-various, x86_64-gnu, x86_64-gnu-debug, x86_64-gnu-gcc, x86_64-gnu-llvm-21, x86_64-gnu-llvm-21-2, x86_64-gnu-llvm-22-2, x86_64-gnu-nopt, x86_64-gnu-stable, x86_64-mingw-1, x86_64-msvc-1
  • J1: x86_64-gnu-llvm-21-3, x86_64-gnu-llvm-22-3
Test dashboard

Run

cargo run --manifest-path src/ci/citool/Cargo.toml -- \
    test-dashboard 0e5924a4a0b57f2c6bc8cac93f59281e68541a91 --output-dir test-dashboard

And then open test-dashboard/index.html in your browser to see an overview of all executed tests.

Job duration changes

  1. x86_64-gnu-llvm-21: 1h 1m -> 1h 22m (+34.1%)
  2. dist-apple-various: 1h 41m -> 2h 6m (+24.1%)
  3. dist-i586-gnu-i586-i686-musl: 1h 36m -> 1h 16m (-20.8%)
  4. armhf-gnu: 1h 33m -> 1h 14m (-20.7%)
  5. x86_64-rust-for-linux: 41m 19s -> 49m 46s (+20.5%)
  6. dist-loongarch64-linux: 1h 51m -> 1h 30m (-18.5%)
  7. dist-armv7-linux: 1h 30m -> 1h 14m (-18.1%)
  8. dist-x86_64-apple: 1h 55m -> 2h 12m (+14.1%)
  9. dist-aarch64-msvc: 1h 40m -> 1h 52m (+11.4%)
  10. x86_64-gnu-llvm-22-2: 1h 39m -> 1h 27m (-11.3%)
How to interpret the job duration changes?

Job durations can vary a lot, based on the actual runner instance
that executed the job, system noise, invalidated caches, etc. The table above is provided
mostly for t-infra members, for simpler debugging of potential CI slow-downs.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

This was referenced May 7, 2026
[TOY] Run MIR opts before coroutine state transform #145330
Draft
add lang items for field projections via virtual places #154940
Draft
constify TryFrom<Vec> for array #155616
Merged
Introduce aarch64-unknown-linux-pauthtest target #155722
Merged
miri: require (almost) all 1-ZST arguments to be actually passed #156085
Merged
@rust-timer

rust-timer commented May 7, 2026

Copy link
Copy Markdown

Finished benchmarking commit (0e5924a): comparison URL.

Overall result: ❌ regressions - please read:

Our benchmarks found a performance regression caused by this PR.
This might be an actual regression, but it can also be just noise.

Next Steps:

  • If the regression was expected or you think it can be justified,
    please write a comment with sufficient written justification, and add
    @rustbot label: +perf-regression-triaged to it, to mark the regression as triaged.
  • If you think that you know of a way to resolve the regression, try to create
    a new PR with a fix for the regression.
  • If you do not understand the regression or you think that it is just noise,
    you can ask the @rust-lang/wg-compiler-performance working group for help (members of this group
    were already notified of this PR).

@rustbot label: +perf-regression
cc @rust-lang/wg-compiler-performance

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
0.3% [0.1%, 0.4%] 4
Regressions ❌
(secondary)
0.1% [0.1%, 0.1%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.3% [0.1%, 0.4%] 4

Max RSS (memory usage)

Results (primary 0.1%, secondary -0.6%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
1.9% [1.9%, 1.9%] 1
Regressions ❌
(secondary)
2.4% [2.3%, 2.5%] 2
Improvements ✅
(primary)
-1.7% [-1.7%, -1.7%] 1
Improvements ✅
(secondary)
-2.7% [-6.2%, -0.4%] 3
All ❌✅ (primary) 0.1% [-1.7%, 1.9%] 2

Cycles

Results (primary -5.5%, secondary 0.6%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
1.8% [0.7%, 3.9%] 3
Improvements ✅
(primary)
-5.5% [-8.4%, -2.6%] 2
Improvements ✅
(secondary)
-0.6% [-0.9%, -0.4%] 3
All ❌✅ (primary) -5.5% [-8.4%, -2.6%] 2

Binary size

This perf run didn't have relevant results for this metric.

Bootstrap: 499.861s -> 498.18s (-0.34%)
Artifact size: 394.98 MiB -> 394.99 MiB (0.00%)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ifsheldon ifsheldon mentioned this pull request May 9, 2026
Track future Rust lint hardening agentic-science/Agentics#5
Open
@Kobzol

Kobzol commented May 12, 2026

Copy link
Copy Markdown
Member

The regression looks genuine, but it is very small. The compiler now runs a new allow-by-default lint, so that is expected. I hoped that there is now a machinery that completely skips allow-by-default lints, but it is probably not applied to builtin lints.

@rustbot label: +perf-regression-triaged

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mu001999 mu001999 mentioned this pull request May 31, 2026
Add a new lint UNCONSTRUCTIBLE_PUB_STRUCTS #146440
Closed
@BoxyUwU BoxyUwU mentioned this pull request Jun 24, 2026
Draft release notes for 1.97.0 #158353
Closed
@github-actions github-actions Bot mentioned this pull request Jul 14, 2026
chore(deps): update ⬆️ mise-packages scottames/dots#978
Merged
1 task
@coderabbitai coderabbitai Bot mentioned this pull request Jul 27, 2026
feat(llm): add pool-scoped KV DC Relay runtime ai-dynamo/dynamo#12199
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@steffahn steffahn steffahn left review comments
@traviscross traviscross Awaiting requested review from traviscross
@jdonszelmann jdonszelmann Awaiting requested review from jdonszelmann
+1 more reviewer
@GrantGryczan GrantGryczan GrantGryczan left review comments
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@jdonszelmann jdonszelmann

Labels

A-attributes Area: Attributes (`#[…]`, `#![…]`) disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. finished-final-comment-period The final comment period is finished for this PR / Issue. I-lang-radar Items that are on lang's radar and will need eventual work or consideration. merged-by-bors This PR was explicitly merged by bors. perf-regression Performance regression. perf-regression-triaged The performance regression has been triaged. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-lang Relevant to the language team to-announce Announce this issue on triage meeting

Projects

None yet

Milestone

1.97.0

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

15 participants

@mu001999 @rustbot @Noratrieb @jdonszelmann @Kobzol @GrantGryczan @rust-log-analyzer @traviscross @rust-rfcbot @joshtriplett @nikomatsakis @tmandry @JonathanBrouwer @rust-timer @steffahn
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.