Skip to content

Commit 795ade0

Browse files
committed
Auto merge of #113365 - dima74:diralik/add-deprecated-suggestions, r=workingjubilee
Add `suggestion` for some `#[deprecated]` items Consider code: ```rust fn main() { let _ = ["a", "b"].connect(" "); } ``` Currently it shows deprecated warning: ```rust warning: use of deprecated method `std::slice::<impl [T]>::connect`: renamed to join --> src/main.rs:2:24 | 2 | let _ = ["a", "b"].connect(" "); | ^^^^^^^ | = note: `#[warn(deprecated)]` on by default ``` This PR adds `suggestion` for `connect` and some other deprecated items, so the warning will be changed to this: ```rust warning: use of deprecated method `std::slice::<impl [T]>::connect`: renamed to join --> src/main.rs:2:24 | 2 | let _ = ["a", "b"].connect(" "); | ^^^^^^^ | = note: `#[warn(deprecated)]` on by default help: replace the use of the deprecated method | 2 | let _ = ["a", "b"].join(" "); | ^^^^ ```
2 parents ef85656 + 07b57f9 commit 795ade0

7 files changed

+21
-5
lines changed

library/alloc/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@
120120
#![feature(const_waker)]
121121
#![feature(core_intrinsics)]
122122
#![feature(core_panic)]
123+
#![feature(deprecated_suggestion)]
123124
#![feature(dispatch_from_dyn)]
124125
#![feature(error_generic_member_access)]
125126
#![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
@@ -997,7 +997,7 @@ impl str {
997997

998998
/// An iterator over the lines of a string.
999999
#[stable(feature = "rust1", since = "1.0.0")]
1000-
#[deprecated(since = "1.4.0", note = "use lines() instead now")]
1000+
#[deprecated(since = "1.4.0", note = "use lines() instead now", suggestion = "lines")]
10011001
#[inline]
10021002
#[allow(deprecated)]
10031003
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)