-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Automatically derived trait implementations on #[deprecated]
items emit warnings
#110374
Comments
Note that this doesn't occur when standard #![deny(deprecated)]
#[deprecated]
#[derive(Copy, Clone)]
struct DeprecatedItem; compiles without warnings. |
@rustbot label +A-lint |
Hi, I made a bug report on this issue, and didn't notice this old issue until now. So I'm copying the info I posted over at #135065. tl;dr any sort of My bug reportCodeextern crate serde; // 1.0.215
#[deprecated]
pub struct A;
impl A {}
#[deprecated]
#[derive(serde::Deserialize)]
pub struct B; Current output Compiling playground v0.0.1 (/playground)
warning: use of deprecated struct `A`
--> src/lib.rs:6:6
|
6 | impl A {}
| ^
|
= note: `#[warn(deprecated)]` on by default
warning: use of deprecated struct `B`
--> src/lib.rs:10:12
|
10 | pub struct B;
| ^
warning: use of deprecated unit struct `B`
--> src/lib.rs:10:12
|
10 | pub struct B;
| ^
warning: `playground` (lib) generated 3 warnings
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.36s Desired output Compiling playground v0.0.1 (/playground)
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.62s Rationale and extra contextWhen Not only that, but the error caused by the derives points to the struct name itself, despite the linting item being from a derive - causing quite a bit of confusion. (This caused me some confusion when I attempted to attach Ideally, this issue would not occur if the Other cases// N/A Rust Versionrustc 1.83.0 (90b35a623 2024-11-26)
binary: rustc
commit-hash: 90b35a6239c3d8bdabc530a6a0816f7ff89a0aaf
commit-date: 2024-11-26
host: x86_64-pc-windows-msvc
release: 1.83.0
LLVM version: 19.1.1 Anything else?
|
When using the
#[automatically_derived]
attribute on deprecated items, deprecation warnings are not omitted for that item. This does not affect macros from the stdlib.The following code will not compile under these conditions:
It would be possible to use
#[allow(deprecated)]
on the derivedimpl
block to omit the warnings, but that affects the entire block instead of onlyDeprecatedItem
. This will also not work if the#![forbid(deprecated)]
lint is enabled.I expected to see this happen: The code should compile despite and ignore the use of
DeprecatedItem
when within the[#automatically_derived]
attribute.Instead, this happened: The code does not compile.
Meta
rustc --version --verbose
:The text was updated successfully, but these errors were encountered: