diff --git a/library/std/src/sys/hermit/thread.rs b/library/std/src/sys/hermit/thread.rs index 3d00e626e1ac..6da79d19f594 100644 --- a/library/std/src/sys/hermit/thread.rs +++ b/library/std/src/sys/hermit/thread.rs @@ -1,5 +1,6 @@ #![allow(dead_code)] +use super::unsupported; use crate::ffi::CStr; use crate::io; use crate::mem; @@ -97,10 +98,7 @@ impl Thread { } pub fn available_concurrency() -> io::Result { - Err(io::Error::new_const( - io::ErrorKind::NotFound, - &"The number of hardware threads is not known for the target platform", - )) + unsupported() } pub mod guard { diff --git a/library/std/src/sys/sgx/thread.rs b/library/std/src/sys/sgx/thread.rs index b82ae86521a0..cbb8ba964018 100644 --- a/library/std/src/sys/sgx/thread.rs +++ b/library/std/src/sys/sgx/thread.rs @@ -1,4 +1,5 @@ #![cfg_attr(test, allow(dead_code))] // why is this necessary? +use super::unsupported; use crate::ffi::CStr; use crate::io; use crate::num::NonZeroUsize; @@ -137,10 +138,7 @@ impl Thread { } pub fn available_concurrency() -> io::Result { - Err(io::Error::new_const( - io::ErrorKind::NotFound, - &"The number of hardware threads is not known for the target platform", - )) + unsupported() } pub mod guard { diff --git a/library/std/src/sys/unix/thread.rs b/library/std/src/sys/unix/thread.rs index e49971de940b..df2ba0a8bc8e 100644 --- a/library/std/src/sys/unix/thread.rs +++ b/library/std/src/sys/unix/thread.rs @@ -276,7 +276,7 @@ pub fn available_concurrency() -> io::Result { Ok(unsafe { NonZeroUsize::new_unchecked(cpus as usize) }) } else { // FIXME: implement on vxWorks, Redox, Haiku, l4re - Err(io::Error::new_const(io::ErrorKind::NotFound, &"The number of hardware threads is not known for the target platform")) + Err(io::Error::new_const(io::ErrorKind::Unsupported, &"Getting the number of hardware threads is not supported on the target platform")) } } } diff --git a/library/std/src/sys/unsupported/thread.rs b/library/std/src/sys/unsupported/thread.rs index 47005ead196a..dc75d4ee6725 100644 --- a/library/std/src/sys/unsupported/thread.rs +++ b/library/std/src/sys/unsupported/thread.rs @@ -32,10 +32,7 @@ impl Thread { } pub fn available_concurrency() -> io::Result { - Err(io::Error::new_const( - io::ErrorKind::NotFound, - &"The number of hardware threads is not known for the target platform", - )) + unsupported() } pub mod guard { diff --git a/library/std/src/sys/wasi/thread.rs b/library/std/src/sys/wasi/thread.rs index 959077f7b54b..9ec02bbec264 100644 --- a/library/std/src/sys/wasi/thread.rs +++ b/library/std/src/sys/wasi/thread.rs @@ -65,10 +65,7 @@ impl Thread { } pub fn available_concurrency() -> io::Result { - Err(io::Error::new_const( - io::ErrorKind::NotFound, - &"The number of hardware threads is not known for the target platform", - )) + unsupported() } pub mod guard { diff --git a/library/std/src/sys/wasm/atomics/thread.rs b/library/std/src/sys/wasm/atomics/thread.rs index 8207a41035db..097148351049 100644 --- a/library/std/src/sys/wasm/atomics/thread.rs +++ b/library/std/src/sys/wasm/atomics/thread.rs @@ -1,3 +1,4 @@ +use super::unsupported; use crate::ffi::CStr; use crate::io; use crate::num::NonZeroUsize; @@ -41,10 +42,7 @@ impl Thread { } pub fn available_concurrency() -> io::Result { - Err(io::Error::new_const( - io::ErrorKind::NotFound, - &"The number of hardware threads is not known for the target platform", - )) + unsupported() } pub mod guard {