Rollup merge of #128954 - zachs18:fromresidual-no-default, r=scottmcm · patricklam/verify-rust-std@0dbf8cf (original) (raw)
4 files changed
lines changed
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -116,7 +116,9 @@ impl<B, C> ops::Try for ControlFlow<B, C> { | ||
116 | 116 | } |
117 | 117 | |
118 | 118 | #[unstable(feature = "try_trait_v2", issue = "84277")] |
119 | -impl<B, C> ops::FromResidual for ControlFlow<B, C> { | |
119 | +// Note: manually specifying the residual type instead of using the default to work around | |
120 | +// https://github.com/rust-lang/rust/issues/99940 | |
121 | +impl<B, C> ops::FromResidual<ControlFlow<B, convert::Infallible>> for ControlFlow<B, C> { | |
120 | 122 | #[inline] |
121 | 123 | fn from_residual(residual: ControlFlow<B, convert::Infallible>) -> Self { |
122 | 124 | match residual { |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -2495,7 +2495,9 @@ impl ops::Try for Option { | ||
2495 | 2495 | } |
2496 | 2496 | |
2497 | 2497 | #[unstable(feature = "try_trait_v2", issue = "84277")] |
2498 | -impl<T> ops::FromResidual for Option<T> { | |
2498 | +// Note: manually specifying the residual type instead of using the default to work around | |
2499 | +// https://github.com/rust-lang/rust/issues/99940 | |
2500 | +impl<T> ops::FromResidual<Optionconvert::Infallible\> for Option<T> { | |
2499 | 2501 | #[inline] |
2500 | 2502 | fn from_residual(residual: Optionconvert::Infallible\) -> Self { |
2501 | 2503 | match residual { |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
1 | 1 | mod control_flow; |
2 | +mod from_residual; | |
2 | 3 | |
3 | 4 | use core::ops::{ |
4 | 5 | Bound, Deref, DerefMut, Range, RangeFrom, RangeFull, RangeInclusive, RangeTo, RangeToInclusive, |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
1 | +//! Regression test that Option and ControlFlow can have downstream FromResidual impls. | |
2 | +//! cc https://github.com/rust-lang/rust/issues/99940, | |
3 | +//! This does NOT test that issue in general; Option and ControlFlow's FromResidual | |
4 | +//! impls in core were changed to not be affected by that issue. | |
5 | + | |
6 | +use core::ops::{ControlFlow, FromResidual}; | |
7 | + | |
8 | +struct Local; | |
9 | + | |
10 | +impl<T> FromResidual<Local> for Option<T> { | |
11 | +fn from_residual(_: Local) -> Option<T> { | |
12 | +unimplemented!() | |
13 | +} | |
14 | +} | |
15 | + | |
16 | +impl<B, C> FromResidual<Local> for ControlFlow<B, C> { | |
17 | +fn from_residual(_: Local) -> ControlFlow<B, C> { | |
18 | +unimplemented!() | |
19 | +} | |
20 | +} | |
21 | + | |
22 | +impl<T, E> FromResidual<Local> for Result<T, E> { | |
23 | +fn from_residual(_: Local) -> Result<T, E> { | |
24 | +unimplemented!() | |
25 | +} | |
26 | +} |