Repository navigation
1.97 beta regression: Rust claims import is unused but crate doesn't compile with it removed #157420
Copy link
Copy link
Closed
Labels
A-intra-doc-linksArea: Intra-doc links, the ability to link to items in docs by nameArea: Intra-doc links, the ability to link to items in docs by nameA-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.A-resolveArea: Name/path resolution done by `rustc_resolve` specificallyArea: Name/path resolution done by `rustc_resolve` specificallyC-bugCategory: This is a bug.Category: This is a bug.L-unused_importsLint: unused_importsLint: unused_importsS-has-bisectionStatus: A bisection has been found for this issueStatus: A bisection has been found for this issueS-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issueStatus: A Minimal Complete and Verifiable Example has been found for this issueT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.Relevant to the rustdoc team, which will review and decide on the PR/issue.regression-from-stable-to-betaPerformance or correctness regression from stable to beta.Performance or correctness regression from stable to beta.
Description
I don't have a minimal reproducer, but I do have a reproducer.
-
Check out
polarsat commit133a52633ba7b0dc08c70a2662abf5d7547df06f. -
Run
make build. Rust will give the following warning (among others):
warning: unused import: `crate::prelude`
--> crates/polars-core/src/chunked_array/ops/sort/options.rs:5:5
|
5 | use crate::prelude::*;
| ^^^^^^^^^^^^^^
|
= note: `#[warn(unused_imports)]` (part of `#[warn(unused)]`) on by default
However, if we remove this line, the project will fail to compile.
Meta
rustc --version --verbose:
rustc 1.98.0-nightly (d595fce01 2026-06-02)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
A-intra-doc-linksArea: Intra-doc links, the ability to link to items in docs by nameArea: Intra-doc links, the ability to link to items in docs by nameA-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.A-resolveArea: Name/path resolution done by `rustc_resolve` specificallyArea: Name/path resolution done by `rustc_resolve` specificallyC-bugCategory: This is a bug.Category: This is a bug.L-unused_importsLint: unused_importsLint: unused_importsS-has-bisectionStatus: A bisection has been found for this issueStatus: A bisection has been found for this issueS-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issueStatus: A Minimal Complete and Verifiable Example has been found for this issueT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.Relevant to the rustdoc team, which will review and decide on the PR/issue.regression-from-stable-to-betaPerformance or correctness regression from stable to beta.Performance or correctness regression from stable to beta.
Activity
orlp commentedon Jun 4, 2026
I have a more minimal reproduction that only touches the
polars-corecrate without having to do the entiremake buildsetup. It goes as follows (still on pola-rs/polars@133a526):This will output:
(There are a lot more warnings due to
polars-corenot being meant as a stand-alone crate, we don't bother getting rid of other unused warnings that aren't unused in the larger project / with full features.)However, removing that line will cause
cargo check -p polars-coreto fail to compile, so it's a false-positive warning.orlp commentedon Jun 4, 2026
I've added
#[deny(unused_imports)]tocrates/polars-core/src/chunked_array/ops/sort/options.rs:5:5. This let me usecargo bisect-rustc --start=2026-04-01 --end=2026-06-03 -- check -p polars-core:It seems a021a77 is the issue.
From that roll-up commit I think it's #154149.
@petrochenkov Assuming the above bisect blame isn't wrong, this would be the second regression introduced to Polars on nightly in that chain of commits. That PR is a revert of #152498 which also broke Polars (#152004). Perhaps it would be possible to try to build Polars with a potential new fix PR and see if it introduces new spurious warnings?
[-]1.98 nightly regression: Rust claims import is unused but crate doesn't compile with it removed[/-][+]1.97 beta regression: Rust claims import is unused but crate doesn't compile with it removed[/+]orlp commentedon Jun 4, 2026
I've also confirmed now that
cargo +beta check -p polars-corefails with#[deny(unused_imports)]added beforecrates/polars-core/src/chunked_array/ops/sort/options.rs:5:5onrustc 1.97.0-beta.2 (0417c2586 2026-05-30), so I've updated the title.theemathas commentedon Jun 7, 2026
cc @petrochenkov @mu001999 (author and reviewer of #154149)
petrochenkov commentedon Jun 7, 2026
I've assigned myself and will look at this in the next few days, but having a minimized reproducer until then would still be nice.
9 remaining items
petrochenkov commentedon Jun 10, 2026
I'm still trying to figure out what's going on.
What is clear:
crate::prelude::*import gets intomaybe_unused_trait_imports, that's why it's reported as unused after type checking (compiler\rustc_hir_analysis\src\check_unused.rs), the imported trait is indeed not usedmaybe_unused_trait_importsbecause/// [A::f]forces collection of traits in scope (and imports to them), and their addition to the potentially unused trait import setWhat is not clear:
crate::prelude::*import is not removed from themaybe_unused_trait_importsset, which is typically happens with imports that are used early, before type checkingpetrochenkov commentedon Jun 10, 2026
Fixed in #157713.
Rollup merge of rust-lang#157713 - petrochenkov:regr197unused, r=oli-obk
Rollup merge of rust-lang#157713 - petrochenkov:regr197unused, r=oli-obk
Rollup merge of rust-lang#157713 - petrochenkov:regr197unused, r=oli-obk
Rollup merge of rust-lang#157713 - petrochenkov:regr197unused, r=oli-obk
Rollup merge of rust-lang#157713 - petrochenkov:regr197unused, r=oli-obk
Rollup merge of rust-lang#157713 - petrochenkov:regr197unused, r=oli-obk
Rollup merge of rust-lang#157713 - petrochenkov:regr197unused, r=oli-obk
Unrolled build for #157713
Rollup merge of #157713 - petrochenkov:regr197unused, r=oli-obk