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 lint should not warn within a deprecated module #16490

Closed
aturon opened this issue Aug 14, 2014 · 6 comments · Fixed by #35317
Closed

deprecated lint should not warn within a deprecated module #16490

aturon opened this issue Aug 14, 2014 · 6 comments · Fixed by #35317
Labels
A-lint Area: Lints (warnings about flaws in source code) such as unused_mut.

Comments

@aturon
Copy link
Member

aturon commented Aug 14, 2014

The stability lint was recently changed to warn on use of deprecated items even when they are defined in the same crate. An unintended consequence is that, when an entire module is deprecated, the body of the module will warn on every use of items defined within it.

We should change this behavior, but it's not entirely clear what the rule should be or how to implement it.

@aturon
Copy link
Member Author

aturon commented Aug 14, 2014

cc @sfackler

@aturon aturon added the A-lint label Aug 14, 2014
@steveklabnik
Copy link
Member

To reproduce:

#![feature(staged_api)]
#![staged_api]

#[unstable(feature = "lol", issue = "1")]
#[deprecated(since = "1.0.0", reason = "lol")]
mod nope {
    pub fn foo() {}
    pub fn bar() {}
}

fn main() {
    nope::foo();
    nope::bar();
}

this will give both

hello.rs:12:5: 12:14 warning: use of deprecated item: lol, #[warn(deprecated)] on by default
hello.rs:12     nope::foo();
                ^~~~~~~~~
hello.rs:13:5: 13:14 warning: use of deprecated item: lol, #[warn(deprecated)] on by default
hello.rs:13     nope::bar();
                ^~~~~~~~~

It's been a year, with no discussion at all. I'm not sure this is worth doing.

@TimNN
Copy link
Contributor

TimNN commented Jul 31, 2016

This just came up again in #35128, although a little bit more surprisingly, due to the expansion of format_args! inside of a deprecated function.

@steveklabnik: If I understand the original issue correctly, I believe your code should continue to warn about the use of deprecated item.

I believe the issue is that the following warning should not happen:

#[deprecated]
mod nope {
    fn foo() {}

    fn bar() {
        foo() //~ WARN use of deprecated item
    }
}

@eddyb
Copy link
Member

eddyb commented Jul 31, 2016

The fix doesn't seem that hard. depr_map can contain a DefId pointing to the definition marked with the #[deprecated] attribute, instead of Deprecation (which can be obtained on demand).
Then, if the current node and the referenced node both have the same DefId, no warning is issued.

@TimNN
Copy link
Contributor

TimNN commented Jul 31, 2016

If nobody has picked this up by then, I'll see if I can come up with a fix for this towards the end of the week.

@cengiz-io
Copy link
Contributor

@eddyb I can work this if nobody else wants to.

LiveEdit: I guess @TimNN wants. 🍀

TimNN added a commit to TimNN/rust that referenced this issue Aug 4, 2016
Whenever a node whould be reported as deprecated:

- check if the parent item is also deprecated

- if it is and both were deprecated by the same attribute

- skip the deprecation warning

fixes rust-lang#35128
closes rust-lang#16490
TimNN added a commit to TimNN/rust that referenced this issue Aug 4, 2016
Whenever a node whould be reported as deprecated:

- check if the parent item is also deprecated

- if it is and both were deprecated by the same attribute

- skip the deprecation warning

fixes rust-lang#35128
closes rust-lang#16490
bors added a commit that referenced this issue Aug 5, 2016
Ignore deprecation for items deprecated by the same attribute

Whenever a node would be reported as deprecated:

- check if the parent item is also deprecated
- if it is and both were deprecated by the same attribute
- skip the deprecation warning

fixes #35128
closes #16490

r? @eddyb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lint Area: Lints (warnings about flaws in source code) such as unused_mut.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants