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

#[deprecated] incorrectly warns in the same crate if derives are involved #55417

Closed
gnzlbg opened this issue Oct 27, 2018 · 4 comments · Fixed by #65310
Closed

#[deprecated] incorrectly warns in the same crate if derives are involved #55417

gnzlbg opened this issue Oct 27, 2018 · 4 comments · Fixed by #65310
Labels
A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) C-bug Category: This is a bug.

Comments

@gnzlbg
Copy link
Contributor

gnzlbg commented Oct 27, 2018

#[derive(Debug)]
#[deprecated(since = "0.1.1", note = "oh noes")]
pub struct A;

#[derive(PartialOrd)]
#[deprecated(since = "0.1.1", note = "oh noes")]
pub struct B;

fn main() {}

(Playground)

Errors:

   Compiling playground v0.0.1 (/playground)
warning: use of deprecated item 'A': oh noes
  |
  = note: #[warn(deprecated)] on by default

warning: use of deprecated item 'B': oh noes

error[E0277]: can't compare `B` with `B`
 --> src/main.rs:6:10
  |
6 | #[derive(PartialOrd)]
  |          ^^^^^^^^^^ no implementation for `B == B`
  |
  = help: the trait `std::cmp::PartialEq` is not implemented for `B`

error: aborting due to previous error

An easy fix might be to #[allow(deprecated)] in the custom derive implementations provided by Rust. Right now one has to manually #[allow(deprecated)] on all deprecated structs with derives, which is a pain, and also on all their impls...

@jonas-schievink jonas-schievink added A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) C-bug Category: This is a bug. labels Mar 23, 2019
@joshlf
Copy link
Contributor

joshlf commented Oct 5, 2019

Same as #38832?

da-x added a commit to da-x/rust that referenced this issue Oct 11, 2019
The dummy Span pointed to the beginning of the source file instead to
where the `#[derive]` is located. Later, it tripped the
`in_derive_expansion(span)` check at `src/librustc/middle/stability.rs`,
causing a span-less deprecation warning to be emitted.

Fixes rust-lang#56195, rust-lang#55417.
@bors bors closed this as completed in c8e3c51 Oct 12, 2019
@joshlf
Copy link
Contributor

joshlf commented Oct 12, 2019

Should this really have been closed? The fix makes the error message better, but doesn't actually address the issue with the deprecation warning being emitted on the generated impl.

@petrochenkov
Copy link
Contributor

#65310 should indeed address the issue and remove the deprecation warning.
Perhaps it's not in nightly yet?

@joshlf
Copy link
Contributor

joshlf commented Oct 12, 2019

Ah you're probably right. I'll check again tomorrow.

@fmease fmease added A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. and removed A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. labels Dec 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) C-bug Category: This is a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants