diff options
Diffstat (limited to 'library/std/src')
| -rw-r--r-- | library/std/src/fs/tests.rs | 4 | ||||
| -rw-r--r-- | library/std/src/sys/common/alloc.rs | 3 | ||||
| -rw-r--r-- | library/std/src/sys/mod.rs | 2 | ||||
| -rw-r--r-- | library/std/src/sys/wasm/alloc.rs | 4 | ||||
| -rw-r--r-- | library/std/src/sys/windows/path.rs | 4 | ||||
| -rw-r--r-- | library/std/src/sys/windows/path/tests.rs | 3 | ||||
| -rw-r--r-- | library/std/src/sys_common/mod.rs | 2 | ||||
| -rw-r--r-- | library/std/src/thread/local.rs | 28 | ||||
| -rw-r--r-- | library/std/src/thread/mod.rs | 2 |
9 files changed, 28 insertions, 24 deletions
diff --git a/library/std/src/fs/tests.rs b/library/std/src/fs/tests.rs index 1417d860c47..9a8f1e44f1f 100644 --- a/library/std/src/fs/tests.rs +++ b/library/std/src/fs/tests.rs @@ -1430,4 +1430,8 @@ fn create_dir_long_paths() { // This will fail if the path isn't converted to verbatim. path.push("a"); fs::create_dir(&path).unwrap(); + + // #90940: Ensure an empty path returns the "Not Found" error. + let path = Path::new(""); + assert_eq!(path.canonicalize().unwrap_err().kind(), crate::io::ErrorKind::NotFound); } diff --git a/library/std/src/sys/common/alloc.rs b/library/std/src/sys/common/alloc.rs index 576667c0173..9665d1fa892 100644 --- a/library/std/src/sys/common/alloc.rs +++ b/library/std/src/sys/common/alloc.rs @@ -24,7 +24,8 @@ pub const MIN_ALIGN: usize = 8; target_arch = "mips64", target_arch = "s390x", target_arch = "sparc64", - target_arch = "riscv64" + target_arch = "riscv64", + target_arch = "wasm64", )))] pub const MIN_ALIGN: usize = 16; diff --git a/library/std/src/sys/mod.rs b/library/std/src/sys/mod.rs index 8b8be6ebc2f..167c918c94c 100644 --- a/library/std/src/sys/mod.rs +++ b/library/std/src/sys/mod.rs @@ -40,7 +40,7 @@ cfg_if::cfg_if! { } else if #[cfg(target_os = "wasi")] { mod wasi; pub use self::wasi::*; - } else if #[cfg(target_arch = "wasm32")] { + } else if #[cfg(target_family = "wasm")] { mod wasm; pub use self::wasm::*; } else if #[cfg(all(target_vendor = "fortanix", target_env = "sgx"))] { diff --git a/library/std/src/sys/wasm/alloc.rs b/library/std/src/sys/wasm/alloc.rs index ef0ca3dd478..3223e894102 100644 --- a/library/std/src/sys/wasm/alloc.rs +++ b/library/std/src/sys/wasm/alloc.rs @@ -1,8 +1,8 @@ -//! This is an implementation of a global allocator on the wasm32 platform when +//! This is an implementation of a global allocator on wasm targets when //! emscripten is not in use. In that situation there's no actual runtime for us //! to lean on for allocation, so instead we provide our own! //! -//! The wasm32 instruction set has two instructions for getting the current +//! The wasm instruction set has two instructions for getting the current //! amount of memory and growing the amount of memory. These instructions are the //! foundation on which we're able to build an allocator, so we do so! Note that //! the instructions are also pretty "global" and this is the "global" allocator diff --git a/library/std/src/sys/windows/path.rs b/library/std/src/sys/windows/path.rs index 460c1eff778..d0b7d9e7377 100644 --- a/library/std/src/sys/windows/path.rs +++ b/library/std/src/sys/windows/path.rs @@ -174,8 +174,8 @@ pub(crate) fn maybe_verbatim(path: &Path) -> io::Result<Vec<u16>> { const UNC_PREFIX: &[u16] = &[SEP, SEP, QUERY, SEP, U, N, C, SEP]; let mut path = to_u16s(path)?; - if path.starts_with(VERBATIM_PREFIX) || path.starts_with(NT_PREFIX) { - // Early return for paths that are already verbatim. + if path.starts_with(VERBATIM_PREFIX) || path.starts_with(NT_PREFIX) || path == &[0] { + // Early return for paths that are already verbatim or empty. return Ok(path); } else if path.len() < LEGACY_MAX_PATH { // Early return if an absolute path is less < 260 UTF-16 code units. diff --git a/library/std/src/sys/windows/path/tests.rs b/library/std/src/sys/windows/path/tests.rs index c6c84519f41..425c2011b32 100644 --- a/library/std/src/sys/windows/path/tests.rs +++ b/library/std/src/sys/windows/path/tests.rs @@ -91,7 +91,6 @@ fn verbatim() { // Make sure opening a drive will work. check("Z:", "Z:"); - // An empty path or a path that contains null are not valid paths. - assert!(maybe_verbatim(Path::new("")).is_err()); + // A path that contains null is not a valid path. assert!(maybe_verbatim(Path::new("\0")).is_err()); } diff --git a/library/std/src/sys_common/mod.rs b/library/std/src/sys_common/mod.rs index 5a5913ebd79..804727fbc54 100644 --- a/library/std/src/sys_common/mod.rs +++ b/library/std/src/sys_common/mod.rs @@ -40,7 +40,7 @@ cfg_if::cfg_if! { if #[cfg(any(target_os = "l4re", target_os = "hermit", feature = "restricted-std", - all(target_arch = "wasm32", not(target_os = "emscripten")), + all(target_family = "wasm", not(target_os = "emscripten")), all(target_vendor = "fortanix", target_env = "sgx")))] { pub use crate::sys::net; } else { diff --git a/library/std/src/thread/local.rs b/library/std/src/thread/local.rs index c53290ec0c7..4da59577d78 100644 --- a/library/std/src/thread/local.rs +++ b/library/std/src/thread/local.rs @@ -165,6 +165,7 @@ macro_rules! __thread_local_inner { #[cfg_attr(not(windows), inline)] // see comments below unsafe fn __getit() -> $crate::option::Option<&'static $t> { const _REQUIRE_UNSTABLE: () = $crate::thread::require_unstable_const_init_thread_local(); + const INIT_EXPR: $t = $init; // wasm without atomics maps directly to `static mut`, and dtors // aren't implemented because thread dtors aren't really a thing @@ -172,30 +173,29 @@ macro_rules! __thread_local_inner { // // FIXME(#84224) this should come after the `target_thread_local` // block. - #[cfg(all(target_arch = "wasm32", not(target_feature = "atomics")))] + #[cfg(all(target_family = "wasm", not(target_feature = "atomics")))] { - static mut VAL: $t = $init; + static mut VAL: $t = INIT_EXPR; Some(&VAL) } // If the platform has support for `#[thread_local]`, use it. #[cfg(all( target_thread_local, - not(all(target_arch = "wasm32", not(target_feature = "atomics"))), + not(all(target_family = "wasm", not(target_feature = "atomics"))), ))] { + #[thread_local] + static mut VAL: $t = INIT_EXPR; + // If a dtor isn't needed we can do something "very raw" and // just get going. if !$crate::mem::needs_drop::<$t>() { - #[thread_local] - static mut VAL: $t = $init; unsafe { return Some(&VAL) } } - #[thread_local] - static mut VAL: $t = $init; // 0 == dtor not registered // 1 == dtor registered, dtor not run // 2 == dtor registered and is running or has run @@ -238,11 +238,11 @@ macro_rules! __thread_local_inner { // same implementation as below for os thread locals. #[cfg(all( not(target_thread_local), - not(all(target_arch = "wasm32", not(target_feature = "atomics"))), + not(all(target_family = "wasm", not(target_feature = "atomics"))), ))] { #[inline] - const fn __init() -> $t { $init } + const fn __init() -> $t { INIT_EXPR } static __KEY: $crate::thread::__OsLocalKeyInner<$t> = $crate::thread::__OsLocalKeyInner::new(); #[allow(unused_unsafe)] @@ -285,21 +285,21 @@ macro_rules! __thread_local_inner { // The issue of "should enable on Windows sometimes" is #84933 #[cfg_attr(not(windows), inline)] unsafe fn __getit() -> $crate::option::Option<&'static $t> { - #[cfg(all(target_arch = "wasm32", not(target_feature = "atomics")))] + #[cfg(all(target_family = "wasm", not(target_feature = "atomics")))] static __KEY: $crate::thread::__StaticLocalKeyInner<$t> = $crate::thread::__StaticLocalKeyInner::new(); #[thread_local] #[cfg(all( target_thread_local, - not(all(target_arch = "wasm32", not(target_feature = "atomics"))), + not(all(target_family = "wasm", not(target_feature = "atomics"))), ))] static __KEY: $crate::thread::__FastLocalKeyInner<$t> = $crate::thread::__FastLocalKeyInner::new(); #[cfg(all( not(target_thread_local), - not(all(target_arch = "wasm32", not(target_feature = "atomics"))), + not(all(target_family = "wasm", not(target_feature = "atomics"))), ))] static __KEY: $crate::thread::__OsLocalKeyInner<$t> = $crate::thread::__OsLocalKeyInner::new(); @@ -479,10 +479,10 @@ mod lazy { } } -/// On some platforms like wasm32 there's no threads, so no need to generate +/// On some targets like wasm there's no threads, so no need to generate /// thread locals and we can instead just use plain statics! #[doc(hidden)] -#[cfg(all(target_arch = "wasm32", not(target_feature = "atomics")))] +#[cfg(all(target_family = "wasm", not(target_feature = "atomics")))] pub mod statik { use super::lazy::LazyKeyInner; use crate::fmt; diff --git a/library/std/src/thread/mod.rs b/library/std/src/thread/mod.rs index 2a155ce3117..39b53b51bfa 100644 --- a/library/std/src/thread/mod.rs +++ b/library/std/src/thread/mod.rs @@ -200,7 +200,7 @@ pub use self::local::fast::Key as __FastLocalKeyInner; #[doc(hidden)] pub use self::local::os::Key as __OsLocalKeyInner; #[unstable(feature = "libstd_thread_internals", issue = "none")] -#[cfg(all(target_arch = "wasm32", not(target_feature = "atomics")))] +#[cfg(all(target_family = "wasm", not(target_feature = "atomics")))] #[doc(hidden)] pub use self::local::statik::Key as __StaticLocalKeyInner; |
