Skip to content

Commit 7830d74

Browse files
committed
Implement the alternative try desugaring
1 parent ed369ff commit 7830d74

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

core/src/ops/try_trait.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -359,11 +359,20 @@ where
359359
/// and in the other direction,
360360
/// `<Result<Infallible, E> as Residual<T>>::TryType = Result<T, E>`.
361361
#[unstable(feature = "try_trait_v2_residual", issue = "91285")]
362-
#[rustc_const_unstable(feature = "const_try", issue = "74935")]
363-
pub const trait Residual<O> {
362+
#[rustc_const_unstable(feature = "const_try_residual", issue = "91285")]
363+
pub const trait Residual<O>: Sized {
364364
/// The "return" type of this meta-function.
365365
#[unstable(feature = "try_trait_v2_residual", issue = "91285")]
366-
type TryType: Try<Output = O, Residual = Self>;
366+
type TryType: [const] Try<Output = O, Residual = Self>;
367+
368+
/// Here for convenience in the `?` desugaring.
369+
/// Probably should not be stabilized, as it should never be overridden.
370+
/// (without a `final fn` of some form, cc RFC#3678)
371+
#[unstable(feature = "try_trait_v2_residual", issue = "91285")]
372+
#[lang = "into_try_type"]
373+
fn into_try_type(self) -> Self::TryType {
374+
FromResidual::from_residual(self)
375+
}
367376
}
368377

369378
#[unstable(feature = "pub_crate_should_not_need_unstable_attr", issue = "none")]

std/src/sys/pal/unix/kernel_copy/tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ fn copy_specialization() -> Result<()> {
5050
"inner Take allowed reading beyond end of file, some bytes should be left"
5151
);
5252

53-
let mut sink = sink.into_inner()?;
53+
let mut sink = sink.into_inner().map_err(io::Error::from)?;
5454
sink.seek(SeekFrom::Start(0))?;
5555
let mut copied = Vec::new();
5656
sink.read_to_end(&mut copied)?;

0 commit comments

Comments
 (0)