From 099cca46d21a85fd8f2530021915067b66cf2e98 Mon Sep 17 00:00:00 2001 From: Martin Habovstiak Date: Thu, 11 Aug 2022 16:49:26 +0200 Subject: [PATCH] `impl From for io::Error` This implements the trivial conversion from (uninhabited) `Infallible` error type. --- library/std/src/io/error.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/library/std/src/io/error.rs b/library/std/src/io/error.rs index ff7fdcae16f53..514cfcd37ca2b 100644 --- a/library/std/src/io/error.rs +++ b/library/std/src/io/error.rs @@ -11,7 +11,7 @@ mod repr_unpacked; #[cfg(not(target_pointer_width = "64"))] use repr_unpacked::Repr; -use crate::convert::From; +use crate::convert::{From, Infallible}; use crate::error; use crate::fmt; use crate::result; @@ -465,6 +465,13 @@ impl From for Error { } } +#[stable(feature = "io_error_from_infallible", since = "1.65.0")] +impl From for Error { + fn from(infallible: Infallible) -> Error { + match infallible {} + } +} + impl Error { /// Creates a new I/O error from a known kind of error as well as an /// arbitrary error payload.