Skip to content

Commit b1ce220

Browse files
committed
io: always impl Error for Errno in rustc 1.81+
In rust 1.81 the feature [`error_in_core`] was stabilized. This makes the `Error` trait available in `core::error` instead of `std::error`, so it can be used in a no-std context, too. [`error_in_core`]: <rust-lang/rust#103765>
1 parent 737e1fb commit b1ce220

File tree

4 files changed

+6
-1
lines changed

4 files changed

+6
-1
lines changed

Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,7 @@ check-cfg = [
262262
'cfg(core_intrinsics)',
263263
'cfg(criterion)',
264264
'cfg(document_experimental_runtime_api)',
265+
'cfg(error_in_core)',
265266
'cfg(fix_y2038)',
266267
'cfg(freebsdlike)',
267268
'cfg(libc)',

build.rs

+1
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ fn main() {
7171
use_feature_or_nothing("core_ffi_c");
7272
use_feature_or_nothing("alloc_c_string");
7373
use_feature_or_nothing("alloc_ffi");
74+
use_feature_or_nothing("error_in_core");
7475
}
7576

7677
// Feature needed for testing.

src/io/errno.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
//! want unrecognized values to create undefined behavior.
66
77
use crate::backend;
8+
#[cfg(all(not(feature = "std"), error_in_core))]
9+
use core::error;
810
use core::{fmt, result};
911
#[cfg(feature = "std")]
1012
use std::error;
@@ -49,7 +51,7 @@ impl fmt::Debug for Errno {
4951
}
5052
}
5153

52-
#[cfg(feature = "std")]
54+
#[cfg(any(feature = "std", error_in_core))]
5355
impl error::Error for Errno {}
5456

5557
#[cfg(feature = "std")]

src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@
108108
#![cfg_attr(all(wasi_ext, target_os = "wasi", feature = "std"), feature(wasi_ext))]
109109
#![cfg_attr(core_ffi_c, feature(core_ffi_c))]
110110
#![cfg_attr(core_c_str, feature(core_c_str))]
111+
#![cfg_attr(error_in_core, feature(error_in_core))]
111112
#![cfg_attr(all(feature = "alloc", alloc_c_string), feature(alloc_c_string))]
112113
#![cfg_attr(all(feature = "alloc", alloc_ffi), feature(alloc_ffi))]
113114
#![cfg_attr(not(feature = "std"), no_std)]

0 commit comments

Comments
 (0)