Skip to content

Improve errors about #[deprecated] attribute#78626

Merged
bors merged 5 commits intorust-lang:masterfrom
fusion-engineering-forks:deprecated-trait-impl
Nov 3, 2020
Merged

Improve errors about #[deprecated] attribute#78626
bors merged 5 commits intorust-lang:masterfrom
fusion-engineering-forks:deprecated-trait-impl

Conversation

@m-ou-se
Copy link
Member

@m-ou-se m-ou-se commented Nov 1, 2020

This change:

  1. Turns #[deprecated] on a trait impl block into an error, which fixes Deprecation attribute on trait impl block is accepted but has no effect #78625;
  2. Changes these and other errors about #[deprecated] to use the span of the attribute instead of the item; and
  3. Turns this error into a lint, to make sure it can be capped with --cap-lints and doesn't break any existing dependencies.

Can be reviewed per commit.


Example:

struct X;

#[deprecated = "a"]
impl Default for X {
    #[deprecated = "b"]
    fn default() -> Self {
        X
    }
}

Before:

error: This deprecation annotation is useless
 --> src/main.rs:6:5
  |
6 | /     fn default() -> Self {
7 | |         X
8 | |     }
  | |_____^

After:

error: this `#[deprecated]' annotation has no effect
 --> src/main.rs:3:1
  |
3 | #[deprecated = "a"]
  | ^^^^^^^^^^^^^^^^^^^ help: try removing the deprecation attribute
  |
  = note: `#[deny(useless_deprecated)]` on by default

error: this `#[deprecated]' annotation has no effect
 --> src/main.rs:5:5
  |
5 |     #[deprecated = "b"]
  |     ^^^^^^^^^^^^^^^^^^^ help: try removing the deprecation attribute

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-diagnostics Area: Messages for errors, warnings, and lints D-papercut Diagnostics: An error or lint that needs small tweaks. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Deprecation attribute on trait impl block is accepted but has no effect

5 participants