Skip to content

Regression: this #[deprecated] annotation has no effect #79304

Closed
@kpcyrd

Description

@kpcyrd

Code

I tried this code:

struct X {}

#[deprecated(since="0.2.2", note="Use the `AsRef` or `AsMut` implementation instead")]
impl ::std::ops::Index<::std::ops::RangeFull> for X {
    type Output = [u8];
    fn index(&self, _index: ::std::ops::RangeFull) -> &[u8] {
        todo!();
    }
}

fn main() {
    println!("Hello, world!");
}

This code currently compiles on stable rust, but stops working on nightly and beta. The example code is a reduced case from sodiumoxide which is currently broken on nightly and beta.

% cargo check      
    Checking regress v0.1.0 (/<redacted>)
    Finished dev [unoptimized + debuginfo] target(s) in 0.62s
% cargo +beta check
    Checking regress v0.1.0 (/<redacted>)
error: this `#[deprecated]` annotation has no effect
 --> src/main.rs:3:1
  |
3 | #[deprecated(since="0.2.2", note="Use the `AsRef` or `AsMut` implementation instead")]
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove the unnecessary deprecation attribute
  |
  = note: `#[deny(useless_deprecated)]` on by default

error: aborting due to previous error

error: could not compile `regress`

To learn more, run the command again with --verbose.

Version it worked on

It most recently worked on: 1.48.0

Version with regression

rustc --version --verbose:

rustc 1.49.0-beta.1 (21dea46d8 2020-11-18)
binary: rustc
commit-hash: 21dea46d8347c8b4117c5567949703f0fbb51649
commit-date: 2020-11-18
host: x86_64-unknown-linux-gnu
release: 1.49.0-beta.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.A-stabilityArea: `#[stable]`, `#[unstable]` etc.regression-from-stable-to-betaPerformance or correctness regression from stable to beta.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions