-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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]
on re-exported items does not work
#84584
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
A-lint
Area: Lints (warnings about flaws in source code) such as unused_mut.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Comments
danielhenrymantilla
added
A-diagnostics
Area: Messages for errors, warnings, and lints
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
labels
Apr 26, 2021
rustbot
added
the
A-lint
Area: Lints (warnings about flaws in source code) such as unused_mut.
label
Apr 26, 2021
ugur-a
added a commit
to ugur-a/libaoc
that referenced
this issue
Oct 23, 2024
- leave a reexport for backwards-compatibility - mark it as deprecated - doesn't actually work, see^[1] ^[1]: rust-lang/rust#84584
matthiaskrgr
added a commit
to matthiaskrgr/rust
that referenced
this issue
Dec 12, 2024
Add lint rule for `#[deprecated]` on re-exports As reported in rust-lang#30827 and rust-lang#84584, marking a re-export (`pub use`) with `#[deprecated]` does not produce a warning for consumers. In fact, there are instances of this in the `core` and `std` crates (see past issue rust-lang#82080 where this caused some confusion). This change modifies the stability annotation visitor to mark `#[deprecated]` annotations on `use` statements with `AnnotationKind::DeprecationProhibited` so that library developers are aware that the annotation is not warning their users as expected. ```rust #[deprecated] pub use a_module::ActiveType; ``` ``` error: this `#[deprecated]` annotation has no effect --> $DIR/deprecated_use.rs:6:1 | LL | #[deprecated] | ^^^^^^^^^^^^^ help: remove the unnecessary deprecation attribute | = note: `#[deny(useless_deprecated)]` on by default error: aborting due to 1 previous error ```
Zalathar
added a commit
to Zalathar/rust
that referenced
this issue
Dec 13, 2024
Add lint rule for `#[deprecated]` on re-exports As reported in rust-lang#30827 and rust-lang#84584, marking a re-export (`pub use`) with `#[deprecated]` does not produce a warning for consumers. In fact, there are instances of this in the `core` and `std` crates (see past issue rust-lang#82080 where this caused some confusion). This change modifies the stability annotation visitor to mark `#[deprecated]` annotations on `use` statements with `AnnotationKind::DeprecationProhibited` so that library developers are aware that the annotation is not warning their users as expected. ```rust #[deprecated] pub use a_module::ActiveType; ``` ``` error: this `#[deprecated]` annotation has no effect --> $DIR/deprecated_use.rs:6:1 | LL | #[deprecated] | ^^^^^^^^^^^^^ help: remove the unnecessary deprecation attribute | = note: `#[deny(useless_deprecated)]` on by default error: aborting due to 1 previous error ```
matthiaskrgr
added a commit
to matthiaskrgr/rust
that referenced
this issue
Dec 13, 2024
Add lint rule for `#[deprecated]` on re-exports As reported in rust-lang#30827 and rust-lang#84584, marking a re-export (`pub use`) with `#[deprecated]` does not produce a warning for consumers. In fact, there are instances of this in the `core` and `std` crates (see past issue rust-lang#82080 where this caused some confusion). This change modifies the stability annotation visitor to mark `#[deprecated]` annotations on `use` statements with `AnnotationKind::DeprecationProhibited` so that library developers are aware that the annotation is not warning their users as expected. ```rust #[deprecated] pub use a_module::ActiveType; ``` ``` error: this `#[deprecated]` annotation has no effect --> $DIR/deprecated_use.rs:6:1 | LL | #[deprecated] | ^^^^^^^^^^^^^ help: remove the unnecessary deprecation attribute | = note: `#[deny(useless_deprecated)]` on by default error: aborting due to 1 previous error ```
matthiaskrgr
added a commit
to matthiaskrgr/rust
that referenced
this issue
Dec 13, 2024
Add lint rule for `#[deprecated]` on re-exports As reported in rust-lang#30827 and rust-lang#84584, marking a re-export (`pub use`) with `#[deprecated]` does not produce a warning for consumers. In fact, there are instances of this in the `core` and `std` crates (see past issue rust-lang#82080 where this caused some confusion). This change modifies the stability annotation visitor to mark `#[deprecated]` annotations on `use` statements with `AnnotationKind::DeprecationProhibited` so that library developers are aware that the annotation is not warning their users as expected. ```rust #[deprecated] pub use a_module::ActiveType; ``` ``` error: this `#[deprecated]` annotation has no effect --> $DIR/deprecated_use.rs:6:1 | LL | #[deprecated] | ^^^^^^^^^^^^^ help: remove the unnecessary deprecation attribute | = note: `#[deny(useless_deprecated)]` on by default error: aborting due to 1 previous error ```
matthiaskrgr
added a commit
to matthiaskrgr/rust
that referenced
this issue
Dec 13, 2024
Add lint rule for `#[deprecated]` on re-exports As reported in rust-lang#30827 and rust-lang#84584, marking a re-export (`pub use`) with `#[deprecated]` does not produce a warning for consumers. In fact, there are instances of this in the `core` and `std` crates (see past issue rust-lang#82080 where this caused some confusion). This change modifies the stability annotation visitor to mark `#[deprecated]` annotations on `use` statements with `AnnotationKind::DeprecationProhibited` so that library developers are aware that the annotation is not warning their users as expected. ```rust #[deprecated] pub use a_module::ActiveType; ``` ``` error: this `#[deprecated]` annotation has no effect --> $DIR/deprecated_use.rs:6:1 | LL | #[deprecated] | ^^^^^^^^^^^^^ help: remove the unnecessary deprecation attribute | = note: `#[deny(useless_deprecated)]` on by default error: aborting due to 1 previous error ```
bors
added a commit
to rust-lang-ci/rust
that referenced
this issue
Dec 13, 2024
Add lint rule for `#[deprecated]` on re-exports As reported in rust-lang#30827 and rust-lang#84584, marking a re-export (`pub use`) with `#[deprecated]` does not produce a warning for consumers. In fact, there are instances of this in the `core` and `std` crates (see past issue rust-lang#82080 where this caused some confusion). This change modifies the stability annotation visitor to mark `#[deprecated]` annotations on `use` statements with `AnnotationKind::DeprecationProhibited` so that library developers are aware that the annotation is not warning their users as expected. ```rust #[deprecated] pub use a_module::ActiveType; ``` ``` error: this `#[deprecated]` annotation has no effect --> $DIR/deprecated_use.rs:6:1 | LL | #[deprecated] | ^^^^^^^^^^^^^ help: remove the unnecessary deprecation attribute | = note: `#[deny(useless_deprecated)]` on by default error: aborting due to 1 previous error ``` try-job: dist-x86_64-linux
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
A-lint
Area: Lints (warnings about flaws in source code) such as unused_mut.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Problem
Given the following code: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=ac1e0d070ba838247ac3587ca23bbaed
The current output is:
deprecated warnings for all four usages of
ConstAndTy
(constant value, type, constant pattern, literal struct constructor).No warnings whatsoever for any of the four usages of
DeprecatedAlias
.Moreover, even if it were to lint about the
use
-reexported deprecated item, I suspect there would be no mention of the item at the origin of the re-export, even when visible and not deprecated itself.Suggested improvement
Ideally:
the output should warn about
DeprecatedAlias
too:And when the source of the re-export is visible to the scope where the deprecated alias is used, it should also suggest using that path instead:
Rationale and further discussion
c.f. https://rust-lang.zulipchat.com/#narrow/stream/122651-general/topic/Updating.20reverse.20dependencies.20using.20code.20modification
The text was updated successfully, but these errors were encountered: