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

Using deprecated items within the crate that deprecated them issues warnings #47219

Open
CasualX opened this issue Jan 5, 2018 · 5 comments
Open
Labels
A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. C-bug Category: This is a bug. L-deprecated Lint: deprecated T-lang Relevant to the language team, which will review and decide on the PR/issue.

Comments

@CasualX
Copy link

CasualX commented Jan 5, 2018

When deprecating an item, you typically still want the helper methods supporting it to work without the compiler whining that the item is deprecated.

I tried this code: playground

#[deprecated]
pub struct Foo;

impl Foo {
    fn foo() -> Foo { Foo }
}

I expected to see this happen: The code compiles without deprecation warnings.

Instead, this happened: Litterally every usage of Foo gets a use of deprecated item Foo warning.

The fact that I'm deprecating an item doesn't mean the crate itself should now be spammed with deprecation warnings. Working around it by either a global #![allow(deprecated)] will swallow legitimate deprecation warnings or require all uses to be tagged with it.

Meta

Playground, all channels (how do you get the version info from the playground?)

@CasualX
Copy link
Author

CasualX commented Jan 5, 2018

Whelp, I only read the RFC (rust-lang/rfcs#1270), not its accompanying tracking issue (#29935) where some people have written concerns about the extreme verbosity of deprecated warnings but the discussion died out.

I was thinking in the direction of allowing access to deprecated items in the crate which defines it in its entirety but I imagine that's more something for rust-lang/rfcs. Still the extreme verbosity of deprecated warning deserves an issue.

@pietroalbini pietroalbini added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. C-feature-request Category: A feature request, i.e: not implemented / a PR. labels Feb 6, 2018
@stevenroose
Copy link

So I still have this issue. We deprecated a type, and suddenly we get tens of deprecation warnings of internal usage of this type, which are just method implementations on those types. Adding a deprecation warning to all these methods doesn't change anything.

I tried adding #[allow(deprecated)] to the impl block of the deprecated type, but then I got this weird warning message without line number (albeit shorter):

warning: use of deprecated item 'util::bip143::SighashComponents': please use `SigHashCache` instead
  |
  = note: `#[warn(deprecated)]` on by default

warning: use of deprecated item 'util::bip143::SighashComponents': please use `SigHashCache` instead

    Finished dev [unoptimized + debuginfo] target(s) in 2.95s

bors bot added a commit to codyps/rust-systemd that referenced this issue Nov 3, 2020
154: journal: adjust open() mechanisms to use a builder pattern r=jmesmon a=jmesmon

 - `JournalFiles` doesn't properly cover all inclusions/exclusions
 - The various boolean arguments were leading to "boolean blindness" (ie: lack of clarity in what `open()` call options meant).
 - `OpenOptions`, `OpenFileOptions`, and `OpenDirectoryOptions` are added. These are patterned after `std::fs::OpenOptions`.
 - I've marked the commonly used `Journal::open()` as deprecated (and was somewhat annoyed by rust-lang/rust#47219).
 - I've removed `Journal::open_directory` and `Journal::open_files` entirely. They'll need to use the new `journal::OpenFileOptions` and `journal::OpenDirectoryOptions`.

Co-authored-by: Cody P Schafer <dev@codyps.com>
bors bot added a commit to codyps/rust-systemd that referenced this issue Nov 3, 2020
154: journal: adjust open() mechanisms to use a builder pattern r=jmesmon a=jmesmon

 - `JournalFiles` doesn't properly cover all inclusions/exclusions
 - The various boolean arguments were leading to "boolean blindness" (ie: lack of clarity in what `open()` call options meant).
 - `OpenOptions`, `OpenFileOptions`, and `OpenDirectoryOptions` are added. These are patterned after `std::fs::OpenOptions`.
 - I've marked the commonly used `Journal::open()` as deprecated (and was somewhat annoyed by rust-lang/rust#47219).
 - I've removed `Journal::open_directory` and `Journal::open_files` entirely. They'll need to use the new `journal::OpenFileOptions` and `journal::OpenDirectoryOptions`.

Co-authored-by: Cody P Schafer <dev@codyps.com>
@WiSaGaN
Copy link
Contributor

WiSaGaN commented Apr 2, 2021

Another related case is whether we should still output deprecated usage warnings for deprecated items inside an already deprecated item.

Say we have an deprecated item Foo in crate foo, and we have below code (in crate foo or in another crate foo2)

#[deprecated]
pub fn drop_foo(f: Foo) {
}

In this case the usage is already in a deprecated function, there is little upside to change the already deprecated code. We can however to add an option if it may indeed be useful in some cases.

@Dylan-DPC Dylan-DPC added C-bug Category: This is a bug. and removed C-feature-request Category: A feature request, i.e: not implemented / a PR. labels Dec 2, 2023
@Enselic
Copy link
Member

Enselic commented Nov 12, 2024

When deprecating an item, you typically still want the helper methods supporting it to work without the compiler whining that the item is deprecated.

Typically you want to know about all usages of a deprecated item, since you want to remove all usage of it. And where you want to temporarily still use it it makes sense to have to add #[allow(deprecated)]. I use the term "temporary" since long term the item will be removed.

Triage: Changing to T-lang since I don't think it's self evident that this should be changed.

@Enselic Enselic added T-lang Relevant to the language team, which will review and decide on the PR/issue. and removed T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Nov 12, 2024
@CasualX
Copy link
Author

CasualX commented Nov 15, 2024

Typically you want to know about all usages of a deprecated item, since you want to remove all usage of it. And where you want to temporarily still use it it makes sense to have to add #[allow(deprecated)]. I use the term "temporary" since long term the item will be removed.

When I made this issue I came from a perspective of using deprecated as a tool to guide consumers of the crate on what to use (without breaking compatibility).

Within my own crate I can just xref all uses and break/fix things as there is no compatibility hazard.

@fmease fmease added A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. L-deprecated Lint: deprecated labels Dec 28, 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. C-bug Category: This is a bug. L-deprecated Lint: deprecated T-lang Relevant to the language team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

7 participants