-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Allow deprecating a re-export #30827
Comments
Triage: the final syntax for mod foo {
#[deprecated(note = "use Foo instead")]
pub use self::Foo as Bar;
pub struct Foo(pub i32);
}
use self::foo::Bar; // <- deprecrated, use Foo instead however, this still reproduces. With no comments in two years, I'm not sure if this will ever be implemented. @rust-lang/lang , is this feature desired? |
I'd like to see this; |
I agree with @joshtriplett. |
IIUC, in the current system, by the time stability/deprecation checks run, information about where you got something from, is lost (it's transient during name resolution). |
|
Same issue - #23937. |
@petrochenkov Would it be a good idea to integrate stability / deprecation with visibility a bit more?
And these would compose across the entire import chain to that destination. However, one complicated aspect is how hierarchical stability is - if something is not annotated, one of its parents might be instead, and that's where it's inherited from. So we'd be doing the "reverse" computation (walking up parents), which shouldn't be significantly more expensive, if we're caching everything computed along the way. |
@eddyb |
Note that this caused actual problems in the standard library itself, where two items that were supposedly deprecated were silently failing to trigger the deprecation warning for several years: #82080 Would making the attribute itself error when applied to a |
From #83269 (comment) :
|
Currently `#[deprecated]` cannot be used for a use declaration (see <rust-lang/rust#30827>), so make it `pub type` temporarily. I believe this change is not breaking since the constructor of `DebugPrettyPrint` is not public.
As pointed out by Sebastien Boeuf [1], the kernel headers are backwards compatible, so there's no need to maintain the bindings for multiple kernel versions. And doing so will make updating the bindings easier, as it won't require adding a new feature each time. It's unfortunately not possible for us to emit a deprecation warning for the features, as in Rust deprecation warnings have to be applied to functions/constants/etc. (not modules or re-exports [2]), so any deprecation warning in this crate would mean editing the generated bindings files. But it doesn't really do any harm to keep the feature declarations in the Cargo.toml around indefinitely. [1]: rust-vmm/virtio-bindings#35 (comment) [2]: rust-lang/rust#30827 Signed-off-by: Alyssa Ross <[email protected]>
As pointed out by Sebastien Boeuf [1], the kernel headers are backwards compatible, so there's no need to maintain the bindings for multiple kernel versions. And doing so will make updating the bindings easier, as it won't require adding a new feature each time. It's unfortunately not possible for us to emit a deprecation warning for the features, as in Rust deprecation warnings have to be applied to functions/constants/etc. (not modules or re-exports [2]), so any deprecation warning in this crate would mean editing the generated bindings files. But it doesn't really do any harm to keep the feature declarations in the Cargo.toml around indefinitely. [1]: rust-vmm/virtio-bindings#35 (comment) [2]: rust-lang/rust#30827 Signed-off-by: Alyssa Ross <[email protected]>
Hey, I'd find the ability to deprecate re-exports very useful for maintaining PyO3, so I'm interested in working on this.
@petrochenkov is the above statement still true, and option (1) preferred? From a quick scan of the code it looks like that is the case. Appreciate that you previously said you're not interested in mentoring this issue. Is there a Zulip room which would be appropriate for me to ask questions about direction / implementation of this? |
As deprecated re-exports are unsupported [0], we go the hard way and just make it a breaking change. Along the way, I reordered some statements in some files to follow our typical order of: - pub mod - private mod - pub use - private use [0] rust-lang/rust#30827
rustdoc: inherit parent's stability where applicable It is currently not possible for a re-export to have a different stability (rust-lang#30827). Therefore the standard library uses a hack when moving items like `std::error::Error` or `std::net::IpAddr` into `core` by marking the containing module (`core::error` / `core::net`) as unstable or stable in a later version than the items the module contains. Previously, rustdoc would always show the *stability as declared* for an item rather than the *stability as publicly reachable* (i.e. the features required to actually access the item), which could be confusing when viewing the docs. This PR changes it so that we show the stability of the first unstable parent or the most recently stabilized parent instead, to hopefully make things less confusing. fixes rust-lang#130765 screenshots: ![error in std](https://github.com/user-attachments/assets/2ab9bdb9-ed81-4e45-a832-ac7d3ba1be3f) ![error in core](https://github.com/user-attachments/assets/46f46182-5642-4ac5-b92e-0b99a8e2496d)
Rollup merge of rust-lang#130798 - lukas-code:doc-stab, r=notriddle rustdoc: inherit parent's stability where applicable It is currently not possible for a re-export to have a different stability (rust-lang#30827). Therefore the standard library uses a hack when moving items like `std::error::Error` or `std::net::IpAddr` into `core` by marking the containing module (`core::error` / `core::net`) as unstable or stable in a later version than the items the module contains. Previously, rustdoc would always show the *stability as declared* for an item rather than the *stability as publicly reachable* (i.e. the features required to actually access the item), which could be confusing when viewing the docs. This PR changes it so that we show the stability of the first unstable parent or the most recently stabilized parent instead, to hopefully make things less confusing. fixes rust-lang#130765 screenshots: ![error in std](https://github.com/user-attachments/assets/2ab9bdb9-ed81-4e45-a832-ac7d3ba1be3f) ![error in core](https://github.com/user-attachments/assets/46f46182-5642-4ac5-b92e-0b99a8e2496d)
rustdoc: inherit parent's stability where applicable It is currently not possible for a re-export to have a different stability (rust-lang/rust#30827). Therefore the standard library uses a hack when moving items like `std::error::Error` or `std::net::IpAddr` into `core` by marking the containing module (`core::error` / `core::net`) as unstable or stable in a later version than the items the module contains. Previously, rustdoc would always show the *stability as declared* for an item rather than the *stability as publicly reachable* (i.e. the features required to actually access the item), which could be confusing when viewing the docs. This PR changes it so that we show the stability of the first unstable parent or the most recently stabilized parent instead, to hopefully make things less confusing. fixes rust-lang/rust#130765 screenshots: ![error in std](https://github.com/user-attachments/assets/2ab9bdb9-ed81-4e45-a832-ac7d3ba1be3f) ![error in core](https://github.com/user-attachments/assets/46f46182-5642-4ac5-b92e-0b99a8e2496d)
This would allow a module to rename an identifier without breaking users, and provide a message that they should change.
Example:
The text was updated successfully, but these errors were encountered: