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 ignored if since > rust version and has patch #57952

Closed
ascjones opened this issue Jan 28, 2019 · 6 comments
Closed

Deprecated ignored if since > rust version and has patch #57952

ascjones opened this issue Jan 28, 2019 · 6 comments
Labels
A-attributes Area: #[attributes(..)] C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@ascjones
Copy link

ascjones commented Jan 28, 2019

When since > version of rustc and patch is in the version then deprecated is ignored:

My expectation is that: since is referring to the version of my crate, not the rustc version.

struct Bar {}
impl Bar {
    #[deprecated(since = "1.32.0")]
    fn patch_works(&self) -> () { () }
    
    #[deprecated(since = "1.33.0")]
    fn patch_ignored1(&self) -> () { () }
    
    #[deprecated(since = "2.1.0")]
    fn patch_ignored2(&self) -> () { () }
    
    #[deprecated(since = "2.0")]
    fn minor_works(&self) -> () { () }
}

fn main() {
    let bar = Bar { };
    bar.patch_works();
    bar.patch_ignored1();
    bar.patch_ignored2();
    bar.minor_works();
}

(Playground)

The docs say:

since expects a version number, as in #[deprecated(since = "1.4.1")]
rustc doesn't know anything about versions, but external tools like clippy may check the validity of this field.

@jonas-schievink jonas-schievink added A-attributes Area: #[attributes(..)] C-bug Category: This is a bug. labels Jan 28, 2019
@Centril Centril added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Jan 28, 2019
@varkor
Copy link
Member

varkor commented Jan 28, 2019

Version numbers are according to semantic versioning, in which there must be three components. 2.0 is not a valid version number and as such as ignored.

@ascjones
Copy link
Author

@varkor the deprecated attribute works as expected with 2.0 (see the example). It is when it has all three major.minor.patch (and is greater than 1.32.0) that it is ignored.

@varkor
Copy link
Member

varkor commented Jan 28, 2019

If you add #![warn(deprecated_in_future)] to the example (on Beta or Nightly), then it will warn for future versions too.

@jonas-schievink
Copy link
Contributor

I think that part is only supposed to be used by libstd and not by user crates. All of these examples should warn by default. (it doesn't really make sense to deprecate things in a crate based on the Rust version)

@varkor
Copy link
Member

varkor commented Jan 28, 2019

it doesn't really make sense to deprecate things in a crate based on the Rust version

Ah, that's true. Maybe it does make more sense to always warn in this case.

@ascjones
Copy link
Author

it doesn't really make sense to deprecate things in a crate based on the Rust version

Exactly. My understanding from the docs for the deprecation attribute is that since should refer to the version of my crate - nothing to do with the version of rustc.

Sorry for not being clear enough originally - the problem was I was troubleshooting why a #[deprecated] attribute I had applied was being ignored and I narrowed it down to the cases in the example - and that's when I noticed that it seemed to relate to the rustc version, which looks like a bug, and decided to report it.

I will update the description

Centril added a commit to Centril/rust that referenced this issue Feb 13, 2019
…r=GuillaumeGomez

Ignore future deprecations in #[deprecated]

The future deprecation warnings should only apply to `#[rustc_deprecated]` as they take into account rustc's version. Fixes rust-lang#57952.

I've also slightly modified rustdoc's display of future deprecation notices to make it more consistent, so I'm assigning a rustdoc team member for review to make sure this is okay.

r? @GuillaumeGomez
Centril added a commit to Centril/rust that referenced this issue Feb 13, 2019
…r=GuillaumeGomez

Ignore future deprecations in #[deprecated]

The future deprecation warnings should only apply to `#[rustc_deprecated]` as they take into account rustc's version. Fixes rust-lang#57952.

I've also slightly modified rustdoc's display of future deprecation notices to make it more consistent, so I'm assigning a rustdoc team member for review to make sure this is okay.

r? @GuillaumeGomez
Centril added a commit to Centril/rust that referenced this issue Feb 13, 2019
…r=GuillaumeGomez

Ignore future deprecations in #[deprecated]

The future deprecation warnings should only apply to `#[rustc_deprecated]` as they take into account rustc's version. Fixes rust-lang#57952.

I've also slightly modified rustdoc's display of future deprecation notices to make it more consistent, so I'm assigning a rustdoc team member for review to make sure this is okay.

r? @GuillaumeGomez
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-attributes Area: #[attributes(..)] C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants