Skip to content

Commit 07b57f9

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

7 files changed

+21
-5
lines changed

library/alloc/src/lib.rs

+1
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

+1-1
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/mem/mod.rs

+2-2
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

+1-1
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<'_> {

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

+2
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

+2
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

+12-1
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)