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

Tracking issue for #[deprecated] #29935

Closed
alexcrichton opened this issue Nov 19, 2015 · 19 comments
Closed

Tracking issue for #[deprecated] #29935

alexcrichton opened this issue Nov 19, 2015 · 19 comments
Labels
B-unstable Blocker: Implemented in the nightly compiler and unstable. final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.

Comments

@alexcrichton
Copy link
Member

Tracking issue for rust-lang/rfcs#1270

@alexcrichton alexcrichton added the B-RFC-approved Blocker: Approved by a merged RFC but not yet implemented. label Nov 19, 2015
@llogiq
Copy link
Contributor

llogiq commented Nov 20, 2015

So should we

  • rename the current rustc-internal feature
  • extends and change the feature so it works (unstably) outside of rustc?

@huonw
Copy link
Member

huonw commented Nov 20, 2015

Renaming may help ensure there's no accidental contamination of the stable one with any new features in the internal one.

@llogiq
Copy link
Contributor

llogiq commented Nov 20, 2015

OK, I'll see if I find the time to whip up a PR to rename #[deprecated] to #[rustc_deprecated].

@petrochenkov
Copy link
Contributor

@llogiq

OK, I'll see if I find the time to whip up a PR to rename #[deprecated] to #[rustc_deprecated]

