Skip to content

Commit f718647

Browse files
committed
Rename FromTryResidual -> FromResidual
1 parent 74f9771 commit f718647

19 files changed

+52
-52
lines changed

library/core/src/iter/traits/iterator.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use crate::cmp::{self, Ordering};
66
use crate::ops::{self, Add, ControlFlow, Try};
77
#[cfg(not(bootstrap))]
8-
use crate::ops::FromTryResidual;
8+
use crate::ops::FromResidual;
99

1010
use super::super::TrustedRandomAccess;
1111
use super::super::{Chain, Cloned, Copied, Cycle, Enumerate, Filter, FilterMap, Fuse};

library/core/src/ops/control_flow.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ impl<C, B> ops::GetCorrespondingTryType<C> for ControlFlow<B, !> {
114114
}
115115

116116
#[unstable(feature = "try_trait_v2", issue = "42327")]
117-
impl<B, C> ops::FromTryResidual for ControlFlow<B, C> {
117+
impl<B, C> ops::FromResidual for ControlFlow<B, C> {
118118
fn from_residual(x: <Self as ops::Try2021>::Residual) -> Self {
119119
match x {
120120
ControlFlow::Break(r) => ControlFlow::Break(r),

library/core/src/ops/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ pub use self::range::{Bound, RangeBounds, RangeInclusive, RangeToInclusive};
185185
pub use self::r#try::Try2015;
186186

187187
#[unstable(feature = "try_trait_v2", issue = "42327")]
188-
pub use self::r#try::{GetCorrespondingTryType, FromTryResidual, Try2021};
188+
pub use self::r#try::{GetCorrespondingTryType, FromResidual, Try2021};
189189

190190
#[cfg(bootstrap)]
191191
#[unstable(feature = "try_trait_v2", issue = "42327")]

library/core/src/ops/try.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ pub trait Try2015 {
8585
)
8686
)]
8787
#[unstable(feature = "try_trait_v2", issue = "42327")]
88-
pub trait Try2021: FromTryResidual {
88+
pub trait Try2021: FromResidual {
8989
/// The type of the value consumed or produced when not short-circuiting.
9090
#[unstable(feature = "try_trait_v2", issue = "42327")]
9191
// Temporarily using `Ok` still so I don't need to change the bounds in the library
@@ -117,7 +117,7 @@ pub trait Try2021: FromTryResidual {
117117
{
118118
match self.branch() {
119119
ControlFlow::Continue(c) => Try2021::from_output(f(c)),
120-
ControlFlow::Break(r) => FromTryResidual::from_residual(r),
120+
ControlFlow::Break(r) => FromResidual::from_residual(r),
121121
}
122122
}
123123
}
@@ -132,12 +132,12 @@ pub trait Try2021: FromTryResidual {
132132
all(from_method = "from_residual", from_desugaring = "QuestionMark"),
133133
message = "the `?` operator can only be used in {ItemContext} \
134134
that returns `Result` or `Option` \
135-
(or another type that implements `{FromTryResidual}`)",
135+
(or another type that implements `{FromResidual}`)",
136136
label = "cannot use the `?` operator in {ItemContext} that returns `{Self}`",
137137
enclosing_scope = "this function should return `Result` or `Option` to accept `?`"
138138
))]
139139
#[unstable(feature = "try_trait_v2", issue = "42327")]
140-
pub trait FromTryResidual<Residual = <Self as Try2021>::Residual> {
140+
pub trait FromResidual<Residual = <Self as Try2021>::Residual> {
141141
/// Recreate the `Try` type from a related residual
142142
#[cfg_attr(not(bootstrap), lang = "from_holder")]
143143
#[unstable(feature = "try_trait_v2", issue = "42327")]

library/core/src/option.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1755,7 +1755,7 @@ impl<T> ops::GetCorrespondingTryType<T> for Option<!> {
17551755
}
17561756

17571757
#[unstable(feature = "try_trait_v2", issue = "42327")]
1758-
impl<T> ops::FromTryResidual for Option<T> {
1758+
impl<T> ops::FromResidual for Option<T> {
17591759
fn from_residual(x: <Self as ops::Try2021>::Residual) -> Self {
17601760
match x {
17611761
None => None,

library/core/src/result.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1643,7 +1643,7 @@ impl<T, E> ops::GetCorrespondingTryType<T> for Result<!, E> {
16431643
}
16441644

16451645
#[unstable(feature = "try_trait_v2", issue = "42327")]
1646-
impl<T, E, F: From<E>> ops::FromTryResidual<Result<!, E>> for Result<T, F> {
1646+
impl<T, E, F: From<E>> ops::FromResidual<Result<!, E>> for Result<T, F> {
16471647
fn from_residual(x: Result<!, E>) -> Self {
16481648
match x {
16491649
Err(e) => Err(From::from(e)),
@@ -1662,7 +1662,7 @@ mod sadness {
16621662
pub struct PleaseCallTheOkOrMethodToUseQuestionMarkOnOptionsInAMethodThatReturnsResult;
16631663

16641664
#[unstable(feature = "try_trait_v2", issue = "42327")]
1665-
impl<T, E> ops::FromTryResidual<Option<!>> for Result<T, E>
1665+
impl<T, E> ops::FromResidual<Option<!>> for Result<T, E>
16661666
where
16671667
E: From<PleaseCallTheOkOrMethodToUseQuestionMarkOnOptionsInAMethodThatReturnsResult>,
16681668
{

library/core/src/task/poll.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ impl<T, E> ops::Try2021 for Poll<Result<T, E>> {
174174
}
175175

176176
#[unstable(feature = "try_trait_v2", issue = "42327")]
177-
impl<T, E, F: From<E>> ops::FromTryResidual<Result<!, E>> for Poll<Result<T, F>> {
177+
impl<T, E, F: From<E>> ops::FromResidual<Result<!, E>> for Poll<Result<T, F>> {
178178
fn from_residual(x: Result<!, E>) -> Self {
179179
match x {
180180
Err(e) => Poll::Ready(Err(From::from(e))),
@@ -252,7 +252,7 @@ impl<T, E> GetCorrespondingTryType<Poll<Option<T>>> for PollOptionResultHolder<E
252252
*/
253253

254254
#[unstable(feature = "try_trait_v2", issue = "42327")]
255-
impl<T, E, F: From<E>> ops::FromTryResidual<Result<!, E>> for Poll<Option<Result<T, F>>> {
255+
impl<T, E, F: From<E>> ops::FromResidual<Result<!, E>> for Poll<Option<Result<T, F>>> {
256256
fn from_residual(x: Result<!, E>) -> Self {
257257
match x {
258258
Err(e) => Poll::Ready(Some(Err(From::from(e)))),

src/test/ui/async-await/try-on-option-in-async.stderr

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error[E0277]: the `?` operator can only be used in an async block that returns `Result` or `Option` (or another type that implements `FromTryResidual`)
1+
error[E0277]: the `?` operator can only be used in an async block that returns `Result` or `Option` (or another type that implements `FromResidual`)
22
--> $DIR/try-on-option-in-async.rs:8:9
33
|
44
LL | async {
@@ -10,10 +10,10 @@ LL | | 22
1010
LL | | }
1111
| |_____- this function should return `Result` or `Option` to accept `?`
1212
|
13-
= help: the trait `FromTryResidual<Option<!>>` is not implemented for `{integer}`
13+
= help: the trait `FromResidual<Option<!>>` is not implemented for `{integer}`
1414
= note: required by `from_residual`
1515

16-
error[E0277]: the `?` operator can only be used in an async closure that returns `Result` or `Option` (or another type that implements `FromTryResidual`)
16+
error[E0277]: the `?` operator can only be used in an async closure that returns `Result` or `Option` (or another type that implements `FromResidual`)
1717
--> $DIR/try-on-option-in-async.rs:17:9
1818
|
1919
LL | let async_closure = async || {
@@ -25,10 +25,10 @@ LL | | 22_u32
2525
LL | | };
2626
| |_____- this function should return `Result` or `Option` to accept `?`
2727
|
28-
= help: the trait `FromTryResidual<Option<!>>` is not implemented for `u32`
28+
= help: the trait `FromResidual<Option<!>>` is not implemented for `u32`
2929
= note: required by `from_residual`
3030

31-
error[E0277]: the `?` operator can only be used in an async function that returns `Result` or `Option` (or another type that implements `FromTryResidual`)
31+
error[E0277]: the `?` operator can only be used in an async function that returns `Result` or `Option` (or another type that implements `FromResidual`)
3232
--> $DIR/try-on-option-in-async.rs:26:5
3333
|
3434
LL | async fn an_async_function() -> u32 {
@@ -40,7 +40,7 @@ LL | | 22
4040
LL | | }
4141
| |_- this function should return `Result` or `Option` to accept `?`
4242
|
43-
= help: the trait `FromTryResidual<Option<!>>` is not implemented for `u32`
43+
= help: the trait `FromResidual<Option<!>>` is not implemented for `u32`
4444
= note: required by `from_residual`
4545

4646
error: aborting due to 3 previous errors

src/test/ui/issues/issue-32709.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ LL | Err(5)?;
77
| ^^^^^^^ the trait `From<{integer}>` is not implemented for `()`
88
|
99
= note: the question mark operation (`?`) implicitly performs a conversion on the error value using the `From` trait
10-
= note: required because of the requirements on the impl of `FromTryResidual<std::result::Result<!, {integer}>>` for `std::result::Result<i32, ()>`
10+
= note: required because of the requirements on the impl of `FromResidual<std::result::Result<!, {integer}>>` for `std::result::Result<i32, ()>`
1111
= note: required by `from_residual`
1212

1313
error: aborting due to previous error

src/test/ui/option-to-result.stderr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ LL | a?;
88
| ^^ the trait `From<result::sadness::PleaseCallTheOkOrMethodToUseQuestionMarkOnOptionsInAMethodThatReturnsResult>` is not implemented for `()`
99
|
1010
= note: the question mark operation (`?`) implicitly performs a conversion on the error value using the `From` trait
11-
= note: required because of the requirements on the impl of `FromTryResidual<Option<!>>` for `std::result::Result<(), ()>`
11+
= note: required because of the requirements on the impl of `FromResidual<Option<!>>` for `std::result::Result<(), ()>`
1212
= note: required by `from_residual`
1313

14-
error[E0277]: the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `FromTryResidual`)
14+
error[E0277]: the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `FromResidual`)
1515
--> $DIR/option-to-result.rs:11:5
1616
|
1717
LL | / fn test_option() -> Option<i32>{
@@ -22,7 +22,7 @@ LL | | Some(5)
2222
LL | | }
2323
| |_- this function should return `Result` or `Option` to accept `?`
2424
|
25-
= help: the trait `FromTryResidual<std::result::Result<!, i32>>` is not implemented for `Option<i32>`
25+
= help: the trait `FromResidual<std::result::Result<!, i32>>` is not implemented for `Option<i32>`
2626
= note: required by `from_residual`
2727

2828
error: aborting due to 2 previous errors

src/test/ui/rfc-2497-if-let-chains/disallowed-positions.stderr

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,7 @@ LL | if (let 0 = 0)? {}
560560
= help: the trait `Try2021` is not implemented for `bool`
561561
= note: required by `branch`
562562

563-
error[E0277]: the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `FromTryResidual`)
563+
error[E0277]: the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `FromResidual`)
564564
--> $DIR/disallowed-positions.rs:46:8
565565
|
566566
LL | / fn nested_within_if_expr() {
@@ -575,7 +575,7 @@ LL | | if let true = let true = true {}
575575
LL | | }
576576
| |_- this function should return `Result` or `Option` to accept `?`
577577
|
578-
= help: the trait `FromTryResidual<_>` is not implemented for `()`
578+
= help: the trait `FromResidual<_>` is not implemented for `()`
579579
= note: required by `from_residual`
580580

581581
error[E0308]: mismatched types
@@ -748,7 +748,7 @@ LL | while (let 0 = 0)? {}
748748
= help: the trait `Try2021` is not implemented for `bool`
749749
= note: required by `branch`
750750

751-
error[E0277]: the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `FromTryResidual`)
751+
error[E0277]: the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `FromResidual`)
752752
--> $DIR/disallowed-positions.rs:110:11
753753
|
754754
LL | / fn nested_within_while_expr() {
@@ -763,7 +763,7 @@ LL | | while let true = let true = true {}
763763
LL | | }
764764
| |_- this function should return `Result` or `Option` to accept `?`
765765
|
766-
= help: the trait `FromTryResidual<_>` is not implemented for `()`
766+
= help: the trait `FromResidual<_>` is not implemented for `()`
767767
= note: required by `from_residual`
768768

769769
error[E0308]: mismatched types
@@ -927,7 +927,7 @@ LL | (let 0 = 0)?;
927927
= help: the trait `Try2021` is not implemented for `bool`
928928
= note: required by `branch`
929929

930-
error[E0277]: the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `FromTryResidual`)
930+
error[E0277]: the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `FromResidual`)
931931
--> $DIR/disallowed-positions.rs:183:5
932932
|
933933
LL | / fn outside_if_and_while_expr() {
@@ -942,7 +942,7 @@ LL | |
942942
LL | | }
943943
| |_- this function should return `Result` or `Option` to accept `?`
944944
|
945-
= help: the trait `FromTryResidual<_>` is not implemented for `()`
945+
= help: the trait `FromResidual<_>` is not implemented for `()`
946946
= note: required by `from_residual`
947947

948948
error[E0308]: mismatched types

src/test/ui/try-on-option-diagnostics.stderr

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error[E0277]: the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `FromTryResidual`)
1+
error[E0277]: the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `FromResidual`)
22
--> $DIR/try-on-option-diagnostics.rs:7:5
33
|
44
LL | / fn a_function() -> u32 {
@@ -9,10 +9,10 @@ LL | | 22
99
LL | | }
1010
| |_- this function should return `Result` or `Option` to accept `?`
1111
|
12-
= help: the trait `FromTryResidual<Option<!>>` is not implemented for `u32`
12+
= help: the trait `FromResidual<Option<!>>` is not implemented for `u32`
1313
= note: required by `from_residual`
1414

15-
error[E0277]: the `?` operator can only be used in a closure that returns `Result` or `Option` (or another type that implements `FromTryResidual`)
15+
error[E0277]: the `?` operator can only be used in a closure that returns `Result` or `Option` (or another type that implements `FromResidual`)
1616
--> $DIR/try-on-option-diagnostics.rs:14:9
1717
|
1818
LL | let a_closure = || {
@@ -24,10 +24,10 @@ LL | | 22
2424
LL | | };
2525
| |_____- this function should return `Result` or `Option` to accept `?`
2626
|
27-
= help: the trait `FromTryResidual<Option<!>>` is not implemented for `{integer}`
27+
= help: the trait `FromResidual<Option<!>>` is not implemented for `{integer}`
2828
= note: required by `from_residual`
2929

30-
error[E0277]: the `?` operator can only be used in a method that returns `Result` or `Option` (or another type that implements `FromTryResidual`)
30+
error[E0277]: the `?` operator can only be used in a method that returns `Result` or `Option` (or another type that implements `FromResidual`)
3131
--> $DIR/try-on-option-diagnostics.rs:26:13
3232
|
3333
LL | / fn a_method() {
@@ -37,10 +37,10 @@ LL | | x?;
3737
LL | | }
3838
| |_________- this function should return `Result` or `Option` to accept `?`
3939
|
40-
= help: the trait `FromTryResidual<Option<!>>` is not implemented for `()`
40+
= help: the trait `FromResidual<Option<!>>` is not implemented for `()`
4141
= note: required by `from_residual`
4242

43-
error[E0277]: the `?` operator can only be used in a trait method that returns `Result` or `Option` (or another type that implements `FromTryResidual`)
43+
error[E0277]: the `?` operator can only be used in a trait method that returns `Result` or `Option` (or another type that implements `FromResidual`)
4444
--> $DIR/try-on-option-diagnostics.rs:39:13
4545
|
4646
LL | / fn a_trait_method() {
@@ -50,7 +50,7 @@ LL | | x?;
5050
LL | | }
5151
| |_________- this function should return `Result` or `Option` to accept `?`
5252
|
53-
= help: the trait `FromTryResidual<Option<!>>` is not implemented for `()`
53+
= help: the trait `FromResidual<Option<!>>` is not implemented for `()`
5454
= note: required by `from_residual`
5555

5656
error: aborting due to 4 previous errors

src/test/ui/try-operator-on-main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use std::ops::Try;
77

88
fn main() {
99
// error for a `Try` type on a non-`Try` fn
10-
std::fs::File::open("foo")?; //~ ERROR the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `FromTryResidual`)
10+
std::fs::File::open("foo")?; //~ ERROR the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `FromResidual`)
1111

1212
// a non-`Try` type on a non-`Try` fn
1313
()?; //~ ERROR the `?` operator can only be applied to values that implement `Try`

src/test/ui/try-operator-on-main.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error[E0277]: the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `FromTryResidual`)
1+
error[E0277]: the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `FromResidual`)
22
--> $DIR/try-operator-on-main.rs:10:5
33
|
44
LL | / fn main() {
@@ -11,7 +11,7 @@ LL | | try_trait_generic::<()>();
1111
LL | | }
1212
| |_- this function should return `Result` or `Option` to accept `?`
1313
|
14-
= help: the trait `FromTryResidual<std::result::Result<!, std::io::Error>>` is not implemented for `()`
14+
= help: the trait `FromResidual<std::result::Result<!, std::io::Error>>` is not implemented for `()`
1515
= note: required by `from_residual`
1616

1717
error[E0277]: the `?` operator can only be applied to values that implement `Try`

src/test/ui/try-trait/try-control-flow-in-result.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error[E0277]: the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `FromTryResidual`)
1+
error[E0277]: the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `FromResidual`)
22
--> $DIR/try-control-flow-in-result.rs:11:5
33
|
44
LL | / fn demo() -> Result<(), ()> {
@@ -8,7 +8,7 @@ LL | | Ok(())
88
LL | | }
99
| |_- this function should return `Result` or `Option` to accept `?`
1010
|
11-
= help: the trait `FromTryResidual<ControlFlow<(), !>>` is not implemented for `std::result::Result<(), ()>`
11+
= help: the trait `FromResidual<ControlFlow<(), !>>` is not implemented for `std::result::Result<(), ()>`
1212
= note: required by `from_residual`
1313

1414
error: aborting due to previous error

src/test/ui/try-trait/try-fold-rfc-example.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#![feature(control_flow_enum)]
44
#![feature(try_trait_v2)]
55

6-
use std::ops::{ControlFlow, Try, FromTryResidual};
6+
use std::ops::{ControlFlow, Try, FromResidual};
77

88
pub fn simple_fold<A, T>(
99
iter: impl Iterator<Item = T>,

src/test/ui/try-trait/try-non-generic-type.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#![feature(try_trait_v2)]
55

66
use std::num::NonZeroI32;
7-
use std::ops::{ControlFlow, Try, FromTryResidual};
7+
use std::ops::{ControlFlow, Try, FromResidual};
88

99
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
1010
#[repr(transparent)]
@@ -32,13 +32,13 @@ impl Try for ResultCode {
3232
}
3333
}
3434

35-
impl FromTryResidual for ResultCode {
35+
impl FromResidual for ResultCode {
3636
fn from_residual(r: ResultCodeResidual) -> Self {
3737
ResultCode(r.0.into())
3838
}
3939
}
4040

41-
impl<T, E: From<FancyError>> FromTryResidual<ResultCodeResidual> for Result<T, E> {
41+
impl<T, E: From<FancyError>> FromResidual<ResultCodeResidual> for Result<T, E> {
4242
fn from_residual(r: ResultCodeResidual) -> Self {
4343
Err(FancyError(format!("Something fancy about {} at {:?}", r.0, std::time::SystemTime::now())).into())
4444
}

src/test/ui/try-trait/try-on-option.stderr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ LL | x?;
88
| ^^ the trait `From<result::sadness::PleaseCallTheOkOrMethodToUseQuestionMarkOnOptionsInAMethodThatReturnsResult>` is not implemented for `()`
99
|
1010
= note: the question mark operation (`?`) implicitly performs a conversion on the error value using the `From` trait
11-
= note: required because of the requirements on the impl of `FromTryResidual<Option<!>>` for `std::result::Result<u32, ()>`
11+
= note: required because of the requirements on the impl of `FromResidual<Option<!>>` for `std::result::Result<u32, ()>`
1212
= note: required by `from_residual`
1313

14-
error[E0277]: the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `FromTryResidual`)
14+
error[E0277]: the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `FromResidual`)
1515
--> $DIR/try-on-option.rs:13:5
1616
|
1717
LL | / fn bar() -> u32 {
@@ -22,7 +22,7 @@ LL | | 22
2222
LL | | }
2323
| |_- this function should return `Result` or `Option` to accept `?`
2424
|
25-
= help: the trait `FromTryResidual<Option<!>>` is not implemented for `u32`
25+
= help: the trait `FromResidual<Option<!>>` is not implemented for `u32`
2626
= note: required by `from_residual`
2727

2828
error: aborting due to 2 previous errors

0 commit comments

Comments
 (0)