Skip to content

Commit 530faed

Browse files
authored
Unrolled build for rust-lang#128008
Rollup merge of rust-lang#128008 - weiznich:fix/121521, r=lcnr Start using `#[diagnostic::do_not_recommend]` in the standard library This commit starts using `#[diagnostic::do_not_recommend]` in the standard library to improve some error messages. In this case we just hide a certain nightly only impl as suggested in rust-lang#121521 The result in not perfect yet, but at least the `Yeet` suggestion is not shown anymore. I would consider that as a minor improvement.
2 parents 20f23ab + 00da9fc commit 530faed

File tree

6 files changed

+10
-22
lines changed

6 files changed

+10
-22
lines changed

library/core/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@
165165
#![feature(const_unsafecell_get_mut)]
166166
#![feature(const_waker)]
167167
#![feature(coverage_attribute)]
168+
#![feature(do_not_recommend)]
168169
#![feature(duration_consts_float)]
169170
#![feature(internal_impls_macro)]
170171
#![feature(ip)]

library/core/src/option.rs

+1
Original file line numberDiff line numberDiff line change
@@ -2507,6 +2507,7 @@ impl<T> ops::FromResidual for Option<T> {
25072507
}
25082508
}
25092509

2510+
#[diagnostic::do_not_recommend]
25102511
#[unstable(feature = "try_trait_v2_yeet", issue = "96374")]
25112512
impl<T> ops::FromResidual<ops::Yeet<()>> for Option<T> {
25122513
#[inline]

library/core/src/result.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1990,7 +1990,7 @@ impl<T, E, F: From<E>> ops::FromResidual<Result<convert::Infallible, E>> for Res
19901990
}
19911991
}
19921992
}
1993-
1993+
#[diagnostic::do_not_recommend]
19941994
#[unstable(feature = "try_trait_v2_yeet", issue = "96374")]
19951995
impl<T, E, F: From<E>> ops::FromResidual<ops::Yeet<E>> for Result<T, F> {
19961996
#[inline]

tests/ui/try-trait/bad-interconversion.stderr

+4-12
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@ LL | Some(3)?;
2323
| ^ use `.ok_or(...)?` to provide an error compatible with `Result<u64, String>`
2424
|
2525
= help: the trait `FromResidual<Option<Infallible>>` is not implemented for `Result<u64, String>`
26-
= help: the following other types implement trait `FromResidual<R>`:
27-
`Result<T, F>` implements `FromResidual<Result<Infallible, E>>`
28-
`Result<T, F>` implements `FromResidual<Yeet<E>>`
26+
= help: the trait `FromResidual<Result<Infallible, E>>` is implemented for `Result<T, F>`
2927

3028
error[E0277]: the `?` operator can only be used on `Result`s in a function that returns `Result`
3129
--> $DIR/bad-interconversion.rs:17:31
@@ -36,9 +34,7 @@ LL | Ok(ControlFlow::Break(123)?)
3634
| ^ this `?` produces `ControlFlow<{integer}, Infallible>`, which is incompatible with `Result<u64, String>`
3735
|
3836
= help: the trait `FromResidual<ControlFlow<{integer}, Infallible>>` is not implemented for `Result<u64, String>`
39-
= help: the following other types implement trait `FromResidual<R>`:
40-
`Result<T, F>` implements `FromResidual<Result<Infallible, E>>`
41-
`Result<T, F>` implements `FromResidual<Yeet<E>>`
37+
= help: the trait `FromResidual<Result<Infallible, E>>` is implemented for `Result<T, F>`
4238

4339
error[E0277]: the `?` operator can only be used on `Option`s, not `Result`s, in a function that returns `Option`
4440
--> $DIR/bad-interconversion.rs:22:22
@@ -49,9 +45,7 @@ LL | Some(Err("hello")?)
4945
| ^ use `.ok()?` if you want to discard the `Result<Infallible, &str>` error information
5046
|
5147
= help: the trait `FromResidual<Result<Infallible, &str>>` is not implemented for `Option<u16>`
52-
= help: the following other types implement trait `FromResidual<R>`:
53-
`Option<T>` implements `FromResidual<Yeet<()>>`
54-
`Option<T>` implements `FromResidual`
48+
= help: the trait `FromResidual` is implemented for `Option<T>`
5549

5650
error[E0277]: the `?` operator can only be used on `Option`s in a function that returns `Option`
5751
--> $DIR/bad-interconversion.rs:27:33
@@ -62,9 +56,7 @@ LL | Some(ControlFlow::Break(123)?)
6256
| ^ this `?` produces `ControlFlow<{integer}, Infallible>`, which is incompatible with `Option<u64>`
6357
|
6458
= help: the trait `FromResidual<ControlFlow<{integer}, Infallible>>` is not implemented for `Option<u64>`
65-
= help: the following other types implement trait `FromResidual<R>`:
66-
`Option<T>` implements `FromResidual<Yeet<()>>`
67-
`Option<T>` implements `FromResidual`
59+
= help: the trait `FromResidual` is implemented for `Option<T>`
6860

6961
error[E0277]: the `?` operator can only be used on `ControlFlow`s in a function that returns `ControlFlow`
7062
--> $DIR/bad-interconversion.rs:32:39

tests/ui/try-trait/option-to-result.stderr

+2-6
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@ LL | a?;
88
| ^ use `.ok_or(...)?` to provide an error compatible with `Result<(), ()>`
99
|
1010
= help: the trait `FromResidual<Option<Infallible>>` is not implemented for `Result<(), ()>`
11-
= help: the following other types implement trait `FromResidual<R>`:
12-
`Result<T, F>` implements `FromResidual<Result<Infallible, E>>`
13-
`Result<T, F>` implements `FromResidual<Yeet<E>>`
11+
= help: the trait `FromResidual<Result<Infallible, E>>` is implemented for `Result<T, F>`
1412

1513
error[E0277]: the `?` operator can only be used on `Option`s, not `Result`s, in a function that returns `Option`
1614
--> $DIR/option-to-result.rs:11:6
@@ -22,9 +20,7 @@ LL | a?;
2220
| ^ use `.ok()?` if you want to discard the `Result<Infallible, i32>` error information
2321
|
2422
= help: the trait `FromResidual<Result<Infallible, i32>>` is not implemented for `Option<i32>`
25-
= help: the following other types implement trait `FromResidual<R>`:
26-
`Option<T>` implements `FromResidual<Yeet<()>>`
27-
`Option<T>` implements `FromResidual`
23+
= help: the trait `FromResidual` is implemented for `Option<T>`
2824

2925
error: aborting due to 2 previous errors
3026

tests/ui/try-trait/try-on-option.stderr

+1-3
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@ LL | x?;
88
| ^ use `.ok_or(...)?` to provide an error compatible with `Result<u32, ()>`
99
|
1010
= help: the trait `FromResidual<Option<Infallible>>` is not implemented for `Result<u32, ()>`
11-
= help: the following other types implement trait `FromResidual<R>`:
12-
`Result<T, F>` implements `FromResidual<Result<Infallible, E>>`
13-
`Result<T, F>` implements `FromResidual<Yeet<E>>`
11+
= help: the trait `FromResidual<Result<Infallible, E>>` is implemented for `Result<T, F>`
1412

1513
error[E0277]: the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `FromResidual`)
1614
--> $DIR/try-on-option.rs:11:6

0 commit comments

Comments
 (0)