Skip to content

Commit 950a249

Browse files
committed
Add suggestion for some #[deprecated] items
1 parent 4dbc7e3 commit 950a249

11 files changed

+39
-10
lines changed

library/alloc/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@
118118
#![feature(const_waker)]
119119
#![feature(core_intrinsics)]
120120
#![feature(core_panic)]
121+
#![feature(deprecated_suggestion)]
121122
#![feature(dispatch_from_dyn)]
122123
#![feature(error_generic_member_access)]
123124
#![feature(error_in_core)]

library/alloc/src/slice.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -592,7 +592,7 @@ impl<T> [T] {
592592
/// ```
593593
#[rustc_allow_incoherent_impl]
594594
#[stable(feature = "rust1", since = "1.0.0")]
595-
#[deprecated(since = "1.3.0", note = "renamed to join")]
595+
#[deprecated(since = "1.3.0", note = "renamed to join", suggestion = "join")]
596596
pub fn connect<Separator>(&self, sep: Separator) -> <Self as Join<Separator>>::Output
597597
where
598598
Self: Join<Separator>,

library/core/src/error.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,8 @@ pub trait Error: Debug + Display {
114114
#[stable(feature = "rust1", since = "1.0.0")]
115115
#[deprecated(
116116
since = "1.33.0",
117-
note = "replaced by Error::source, which can support downcasting"
117+
note = "replaced by Error::source, which can support downcasting",
118+
suggestion = "source"
118119
)]
119120
#[allow(missing_docs)]
120121
fn cause(&self) -> Option<&dyn Error> {

library/core/src/mem/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ pub const unsafe fn size_of_val_raw<T: ?Sized>(val: *const T) -> usize {
413413
#[inline]
414414
#[must_use]
415415
#[stable(feature = "rust1", since = "1.0.0")]
416-
#[deprecated(note = "use `align_of` instead", since = "1.2.0")]
416+
#[deprecated(note = "use `align_of` instead", since = "1.2.0", suggestion = "align_of")]
417417
pub fn min_align_of<T>() -> usize {
418418
intrinsics::min_align_of::<T>()
419419
}
@@ -436,7 +436,7 @@ pub fn min_align_of<T>() -> usize {
436436
#[inline]
437437
#[must_use]
438438
#[stable(feature = "rust1", since = "1.0.0")]
439-
#[deprecated(note = "use `align_of_val` instead", since = "1.2.0")]
439+
#[deprecated(note = "use `align_of_val` instead", since = "1.2.0", suggestion = "align_of_val")]
440440
pub fn min_align_of_val<T: ?Sized>(val: &T) -> usize {
441441
// SAFETY: val is a reference, so it's a valid raw pointer
442442
unsafe { intrinsics::min_align_of_val(val) }

library/core/src/str/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -993,7 +993,7 @@ impl str {
993993

994994
/// An iterator over the lines of a string.
995995
#[stable(feature = "rust1", since = "1.0.0")]
996-
#[deprecated(since = "1.4.0", note = "use lines() instead now")]
996+
#[deprecated(since = "1.4.0", note = "use lines() instead now", suggestion = "lines")]
997997
#[inline]
998998
#[allow(deprecated)]
999999
pub fn lines_any(&self) -> LinesAny<'_> {

library/std/src/os/unix/process.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,11 @@ pub trait CommandExt: Sealed {
109109
///
110110
/// [`pre_exec`]: CommandExt::pre_exec
111111
#[stable(feature = "process_exec", since = "1.15.0")]
112-
#[deprecated(since = "1.37.0", note = "should be unsafe, use `pre_exec` instead")]
112+
#[deprecated(
113+
since = "1.37.0",
114+
note = "should be unsafe, use `pre_exec` instead",
115+
suggestion = "pre_exec"
116+
)]
113117
fn before_exec<F>(&mut self, f: F) -> &mut process::Command
114118
where
115119
F: FnMut() -> io::Result<()> + Send + Sync + 'static,

library/std/src/sync/condvar.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,11 @@ impl Condvar {
305305
/// }
306306
/// ```
307307
#[stable(feature = "rust1", since = "1.0.0")]
308-
#[deprecated(since = "1.6.0", note = "replaced by `std::sync::Condvar::wait_timeout`")]
308+
#[deprecated(
309+
since = "1.6.0",
310+
note = "replaced by `std::sync::Condvar::wait_timeout`",
311+
suggestion = "wait_timeout"
312+
)]
309313
pub fn wait_timeout_ms<'a, T>(
310314
&self,
311315
guard: MutexGuard<'a, T>,

library/std/src/thread/mod.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -825,7 +825,7 @@ pub fn panicking() -> bool {
825825
/// thread::sleep_ms(2000);
826826
/// ```
827827
#[stable(feature = "rust1", since = "1.0.0")]
828-
#[deprecated(since = "1.6.0", note = "replaced by `std::thread::sleep`")]
828+
#[deprecated(since = "1.6.0", note = "replaced by `std::thread::sleep`", suggestion = "sleep")]
829829
pub fn sleep_ms(ms: u32) {
830830
sleep(Duration::from_millis(ms as u64))
831831
}
@@ -1004,7 +1004,11 @@ pub fn park() {
10041004
///
10051005
/// See the [park documentation][`park`] for more detail.
10061006
#[stable(feature = "rust1", since = "1.0.0")]
1007-
#[deprecated(since = "1.6.0", note = "replaced by `std::thread::park_timeout`")]
1007+
#[deprecated(
1008+
since = "1.6.0",
1009+
note = "replaced by `std::thread::park_timeout`",
1010+
suggestion = "park_timeout"
1011+
)]
10081012
pub fn park_timeout_ms(ms: u32) {
10091013
park_timeout(Duration::from_millis(ms as u64))
10101014
}

tests/ui/deprecation/issue-84637-deprecated-associated-function.fixed

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,6 @@ fn main() {
66
let _foo = str::trim_start(" aoeu"); //~ ERROR use of deprecated method `core::str::<impl str>::trim_left`: superseded by `trim_start` [deprecated]
77

88
let _bar = " aoeu".trim_start(); //~ ERROR use of deprecated method `core::str::<impl str>::trim_left`: superseded by `trim_start` [deprecated]
9+
10+
let _baz = ["a", "b"].join(" "); //~ ERROR use of deprecated method `std::slice::<impl [T]>::connect`: renamed to join [deprecated]
911
}

tests/ui/deprecation/issue-84637-deprecated-associated-function.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,6 @@ fn main() {
66
let _foo = str::trim_left(" aoeu"); //~ ERROR use of deprecated method `core::str::<impl str>::trim_left`: superseded by `trim_start` [deprecated]
77

88
let _bar = " aoeu".trim_left(); //~ ERROR use of deprecated method `core::str::<impl str>::trim_left`: superseded by `trim_start` [deprecated]
9+
10+
let _baz = ["a", "b"].connect(" "); //~ ERROR use of deprecated method `std::slice::<impl [T]>::connect`: renamed to join [deprecated]
911
}

tests/ui/deprecation/issue-84637-deprecated-associated-function.stderr

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,16 @@ help: replace the use of the deprecated method
2525
LL | let _bar = " aoeu".trim_start();
2626
| ~~~~~~~~~~
2727

28-
error: aborting due to 2 previous errors
28+
error: use of deprecated method `std::slice::<impl [T]>::connect`: renamed to join
29+
--> $DIR/issue-84637-deprecated-associated-function.rs:10:27
30+
|
31+
LL | let _baz = ["a", "b"].connect(" ");
32+
| ^^^^^^^
33+
|
34+
help: replace the use of the deprecated method
35+
|
36+
LL | let _baz = ["a", "b"].join(" ");
37+
| ~~~~
38+
39+
error: aborting due to 3 previous errors
2940

0 commit comments

Comments
 (0)