Repository navigation
Lint #[deprecated] on use items, where it has no effect - #165842
johncarmack1984 wants to merge 2 commits into
Conversation
|
|
|
Thanks for the pull request, and welcome! The Rust Project has assigned @WaffleLapkin (or someone else) to review your changes, you should hear from them (or someone else) within the next two weeks. Please see the contribution instructions and our LLM policy for more information. |
This comment has been minimized.
This comment has been minimized.
Deprecation is checked on the item a path resolves to, so a `#[deprecated]` attribute on a `use` item is accepted and never consulted at use sites. Deprecating a re-export that way warns nobody. Add `ineffective_deprecated_reexports`, a warn-by-default lint emitted from the stability checker for every `use` item carrying `#[deprecated]`. Its note says this is a long-standing bug and links the tracking issue; its help suggests deprecating the item itself, or a `#[deprecated]` type alias or wrapper function where one applies. core (`alloc::LayoutErr`) and std (`collections::Bound`) each carry one of these attributes. Both get an item-level `#[expect]`, which std's deny-warnings build turns into an error once the lint stops firing there, so the annotations go away with the fix for deprecating re-exports. The run-rustfix import test carries its expectation on the item too: a crate-level one is unfulfilled in the fixed output, which removes the annotated `use`.
ee5fc9e to
0c50040
Compare
|
What exactly is the LLM involvement here? What does "I wrote this lint" entail? |
Hi, first of all, all user-facing components including PR description should be written manually from start to finish; otherwise, this violates our policy. Second, you should have found a pre-arranged LLM reviewer in #llm-reviews before opening a PR. More you can read in our LLM policy. |
I believe this part violates the LLM policy as well. |
It means only that; I sat down in front of my code editor in mid-October and thought through the problem one character at a time until it was solved.
The PR description and docs are my own writing. The LLM was used for correctness checks when drafting, but the prose is my own. I address this on the Zulip thread, and I apologize that it makes things hard for reviewers, but when trying to be thorough and clear, I actually do sound a lot like an LLM. And I miss being able to use em-dashes and the word “delve”. Would be happy to give you a call on zoom/teams/FaceTime if that sounds hard to believe. I get very excited and agreeable and try to sound like everyone’s favorite Reddit commenter from 2009. It only became a problem in 2023.
That… is fair. Oversight on my part. I can do that now.
The LLM was used when choosing between approaches (and I know this sounds ridiculous but it’s what I did to stay in accordance with the policy): I would have the tool create implementations in a folder I refused to look at, based on instructions I gave it, and have it run tests & benchmarks to ensure given approaches would not create regressions, unexpected drawbacks, etc.. If a given approach did not have inherent flaws under this system, I would then go about hand-typing a naive implementation from the prompt I had previously given the LLM. The submitted code in this PR was hand-typed by a human without significant portions being written by an LLM. |
To clarify the policy, I don't see you've missed anything here. As far as I can tell with your latest explanations here (thank you for those), you did not use LLMs in a way that would run into the need for pre-arranging reviewers. |
|
Could you please rewrite the disclosure in the PR description to reflect the actual workflow? As it stands, some points contradict each other and are too ambiguous. |
Replace the dedicated lint with an `unused_attributes` warning emitted from the deprecation attribute parser, beside its existing warning for trait-impl items. `use` becomes an `AllowSilent` target, so the misplaced-attribute help no longer lists it. The text is unchanged. core, std and the run-rustfix import test expect `unused_attributes` instead.
|
Some changes occurred in compiler/rustc_attr_parsing |
|
Fixing #30827 needs a design decision first: check deprecation during name resolution, or record each path's import chain and check it later. I asked which in #t-compiler so I can start on it. Until it's fixed (it's been open since 2016), On #142731, epage argued for a temporary lint: library authors write changelogs assuming their deprecations show up, and users then get breaking changes nobody warned them about. Although WaffleLapkin expected some churn (people dropping the deprecation or adding an |
#[deprecated]on auseitem is accepted and then ignored: deprecation is checked on the resolved item, not on the imports a path went through, so deprecating a re-export that way warns nobody (#30827).This warns at the attribute, under
unused_attributes, that it has no effect, notes that it's a long-standing bug, and suggests what does work: deprecating the item itself, or a#[deprecated]type alias or wrapper function where one applies.Choices made:
#[deprecated]parser inrustc_attr_parsing, beside its existingunused_attributeswarning for trait-impl items, withuseas anAllowSilenttarget as those are. The literalWarn(Target::Use)routes touseless_deprecated, which is deny-by-default and says the attribute is being phased out; the review on Add lint rule for#[deprecated]on re-exports (rebase) #142731 asked for a warning that calls it a bug instead.#![allow(unused)]covers it, as it covers every other attribute with no effect. The example in Warn that#[deprecated]does not work on re-exports #142436 starts with that line; with#![allow(unused_imports, dead_code)]it prints the output the issue asks for.use Alias::Variant, a function needs a wrapper, and a module or macro re-export has no equivalent.alloc::LayoutErr) and std (collections::Bound) each carry one of these attributes. Both get an item-level#[expect], which std's deny-warnings build turns into an error once the warning stops firing there; core gets a FIXME, std already had one. The run-rustfix test intests/ui/importscarries its expectation on the item: a crate-level one is unfulfilled in the fixed output, which deletes the annotateduse.The fix for #30827 should delete this.
Supersedes #142731 (I asked GrigorenkoPV there on Oct 22 whether they planned to return to it and haven't heard back). Closes #142436.
r? @WaffleLapkin
LLM disclosure: I wrote this lint. Claude Code (Fable 5.1, then Opus 5.5, both max effort) were used to evaluate design options from the issue's history for inherent virtues or flaws, after which I drafted the implementation, docs and tests, while Claude ran the test suites. Codex reviewed.