Skip to content

Commit eff3994

Browse files
committed
Remove type parameter default from FromResidual.
1 parent 730d5d4 commit eff3994

9 files changed

+15
-15
lines changed

library/core/src/ops/control_flow.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ impl<B, C> ops::Try for ControlFlow<B, C> {
116116
}
117117

118118
#[unstable(feature = "try_trait_v2", issue = "84277")]
119-
impl<B, C> ops::FromResidual for ControlFlow<B, C> {
119+
impl<B, C> ops::FromResidual<ControlFlow<B, convert::Infallible>> for ControlFlow<B, C> {
120120
#[inline]
121121
fn from_residual(residual: ControlFlow<B, convert::Infallible>) -> Self {
122122
match residual {

library/core/src/ops/try_trait.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ use crate::ops::ControlFlow;
128128
)]
129129
#[doc(alias = "?")]
130130
#[lang = "Try"]
131-
pub trait Try: FromResidual {
131+
pub trait Try: FromResidual<Self::Residual> {
132132
/// The type of the value produced by `?` when *not* short-circuiting.
133133
#[unstable(feature = "try_trait_v2", issue = "84277")]
134134
type Output;
@@ -304,7 +304,7 @@ pub trait Try: FromResidual {
304304
)]
305305
#[rustc_diagnostic_item = "FromResidual"]
306306
#[unstable(feature = "try_trait_v2", issue = "84277")]
307-
pub trait FromResidual<R = <Self as Try>::Residual> {
307+
pub trait FromResidual<R> {
308308
/// Constructs the type from a compatible `Residual` type.
309309
///
310310
/// This should be implemented consistently with the `branch` method such
@@ -410,7 +410,7 @@ impl<T> Try for NeverShortCircuit<T> {
410410
}
411411
}
412412

413-
impl<T> FromResidual for NeverShortCircuit<T> {
413+
impl<T> FromResidual<NeverShortCircuitResidual> for NeverShortCircuit<T> {
414414
#[inline]
415415
fn from_residual(never: NeverShortCircuitResidual) -> Self {
416416
match never {}

library/core/src/option.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2495,7 +2495,7 @@ impl<T> ops::Try for Option<T> {
24952495
}
24962496

24972497
#[unstable(feature = "try_trait_v2", issue = "84277")]
2498-
impl<T> ops::FromResidual for Option<T> {
2498+
impl<T> ops::FromResidual<Option<convert::Infallible>> for Option<T> {
24992499
#[inline]
25002500
fn from_residual(residual: Option<convert::Infallible>) -> Self {
25012501
match residual {

tests/ui/rfcs/rfc-2632-const-trait-impl/ice-119717-constant-lifetime.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
use std::ops::FromResidual;
55

6-
impl<T> const FromResidual for T {
6+
impl<T> const FromResidual<T> for T {
77
//~^ ERROR const `impl` for trait `FromResidual` which is not marked with `#[const_trait]`
88
//~| type parameter `T` must be used as the type parameter for some local type
99
fn from_residual(t: T) -> _ {

tests/ui/rfcs/rfc-2632-const-trait-impl/ice-119717-constant-lifetime.stderr

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@ error: using `#![feature(effects)]` without enabling next trait solver globally
66
error: const `impl` for trait `FromResidual` which is not marked with `#[const_trait]`
77
--> $DIR/ice-119717-constant-lifetime.rs:6:15
88
|
9-
LL | impl<T> const FromResidual for T {
10-
| ^^^^^^^^^^^^
9+
LL | impl<T> const FromResidual<T> for T {
10+
| ^^^^^^^^^^^^^^^
1111
|
1212
= note: marking a trait with `#[const_trait]` ensures all default method bodies are `const`
1313
= note: adding a non-const method body in the future would be a breaking change
1414

1515
error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct<T>`)
1616
--> $DIR/ice-119717-constant-lifetime.rs:6:6
1717
|
18-
LL | impl<T> const FromResidual for T {
18+
LL | impl<T> const FromResidual<T> for T {
1919
| ^ type parameter `T` must be used as the type parameter for some local type
2020
|
2121
= note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local

tests/ui/rfcs/rfc-2632-const-trait-impl/trait-default-body-stability.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ impl const Try for T {
3131

3232
#[stable(feature = "foo", since = "1.0")]
3333
#[rustc_const_unstable(feature = "const_t_try", issue = "none")]
34-
impl const FromResidual for T {
34+
impl const FromResidual<T> for T {
3535
fn from_residual(t: T) -> T {
3636
t
3737
}

tests/ui/rfcs/rfc-2632-const-trait-impl/trait-default-body-stability.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ LL | impl const Try for T {
1010
error: const `impl` for trait `FromResidual` which is not marked with `#[const_trait]`
1111
--> $DIR/trait-default-body-stability.rs:34:12
1212
|
13-
LL | impl const FromResidual for T {
14-
| ^^^^^^^^^^^^
13+
LL | impl const FromResidual<T> for T {
14+
| ^^^^^^^^^^^^^^^
1515
|
1616
= note: marking a trait with `#[const_trait]` ensures all default method bodies are `const`
1717
= note: adding a non-const method body in the future would be a breaking change

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ LL | Some(Err("hello")?)
4545
| ^ use `.ok()?` if you want to discard the `Result<Infallible, &str>` error information
4646
|
4747
= help: the trait `FromResidual<Result<Infallible, &str>>` is not implemented for `Option<u16>`
48-
= help: the trait `FromResidual` is implemented for `Option<T>`
48+
= help: the trait `FromResidual<Option<Infallible>>` is implemented for `Option<T>`
4949

5050
error[E0277]: the `?` operator can only be used on `Option`s in a function that returns `Option`
5151
--> $DIR/bad-interconversion.rs:27:33
@@ -56,7 +56,7 @@ LL | Some(ControlFlow::Break(123)?)
5656
| ^ this `?` produces `ControlFlow<{integer}, Infallible>`, which is incompatible with `Option<u64>`
5757
|
5858
= help: the trait `FromResidual<ControlFlow<{integer}, Infallible>>` is not implemented for `Option<u64>`
59-
= help: the trait `FromResidual` is implemented for `Option<T>`
59+
= help: the trait `FromResidual<Option<Infallible>>` is implemented for `Option<T>`
6060

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

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ LL | a?;
2020
| ^ use `.ok()?` if you want to discard the `Result<Infallible, i32>` error information
2121
|
2222
= help: the trait `FromResidual<Result<Infallible, i32>>` is not implemented for `Option<i32>`
23-
= help: the trait `FromResidual` is implemented for `Option<T>`
23+
= help: the trait `FromResidual<Option<Infallible>>` is implemented for `Option<T>`
2424

2525
error: aborting due to 2 previous errors
2626

0 commit comments

Comments
 (0)