I'll go ahead and do it right now if you do not mind.
(I'm currently doing some work with stability anyway)

@llogiq
Copy link
Contributor

llogiq commented Nov 20, 2015

Fine with me.

bors added a commit that referenced this issue Nov 23, 2015
Part of #29935

The deprecation lint is still called "deprecated", so people can continue using `#[allow(deprecated)]` and similar things.
bors added a commit that referenced this issue Dec 16, 2015
Closes #29935

The attributes `deprecated` and `rustc_deprecated` are completely independent in this implementation and it leads to some noticeable code duplication. Representing `deprecated` as
```
Stability {
    level: Stable { since: "" },
    feature: "",
    depr: Some(Deprecation),
}
```
or, contrariwise, splitting rustc_deprecation from stability makes most of the duplication go away.
I can do this refactoring, but before doing it I must be sure, that further divergence of `deprecated` and `rustc_deprecated` is certainly not a goal.

cc @llogiq
@bluss
Copy link
Member

bluss commented Feb 8, 2016

#[deprecated] is great, but still unstable! Can we stabilize it soon? I'm putting it to use where possible.

I am reopening this as the tracking issue should be open until it's stable.

@bluss bluss reopened this Feb 8, 2016
@bluss bluss added the B-unstable Blocker: Implemented in the nightly compiler and unstable. label Feb 8, 2016
@bluss bluss changed the title Allow #[deprecated] outside of #[staged_api] Tracking issue for #[deprecated] Feb 8, 2016
@petrochenkov
Copy link
Contributor

Oh, by the way, #[deprecated] on a module (or any other item) is inherited by all the child items of that module.
This behavior is reasonable and it's inherited from #[rustc_deprecated] and other stability attributes, but it was never discussed explicitly, AFAIR.
One minor drawback of this behavior is that items inside of deprecated modules can't be "undeprecated".

@alexcrichton alexcrichton added T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. and removed B-RFC-approved Blocker: Approved by a merged RFC but not yet implemented. labels Feb 18, 2016
@alexcrichton
Copy link
Member Author

🔔 This issue is now entering its cycle-long final comment period for stabilization in 1.9 🔔

A question to consider as part of FCP is that you can't selectively allow deprecations, only blanket allow deprecations. This is somewhat unfortunate as you frequently just want to allow usage of one deprecated API, but not necessarily all.

@alexcrichton alexcrichton added final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. and removed I-nominated labels Mar 11, 2016
@jonas-schievink
Copy link
Contributor

@alexcrichton When attributes on statements and expression are stable (and the current #[allow] logic is fixed), you could just allow a single use of a deprecated item

@alexcrichton
Copy link
Member Author

@jonas-schievink indeed! One problem with that though is if I have widespread usage of one API in my program I'd have to tag lots of places as #[allow] :(

An example is that in the past Cargo was trying to support super old Rust versions, and one notable part of that was the deprecation of str::connect in favor of str::join, where Cargo called connect quite a bit. This ended up meaning that #[allow(deprecated)] had to be put in lots of places :(

@llogiq
Copy link
Contributor

llogiq commented Mar 11, 2016

One partial solution is to write a non-deprecated wrapper around the deprecated API and redact usage to use the wrapper. Of course this is tedious.

@huonw
Copy link
Member

huonw commented Apr 6, 2016

A question to consider as part of FCP is that you can't selectively allow deprecations, only blanket allow deprecations. This is somewhat unfortunate as you frequently just want to allow usage of one deprecated API, but not necessarily all.

Easy targeted allows is the sticking point for me, e.g. people are able to stick an attribute at the top of a crate, rather than at every usage, or writing their own wrappers. Without that, it seems like widespread usage of #[deprecated] by library authors (a good thing!) would result in a lot of crates with #[allow(deprecated)] due to one dependency. This would dramatically weaken the utility of deprecated: any crate with that allow would get no new deprecation warnings even from crates that they did not originally need the allow for.

(For that reason, maybe we want to deprecate #[allow(deprecated)] once we have targeted allows, either removing that blanket allow functionality, or at least making it more explicit?)

@bluss
Copy link
Member

bluss commented Apr 6, 2016

I've only had to put allow(deprecated) on use lines and the actual methods where I used the deprecated items. That was pretty well scoped.

@jan-hudec
Copy link

Actually I would consider a better option to normally keep the warnings, but report each deprecated symbol only once. That would make it short enough to notice any new warnings while keeping it up as a reminder that something needs to be done about it.

@hoodie
Copy link
Contributor

hoodie commented Apr 6, 2016

isn't that already the case?

@alexcrichton
Copy link
Member Author

The libs team discussed this during triage yesterday and the decision was to stabilize.

We discussed @huonw's concern but we felt that this has been waiting long enough and the situation isn't bad enough that we should hold off stabilization.

alexcrichton added a commit to alexcrichton/rust that referenced this issue Apr 11, 2016
This commit applies all stabilizations, renamings, and deprecations that the
library team has decided on for the upcoming 1.9 release. All tracking issues
have gone through a cycle-long "final comment period" and the specific APIs
stabilized/deprecated are:

Stable

* `std::panic`
* `std::panic::catch_unwind` (renamed from `recover`)
* `std::panic::resume_unwind` (renamed from `propagate`)
* `std::panic::AssertUnwindSafe` (renamed from `AssertRecoverSafe`)
* `std::panic::UnwindSafe` (renamed from `RecoverSafe`)
* `str::is_char_boundary`
* `<*const T>::as_ref`
* `<*mut T>::as_ref`
* `<*mut T>::as_mut`
* `AsciiExt::make_ascii_uppercase`
* `AsciiExt::make_ascii_lowercase`
* `char::decode_utf16`
* `char::DecodeUtf16`
* `char::DecodeUtf16Error`
* `char::DecodeUtf16Error::unpaired_surrogate`
* `BTreeSet::take`
* `BTreeSet::replace`
* `BTreeSet::get`
* `HashSet::take`
* `HashSet::replace`
* `HashSet::get`
* `OsString::with_capacity`
* `OsString::clear`
* `OsString::capacity`
* `OsString::reserve`
* `OsString::reserve_exact`
* `OsStr::is_empty`
* `OsStr::len`
* `std::os::unix::thread`
* `RawPthread`
* `JoinHandleExt`
* `JoinHandleExt::as_pthread_t`
* `JoinHandleExt::into_pthread_t`
* `HashSet::hasher`
* `HashMap::hasher`
* `CommandExt::exec`
* `File::try_clone`
* `SocketAddr::set_ip`
* `SocketAddr::set_port`
* `SocketAddrV4::set_ip`
* `SocketAddrV4::set_port`
* `SocketAddrV6::set_ip`
* `SocketAddrV6::set_port`
* `SocketAddrV6::set_flowinfo`
* `SocketAddrV6::set_scope_id`
* `<[T]>::copy_from_slice`
* `ptr::read_volatile`
* `ptr::write_volatile`
* The `#[deprecated]` attribute
* `OpenOptions::create_new`

Deprecated

* `std::raw::Slice` - use raw parts of `slice` module instead
* `std::raw::Repr` - use raw parts of `slice` module instead
* `str::char_range_at` - use slicing plus `chars()` plus `len_utf8`
* `str::char_range_at_reverse` - use slicing plus `chars().rev()` plus `len_utf8`
* `str::char_at` - use slicing plus `chars()`
* `str::char_at_reverse` - use slicing plus `chars().rev()`
* `str::slice_shift_char` - use `chars()` plus `Chars::as_str`
* `CommandExt::session_leader` - use `before_exec` instead.

Closes rust-lang#27719
cc rust-lang#27751 (deprecating the `Slice` bits)
Closes rust-lang#27754
Closes rust-lang#27780
Closes rust-lang#27809
Closes rust-lang#27811
Closes rust-lang#27830
Closes rust-lang#28050
Closes rust-lang#29453
Closes rust-lang#29791
Closes rust-lang#29935
Closes rust-lang#30014
Closes rust-lang#30752
Closes rust-lang#31262
cc rust-lang#31398 (still need to deal with `before_exec`)
Closes rust-lang#31405
Closes rust-lang#31572
Closes rust-lang#31755
Closes rust-lang#31756
bors added a commit that referenced this issue Apr 12, 2016
std: Stabilize APIs for the 1.9 release

This commit applies all stabilizations, renamings, and deprecations that the
library team has decided on for the upcoming 1.9 release. All tracking issues
have gone through a cycle-long "final comment period" and the specific APIs
stabilized/deprecated are:

Stable

* `std::panic`
* `std::panic::catch_unwind` (renamed from `recover`)
* `std::panic::resume_unwind` (renamed from `propagate`)
* `std::panic::AssertUnwindSafe` (renamed from `AssertRecoverSafe`)
* `std::panic::UnwindSafe` (renamed from `RecoverSafe`)
* `str::is_char_boundary`
* `<*const T>::as_ref`
* `<*mut T>::as_ref`
* `<*mut T>::as_mut`
* `AsciiExt::make_ascii_uppercase`
* `AsciiExt::make_ascii_lowercase`
* `char::decode_utf16`
* `char::DecodeUtf16`
* `char::DecodeUtf16Error`
* `char::DecodeUtf16Error::unpaired_surrogate`
* `BTreeSet::take`
* `BTreeSet::replace`
* `BTreeSet::get`
* `HashSet::take`
* `HashSet::replace`
* `HashSet::get`
* `OsString::with_capacity`
* `OsString::clear`
* `OsString::capacity`
* `OsString::reserve`
* `OsString::reserve_exact`
* `OsStr::is_empty`
* `OsStr::len`
* `std::os::unix::thread`
* `RawPthread`
* `JoinHandleExt`
* `JoinHandleExt::as_pthread_t`
* `JoinHandleExt::into_pthread_t`
* `HashSet::hasher`
* `HashMap::hasher`
* `CommandExt::exec`
* `File::try_clone`
* `SocketAddr::set_ip`
* `SocketAddr::set_port`
* `SocketAddrV4::set_ip`
* `SocketAddrV4::set_port`
* `SocketAddrV6::set_ip`
* `SocketAddrV6::set_port`
* `SocketAddrV6::set_flowinfo`
* `SocketAddrV6::set_scope_id`
* `<[T]>::copy_from_slice`
* `ptr::read_volatile`
* `ptr::write_volatile`
* The `#[deprecated]` attribute
* `OpenOptions::create_new`

Deprecated

* `std::raw::Slice` - use raw parts of `slice` module instead
* `std::raw::Repr` - use raw parts of `slice` module instead
* `str::char_range_at` - use slicing plus `chars()` plus `len_utf8`
* `str::char_range_at_reverse` - use slicing plus `chars().rev()` plus `len_utf8`
* `str::char_at` - use slicing plus `chars()`
* `str::char_at_reverse` - use slicing plus `chars().rev()`
* `str::slice_shift_char` - use `chars()` plus `Chars::as_str`
* `CommandExt::session_leader` - use `before_exec` instead.

Closes #27719
cc #27751 (deprecating the `Slice` bits)
Closes #27754
Closes #27780
Closes #27809
Closes #27811
Closes #27830
Closes #28050
Closes #29453
Closes #29791
Closes #29935
Closes #30014
Closes #30752
Closes #31262
cc #31398 (still need to deal with `before_exec`)
Closes #31405
Closes #31572
Closes #31755
Closes #31756
alexcrichton added a commit to alexcrichton/rust that referenced this issue Apr 12, 2016
This commit applies all stabilizations, renamings, and deprecations that the
library team has decided on for the upcoming 1.9 release. All tracking issues
have gone through a cycle-long "final comment period" and the specific APIs
stabilized/deprecated are:

Stable

* `std::panic`
* `std::panic::catch_unwind` (renamed from `recover`)
* `std::panic::resume_unwind` (renamed from `propagate`)
* `std::panic::AssertUnwindSafe` (renamed from `AssertRecoverSafe`)
* `std::panic::UnwindSafe` (renamed from `RecoverSafe`)
* `str::is_char_boundary`
* `<*const T>::as_ref`
* `<*mut T>::as_ref`
* `<*mut T>::as_mut`
* `AsciiExt::make_ascii_uppercase`
* `AsciiExt::make_ascii_lowercase`
* `char::decode_utf16`
* `char::DecodeUtf16`
* `char::DecodeUtf16Error`
* `char::DecodeUtf16Error::unpaired_surrogate`
* `BTreeSet::take`
* `BTreeSet::replace`
* `BTreeSet::get`
* `HashSet::take`
* `HashSet::replace`
* `HashSet::get`
* `OsString::with_capacity`
* `OsString::clear`
* `OsString::capacity`
* `OsString::reserve`
* `OsString::reserve_exact`
* `OsStr::is_empty`
* `OsStr::len`
* `std::os::unix::thread`
* `RawPthread`
* `JoinHandleExt`
* `JoinHandleExt::as_pthread_t`
* `JoinHandleExt::into_pthread_t`
* `HashSet::hasher`
* `HashMap::hasher`
* `CommandExt::exec`
* `File::try_clone`
* `SocketAddr::set_ip`
* `SocketAddr::set_port`
* `SocketAddrV4::set_ip`
* `SocketAddrV4::set_port`
* `SocketAddrV6::set_ip`
* `SocketAddrV6::set_port`
* `SocketAddrV6::set_flowinfo`
* `SocketAddrV6::set_scope_id`
* `<[T]>::copy_from_slice`
* `ptr::read_volatile`
* `ptr::write_volatile`
* The `#[deprecated]` attribute
* `OpenOptions::create_new`

Deprecated

* `std::raw::Slice` - use raw parts of `slice` module instead
* `std::raw::Repr` - use raw parts of `slice` module instead
* `str::char_range_at` - use slicing plus `chars()` plus `len_utf8`
* `str::char_range_at_reverse` - use slicing plus `chars().rev()` plus `len_utf8`
* `str::char_at` - use slicing plus `chars()`
* `str::char_at_reverse` - use slicing plus `chars().rev()`
* `str::slice_shift_char` - use `chars()` plus `Chars::as_str`
* `CommandExt::session_leader` - use `before_exec` instead.

Closes rust-lang#27719
cc rust-lang#27751 (deprecating the `Slice` bits)
Closes rust-lang#27754
Closes rust-lang#27780
Closes rust-lang#27809
Closes rust-lang#27811
Closes rust-lang#27830
Closes rust-lang#28050
Closes rust-lang#29453
Closes rust-lang#29791
Closes rust-lang#29935
Closes rust-lang#30014
Closes rust-lang#30752
Closes rust-lang#31262
cc rust-lang#31398 (still need to deal with `before_exec`)
Closes rust-lang#31405
Closes rust-lang#31572
Closes rust-lang#31755
Closes rust-lang#31756
@iddm
Copy link

iddm commented Jun 13, 2019

I have just deprecated a function and now whenever I invoke cargo test --doc, the code example in the doc comment for this function gives me a warning. I wonder, is there any sense in this? I would disable printing deprecation warning in the doc comments of the function which has been deprecated.

@llogiq
Copy link
Contributor

llogiq commented Jun 14, 2019

That would quell deprecation warnings from other places, which would then fly under the radar.

The optimum solution would be to create an annotation that works as allow(deprecation) but only for deprecated items within the current module. We could then extend rustdoc to search for deprecation annotations and add this restricted allow annotation to the doctest item.

@iddm
Copy link

iddm commented Jun 14, 2019

That would quell deprecation warnings from other places, which would then fly under the radar.

The optimum solution would be to create an annotation that works as allow(deprecation) but only for deprecated items within the current module. We could then extend rustdoc to search for deprecation annotations and add this restricted allow annotation to the doctest item.

Sounds legit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
B-unstable Blocker: Implemented in the nightly compiler and unstable. final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

10 participants