Skip to content

Commit ad82bed

Browse files
committed
Adjust usage of std::io::ErrorKind to be core compatible
* Checking exhaustion will no longer be possible for `repr_bitpacked`. We can rely on `non_exhaustive_omitted_patterns` to maintain the exhaustive property for us instead. * `ErrorKind::as_str` is private, but it's only usage is trivially replaced with `Display::fmt` * The features io_error_inprogress, io_error_more, and io_error_uncategorized will all need to be enabled
1 parent 27b5f02 commit ad82bed

3 files changed

Lines changed: 8 additions & 2 deletions

File tree

library/std/src/io/error.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1038,7 +1038,7 @@ impl fmt::Display for Error {
10381038
write!(fmt, "{detail} (os error {code})")
10391039
}
10401040
ErrorData::Custom(ref c) => c.error.fmt(fmt),
1041-
ErrorData::Simple(kind) => write!(fmt, "{}", kind.as_str()),
1041+
ErrorData::Simple(kind) => kind.fmt(fmt),
10421042
ErrorData::SimpleMessage(msg) => msg.message.fmt(fmt),
10431043
}
10441044
}

library/std/src/io/error/repr_bitpacked.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,11 +288,14 @@ where
288288
// couldn't verify.
289289
#[inline]
290290
fn kind_from_prim(ek: u32) -> Option<ErrorKind> {
291+
#[allow_internal_unstable(non_exhaustive_omitted_patterns_lint)]
291292
macro_rules! from_prim {
292293
($prim:expr => $Enum:ident { $($Variant:ident),* $(,)? }) => {{
293294
// Force a compile error if the list gets out of date.
295+
#[deny(non_exhaustive_omitted_patterns)]
294296
const _: fn(e: $Enum) = |e: $Enum| match e {
295-
$($Enum::$Variant => ()),*
297+
$($Enum::$Variant => (),)*
298+
_ => (),
296299
};
297300
match $prim {
298301
$(v if v == ($Enum::$Variant as _) => Some($Enum::$Variant),)*

library/std/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,9 @@
343343
#![feature(hashmap_internals)]
344344
#![feature(hint_must_use)]
345345
#![feature(int_from_ascii)]
346+
#![feature(io_error_inprogress)]
347+
#![feature(io_error_more)]
348+
#![feature(io_error_uncategorized)]
346349
#![feature(ip)]
347350
#![feature(iter_advance_by)]
348351
#![feature(iter_next_chunk)]

0 commit comments

Comments
 (0)