diff --git a/Cargo.lock b/Cargo.lock index 8b78908e6d730..de9685742f59f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -61,9 +61,9 @@ dependencies = [ [[package]] name = "compiler_builtins" -version = "0.1.145" +version = "0.1.148" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da0705f5abaaab7168ccc14f8f340ded61be2bd3ebea86b9834b6acbc8495de8" +checksum = "26137996631d90d2727b905b480fdcf8c4479fdbce7afd7f8e3796d689b33cc2" dependencies = [ "cc", "rustc-std-workspace-core", @@ -215,6 +215,15 @@ dependencies = [ "unwind", ] +[[package]] +name = "proc-macro2" +version = "1.0.93" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60946a68e5f9d28b0dc1c21bb8a97ee7d018a8b322fa57838ba31cc878e22d99" +dependencies = [ + "unicode-ident", +] + [[package]] name = "proc_macro" version = "0.0.0" @@ -230,6 +239,15 @@ dependencies = [ "cc", ] +[[package]] +name = "quote" +version = "1.0.38" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e4dccaaaf89514f546c693ddc140f729f958c247918a13380cccc6078391acc" +dependencies = [ + "proc-macro2", +] + [[package]] name = "r-efi" version = "4.5.0" @@ -253,24 +271,28 @@ dependencies = [ [[package]] name = "rand" -version = "0.8.5" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +checksum = "3779b94aeb87e8bd4e834cee3650289ee9e0d5677f976ecdb6d219e5f4f6cd94" dependencies = [ "rand_core", + "zerocopy", ] [[package]] name = "rand_core" -version = "0.6.4" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +checksum = "b08f3c9802962f7e1b25113931d94f43ed9725bebc59db9d0c3e9a23b67e15ff" +dependencies = [ + "zerocopy", +] [[package]] name = "rand_xorshift" -version = "0.3.0" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d25bf25ec5ae4a3f1b92f929810509a2f53d7dca2f50b794ff57e3face536c8f" +checksum = "513962919efc330f829edb2535844d1b912b0fbe2ca165d613e4e8788bb05a5a" dependencies = [ "rand_core", ] @@ -352,6 +374,17 @@ dependencies = [ "rustc-std-workspace-core", ] +[[package]] +name = "syn" +version = "2.0.98" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "36147f1a48ae0ec2b5b3bc5b537d267457555a10dc06f3dbc8cb11ba3006d3b1" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + [[package]] name = "sysroot" version = "0.0.0" @@ -372,6 +405,12 @@ dependencies = [ "std", ] +[[package]] +name = "unicode-ident" +version = "1.0.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a210d160f08b701c8721ba1c726c11662f877ea6b7094007e1ca9a1041945034" + [[package]] name = "unicode-width" version = "0.1.14" @@ -492,3 +531,23 @@ name = "windows_x86_64_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + +[[package]] +name = "zerocopy" +version = "0.8.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa91407dacce3a68c56de03abe2760159582b846c6a4acd2f456618087f12713" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.8.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06718a168365cad3d5ff0bb133aad346959a2074bd4a85c121255a11304a8626" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] diff --git a/alloc/Cargo.toml b/alloc/Cargo.toml index db7eaf52fb227..9e80f3579e808 100644 --- a/alloc/Cargo.toml +++ b/alloc/Cargo.toml @@ -1,3 +1,5 @@ +cargo-features = ["public-dependency"] + [package] name = "alloc" version = "0.0.0" @@ -9,12 +11,12 @@ autobenches = false edition = "2021" [dependencies] -core = { path = "../core" } -compiler_builtins = { version = "=0.1.145", features = ['rustc-dep-of-std'] } +core = { path = "../core", public = true } +compiler_builtins = { version = "=0.1.148", features = ['rustc-dep-of-std'] } [dev-dependencies] -rand = { version = "0.8.5", default-features = false, features = ["alloc"] } -rand_xorshift = "0.3.0" +rand = { version = "0.9.0", default-features = false, features = ["alloc"] } +rand_xorshift = "0.4.0" [[test]] name = "alloctests" diff --git a/alloc/benches/btree/map.rs b/alloc/benches/btree/map.rs index 5b15aaeddbc40..20f02dc3a968a 100644 --- a/alloc/benches/btree/map.rs +++ b/alloc/benches/btree/map.rs @@ -9,19 +9,19 @@ macro_rules! map_insert_rand_bench { ($name: ident, $n: expr, $map: ident) => { #[bench] pub fn $name(b: &mut Bencher) { - let n: usize = $n; + let n: u32 = $n; let mut map = $map::new(); // setup let mut rng = crate::bench_rng(); for _ in 0..n { - let i = rng.gen::() % n; + let i = rng.random::() % n; map.insert(i, i); } // measure b.iter(|| { - let k = rng.gen::() % n; + let k = rng.random::() % n; map.insert(k, k); map.remove(&k); }); @@ -57,13 +57,13 @@ macro_rules! map_from_iter_rand_bench { ($name: ident, $n: expr, $map: ident) => { #[bench] pub fn $name(b: &mut Bencher) { - let n: usize = $n; + let n: u32 = $n; // setup let mut rng = crate::bench_rng(); - let mut vec = Vec::with_capacity(n); + let mut vec = Vec::with_capacity(n as usize); for _ in 0..n { - let i = rng.gen::() % n; + let i = rng.random::() % n; vec.push((i, i)); } @@ -102,11 +102,11 @@ macro_rules! map_find_rand_bench { #[bench] pub fn $name(b: &mut Bencher) { let mut map = $map::new(); - let n: usize = $n; + let n: u32 = $n; // setup let mut rng = crate::bench_rng(); - let mut keys: Vec<_> = (0..n).map(|_| rng.gen::() % n).collect(); + let mut keys: Vec<_> = (0..n).map(|_| rng.random::() % n).collect(); for &k in &keys { map.insert(k, k); @@ -115,9 +115,9 @@ macro_rules! map_find_rand_bench { keys.shuffle(&mut rng); // measure - let mut i = 0; + let mut i = 0u32; b.iter(|| { - let t = map.get(&keys[i]); + let t = map.get(&keys[i as usize]); i = (i + 1) % n; black_box(t); }) @@ -171,7 +171,7 @@ fn bench_iteration(b: &mut Bencher, size: i32) { let mut rng = crate::bench_rng(); for _ in 0..size { - map.insert(rng.gen(), rng.gen()); + map.insert(rng.random(), rng.random()); } b.iter(|| { @@ -201,7 +201,7 @@ fn bench_iteration_mut(b: &mut Bencher, size: i32) { let mut rng = crate::bench_rng(); for _ in 0..size { - map.insert(rng.gen(), rng.gen()); + map.insert(rng.random(), rng.random()); } b.iter(|| { diff --git a/alloc/benches/btree/set.rs b/alloc/benches/btree/set.rs index 09d72c7206469..5aa395b4d52ac 100644 --- a/alloc/benches/btree/set.rs +++ b/alloc/benches/btree/set.rs @@ -3,13 +3,13 @@ use std::collections::BTreeSet; use rand::Rng; use test::Bencher; -fn random(n: usize) -> BTreeSet { +fn random(n: u32) -> BTreeSet { let mut rng = crate::bench_rng(); let mut set = BTreeSet::new(); - while set.len() < n { - set.insert(rng.gen()); + while set.len() < n as usize { + set.insert(rng.random()); } - assert_eq!(set.len(), n); + assert_eq!(set.len(), n as usize); set } diff --git a/alloc/benches/slice.rs b/alloc/benches/slice.rs index c45c372271297..c6b46e6a2a188 100644 --- a/alloc/benches/slice.rs +++ b/alloc/benches/slice.rs @@ -1,7 +1,7 @@ use std::{mem, ptr}; use rand::Rng; -use rand::distributions::{Alphanumeric, DistString, Standard}; +use rand::distr::{Alphanumeric, SampleString, StandardUniform}; use test::{Bencher, black_box}; #[bench] @@ -156,7 +156,7 @@ fn random_inserts(b: &mut Bencher) { let mut v = vec![(0, 0); 30]; for _ in 0..100 { let l = v.len(); - v.insert(rng.gen::() % (l + 1), (1, 1)); + v.insert(rng.random::() as usize % (l + 1), (1, 1)); } }) } @@ -168,7 +168,7 @@ fn random_removes(b: &mut Bencher) { let mut v = vec![(0, 0); 130]; for _ in 0..100 { let l = v.len(); - v.remove(rng.gen::() % l); + v.remove(rng.random::() as usize % l); } }) } @@ -183,20 +183,20 @@ fn gen_descending(len: usize) -> Vec { fn gen_random(len: usize) -> Vec { let mut rng = crate::bench_rng(); - (&mut rng).sample_iter(&Standard).take(len).collect() + (&mut rng).sample_iter(&StandardUniform).take(len).collect() } fn gen_random_bytes(len: usize) -> Vec { let mut rng = crate::bench_rng(); - (&mut rng).sample_iter(&Standard).take(len).collect() + (&mut rng).sample_iter(&StandardUniform).take(len).collect() } fn gen_mostly_ascending(len: usize) -> Vec { let mut rng = crate::bench_rng(); let mut v = gen_ascending(len); for _ in (0usize..).take_while(|x| x * x <= len) { - let x = rng.gen::() % len; - let y = rng.gen::() % len; + let x = rng.random::() as usize % len; + let y = rng.random::() as usize % len; v.swap(x, y); } v @@ -206,8 +206,8 @@ fn gen_mostly_descending(len: usize) -> Vec { let mut rng = crate::bench_rng(); let mut v = gen_descending(len); for _ in (0usize..).take_while(|x| x * x <= len) { - let x = rng.gen::() % len; - let y = rng.gen::() % len; + let x = rng.random::() as usize % len; + let y = rng.random::() as usize % len; v.swap(x, y); } v @@ -217,15 +217,15 @@ fn gen_strings(len: usize) -> Vec { let mut rng = crate::bench_rng(); let mut v = vec![]; for _ in 0..len { - let n = rng.gen::() % 20 + 1; - v.push(Alphanumeric.sample_string(&mut rng, n)); + let n = rng.random::() % 20 + 1; + v.push(Alphanumeric.sample_string(&mut rng, n as usize)); } v } fn gen_big_random(len: usize) -> Vec<[u64; 16]> { let mut rng = crate::bench_rng(); - (&mut rng).sample_iter(&Standard).map(|x| [x; 16]).take(len).collect() + (&mut rng).sample_iter(&StandardUniform).map(|x| [x; 16]).take(len).collect() } macro_rules! sort { diff --git a/alloc/src/alloc.rs b/alloc/src/alloc.rs index e9b7f9856677c..e686a02f29b0c 100644 --- a/alloc/src/alloc.rs +++ b/alloc/src/alloc.rs @@ -10,7 +10,7 @@ use core::hint; #[cfg(not(test))] use core::ptr::{self, NonNull}; -extern "Rust" { +unsafe extern "Rust" { // These are the magic symbols to call the global allocator. rustc generates // them to call `__rg_alloc` etc. if there is a `#[global_allocator]` attribute // (the code expanding that attribute macro generates those functions), or to call @@ -355,7 +355,7 @@ unsafe fn exchange_malloc(size: usize, align: usize) -> *mut u8 { // # Allocation error handler #[cfg(not(no_global_oom_handling))] -extern "Rust" { +unsafe extern "Rust" { // This is the magic symbol to call the global alloc error handler. rustc generates // it to call `__rg_oom` if there is a `#[alloc_error_handler]`, or to call the // default implementations below (`__rdl_oom`) otherwise. @@ -426,7 +426,7 @@ pub mod __alloc_error_handler { // `#[alloc_error_handler]`. #[rustc_std_internal_symbol] pub unsafe fn __rdl_oom(size: usize, _align: usize) -> ! { - extern "Rust" { + unsafe extern "Rust" { // This symbol is emitted by rustc next to __rust_alloc_error_handler. // Its value depends on the -Zoom={panic,abort} compiler option. static __rust_alloc_error_handler_should_panic: u8; diff --git a/alloc/src/borrow.rs b/alloc/src/borrow.rs index dbfd2e74abee6..17dad3277b95d 100644 --- a/alloc/src/borrow.rs +++ b/alloc/src/borrow.rs @@ -340,8 +340,18 @@ where } } +// `Cow<'_, T>` can only implement `DerefPure` if `>` (and `BorrowMut`) is trusted. +// For now, we restrict `DerefPure for Cow` to `T: Sized` (`T as Borrow` is trusted), +// `str` (`String as Borrow` is trusted) and `[T]` (`Vec as Borrow<[T]>` is trusted). +// In the future, a `BorrowPure` trait analogous to `DerefPure` might generalize this. #[unstable(feature = "deref_pure_trait", issue = "87121")] -unsafe impl DerefPure for Cow<'_, B> where B::Owned: Borrow {} +unsafe impl DerefPure for Cow<'_, T> {} +#[cfg(not(no_global_oom_handling))] +#[unstable(feature = "deref_pure_trait", issue = "87121")] +unsafe impl DerefPure for Cow<'_, str> {} +#[cfg(not(no_global_oom_handling))] +#[unstable(feature = "deref_pure_trait", issue = "87121")] +unsafe impl DerefPure for Cow<'_, [T]> {} #[stable(feature = "rust1", since = "1.0.0")] impl Eq for Cow<'_, B> where B: Eq + ToOwned {} diff --git a/alloc/src/boxed.rs b/alloc/src/boxed.rs index 8b38e6fc259af..c3f5806e1aa90 100644 --- a/alloc/src/boxed.rs +++ b/alloc/src/boxed.rs @@ -24,7 +24,7 @@ //! Creating a recursive data structure: //! //! ``` -//! ##[allow(dead_code)] +//! # #[allow(dead_code)] //! #[derive(Debug)] //! enum List { //! Cons(T, Box>), @@ -97,12 +97,12 @@ //! #[repr(C)] //! pub struct Foo; //! -//! #[no_mangle] +//! #[unsafe(no_mangle)] //! pub extern "C" fn foo_new() -> Box { //! Box::new(Foo) //! } //! -//! #[no_mangle] +//! #[unsafe(no_mangle)] //! pub extern "C" fn foo_delete(_: Option>) {} //! ``` //! @@ -237,22 +237,9 @@ pub struct Box< /// the newly allocated memory. This is an intrinsic to avoid unnecessary copies. /// /// This is the surface syntax for `box ` expressions. -#[cfg(not(bootstrap))] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[unstable(feature = "liballoc_internals", issue = "none")] -pub fn box_new(_x: T) -> Box { - unreachable!() -} - -/// Transition function for the next bootstrap bump. -#[cfg(bootstrap)] -#[unstable(feature = "liballoc_internals", issue = "none")] -#[inline(always)] -pub fn box_new(x: T) -> Box { - #[rustc_box] - Box::new(x) -} +pub fn box_new(_x: T) -> Box; impl Box { /// Allocates memory on the heap and then places `x` into it. @@ -280,13 +267,9 @@ impl Box { /// /// ``` /// let mut five = Box::::new_uninit(); - /// - /// let five = unsafe { - /// // Deferred initialization: - /// five.as_mut_ptr().write(5); - /// - /// five.assume_init() - /// }; + /// // Deferred initialization: + /// five.write(5); + /// let five = unsafe { five.assume_init() }; /// /// assert_eq!(*five, 5) /// ``` @@ -367,13 +350,9 @@ impl Box { /// #![feature(allocator_api)] /// /// let mut five = Box::::try_new_uninit()?; - /// - /// let five = unsafe { - /// // Deferred initialization: - /// five.as_mut_ptr().write(5); - /// - /// five.assume_init() - /// }; + /// // Deferred initialization: + /// five.write(5); + /// let five = unsafe { five.assume_init() }; /// /// assert_eq!(*five, 5); /// # Ok::<(), std::alloc::AllocError>(()) @@ -435,10 +414,8 @@ impl Box { A: Allocator, { let mut boxed = Self::new_uninit_in(alloc); - unsafe { - boxed.as_mut_ptr().write(x); - boxed.assume_init() - } + boxed.write(x); + unsafe { boxed.assume_init() } } /// Allocates memory in the given allocator then places `x` into it, @@ -463,10 +440,8 @@ impl Box { A: Allocator, { let mut boxed = Self::try_new_uninit_in(alloc)?; - unsafe { - boxed.as_mut_ptr().write(x); - Ok(boxed.assume_init()) - } + boxed.write(x); + unsafe { Ok(boxed.assume_init()) } } /// Constructs a new box with uninitialized contents in the provided allocator. @@ -479,13 +454,9 @@ impl Box { /// use std::alloc::System; /// /// let mut five = Box::::new_uninit_in(System); - /// - /// let five = unsafe { - /// // Deferred initialization: - /// five.as_mut_ptr().write(5); - /// - /// five.assume_init() - /// }; + /// // Deferred initialization: + /// five.write(5); + /// let five = unsafe { five.assume_init() }; /// /// assert_eq!(*five, 5) /// ``` @@ -517,13 +488,9 @@ impl Box { /// use std::alloc::System; /// /// let mut five = Box::::try_new_uninit_in(System)?; - /// - /// let five = unsafe { - /// // Deferred initialization: - /// five.as_mut_ptr().write(5); - /// - /// five.assume_init() - /// }; + /// // Deferred initialization: + /// five.write(5); + /// let five = unsafe { five.assume_init() }; /// /// assert_eq!(*five, 5); /// # Ok::<(), std::alloc::AllocError>(()) @@ -669,15 +636,11 @@ impl Box<[T]> { /// /// ``` /// let mut values = Box::<[u32]>::new_uninit_slice(3); - /// - /// let values = unsafe { - /// // Deferred initialization: - /// values[0].as_mut_ptr().write(1); - /// values[1].as_mut_ptr().write(2); - /// values[2].as_mut_ptr().write(3); - /// - /// values.assume_init() - /// }; + /// // Deferred initialization: + /// values[0].write(1); + /// values[1].write(2); + /// values[2].write(3); + /// let values = unsafe {values.assume_init() }; /// /// assert_eq!(*values, [1, 2, 3]) /// ``` @@ -722,13 +685,11 @@ impl Box<[T]> { /// #![feature(allocator_api)] /// /// let mut values = Box::<[u32]>::try_new_uninit_slice(3)?; - /// let values = unsafe { - /// // Deferred initialization: - /// values[0].as_mut_ptr().write(1); - /// values[1].as_mut_ptr().write(2); - /// values[2].as_mut_ptr().write(3); - /// values.assume_init() - /// }; + /// // Deferred initialization: + /// values[0].write(1); + /// values[1].write(2); + /// values[2].write(3); + /// let values = unsafe { values.assume_init() }; /// /// assert_eq!(*values, [1, 2, 3]); /// # Ok::<(), std::alloc::AllocError>(()) @@ -814,15 +775,11 @@ impl Box<[T], A> { /// use std::alloc::System; /// /// let mut values = Box::<[u32], _>::new_uninit_slice_in(3, System); - /// - /// let values = unsafe { - /// // Deferred initialization: - /// values[0].as_mut_ptr().write(1); - /// values[1].as_mut_ptr().write(2); - /// values[2].as_mut_ptr().write(3); - /// - /// values.assume_init() - /// }; + /// // Deferred initialization: + /// values[0].write(1); + /// values[1].write(2); + /// values[2].write(3); + /// let values = unsafe { values.assume_init() }; /// /// assert_eq!(*values, [1, 2, 3]) /// ``` @@ -873,13 +830,11 @@ impl Box<[T], A> { /// use std::alloc::System; /// /// let mut values = Box::<[u32], _>::try_new_uninit_slice_in(3, System)?; - /// let values = unsafe { - /// // Deferred initialization: - /// values[0].as_mut_ptr().write(1); - /// values[1].as_mut_ptr().write(2); - /// values[2].as_mut_ptr().write(3); - /// values.assume_init() - /// }; + /// // Deferred initialization: + /// values[0].write(1); + /// values[1].write(2); + /// values[2].write(3); + /// let values = unsafe { values.assume_init() }; /// /// assert_eq!(*values, [1, 2, 3]); /// # Ok::<(), std::alloc::AllocError>(()) @@ -959,13 +914,9 @@ impl Box, A> { /// /// ``` /// let mut five = Box::::new_uninit(); - /// - /// let five: Box = unsafe { - /// // Deferred initialization: - /// five.as_mut_ptr().write(5); - /// - /// five.assume_init() - /// }; + /// // Deferred initialization: + /// five.write(5); + /// let five: Box = unsafe { five.assume_init() }; /// /// assert_eq!(*five, 5) /// ``` @@ -1030,15 +981,11 @@ impl Box<[mem::MaybeUninit], A> { /// /// ``` /// let mut values = Box::<[u32]>::new_uninit_slice(3); - /// - /// let values = unsafe { - /// // Deferred initialization: - /// values[0].as_mut_ptr().write(1); - /// values[1].as_mut_ptr().write(2); - /// values[2].as_mut_ptr().write(3); - /// - /// values.assume_init() - /// }; + /// // Deferred initialization: + /// values[0].write(1); + /// values[1].write(2); + /// values[2].write(3); + /// let values = unsafe { values.assume_init() }; /// /// assert_eq!(*values, [1, 2, 3]) /// ``` @@ -1093,7 +1040,6 @@ impl Box { /// ``` /// /// [memory layout]: self#memory-layout - /// [`Layout`]: crate::Layout #[stable(feature = "box_raw", since = "1.4.0")] #[inline] #[must_use = "call `drop(Box::from_raw(ptr))` if you intend to drop the `Box`"] @@ -1148,7 +1094,6 @@ impl Box { /// ``` /// /// [memory layout]: self#memory-layout - /// [`Layout`]: crate::Layout #[unstable(feature = "box_vec_non_null", reason = "new API", issue = "130364")] #[inline] #[must_use = "call `drop(Box::from_non_null(ptr))` if you intend to drop the `Box`"] @@ -1205,7 +1150,6 @@ impl Box { /// ``` /// /// [memory layout]: self#memory-layout - /// [`Layout`]: crate::Layout #[unstable(feature = "allocator_api", issue = "32838")] #[rustc_const_unstable(feature = "const_box", issue = "92521")] #[inline] @@ -1259,7 +1203,6 @@ impl Box { /// ``` /// /// [memory layout]: self#memory-layout - /// [`Layout`]: crate::Layout #[unstable(feature = "allocator_api", issue = "32838")] // #[unstable(feature = "box_vec_non_null", reason = "new API", issue = "130364")] #[rustc_const_unstable(feature = "const_box", issue = "92521")] @@ -1733,7 +1676,20 @@ impl Default for Box { /// Creates a `Box`, with the `Default` value for T. #[inline] fn default() -> Self { - Box::write(Box::new_uninit(), T::default()) + let mut x: Box> = Box::new_uninit(); + unsafe { + // SAFETY: `x` is valid for writing and has the same layout as `T`. + // If `T::default()` panics, dropping `x` will just deallocate the Box as `MaybeUninit` + // does not have a destructor. + // + // We use `ptr::write` as `MaybeUninit::write` creates + // extra stack copies of `T` in debug mode. + // + // See https://github.com/rust-lang/rust/issues/136043 for more context. + ptr::write(&raw mut *x as *mut T, T::default()); + // SAFETY: `x` was just initialized above. + x.assume_init() + } } } diff --git a/alloc/src/collections/btree/map.rs b/alloc/src/collections/btree/map.rs index 6d305386dbfa0..78b7da9d6b3ee 100644 --- a/alloc/src/collections/btree/map.rs +++ b/alloc/src/collections/btree/map.rs @@ -289,7 +289,7 @@ impl Clone for BTreeMap { } } -/// Internal functionality for `BTreeSet`. +// Internal functionality for `BTreeSet`. impl BTreeMap { pub(super) fn replace(&mut self, key: K) -> Option where diff --git a/alloc/src/collections/btree/merge_iter.rs b/alloc/src/collections/btree/merge_iter.rs index c5b93d30a1185..5077062e25d87 100644 --- a/alloc/src/collections/btree/merge_iter.rs +++ b/alloc/src/collections/btree/merge_iter.rs @@ -74,7 +74,7 @@ impl MergeIterInner { b_next = self.b.next(); } } - if let (Some(ref a1), Some(ref b1)) = (&a_next, &b_next) { + if let (Some(a1), Some(b1)) = (&a_next, &b_next) { match cmp(a1, b1) { Ordering::Less => self.peeked = b_next.take().map(Peeked::B), Ordering::Greater => self.peeked = a_next.take().map(Peeked::A), diff --git a/alloc/src/collections/linked_list.rs b/alloc/src/collections/linked_list.rs index 13168b7a39fe4..3183268b4b32e 100644 --- a/alloc/src/collections/linked_list.rs +++ b/alloc/src/collections/linked_list.rs @@ -1140,7 +1140,6 @@ impl LinkedList { /// Splitting a list into evens and odds, reusing the original list: /// /// ``` - /// #![feature(extract_if)] /// use std::collections::LinkedList; /// /// let mut numbers: LinkedList = LinkedList::new(); @@ -1152,7 +1151,7 @@ impl LinkedList { /// assert_eq!(evens.into_iter().collect::>(), vec![2, 4, 6, 8, 14]); /// assert_eq!(odds.into_iter().collect::>(), vec![1, 3, 5, 9, 11, 13, 15]); /// ``` - #[unstable(feature = "extract_if", reason = "recently added", issue = "43244")] + #[stable(feature = "extract_if", since = "CURRENT_RUSTC_VERSION")] pub fn extract_if(&mut self, filter: F) -> ExtractIf<'_, T, F, A> where F: FnMut(&mut T) -> bool, @@ -1932,7 +1931,7 @@ impl<'a, T, A: Allocator> CursorMut<'a, T, A> { } /// An iterator produced by calling `extract_if` on LinkedList. -#[unstable(feature = "extract_if", reason = "recently added", issue = "43244")] +#[stable(feature = "extract_if", since = "CURRENT_RUSTC_VERSION")] #[must_use = "iterators are lazy and do nothing unless consumed"] pub struct ExtractIf< 'a, @@ -1947,7 +1946,7 @@ pub struct ExtractIf< old_len: usize, } -#[unstable(feature = "extract_if", reason = "recently added", issue = "43244")] +#[stable(feature = "extract_if", since = "CURRENT_RUSTC_VERSION")] impl Iterator for ExtractIf<'_, T, F, A> where F: FnMut(&mut T) -> bool, @@ -1976,7 +1975,7 @@ where } } -#[unstable(feature = "extract_if", reason = "recently added", issue = "43244")] +#[stable(feature = "extract_if", since = "CURRENT_RUSTC_VERSION")] impl fmt::Debug for ExtractIf<'_, T, F> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_tuple("ExtractIf").field(&self.list).finish() diff --git a/alloc/src/ffi/c_str.rs b/alloc/src/ffi/c_str.rs index 07c75677d0532..fd93045a5ac4d 100644 --- a/alloc/src/ffi/c_str.rs +++ b/alloc/src/ffi/c_str.rs @@ -397,7 +397,7 @@ impl CString { // information about the size of the allocation is correct on Rust's // side. unsafe { - extern "C" { + unsafe extern "C" { /// Provided by libc or compiler_builtins. fn strlen(s: *const c_char) -> usize; } diff --git a/alloc/src/lib.rs b/alloc/src/lib.rs index 0bb7c432cc35f..2e9dd98571537 100644 --- a/alloc/src/lib.rs +++ b/alloc/src/lib.rs @@ -105,6 +105,7 @@ #![feature(box_uninit_write)] #![feature(bstr)] #![feature(bstr_internals)] +#![feature(char_max_len)] #![feature(clone_to_uninit)] #![feature(coerce_unsized)] #![feature(const_eval_select)] @@ -136,7 +137,6 @@ #![feature(pointer_like_trait)] #![feature(ptr_internals)] #![feature(ptr_metadata)] -#![feature(ptr_sub_ptr)] #![feature(set_ptr_value)] #![feature(sized_type_properties)] #![feature(slice_from_ptr_range)] @@ -156,7 +156,6 @@ #![feature(unicode_internals)] #![feature(unsize)] #![feature(unwrap_infallible)] -#![feature(vec_pop_if)] // tidy-alphabetical-end // // Language features: diff --git a/alloc/src/rc.rs b/alloc/src/rc.rs index 6d82f514aa683..09206c2f8b290 100644 --- a/alloc/src/rc.rs +++ b/alloc/src/rc.rs @@ -1462,18 +1462,18 @@ impl Rc { /// Provides a raw pointer to the data. /// /// The counts are not affected in any way and the `Rc` is not consumed. The pointer is valid - /// for as long there are strong counts in the `Rc`. + /// for as long as there are strong counts in the `Rc`. /// /// # Examples /// /// ``` /// use std::rc::Rc; /// - /// let x = Rc::new("hello".to_owned()); + /// let x = Rc::new(0); /// let y = Rc::clone(&x); /// let x_ptr = Rc::as_ptr(&x); /// assert_eq!(x_ptr, Rc::as_ptr(&y)); - /// assert_eq!(unsafe { &*x_ptr }, "hello"); + /// assert_eq!(unsafe { *x_ptr }, 0); /// ``` #[stable(feature = "weak_into_raw", since = "1.45.0")] #[rustc_never_returns_null_ptr] diff --git a/alloc/src/slice.rs b/alloc/src/slice.rs index 1cedead7aa243..dcd95ddf00ff5 100644 --- a/alloc/src/slice.rs +++ b/alloc/src/slice.rs @@ -27,8 +27,8 @@ pub use core::slice::ArrayChunksMut; pub use core::slice::ArrayWindows; #[stable(feature = "inherent_ascii_escape", since = "1.60.0")] pub use core::slice::EscapeAscii; -#[unstable(feature = "get_many_mut", issue = "104642")] -pub use core::slice::GetManyMutError; +#[stable(feature = "get_many_mut", since = "1.86.0")] +pub use core::slice::GetDisjointMutError; #[stable(feature = "slice_get_slice", since = "1.28.0")] pub use core::slice::SliceIndex; #[cfg(not(no_global_oom_handling))] diff --git a/alloc/src/string.rs b/alloc/src/string.rs index b29f740ef0f2a..f10ef1fca1377 100644 --- a/alloc/src/string.rs +++ b/alloc/src/string.rs @@ -966,11 +966,8 @@ impl String { /// This is highly unsafe, due to the number of invariants that aren't /// checked: /// - /// * The memory at `buf` needs to have been previously allocated by the - /// same allocator the standard library uses, with a required alignment of exactly 1. - /// * `length` needs to be less than or equal to `capacity`. - /// * `capacity` needs to be the correct value. - /// * The first `length` bytes at `buf` need to be valid UTF-8. + /// * all safety requirements for [`Vec::::from_raw_parts`]. + /// * all safety requirements for [`String::from_utf8_unchecked`]. /// /// Violating these may cause problems like corrupting the allocator's /// internal data structures. For example, it is normally **not** safe to @@ -1419,7 +1416,9 @@ impl String { pub fn push(&mut self, ch: char) { match ch.len_utf8() { 1 => self.vec.push(ch as u8), - _ => self.vec.extend_from_slice(ch.encode_utf8(&mut [0; 4]).as_bytes()), + _ => { + self.vec.extend_from_slice(ch.encode_utf8(&mut [0; char::MAX_LEN_UTF8]).as_bytes()) + } } } @@ -1716,7 +1715,7 @@ impl String { #[rustc_confusables("set")] pub fn insert(&mut self, idx: usize, ch: char) { assert!(self.is_char_boundary(idx)); - let mut bits = [0; 4]; + let mut bits = [0; char::MAX_LEN_UTF8]; let bits = ch.encode_utf8(&mut bits).as_bytes(); unsafe { @@ -2442,6 +2441,32 @@ impl<'a> Extend> for String { } } +#[cfg(not(no_global_oom_handling))] +#[unstable(feature = "ascii_char", issue = "110998")] +impl Extend for String { + fn extend>(&mut self, iter: I) { + self.vec.extend(iter.into_iter().map(|c| c.to_u8())); + } + + #[inline] + fn extend_one(&mut self, c: core::ascii::Char) { + self.vec.push(c.to_u8()); + } +} + +#[cfg(not(no_global_oom_handling))] +#[unstable(feature = "ascii_char", issue = "110998")] +impl<'a> Extend<&'a core::ascii::Char> for String { + fn extend>(&mut self, iter: I) { + self.extend(iter.into_iter().cloned()); + } + + #[inline] + fn extend_one(&mut self, c: &'a core::ascii::Char) { + self.vec.push(c.to_u8()); + } +} + /// A convenience impl that delegates to the impl for `&str`. /// /// # Examples @@ -2771,7 +2796,7 @@ impl SpecToString for core::ascii::Char { impl SpecToString for char { #[inline] fn spec_to_string(&self) -> String { - String::from(self.encode_utf8(&mut [0; 4])) + String::from(self.encode_utf8(&mut [0; char::MAX_LEN_UTF8])) } } @@ -3129,6 +3154,24 @@ impl From for Vec { } } +#[stable(feature = "try_from_vec_u8_for_string", since = "CURRENT_RUSTC_VERSION")] +impl TryFrom> for String { + type Error = FromUtf8Error; + /// Converts the given [`Vec`] into a [`String`] if it contains valid UTF-8 data. + /// + /// # Examples + /// + /// ``` + /// let s1 = b"hello world".to_vec(); + /// let v1 = String::try_from(s1).unwrap(); + /// assert_eq!(v1, "hello world"); + /// + /// ``` + fn try_from(bytes: Vec) -> Result { + Self::from_utf8(bytes) + } +} + #[cfg(not(no_global_oom_handling))] #[stable(feature = "rust1", since = "1.0.0")] impl fmt::Write for String { diff --git a/alloc/src/vec/drain.rs b/alloc/src/vec/drain.rs index 9362cef2a1b00..8705a9c3d2679 100644 --- a/alloc/src/vec/drain.rs +++ b/alloc/src/vec/drain.rs @@ -232,7 +232,7 @@ impl Drop for Drain<'_, T, A> { // it from the original vec but also avoid creating a &mut to the front since that could // invalidate raw pointers to it which some unsafe code might rely on. let vec_ptr = vec.as_mut().as_mut_ptr(); - let drop_offset = drop_ptr.sub_ptr(vec_ptr); + let drop_offset = drop_ptr.offset_from_unsigned(vec_ptr); let to_drop = ptr::slice_from_raw_parts_mut(vec_ptr.add(drop_offset), drop_len); ptr::drop_in_place(to_drop); } diff --git a/alloc/src/vec/extract_if.rs b/alloc/src/vec/extract_if.rs index 4db13981596bc..be869553ef4e1 100644 --- a/alloc/src/vec/extract_if.rs +++ b/alloc/src/vec/extract_if.rs @@ -12,12 +12,10 @@ use crate::alloc::{Allocator, Global}; /// # Example /// /// ``` -/// #![feature(extract_if)] -/// /// let mut v = vec![0, 1, 2]; /// let iter: std::vec::ExtractIf<'_, _, _> = v.extract_if(.., |x| *x % 2 == 0); /// ``` -#[unstable(feature = "extract_if", reason = "recently added", issue = "43244")] +#[stable(feature = "extract_if", since = "CURRENT_RUSTC_VERSION")] #[derive(Debug)] #[must_use = "iterators are lazy and do nothing unless consumed"] pub struct ExtractIf< @@ -59,7 +57,7 @@ impl<'a, T, F, A: Allocator> ExtractIf<'a, T, F, A> { } } -#[unstable(feature = "extract_if", reason = "recently added", issue = "43244")] +#[stable(feature = "extract_if", since = "CURRENT_RUSTC_VERSION")] impl Iterator for ExtractIf<'_, T, F, A> where F: FnMut(&mut T) -> bool, @@ -95,7 +93,7 @@ where } } -#[unstable(feature = "extract_if", reason = "recently added", issue = "43244")] +#[stable(feature = "extract_if", since = "CURRENT_RUSTC_VERSION")] impl Drop for ExtractIf<'_, T, F, A> { fn drop(&mut self) { unsafe { diff --git a/alloc/src/vec/in_place_collect.rs b/alloc/src/vec/in_place_collect.rs index a7dba16944e7d..dffd85f13aa50 100644 --- a/alloc/src/vec/in_place_collect.rs +++ b/alloc/src/vec/in_place_collect.rs @@ -379,7 +379,7 @@ where let sink = self.try_fold::<_, _, Result<_, !>>(sink, write_in_place_with_drop(end)).into_ok(); // iteration succeeded, don't drop head - unsafe { ManuallyDrop::new(sink).dst.sub_ptr(dst_buf) } + unsafe { ManuallyDrop::new(sink).dst.offset_from_unsigned(dst_buf) } } } diff --git a/alloc/src/vec/in_place_drop.rs b/alloc/src/vec/in_place_drop.rs index 4d5b4e47d39e4..997c4c7525b5a 100644 --- a/alloc/src/vec/in_place_drop.rs +++ b/alloc/src/vec/in_place_drop.rs @@ -14,7 +14,7 @@ pub(super) struct InPlaceDrop { impl InPlaceDrop { fn len(&self) -> usize { - unsafe { self.dst.sub_ptr(self.inner) } + unsafe { self.dst.offset_from_unsigned(self.inner) } } } diff --git a/alloc/src/vec/into_iter.rs b/alloc/src/vec/into_iter.rs index 9a6745fdbc0a3..52597e41c1cf8 100644 --- a/alloc/src/vec/into_iter.rs +++ b/alloc/src/vec/into_iter.rs @@ -179,7 +179,7 @@ impl IntoIter { // say that they're all at the beginning of the "allocation". 0..this.len() } else { - this.ptr.sub_ptr(this.buf)..this.end.sub_ptr(buf) + this.ptr.offset_from_unsigned(this.buf)..this.end.offset_from_unsigned(buf) }; let cap = this.cap; let alloc = ManuallyDrop::take(&mut this.alloc); @@ -230,7 +230,7 @@ impl Iterator for IntoIter { let exact = if T::IS_ZST { self.end.addr().wrapping_sub(self.ptr.as_ptr().addr()) } else { - unsafe { non_null!(self.end, T).sub_ptr(self.ptr) } + unsafe { non_null!(self.end, T).offset_from_unsigned(self.ptr) } }; (exact, Some(exact)) } diff --git a/alloc/src/vec/mod.rs b/alloc/src/vec/mod.rs index 48afcf6e0645b..701144cc3af22 100644 --- a/alloc/src/vec/mod.rs +++ b/alloc/src/vec/mod.rs @@ -66,7 +66,7 @@ use core::ptr::{self, NonNull}; use core::slice::{self, SliceIndex}; use core::{fmt, intrinsics}; -#[unstable(feature = "extract_if", reason = "recently added", issue = "43244")] +#[stable(feature = "extract_if", since = "CURRENT_RUSTC_VERSION")] pub use self::extract_if::ExtractIf; use crate::alloc::{Allocator, Global}; use crate::borrow::{Cow, ToOwned}; @@ -355,11 +355,20 @@ mod spec_extend; /// and it may prove desirable to use a non-constant growth factor. Whatever /// strategy is used will of course guarantee *O*(1) amortized [`push`]. /// -/// `vec![x; n]`, `vec![a, b, c, d]`, and -/// [`Vec::with_capacity(n)`][`Vec::with_capacity`], will all produce a `Vec` -/// with at least the requested capacity. If [len] == [capacity], -/// (as is the case for the [`vec!`] macro), then a `Vec` can be converted to -/// and from a [`Box<[T]>`][owned slice] without reallocating or moving the elements. +/// It is guaranteed, in order to respect the intentions of the programmer, that +/// all of `vec![e_1, e_2, ..., e_n]`, `vec![x; n]`, and [`Vec::with_capacity(n)`] produce a `Vec` +/// that requests an allocation of the exact size needed for precisely `n` elements from the allocator, +/// and no other size (such as, for example: a size rounded up to the nearest power of 2). +/// The allocator will return an allocation that is at least as large as requested, but it may be larger. +/// +/// It is guaranteed that the [`Vec::capacity`] method returns a value that is at least the requested capacity +/// and not more than the allocated capacity. +/// +/// The method [`Vec::shrink_to_fit`] will attempt to discard excess capacity an allocator has given to a `Vec`. +/// If [len] == [capacity], then a `Vec` can be converted +/// to and from a [`Box<[T]>`][owned slice] without reallocating or moving the elements. +/// `Vec` exploits this fact as much as reasonable when implementing common conversions +/// such as [`into_boxed_slice`]. /// /// `Vec` will not specifically overwrite any data that is removed from it, /// but also won't specifically preserve it. Its uninitialized memory is @@ -383,14 +392,17 @@ mod spec_extend; /// [`shrink_to`]: Vec::shrink_to /// [capacity]: Vec::capacity /// [`capacity`]: Vec::capacity +/// [`Vec::capacity`]: Vec::capacity /// [mem::size_of::\]: core::mem::size_of /// [len]: Vec::len /// [`len`]: Vec::len /// [`push`]: Vec::push /// [`insert`]: Vec::insert /// [`reserve`]: Vec::reserve +/// [`Vec::with_capacity(n)`]: Vec::with_capacity /// [`MaybeUninit`]: core::mem::MaybeUninit /// [owned slice]: Box +/// [`into_boxed_slice`]: Vec::into_boxed_slice #[stable(feature = "rust1", since = "1.0.0")] #[cfg_attr(not(test), rustc_diagnostic_item = "Vec")] #[rustc_insignificant_dtor] @@ -1837,7 +1849,7 @@ impl Vec { /// # // don't use this as a starting point for a real library. /// # pub struct StreamWrapper { strm: *mut std::ffi::c_void } /// # const Z_OK: i32 = 0; - /// # extern "C" { + /// # unsafe extern "C" { /// # fn deflateGetDictionary( /// # strm: *mut std::ffi::c_void, /// # dictionary: *mut u8, @@ -2519,8 +2531,6 @@ impl Vec { /// # Examples /// /// ``` - /// #![feature(vec_pop_if)] - /// /// let mut vec = vec![1, 2, 3, 4]; /// let pred = |x: &mut i32| *x % 2 == 0; /// @@ -2528,7 +2538,7 @@ impl Vec { /// assert_eq!(vec, [1, 2, 3]); /// assert_eq!(vec.pop_if(pred), None); /// ``` - #[unstable(feature = "vec_pop_if", issue = "122741")] + #[stable(feature = "vec_pop_if", since = "1.86.0")] pub fn pop_if(&mut self, predicate: impl FnOnce(&mut T) -> bool) -> Option { let last = self.last_mut()?; if predicate(last) { self.pop() } else { None } @@ -3686,7 +3696,6 @@ impl Vec { /// Splitting an array into evens and odds, reusing the original allocation: /// /// ``` - /// #![feature(extract_if)] /// let mut numbers = vec![1, 2, 3, 4, 5, 6, 8, 9, 11, 13, 14, 15]; /// /// let evens = numbers.extract_if(.., |x| *x % 2 == 0).collect::>(); @@ -3699,13 +3708,12 @@ impl Vec { /// Using the range argument to only process a part of the vector: /// /// ``` - /// #![feature(extract_if)] /// let mut items = vec![0, 0, 0, 0, 0, 0, 0, 1, 2, 1, 2, 1, 2]; /// let ones = items.extract_if(7.., |x| *x == 1).collect::>(); /// assert_eq!(items, vec![0, 0, 0, 0, 0, 0, 0, 2, 2, 2]); /// assert_eq!(ones.len(), 3); /// ``` - #[unstable(feature = "extract_if", reason = "recently added", issue = "43244")] + #[stable(feature = "extract_if", since = "CURRENT_RUSTC_VERSION")] pub fn extract_if(&mut self, range: R, filter: F) -> ExtractIf<'_, T, F, A> where F: FnMut(&mut T) -> bool, diff --git a/alloc/tests/lib.rs b/alloc/tests/lib.rs index 391ff04a4b8e4..785070fb2bbcb 100644 --- a/alloc/tests/lib.rs +++ b/alloc/tests/lib.rs @@ -3,10 +3,10 @@ #![feature(iter_array_chunks)] #![feature(assert_matches)] #![feature(btree_extract_if)] +#![feature(char_max_len)] #![feature(cow_is_borrowed)] #![feature(core_intrinsics)] #![feature(downcast_unchecked)] -#![feature(extract_if)] #![feature(exact_size_is_empty)] #![feature(hashmap_internals)] #![feature(linked_list_cursors)] @@ -28,7 +28,6 @@ #![feature(string_remove_matches)] #![feature(const_btree_len)] #![feature(const_trait_impl)] -#![feature(const_str_from_utf8)] #![feature(panic_update_hook)] #![feature(pointer_is_aligned_to)] #![feature(test)] @@ -37,7 +36,6 @@ #![feature(local_waker)] #![feature(str_as_str)] #![feature(strict_provenance_lints)] -#![feature(vec_pop_if)] #![feature(vec_deque_pop_if)] #![feature(unique_rc_arc)] #![feature(macro_metavar_expr_concat)] diff --git a/alloc/tests/sort/patterns.rs b/alloc/tests/sort/patterns.rs index e5d31d868b251..0f1ec664d3d4f 100644 --- a/alloc/tests/sort/patterns.rs +++ b/alloc/tests/sort/patterns.rs @@ -1,8 +1,8 @@ use std::env; -use std::hash::Hash; use std::str::FromStr; use std::sync::OnceLock; +use rand::distr::Uniform; use rand::prelude::*; use rand_xorshift::XorShiftRng; @@ -23,14 +23,14 @@ pub fn random(len: usize) -> Vec { pub fn random_uniform(len: usize, range: R) -> Vec where - R: Into> + Hash, + Uniform: TryFrom, { // :.:.:.:: let mut rng: XorShiftRng = rand::SeedableRng::seed_from_u64(get_or_init_rand_seed()); // Abstracting over ranges in Rust :( - let dist: rand::distributions::Uniform = range.into(); + let dist = Uniform::try_from(range).unwrap(); (0..len).map(|_| dist.sample(&mut rng)).collect() } @@ -207,5 +207,5 @@ fn rand_root_seed() -> u64 { fn random_vec(len: usize) -> Vec { let mut rng: XorShiftRng = rand::SeedableRng::seed_from_u64(get_or_init_rand_seed()); - (0..len).map(|_| rng.gen::()).collect() + (0..len).map(|_| rng.random::()).collect() } diff --git a/alloc/tests/sort/zipf.rs b/alloc/tests/sort/zipf.rs index cc774ee5c43bf..3dad2db521f4b 100644 --- a/alloc/tests/sort/zipf.rs +++ b/alloc/tests/sort/zipf.rs @@ -80,7 +80,7 @@ impl ZipfDistribution { loop { use std::cmp; - let u: f64 = hnum + rng.gen::() * (self.h_integral_x1 - hnum); + let u: f64 = hnum + rng.random::() * (self.h_integral_x1 - hnum); // u is uniformly distributed in (h_integral_x1, h_integral_num_elements] let x: f64 = ZipfDistribution::h_integral_inv(u, self.exponent); @@ -145,7 +145,7 @@ impl ZipfDistribution { } } -impl rand::distributions::Distribution for ZipfDistribution { +impl rand::distr::Distribution for ZipfDistribution { fn sample(&self, rng: &mut R) -> usize { self.next(rng) } diff --git a/alloc/tests/str.rs b/alloc/tests/str.rs index 23a0e5e525643..906fa2d425e77 100644 --- a/alloc/tests/str.rs +++ b/alloc/tests/str.rs @@ -2,6 +2,7 @@ use std::assert_matches::assert_matches; use std::borrow::Cow; +use std::char::MAX_LEN_UTF8; use std::cmp::Ordering::{Equal, Greater, Less}; use std::str::{from_utf8, from_utf8_unchecked}; @@ -1231,7 +1232,7 @@ fn test_to_uppercase_rev_iterator() { #[test] #[cfg_attr(miri, ignore)] // Miri is too slow fn test_chars_decoding() { - let mut bytes = [0; 4]; + let mut bytes = [0; MAX_LEN_UTF8]; for c in (0..0x110000).filter_map(std::char::from_u32) { let s = c.encode_utf8(&mut bytes); if Some(c) != s.chars().next() { @@ -1243,7 +1244,7 @@ fn test_chars_decoding() { #[test] #[cfg_attr(miri, ignore)] // Miri is too slow fn test_chars_rev_decoding() { - let mut bytes = [0; 4]; + let mut bytes = [0; MAX_LEN_UTF8]; for c in (0..0x110000).filter_map(std::char::from_u32) { let s = c.encode_utf8(&mut bytes); if Some(c) != s.chars().rev().next() { diff --git a/backtrace b/backtrace index f8cc6ac9acc4e..9d2c34e7e63af 160000 --- a/backtrace +++ b/backtrace @@ -1 +1 @@ -Subproject commit f8cc6ac9acc4e663ecd96f9bcf1ff4542636d1b9 +Subproject commit 9d2c34e7e63afe1e71c333b247065e3b7ba4d883 diff --git a/core/Cargo.toml b/core/Cargo.toml index b7c6db6c78dde..1538ecc6b9297 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -23,6 +23,8 @@ optimize_for_size = [] # Make `RefCell` store additional debugging information, which is printed out when # a borrow error occurs debug_refcell = [] +# Make `TypeId` store a reference to the name of the type, so that it can print that name. +debug_typeid = [] [lints.rust.unexpected_cfgs] level = "warn" @@ -30,7 +32,6 @@ check-cfg = [ 'cfg(bootstrap)', 'cfg(no_fp_fmt_parse)', 'cfg(stdarch_intel_sde)', - 'cfg(target_arch, values("xtensa"))', # core use #[path] imports to portable-simd `core_simd` crate # and to stdarch `core_arch` crate which messes-up with Cargo list # of declared features, we therefor expect any feature cfg diff --git a/core/src/alloc/global.rs b/core/src/alloc/global.rs index 8f48af24557d8..5bf6f143b4f82 100644 --- a/core/src/alloc/global.rs +++ b/core/src/alloc/global.rs @@ -70,7 +70,7 @@ use crate::{cmp, ptr}; /// { /// return null_mut(); /// }; -/// self.arena.get().cast::().add(allocated) +/// unsafe { self.arena.get().cast::().add(allocated) } /// } /// unsafe fn dealloc(&self, _ptr: *mut u8, _layout: Layout) {} /// } diff --git a/core/src/alloc/mod.rs b/core/src/alloc/mod.rs index dcab6136ae8a1..9805cee1c331e 100644 --- a/core/src/alloc/mod.rs +++ b/core/src/alloc/mod.rs @@ -94,7 +94,7 @@ impl fmt::Display for AllocError { /// - the memory block is deallocated, or /// - the allocator is dropped. /// -/// Copying, cloning, or moving the allocator must not invalidate memory blocks returned from it +/// Copying, cloning, or moving the allocator must not invalidate memory blocks returned from it. /// A copied or cloned allocator must behave like the original allocator. /// /// A memory block which is [*currently allocated*] may be passed to diff --git a/core/src/any.rs b/core/src/any.rs index 17d9455592787..9ed2c8e9f3ad1 100644 --- a/core/src/any.rs +++ b/core/src/any.rs @@ -610,12 +610,109 @@ impl dyn Any + Send + Sync { /// While `TypeId` implements `Hash`, `PartialOrd`, and `Ord`, it is worth /// noting that the hashes and ordering will vary between Rust releases. Beware /// of relying on them inside of your code! +/// +/// # Danger of Improper Variance +/// +/// You might think that subtyping is impossible between two static types, +/// but this is false; there exists a static type with a static subtype. +/// To wit, `fn(&str)`, which is short for `for<'any> fn(&'any str)`, and +/// `fn(&'static str)`, are two distinct, static types, and yet, +/// `fn(&str)` is a subtype of `fn(&'static str)`, since any value of type +/// `fn(&str)` can be used where a value of type `fn(&'static str)` is needed. +/// +/// This means that abstractions around `TypeId`, despite its +/// `'static` bound on arguments, still need to worry about unnecessary +/// and improper variance: it is advisable to strive for invariance +/// first. The usability impact will be negligible, while the reduction +/// in the risk of unsoundness will be most welcome. +/// +/// ## Examples +/// +/// Suppose `SubType` is a subtype of `SuperType`, that is, +/// a value of type `SubType` can be used wherever +/// a value of type `SuperType` is expected. +/// Suppose also that `CoVar` is a generic type, which is covariant over `T` +/// (like many other types, including `PhantomData` and `Vec`). +/// +/// Then, by covariance, `CoVar` is a subtype of `CoVar`, +/// that is, a value of type `CoVar` can be used wherever +/// a value of type `CoVar` is expected. +/// +/// Then if `CoVar` relies on `TypeId::of::()` to uphold any invariants, +/// those invariants may be broken because a value of type `CoVar` can be created +/// without going through any of its methods, like so: +/// ``` +/// type SubType = fn(&()); +/// type SuperType = fn(&'static ()); +/// type CoVar = Vec; // imagine something more complicated +/// +/// let sub: CoVar = CoVar::new(); +/// // we have a `CoVar` instance without +/// // *ever* having called `CoVar::::new()`! +/// let fake_super: CoVar = sub; +/// ``` +/// +/// The following is an example program that tries to use `TypeId::of` to +/// implement a generic type `Unique` that guarantees unique instances for each `Unique`, +/// that is, and for each type `T` there can be at most one value of type `Unique` at any time. +/// +/// ``` +/// mod unique { +/// use std::any::TypeId; +/// use std::collections::BTreeSet; +/// use std::marker::PhantomData; +/// use std::sync::Mutex; +/// +/// static ID_SET: Mutex> = Mutex::new(BTreeSet::new()); +/// +/// // TypeId has only covariant uses, which makes Unique covariant over TypeAsId 🚨 +/// #[derive(Debug, PartialEq)] +/// pub struct Unique( +/// // private field prevents creation without `new` outside this module +/// PhantomData, +/// ); +/// +/// impl Unique { +/// pub fn new() -> Option { +/// let mut set = ID_SET.lock().unwrap(); +/// (set.insert(TypeId::of::())).then(|| Self(PhantomData)) +/// } +/// } +/// +/// impl Drop for Unique { +/// fn drop(&mut self) { +/// let mut set = ID_SET.lock().unwrap(); +/// (!set.remove(&TypeId::of::())).then(|| panic!("duplicity detected")); +/// } +/// } +/// } +/// +/// use unique::Unique; +/// +/// // `OtherRing` is a subtype of `TheOneRing`. Both are 'static, and thus have a TypeId. +/// type TheOneRing = fn(&'static ()); +/// type OtherRing = fn(&()); +/// +/// fn main() { +/// let the_one_ring: Unique = Unique::new().unwrap(); +/// assert_eq!(Unique::::new(), None); +/// +/// let other_ring: Unique = Unique::new().unwrap(); +/// // Use that `Unique` is a subtype of `Unique` 🚨 +/// let fake_one_ring: Unique = other_ring; +/// assert_eq!(fake_one_ring, the_one_ring); +/// +/// std::mem::forget(fake_one_ring); +/// } +/// ``` #[derive(Clone, Copy, Eq, PartialOrd, Ord)] #[stable(feature = "rust1", since = "1.0.0")] pub struct TypeId { // We avoid using `u128` because that imposes higher alignment requirements on many platforms. // See issue #115620 for more information. t: (u64, u64), + #[cfg(feature = "debug_typeid")] + name: &'static str, } #[stable(feature = "rust1", since = "1.0.0")] @@ -627,8 +724,7 @@ impl PartialEq for TypeId { } impl TypeId { - /// Returns the `TypeId` of the type this generic function has been - /// instantiated with. + /// Returns the `TypeId` of the generic type parameter. /// /// # Examples /// @@ -647,10 +743,14 @@ impl TypeId { #[rustc_const_unstable(feature = "const_type_id", issue = "77125")] pub const fn of() -> TypeId { let t: u128 = intrinsics::type_id::(); - let t1 = (t >> 64) as u64; let t2 = t as u64; - TypeId { t: (t1, t2) } + + TypeId { + t: (t1, t2), + #[cfg(feature = "debug_typeid")] + name: type_name::(), + } } fn as_u128(self) -> u128 { @@ -681,7 +781,15 @@ impl hash::Hash for TypeId { #[stable(feature = "rust1", since = "1.0.0")] impl fmt::Debug for TypeId { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> { - write!(f, "TypeId({:#034x})", self.as_u128()) + #[cfg(feature = "debug_typeid")] + { + write!(f, "TypeId({:#034x} = {})", self.as_u128(), self.name)?; + } + #[cfg(not(feature = "debug_typeid"))] + { + write!(f, "TypeId({:#034x})", self.as_u128())?; + } + Ok(()) } } diff --git a/core/src/char/methods.rs b/core/src/char/methods.rs index ccfdbf0eb704d..85cc315626d4b 100644 --- a/core/src/char/methods.rs +++ b/core/src/char/methods.rs @@ -71,6 +71,16 @@ impl char { #[stable(feature = "assoc_char_consts", since = "1.52.0")] pub const MAX: char = '\u{10FFFF}'; + /// The maximum number of bytes required to [encode](char::encode_utf8) a `char` to + /// UTF-8 encoding. + #[unstable(feature = "char_max_len", issue = "121714")] + pub const MAX_LEN_UTF8: usize = 4; + + /// The maximum number of two-byte units required to [encode](char::encode_utf16) a `char` + /// to UTF-16 encoding. + #[unstable(feature = "char_max_len", issue = "121714")] + pub const MAX_LEN_UTF16: usize = 2; + /// `U+FFFD REPLACEMENT CHARACTER` (�) is used in Unicode to represent a /// decoding error. /// @@ -1168,6 +1178,7 @@ impl char { #[must_use] #[stable(feature = "ascii_methods_on_intrinsics", since = "1.23.0")] #[rustc_const_stable(feature = "const_char_is_ascii", since = "1.32.0")] + #[cfg_attr(not(test), rustc_diagnostic_item = "char_is_ascii")] #[inline] pub const fn is_ascii(&self) -> bool { *self as u32 <= 0x7F diff --git a/core/src/char/mod.rs b/core/src/char/mod.rs index 59fd7250e8f8e..088c709f1a2af 100644 --- a/core/src/char/mod.rs +++ b/core/src/char/mod.rs @@ -95,6 +95,16 @@ const MAX_THREE_B: u32 = 0x10000; #[stable(feature = "rust1", since = "1.0.0")] pub const MAX: char = char::MAX; +/// The maximum number of bytes required to [encode](char::encode_utf8) a `char` to +/// UTF-8 encoding. +#[unstable(feature = "char_max_len", issue = "121714")] +pub const MAX_LEN_UTF8: usize = char::MAX_LEN_UTF8; + +/// The maximum number of two-byte units required to [encode](char::encode_utf16) a `char` +/// to UTF-16 encoding. +#[unstable(feature = "char_max_len", issue = "121714")] +pub const MAX_LEN_UTF16: usize = char::MAX_LEN_UTF16; + /// `U+FFFD REPLACEMENT CHARACTER` (�) is used in Unicode to represent a /// decoding error. Use [`char::REPLACEMENT_CHARACTER`] instead. #[stable(feature = "decode_utf16", since = "1.9.0")] diff --git a/core/src/cmp.rs b/core/src/cmp.rs index 594236cf1d96f..c8ced78c4d791 100644 --- a/core/src/cmp.rs +++ b/core/src/cmp.rs @@ -1369,7 +1369,7 @@ pub trait PartialOrd: PartialEq { #[stable(feature = "rust1", since = "1.0.0")] #[rustc_diagnostic_item = "cmp_partialord_lt"] fn lt(&self, other: &Rhs) -> bool { - matches!(self.partial_cmp(other), Some(Less)) + self.partial_cmp(other).is_some_and(Ordering::is_lt) } /// Tests less than or equal to (for `self` and `other`) and is used by the @@ -1387,7 +1387,7 @@ pub trait PartialOrd: PartialEq { #[stable(feature = "rust1", since = "1.0.0")] #[rustc_diagnostic_item = "cmp_partialord_le"] fn le(&self, other: &Rhs) -> bool { - matches!(self.partial_cmp(other), Some(Less | Equal)) + self.partial_cmp(other).is_some_and(Ordering::is_le) } /// Tests greater than (for `self` and `other`) and is used by the `>` @@ -1405,7 +1405,7 @@ pub trait PartialOrd: PartialEq { #[stable(feature = "rust1", since = "1.0.0")] #[rustc_diagnostic_item = "cmp_partialord_gt"] fn gt(&self, other: &Rhs) -> bool { - matches!(self.partial_cmp(other), Some(Greater)) + self.partial_cmp(other).is_some_and(Ordering::is_gt) } /// Tests greater than or equal to (for `self` and `other`) and is used by @@ -1423,7 +1423,7 @@ pub trait PartialOrd: PartialEq { #[stable(feature = "rust1", since = "1.0.0")] #[rustc_diagnostic_item = "cmp_partialord_ge"] fn ge(&self, other: &Rhs) -> bool { - matches!(self.partial_cmp(other), Some(Greater | Equal)) + self.partial_cmp(other).is_some_and(Ordering::is_ge) } } diff --git a/core/src/contracts.rs b/core/src/contracts.rs index c769e219e4d49..8b79a3a7eba86 100644 --- a/core/src/contracts.rs +++ b/core/src/contracts.rs @@ -1,5 +1,4 @@ //! Unstable module containing the unstable contracts lang items and attribute macros. -#![cfg(not(bootstrap))] pub use crate::macros::builtin::{contracts_ensures as ensures, contracts_requires as requires}; diff --git a/core/src/error.rs b/core/src/error.rs index 9dbea57fa1f86..94847685ec965 100644 --- a/core/src/error.rs +++ b/core/src/error.rs @@ -22,6 +22,30 @@ use crate::fmt::{self, Debug, Display, Formatter}; /// accessing that error via [`Error::source()`]. This makes it possible for the /// high-level module to provide its own errors while also revealing some of the /// implementation for debugging. +/// +/// # Example +/// +/// Implementing the `Error` trait only requires that `Debug` and `Display` are implemented too. +/// +/// ``` +/// use std::error::Error; +/// use std::fmt; +/// use std::path::PathBuf; +/// +/// #[derive(Debug)] +/// struct ReadConfigError { +/// path: PathBuf +/// } +/// +/// impl fmt::Display for ReadConfigError { +/// fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { +/// let path = self.path.display(); +/// write!(f, "unable to read configuration at {path}") +/// } +/// } +/// +/// impl Error for ReadConfigError {} +/// ``` #[stable(feature = "rust1", since = "1.0.0")] #[cfg_attr(not(test), rustc_diagnostic_item = "Error")] #[rustc_has_incoherent_inherent_impls] @@ -1075,5 +1099,5 @@ impl Error for crate::time::TryFromFloatSecsError {} #[stable(feature = "cstr_from_bytes_until_nul", since = "1.69.0")] impl Error for crate::ffi::FromBytesUntilNulError {} -#[unstable(feature = "get_many_mut", issue = "104642")] -impl Error for crate::slice::GetManyMutError {} +#[stable(feature = "get_many_mut", since = "1.86.0")] +impl Error for crate::slice::GetDisjointMutError {} diff --git a/core/src/ffi/c_str.rs b/core/src/ffi/c_str.rs index 7180593edf0d0..080c0cef53304 100644 --- a/core/src/ffi/c_str.rs +++ b/core/src/ffi/c_str.rs @@ -55,18 +55,15 @@ use crate::{fmt, ops, slice, str}; /// Passing a Rust-originating C string: /// /// ``` -/// use std::ffi::{CString, CStr}; +/// use std::ffi::CStr; /// use std::os::raw::c_char; /// /// fn work(data: &CStr) { -/// # /* Extern functions are awkward in doc comments - fake it instead -/// extern "C" { fn work_with(data: *const c_char); } -/// # */ unsafe extern "C" fn work_with(s: *const c_char) {} -/// +/// unsafe extern "C" fn work_with(s: *const c_char) {} /// unsafe { work_with(data.as_ptr()) } /// } /// -/// let s = CString::new("data data data data").expect("CString::new failed"); +/// let s = c"Hello world!"; /// work(&s); /// ``` /// @@ -384,13 +381,12 @@ impl CStr { /// # Examples /// /// ``` - /// use std::ffi::{CStr, CString}; + /// use std::ffi::CStr; /// - /// unsafe { - /// let cstring = CString::new("hello").expect("CString::new failed"); - /// let cstr = CStr::from_bytes_with_nul_unchecked(cstring.to_bytes_with_nul()); - /// assert_eq!(cstr, &*cstring); - /// } + /// let bytes = b"Hello world!\0"; + /// + /// let cstr = unsafe { CStr::from_bytes_with_nul_unchecked(bytes) }; + /// assert_eq!(cstr.to_bytes_with_nul(), bytes); /// ``` #[inline] #[must_use] @@ -449,38 +445,43 @@ impl CStr { /// behavior when `ptr` is used inside the `unsafe` block: /// /// ```no_run - /// # #![allow(unused_must_use)] /// # #![expect(dangling_pointers_from_temporaries)] - /// use std::ffi::CString; + /// use std::ffi::{CStr, CString}; /// - /// // Do not do this: - /// let ptr = CString::new("Hello").expect("CString::new failed").as_ptr(); - /// unsafe { - /// // `ptr` is dangling - /// *ptr; - /// } + /// // 💀 The meaning of this entire program is undefined, + /// // 💀 and nothing about its behavior is guaranteed, + /// // 💀 not even that its behavior resembles the code as written, + /// // 💀 just because it contains a single instance of undefined behavior! + /// + /// // 🚨 creates a dangling pointer to a temporary `CString` + /// // 🚨 that is deallocated at the end of the statement + /// let ptr = CString::new("Hi!".to_uppercase()).unwrap().as_ptr(); + /// + /// // without undefined behavior, you would expect that `ptr` equals: + /// dbg!(CStr::from_bytes_with_nul(b"HI!\0").unwrap()); + /// + /// // 🙏 Possibly the program behaved as expected so far, + /// // 🙏 and this just shows `ptr` is now garbage..., but + /// // 💀 this violates `CStr::from_ptr`'s safety contract + /// // 💀 leading to a dereference of a dangling pointer, + /// // 💀 which is immediate undefined behavior. + /// // 💀 *BOOM*, you're dead, you're entire program has no meaning. + /// dbg!(unsafe { CStr::from_ptr(ptr) }); /// ``` /// - /// This happens because the pointer returned by `as_ptr` does not carry any - /// lifetime information and the `CString` is deallocated immediately after - /// the `CString::new("Hello").expect("CString::new failed").as_ptr()` - /// expression is evaluated. + /// This happens because, the pointer returned by `as_ptr` does not carry any + /// lifetime information, and the `CString` is deallocated immediately after + /// the expression that it is part of has been evaluated. /// To fix the problem, bind the `CString` to a local variable: /// - /// ```no_run - /// # #![allow(unused_must_use)] - /// use std::ffi::CString; - /// - /// let hello = CString::new("Hello").expect("CString::new failed"); - /// let ptr = hello.as_ptr(); - /// unsafe { - /// // `ptr` is valid because `hello` is in scope - /// *ptr; - /// } /// ``` + /// use std::ffi::{CStr, CString}; /// - /// This way, the lifetime of the `CString` in `hello` encompasses - /// the lifetime of `ptr` and the `unsafe` block. + /// let c_str = CString::new("Hi!".to_uppercase()).unwrap(); + /// let ptr = c_str.as_ptr(); + /// + /// assert_eq!(unsafe { CStr::from_ptr(ptr) }, c"HI!"); + /// ``` #[inline] #[must_use] #[stable(feature = "rust1", since = "1.0.0")] @@ -731,7 +732,7 @@ const unsafe fn strlen(ptr: *const c_char) -> usize { len } else { - extern "C" { + unsafe extern "C" { /// Provided by libc or compiler_builtins. fn strlen(s: *const c_char) -> usize; } diff --git a/core/src/ffi/mod.rs b/core/src/ffi/mod.rs index 50968c57adc62..9bae5fd466a18 100644 --- a/core/src/ffi/mod.rs +++ b/core/src/ffi/mod.rs @@ -90,4 +90,4 @@ impl fmt::Debug for c_void { cfg(not(target_feature = "crt-static")) )] #[link(name = "/defaultlib:libcmt", modifiers = "+verbatim", cfg(target_feature = "crt-static"))] -extern "C" {} +unsafe extern "C" {} diff --git a/core/src/ffi/va_list.rs b/core/src/ffi/va_list.rs index cceb186b31e79..cefa0e3950cad 100644 --- a/core/src/ffi/va_list.rs +++ b/core/src/ffi/va_list.rs @@ -305,25 +305,16 @@ impl<'f> Drop for VaListImpl<'f> { /// Destroy the arglist `ap` after initialization with `va_start` or /// `va_copy`. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -unsafe fn va_end(_ap: &mut VaListImpl<'_>) { - unreachable!() -} +unsafe fn va_end(_ap: &mut VaListImpl<'_>); /// Copies the current location of arglist `src` to the arglist `dst`. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -unsafe fn va_copy<'f>(_dest: *mut VaListImpl<'f>, _src: &VaListImpl<'f>) { - unreachable!() -} +unsafe fn va_copy<'f>(_dest: *mut VaListImpl<'f>, _src: &VaListImpl<'f>); /// Loads an argument of type `T` from the `va_list` `ap` and increment the /// argument `ap` points to. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -unsafe fn va_arg(_ap: &mut VaListImpl<'_>) -> T { - unreachable!() -} +unsafe fn va_arg(_ap: &mut VaListImpl<'_>) -> T; diff --git a/core/src/fmt/mod.rs b/core/src/fmt/mod.rs index a1bf3a4d7a706..764e7fff33ec7 100644 --- a/core/src/fmt/mod.rs +++ b/core/src/fmt/mod.rs @@ -3,7 +3,7 @@ #![stable(feature = "rust1", since = "1.0.0")] use crate::cell::{Cell, Ref, RefCell, RefMut, SyncUnsafeCell, UnsafeCell}; -use crate::char::EscapeDebugExtArgs; +use crate::char::{EscapeDebugExtArgs, MAX_LEN_UTF8}; use crate::marker::PhantomData; use crate::num::fmt as numfmt; use crate::ops::Deref; @@ -187,7 +187,7 @@ pub trait Write { /// ``` #[stable(feature = "fmt_write_char", since = "1.1.0")] fn write_char(&mut self, c: char) -> Result { - self.write_str(c.encode_utf8(&mut [0; 4])) + self.write_str(c.encode_utf8(&mut [0; MAX_LEN_UTF8])) } /// Glue for usage of the [`write!`] macro with implementors of this trait. @@ -2768,7 +2768,7 @@ impl Display for char { if f.options.width.is_none() && f.options.precision.is_none() { f.write_char(*self) } else { - f.pad(self.encode_utf8(&mut [0; 4])) + f.pad(self.encode_utf8(&mut [0; MAX_LEN_UTF8])) } } } diff --git a/core/src/future/mod.rs b/core/src/future/mod.rs index e5a368796ec93..65c0171c88d5b 100644 --- a/core/src/future/mod.rs +++ b/core/src/future/mod.rs @@ -46,19 +46,19 @@ pub use self::join::join; /// It also simplifies the HIR lowering of `.await`. #[lang = "ResumeTy"] #[doc(hidden)] -#[unstable(feature = "gen_future", issue = "50547")] +#[unstable(feature = "gen_future", issue = "none")] #[derive(Debug, Copy, Clone)] pub struct ResumeTy(NonNull>); -#[unstable(feature = "gen_future", issue = "50547")] +#[unstable(feature = "gen_future", issue = "none")] unsafe impl Send for ResumeTy {} -#[unstable(feature = "gen_future", issue = "50547")] +#[unstable(feature = "gen_future", issue = "none")] unsafe impl Sync for ResumeTy {} #[lang = "get_context"] #[doc(hidden)] -#[unstable(feature = "gen_future", issue = "50547")] +#[unstable(feature = "gen_future", issue = "none")] #[must_use] #[inline] pub unsafe fn get_context<'a, 'b>(cx: ResumeTy) -> &'a mut Context<'b> { diff --git a/core/src/hint.rs b/core/src/hint.rs index e5c1a64c12ee5..5ce282b05de73 100644 --- a/core/src/hint.rs +++ b/core/src/hint.rs @@ -52,7 +52,7 @@ use crate::{intrinsics, ub_checks}; /// // Safety: `divisor` can't be zero because of `prepare_inputs`, /// // but the compiler does not know about this. We *promise* /// // that we always call `prepare_inputs`. -/// std::hint::unreachable_unchecked() +/// unsafe { std::hint::unreachable_unchecked() } /// } /// // The compiler would normally introduce a check here that prevents /// // a division by zero. However, if `divisor` was zero, the branch @@ -472,7 +472,7 @@ pub fn spin_loop() { /// During constant evaluation, `black_box` is treated as a no-op. #[inline] #[stable(feature = "bench_black_box", since = "1.66.0")] -#[rustc_const_stable(feature = "const_black_box", since = "CURRENT_RUSTC_VERSION")] +#[rustc_const_stable(feature = "const_black_box", since = "1.86.0")] pub const fn black_box(dummy: T) -> T { crate::intrinsics::black_box(dummy) } @@ -646,7 +646,7 @@ pub const fn must_use(value: T) -> T { /// ``` /// /// -#[unstable(feature = "likely_unlikely", issue = "26179")] +#[unstable(feature = "likely_unlikely", issue = "136873")] #[inline(always)] pub const fn likely(b: bool) -> bool { crate::intrinsics::likely(b) @@ -696,7 +696,7 @@ pub const fn likely(b: bool) -> bool { /// } /// } /// ``` -#[unstable(feature = "likely_unlikely", issue = "26179")] +#[unstable(feature = "likely_unlikely", issue = "136873")] #[inline(always)] pub const fn unlikely(b: bool) -> bool { crate::intrinsics::unlikely(b) @@ -729,7 +729,7 @@ pub const fn unlikely(b: bool) -> bool { /// } /// } /// ``` -#[unstable(feature = "cold_path", issue = "26179")] +#[unstable(feature = "cold_path", issue = "136873")] #[inline(always)] pub const fn cold_path() { crate::intrinsics::cold_path() diff --git a/core/src/intrinsics/mod.rs b/core/src/intrinsics/mod.rs index 3b249c835f237..38a60338e74ed 100644 --- a/core/src/intrinsics/mod.rs +++ b/core/src/intrinsics/mod.rs @@ -78,11 +78,7 @@ pub mod simd; use crate::sync::atomic::{self, AtomicBool, AtomicI32, AtomicIsize, AtomicU32, Ordering}; #[stable(feature = "drop_in_place", since = "1.8.0")] -#[cfg_attr(bootstrap, rustc_allowed_through_unstable_modules)] -#[cfg_attr( - not(bootstrap), - rustc_allowed_through_unstable_modules = "import this function via `std::ptr` instead" -)] +#[rustc_allowed_through_unstable_modules = "import this function via `std::ptr` instead"] #[deprecated(note = "no longer an intrinsic - use `ptr::drop_in_place` directly", since = "1.52.0")] #[inline] pub unsafe fn drop_in_place(to_drop: *mut T) { @@ -100,11 +96,8 @@ pub unsafe fn drop_in_place(to_drop: *mut T) { /// [`Ordering::Relaxed`] as both the success and failure parameters. /// For example, [`AtomicBool::compare_exchange`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_cxchg_relaxed_relaxed(_dst: *mut T, _old: T, _src: T) -> (T, bool) { - unreachable!() -} +pub unsafe fn atomic_cxchg_relaxed_relaxed(_dst: *mut T, _old: T, _src: T) -> (T, bool); /// Stores a value if the current value is the same as the `old` value. /// /// The stabilized version of this intrinsic is available on the @@ -112,11 +105,8 @@ pub unsafe fn atomic_cxchg_relaxed_relaxed(_dst: *mut T, _old: T, _src: /// [`Ordering::Relaxed`] and [`Ordering::Acquire`] as the success and failure parameters. /// For example, [`AtomicBool::compare_exchange`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_cxchg_relaxed_acquire(_dst: *mut T, _old: T, _src: T) -> (T, bool) { - unreachable!() -} +pub unsafe fn atomic_cxchg_relaxed_acquire(_dst: *mut T, _old: T, _src: T) -> (T, bool); /// Stores a value if the current value is the same as the `old` value. /// /// The stabilized version of this intrinsic is available on the @@ -124,11 +114,8 @@ pub unsafe fn atomic_cxchg_relaxed_acquire(_dst: *mut T, _old: T, _src: /// [`Ordering::Relaxed`] and [`Ordering::SeqCst`] as the success and failure parameters. /// For example, [`AtomicBool::compare_exchange`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_cxchg_relaxed_seqcst(_dst: *mut T, _old: T, _src: T) -> (T, bool) { - unreachable!() -} +pub unsafe fn atomic_cxchg_relaxed_seqcst(_dst: *mut T, _old: T, _src: T) -> (T, bool); /// Stores a value if the current value is the same as the `old` value. /// /// The stabilized version of this intrinsic is available on the @@ -136,11 +123,8 @@ pub unsafe fn atomic_cxchg_relaxed_seqcst(_dst: *mut T, _old: T, _src: /// [`Ordering::Acquire`] and [`Ordering::Relaxed`] as the success and failure parameters. /// For example, [`AtomicBool::compare_exchange`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_cxchg_acquire_relaxed(_dst: *mut T, _old: T, _src: T) -> (T, bool) { - unreachable!() -} +pub unsafe fn atomic_cxchg_acquire_relaxed(_dst: *mut T, _old: T, _src: T) -> (T, bool); /// Stores a value if the current value is the same as the `old` value. /// /// The stabilized version of this intrinsic is available on the @@ -148,11 +132,8 @@ pub unsafe fn atomic_cxchg_acquire_relaxed(_dst: *mut T, _old: T, _src: /// [`Ordering::Acquire`] as both the success and failure parameters. /// For example, [`AtomicBool::compare_exchange`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_cxchg_acquire_acquire(_dst: *mut T, _old: T, _src: T) -> (T, bool) { - unreachable!() -} +pub unsafe fn atomic_cxchg_acquire_acquire(_dst: *mut T, _old: T, _src: T) -> (T, bool); /// Stores a value if the current value is the same as the `old` value. /// /// The stabilized version of this intrinsic is available on the @@ -160,11 +141,8 @@ pub unsafe fn atomic_cxchg_acquire_acquire(_dst: *mut T, _old: T, _src: /// [`Ordering::Acquire`] and [`Ordering::SeqCst`] as the success and failure parameters. /// For example, [`AtomicBool::compare_exchange`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_cxchg_acquire_seqcst(_dst: *mut T, _old: T, _src: T) -> (T, bool) { - unreachable!() -} +pub unsafe fn atomic_cxchg_acquire_seqcst(_dst: *mut T, _old: T, _src: T) -> (T, bool); /// Stores a value if the current value is the same as the `old` value. /// /// The stabilized version of this intrinsic is available on the @@ -172,11 +150,8 @@ pub unsafe fn atomic_cxchg_acquire_seqcst(_dst: *mut T, _old: T, _src: /// [`Ordering::Release`] and [`Ordering::Relaxed`] as the success and failure parameters. /// For example, [`AtomicBool::compare_exchange`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_cxchg_release_relaxed(_dst: *mut T, _old: T, _src: T) -> (T, bool) { - unreachable!() -} +pub unsafe fn atomic_cxchg_release_relaxed(_dst: *mut T, _old: T, _src: T) -> (T, bool); /// Stores a value if the current value is the same as the `old` value. /// /// The stabilized version of this intrinsic is available on the @@ -184,11 +159,8 @@ pub unsafe fn atomic_cxchg_release_relaxed(_dst: *mut T, _old: T, _src: /// [`Ordering::Release`] and [`Ordering::Acquire`] as the success and failure parameters. /// For example, [`AtomicBool::compare_exchange`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_cxchg_release_acquire(_dst: *mut T, _old: T, _src: T) -> (T, bool) { - unreachable!() -} +pub unsafe fn atomic_cxchg_release_acquire(_dst: *mut T, _old: T, _src: T) -> (T, bool); /// Stores a value if the current value is the same as the `old` value. /// /// The stabilized version of this intrinsic is available on the @@ -196,11 +168,8 @@ pub unsafe fn atomic_cxchg_release_acquire(_dst: *mut T, _old: T, _src: /// [`Ordering::Release`] and [`Ordering::SeqCst`] as the success and failure parameters. /// For example, [`AtomicBool::compare_exchange`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_cxchg_release_seqcst(_dst: *mut T, _old: T, _src: T) -> (T, bool) { - unreachable!() -} +pub unsafe fn atomic_cxchg_release_seqcst(_dst: *mut T, _old: T, _src: T) -> (T, bool); /// Stores a value if the current value is the same as the `old` value. /// /// The stabilized version of this intrinsic is available on the @@ -208,11 +177,8 @@ pub unsafe fn atomic_cxchg_release_seqcst(_dst: *mut T, _old: T, _src: /// [`Ordering::AcqRel`] and [`Ordering::Relaxed`] as the success and failure parameters. /// For example, [`AtomicBool::compare_exchange`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_cxchg_acqrel_relaxed(_dst: *mut T, _old: T, _src: T) -> (T, bool) { - unreachable!() -} +pub unsafe fn atomic_cxchg_acqrel_relaxed(_dst: *mut T, _old: T, _src: T) -> (T, bool); /// Stores a value if the current value is the same as the `old` value. /// /// The stabilized version of this intrinsic is available on the @@ -220,11 +186,8 @@ pub unsafe fn atomic_cxchg_acqrel_relaxed(_dst: *mut T, _old: T, _src: /// [`Ordering::AcqRel`] and [`Ordering::Acquire`] as the success and failure parameters. /// For example, [`AtomicBool::compare_exchange`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_cxchg_acqrel_acquire(_dst: *mut T, _old: T, _src: T) -> (T, bool) { - unreachable!() -} +pub unsafe fn atomic_cxchg_acqrel_acquire(_dst: *mut T, _old: T, _src: T) -> (T, bool); /// Stores a value if the current value is the same as the `old` value. /// /// The stabilized version of this intrinsic is available on the @@ -232,11 +195,8 @@ pub unsafe fn atomic_cxchg_acqrel_acquire(_dst: *mut T, _old: T, _src: /// [`Ordering::AcqRel`] and [`Ordering::SeqCst`] as the success and failure parameters. /// For example, [`AtomicBool::compare_exchange`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_cxchg_acqrel_seqcst(_dst: *mut T, _old: T, _src: T) -> (T, bool) { - unreachable!() -} +pub unsafe fn atomic_cxchg_acqrel_seqcst(_dst: *mut T, _old: T, _src: T) -> (T, bool); /// Stores a value if the current value is the same as the `old` value. /// /// The stabilized version of this intrinsic is available on the @@ -244,11 +204,8 @@ pub unsafe fn atomic_cxchg_acqrel_seqcst(_dst: *mut T, _old: T, _src: T /// [`Ordering::SeqCst`] and [`Ordering::Relaxed`] as the success and failure parameters. /// For example, [`AtomicBool::compare_exchange`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_cxchg_seqcst_relaxed(_dst: *mut T, _old: T, _src: T) -> (T, bool) { - unreachable!() -} +pub unsafe fn atomic_cxchg_seqcst_relaxed(_dst: *mut T, _old: T, _src: T) -> (T, bool); /// Stores a value if the current value is the same as the `old` value. /// /// The stabilized version of this intrinsic is available on the @@ -256,11 +213,8 @@ pub unsafe fn atomic_cxchg_seqcst_relaxed(_dst: *mut T, _old: T, _src: /// [`Ordering::SeqCst`] and [`Ordering::Acquire`] as the success and failure parameters. /// For example, [`AtomicBool::compare_exchange`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_cxchg_seqcst_acquire(_dst: *mut T, _old: T, _src: T) -> (T, bool) { - unreachable!() -} +pub unsafe fn atomic_cxchg_seqcst_acquire(_dst: *mut T, _old: T, _src: T) -> (T, bool); /// Stores a value if the current value is the same as the `old` value. /// /// The stabilized version of this intrinsic is available on the @@ -268,11 +222,8 @@ pub unsafe fn atomic_cxchg_seqcst_acquire(_dst: *mut T, _old: T, _src: /// [`Ordering::SeqCst`] as both the success and failure parameters. /// For example, [`AtomicBool::compare_exchange`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_cxchg_seqcst_seqcst(_dst: *mut T, _old: T, _src: T) -> (T, bool) { - unreachable!() -} +pub unsafe fn atomic_cxchg_seqcst_seqcst(_dst: *mut T, _old: T, _src: T) -> (T, bool); /// Stores a value if the current value is the same as the `old` value. /// @@ -281,15 +232,12 @@ pub unsafe fn atomic_cxchg_seqcst_seqcst(_dst: *mut T, _old: T, _src: T /// [`Ordering::Relaxed`] as both the success and failure parameters. /// For example, [`AtomicBool::compare_exchange_weak`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] pub unsafe fn atomic_cxchgweak_relaxed_relaxed( _dst: *mut T, _old: T, _src: T, -) -> (T, bool) { - unreachable!() -} +) -> (T, bool); /// Stores a value if the current value is the same as the `old` value. /// /// The stabilized version of this intrinsic is available on the @@ -297,15 +245,12 @@ pub unsafe fn atomic_cxchgweak_relaxed_relaxed( /// [`Ordering::Relaxed`] and [`Ordering::Acquire`] as the success and failure parameters. /// For example, [`AtomicBool::compare_exchange_weak`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] pub unsafe fn atomic_cxchgweak_relaxed_acquire( _dst: *mut T, _old: T, _src: T, -) -> (T, bool) { - unreachable!() -} +) -> (T, bool); /// Stores a value if the current value is the same as the `old` value. /// /// The stabilized version of this intrinsic is available on the @@ -313,15 +258,9 @@ pub unsafe fn atomic_cxchgweak_relaxed_acquire( /// [`Ordering::Relaxed`] and [`Ordering::SeqCst`] as the success and failure parameters. /// For example, [`AtomicBool::compare_exchange_weak`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_cxchgweak_relaxed_seqcst( - _dst: *mut T, - _old: T, - _src: T, -) -> (T, bool) { - unreachable!() -} +pub unsafe fn atomic_cxchgweak_relaxed_seqcst(_dst: *mut T, _old: T, _src: T) +-> (T, bool); /// Stores a value if the current value is the same as the `old` value. /// /// The stabilized version of this intrinsic is available on the @@ -329,15 +268,12 @@ pub unsafe fn atomic_cxchgweak_relaxed_seqcst( /// [`Ordering::Acquire`] and [`Ordering::Relaxed`] as the success and failure parameters. /// For example, [`AtomicBool::compare_exchange_weak`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] pub unsafe fn atomic_cxchgweak_acquire_relaxed( _dst: *mut T, _old: T, _src: T, -) -> (T, bool) { - unreachable!() -} +) -> (T, bool); /// Stores a value if the current value is the same as the `old` value. /// /// The stabilized version of this intrinsic is available on the @@ -345,15 +281,12 @@ pub unsafe fn atomic_cxchgweak_acquire_relaxed( /// [`Ordering::Acquire`] as both the success and failure parameters. /// For example, [`AtomicBool::compare_exchange_weak`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] pub unsafe fn atomic_cxchgweak_acquire_acquire( _dst: *mut T, _old: T, _src: T, -) -> (T, bool) { - unreachable!() -} +) -> (T, bool); /// Stores a value if the current value is the same as the `old` value. /// /// The stabilized version of this intrinsic is available on the @@ -361,15 +294,9 @@ pub unsafe fn atomic_cxchgweak_acquire_acquire( /// [`Ordering::Acquire`] and [`Ordering::SeqCst`] as the success and failure parameters. /// For example, [`AtomicBool::compare_exchange_weak`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_cxchgweak_acquire_seqcst( - _dst: *mut T, - _old: T, - _src: T, -) -> (T, bool) { - unreachable!() -} +pub unsafe fn atomic_cxchgweak_acquire_seqcst(_dst: *mut T, _old: T, _src: T) +-> (T, bool); /// Stores a value if the current value is the same as the `old` value. /// /// The stabilized version of this intrinsic is available on the @@ -377,15 +304,12 @@ pub unsafe fn atomic_cxchgweak_acquire_seqcst( /// [`Ordering::Release`] and [`Ordering::Relaxed`] as the success and failure parameters. /// For example, [`AtomicBool::compare_exchange_weak`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] pub unsafe fn atomic_cxchgweak_release_relaxed( _dst: *mut T, _old: T, _src: T, -) -> (T, bool) { - unreachable!() -} +) -> (T, bool); /// Stores a value if the current value is the same as the `old` value. /// /// The stabilized version of this intrinsic is available on the @@ -393,15 +317,12 @@ pub unsafe fn atomic_cxchgweak_release_relaxed( /// [`Ordering::Release`] and [`Ordering::Acquire`] as the success and failure parameters. /// For example, [`AtomicBool::compare_exchange_weak`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] pub unsafe fn atomic_cxchgweak_release_acquire( _dst: *mut T, _old: T, _src: T, -) -> (T, bool) { - unreachable!() -} +) -> (T, bool); /// Stores a value if the current value is the same as the `old` value. /// /// The stabilized version of this intrinsic is available on the @@ -409,15 +330,9 @@ pub unsafe fn atomic_cxchgweak_release_acquire( /// [`Ordering::Release`] and [`Ordering::SeqCst`] as the success and failure parameters. /// For example, [`AtomicBool::compare_exchange_weak`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_cxchgweak_release_seqcst( - _dst: *mut T, - _old: T, - _src: T, -) -> (T, bool) { - unreachable!() -} +pub unsafe fn atomic_cxchgweak_release_seqcst(_dst: *mut T, _old: T, _src: T) +-> (T, bool); /// Stores a value if the current value is the same as the `old` value. /// /// The stabilized version of this intrinsic is available on the @@ -425,15 +340,9 @@ pub unsafe fn atomic_cxchgweak_release_seqcst( /// [`Ordering::AcqRel`] and [`Ordering::Relaxed`] as the success and failure parameters. /// For example, [`AtomicBool::compare_exchange_weak`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_cxchgweak_acqrel_relaxed( - _dst: *mut T, - _old: T, - _src: T, -) -> (T, bool) { - unreachable!() -} +pub unsafe fn atomic_cxchgweak_acqrel_relaxed(_dst: *mut T, _old: T, _src: T) +-> (T, bool); /// Stores a value if the current value is the same as the `old` value. /// /// The stabilized version of this intrinsic is available on the @@ -441,15 +350,9 @@ pub unsafe fn atomic_cxchgweak_acqrel_relaxed( /// [`Ordering::AcqRel`] and [`Ordering::Acquire`] as the success and failure parameters. /// For example, [`AtomicBool::compare_exchange_weak`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_cxchgweak_acqrel_acquire( - _dst: *mut T, - _old: T, - _src: T, -) -> (T, bool) { - unreachable!() -} +pub unsafe fn atomic_cxchgweak_acqrel_acquire(_dst: *mut T, _old: T, _src: T) +-> (T, bool); /// Stores a value if the current value is the same as the `old` value. /// /// The stabilized version of this intrinsic is available on the @@ -457,11 +360,8 @@ pub unsafe fn atomic_cxchgweak_acqrel_acquire( /// [`Ordering::AcqRel`] and [`Ordering::SeqCst`] as the success and failure parameters. /// For example, [`AtomicBool::compare_exchange_weak`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_cxchgweak_acqrel_seqcst(_dst: *mut T, _old: T, _src: T) -> (T, bool) { - unreachable!() -} +pub unsafe fn atomic_cxchgweak_acqrel_seqcst(_dst: *mut T, _old: T, _src: T) -> (T, bool); /// Stores a value if the current value is the same as the `old` value. /// /// The stabilized version of this intrinsic is available on the @@ -469,15 +369,9 @@ pub unsafe fn atomic_cxchgweak_acqrel_seqcst(_dst: *mut T, _old: T, _sr /// [`Ordering::SeqCst`] and [`Ordering::Relaxed`] as the success and failure parameters. /// For example, [`AtomicBool::compare_exchange_weak`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_cxchgweak_seqcst_relaxed( - _dst: *mut T, - _old: T, - _src: T, -) -> (T, bool) { - unreachable!() -} +pub unsafe fn atomic_cxchgweak_seqcst_relaxed(_dst: *mut T, _old: T, _src: T) +-> (T, bool); /// Stores a value if the current value is the same as the `old` value. /// /// The stabilized version of this intrinsic is available on the @@ -485,15 +379,9 @@ pub unsafe fn atomic_cxchgweak_seqcst_relaxed( /// [`Ordering::SeqCst`] and [`Ordering::Acquire`] as the success and failure parameters. /// For example, [`AtomicBool::compare_exchange_weak`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_cxchgweak_seqcst_acquire( - _dst: *mut T, - _old: T, - _src: T, -) -> (T, bool) { - unreachable!() -} +pub unsafe fn atomic_cxchgweak_seqcst_acquire(_dst: *mut T, _old: T, _src: T) +-> (T, bool); /// Stores a value if the current value is the same as the `old` value. /// /// The stabilized version of this intrinsic is available on the @@ -501,11 +389,8 @@ pub unsafe fn atomic_cxchgweak_seqcst_acquire( /// [`Ordering::SeqCst`] as both the success and failure parameters. /// For example, [`AtomicBool::compare_exchange_weak`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_cxchgweak_seqcst_seqcst(_dst: *mut T, _old: T, _src: T) -> (T, bool) { - unreachable!() -} +pub unsafe fn atomic_cxchgweak_seqcst_seqcst(_dst: *mut T, _old: T, _src: T) -> (T, bool); /// Loads the current value of the pointer. /// @@ -513,42 +398,30 @@ pub unsafe fn atomic_cxchgweak_seqcst_seqcst(_dst: *mut T, _old: T, _sr /// [`atomic`] types via the `load` method by passing /// [`Ordering::SeqCst`] as the `order`. For example, [`AtomicBool::load`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_load_seqcst(_src: *const T) -> T { - unreachable!() -} +pub unsafe fn atomic_load_seqcst(_src: *const T) -> T; /// Loads the current value of the pointer. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] types via the `load` method by passing /// [`Ordering::Acquire`] as the `order`. For example, [`AtomicBool::load`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_load_acquire(_src: *const T) -> T { - unreachable!() -} +pub unsafe fn atomic_load_acquire(_src: *const T) -> T; /// Loads the current value of the pointer. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] types via the `load` method by passing /// [`Ordering::Relaxed`] as the `order`. For example, [`AtomicBool::load`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_load_relaxed(_src: *const T) -> T { - unreachable!() -} +pub unsafe fn atomic_load_relaxed(_src: *const T) -> T; /// Do NOT use this intrinsic; "unordered" operations do not exist in our memory model! /// In terms of the Rust Abstract Machine, this operation is equivalent to `src.read()`, /// i.e., it performs a non-atomic read. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_load_unordered(_src: *const T) -> T { - unreachable!() -} +pub unsafe fn atomic_load_unordered(_src: *const T) -> T; /// Stores the value at the specified memory location. /// @@ -556,42 +429,30 @@ pub unsafe fn atomic_load_unordered(_src: *const T) -> T { /// [`atomic`] types via the `store` method by passing /// [`Ordering::SeqCst`] as the `order`. For example, [`AtomicBool::store`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_store_seqcst(_dst: *mut T, _val: T) { - unreachable!() -} +pub unsafe fn atomic_store_seqcst(_dst: *mut T, _val: T); /// Stores the value at the specified memory location. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] types via the `store` method by passing /// [`Ordering::Release`] as the `order`. For example, [`AtomicBool::store`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_store_release(_dst: *mut T, _val: T) { - unreachable!() -} +pub unsafe fn atomic_store_release(_dst: *mut T, _val: T); /// Stores the value at the specified memory location. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] types via the `store` method by passing /// [`Ordering::Relaxed`] as the `order`. For example, [`AtomicBool::store`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_store_relaxed(_dst: *mut T, _val: T) { - unreachable!() -} +pub unsafe fn atomic_store_relaxed(_dst: *mut T, _val: T); /// Do NOT use this intrinsic; "unordered" operations do not exist in our memory model! /// In terms of the Rust Abstract Machine, this operation is equivalent to `dst.write(val)`, /// i.e., it performs a non-atomic write. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_store_unordered(_dst: *mut T, _val: T) { - unreachable!() -} +pub unsafe fn atomic_store_unordered(_dst: *mut T, _val: T); /// Stores the value at the specified memory location, returning the old value. /// @@ -599,55 +460,40 @@ pub unsafe fn atomic_store_unordered(_dst: *mut T, _val: T) { /// [`atomic`] types via the `swap` method by passing /// [`Ordering::SeqCst`] as the `order`. For example, [`AtomicBool::swap`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_xchg_seqcst(_dst: *mut T, _src: T) -> T { - unreachable!() -} +pub unsafe fn atomic_xchg_seqcst(_dst: *mut T, _src: T) -> T; /// Stores the value at the specified memory location, returning the old value. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] types via the `swap` method by passing /// [`Ordering::Acquire`] as the `order`. For example, [`AtomicBool::swap`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_xchg_acquire(_dst: *mut T, _src: T) -> T { - unreachable!() -} +pub unsafe fn atomic_xchg_acquire(_dst: *mut T, _src: T) -> T; /// Stores the value at the specified memory location, returning the old value. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] types via the `swap` method by passing /// [`Ordering::Release`] as the `order`. For example, [`AtomicBool::swap`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_xchg_release(_dst: *mut T, _src: T) -> T { - unreachable!() -} +pub unsafe fn atomic_xchg_release(_dst: *mut T, _src: T) -> T; /// Stores the value at the specified memory location, returning the old value. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] types via the `swap` method by passing /// [`Ordering::AcqRel`] as the `order`. For example, [`AtomicBool::swap`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_xchg_acqrel(_dst: *mut T, _src: T) -> T { - unreachable!() -} +pub unsafe fn atomic_xchg_acqrel(_dst: *mut T, _src: T) -> T; /// Stores the value at the specified memory location, returning the old value. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] types via the `swap` method by passing /// [`Ordering::Relaxed`] as the `order`. For example, [`AtomicBool::swap`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_xchg_relaxed(_dst: *mut T, _src: T) -> T { - unreachable!() -} +pub unsafe fn atomic_xchg_relaxed(_dst: *mut T, _src: T) -> T; /// Adds to the current value, returning the previous value. /// @@ -655,55 +501,40 @@ pub unsafe fn atomic_xchg_relaxed(_dst: *mut T, _src: T) -> T { /// [`atomic`] types via the `fetch_add` method by passing /// [`Ordering::SeqCst`] as the `order`. For example, [`AtomicIsize::fetch_add`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_xadd_seqcst(_dst: *mut T, _src: T) -> T { - unreachable!() -} +pub unsafe fn atomic_xadd_seqcst(_dst: *mut T, _src: T) -> T; /// Adds to the current value, returning the previous value. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] types via the `fetch_add` method by passing /// [`Ordering::Acquire`] as the `order`. For example, [`AtomicIsize::fetch_add`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_xadd_acquire(_dst: *mut T, _src: T) -> T { - unreachable!() -} +pub unsafe fn atomic_xadd_acquire(_dst: *mut T, _src: T) -> T; /// Adds to the current value, returning the previous value. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] types via the `fetch_add` method by passing /// [`Ordering::Release`] as the `order`. For example, [`AtomicIsize::fetch_add`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_xadd_release(_dst: *mut T, _src: T) -> T { - unreachable!() -} +pub unsafe fn atomic_xadd_release(_dst: *mut T, _src: T) -> T; /// Adds to the current value, returning the previous value. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] types via the `fetch_add` method by passing /// [`Ordering::AcqRel`] as the `order`. For example, [`AtomicIsize::fetch_add`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_xadd_acqrel(_dst: *mut T, _src: T) -> T { - unreachable!() -} +pub unsafe fn atomic_xadd_acqrel(_dst: *mut T, _src: T) -> T; /// Adds to the current value, returning the previous value. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] types via the `fetch_add` method by passing /// [`Ordering::Relaxed`] as the `order`. For example, [`AtomicIsize::fetch_add`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_xadd_relaxed(_dst: *mut T, _src: T) -> T { - unreachable!() -} +pub unsafe fn atomic_xadd_relaxed(_dst: *mut T, _src: T) -> T; /// Subtract from the current value, returning the previous value. /// @@ -711,55 +542,40 @@ pub unsafe fn atomic_xadd_relaxed(_dst: *mut T, _src: T) -> T { /// [`atomic`] types via the `fetch_sub` method by passing /// [`Ordering::SeqCst`] as the `order`. For example, [`AtomicIsize::fetch_sub`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_xsub_seqcst(_dst: *mut T, _src: T) -> T { - unreachable!() -} +pub unsafe fn atomic_xsub_seqcst(_dst: *mut T, _src: T) -> T; /// Subtract from the current value, returning the previous value. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] types via the `fetch_sub` method by passing /// [`Ordering::Acquire`] as the `order`. For example, [`AtomicIsize::fetch_sub`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_xsub_acquire(_dst: *mut T, _src: T) -> T { - unreachable!() -} +pub unsafe fn atomic_xsub_acquire(_dst: *mut T, _src: T) -> T; /// Subtract from the current value, returning the previous value. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] types via the `fetch_sub` method by passing /// [`Ordering::Release`] as the `order`. For example, [`AtomicIsize::fetch_sub`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_xsub_release(_dst: *mut T, _src: T) -> T { - unreachable!() -} +pub unsafe fn atomic_xsub_release(_dst: *mut T, _src: T) -> T; /// Subtract from the current value, returning the previous value. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] types via the `fetch_sub` method by passing /// [`Ordering::AcqRel`] as the `order`. For example, [`AtomicIsize::fetch_sub`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_xsub_acqrel(_dst: *mut T, _src: T) -> T { - unreachable!() -} +pub unsafe fn atomic_xsub_acqrel(_dst: *mut T, _src: T) -> T; /// Subtract from the current value, returning the previous value. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] types via the `fetch_sub` method by passing /// [`Ordering::Relaxed`] as the `order`. For example, [`AtomicIsize::fetch_sub`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_xsub_relaxed(_dst: *mut T, _src: T) -> T { - unreachable!() -} +pub unsafe fn atomic_xsub_relaxed(_dst: *mut T, _src: T) -> T; /// Bitwise and with the current value, returning the previous value. /// @@ -767,55 +583,40 @@ pub unsafe fn atomic_xsub_relaxed(_dst: *mut T, _src: T) -> T { /// [`atomic`] types via the `fetch_and` method by passing /// [`Ordering::SeqCst`] as the `order`. For example, [`AtomicBool::fetch_and`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_and_seqcst(_dst: *mut T, _src: T) -> T { - unreachable!() -} +pub unsafe fn atomic_and_seqcst(_dst: *mut T, _src: T) -> T; /// Bitwise and with the current value, returning the previous value. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] types via the `fetch_and` method by passing /// [`Ordering::Acquire`] as the `order`. For example, [`AtomicBool::fetch_and`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_and_acquire(_dst: *mut T, _src: T) -> T { - unreachable!() -} +pub unsafe fn atomic_and_acquire(_dst: *mut T, _src: T) -> T; /// Bitwise and with the current value, returning the previous value. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] types via the `fetch_and` method by passing /// [`Ordering::Release`] as the `order`. For example, [`AtomicBool::fetch_and`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_and_release(_dst: *mut T, _src: T) -> T { - unreachable!() -} +pub unsafe fn atomic_and_release(_dst: *mut T, _src: T) -> T; /// Bitwise and with the current value, returning the previous value. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] types via the `fetch_and` method by passing /// [`Ordering::AcqRel`] as the `order`. For example, [`AtomicBool::fetch_and`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_and_acqrel(_dst: *mut T, _src: T) -> T { - unreachable!() -} +pub unsafe fn atomic_and_acqrel(_dst: *mut T, _src: T) -> T; /// Bitwise and with the current value, returning the previous value. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] types via the `fetch_and` method by passing /// [`Ordering::Relaxed`] as the `order`. For example, [`AtomicBool::fetch_and`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_and_relaxed(_dst: *mut T, _src: T) -> T { - unreachable!() -} +pub unsafe fn atomic_and_relaxed(_dst: *mut T, _src: T) -> T; /// Bitwise nand with the current value, returning the previous value. /// @@ -823,55 +624,40 @@ pub unsafe fn atomic_and_relaxed(_dst: *mut T, _src: T) -> T { /// [`AtomicBool`] type via the `fetch_nand` method by passing /// [`Ordering::SeqCst`] as the `order`. For example, [`AtomicBool::fetch_nand`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_nand_seqcst(_dst: *mut T, _src: T) -> T { - unreachable!() -} +pub unsafe fn atomic_nand_seqcst(_dst: *mut T, _src: T) -> T; /// Bitwise nand with the current value, returning the previous value. /// /// The stabilized version of this intrinsic is available on the /// [`AtomicBool`] type via the `fetch_nand` method by passing /// [`Ordering::Acquire`] as the `order`. For example, [`AtomicBool::fetch_nand`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_nand_acquire(_dst: *mut T, _src: T) -> T { - unreachable!() -} +pub unsafe fn atomic_nand_acquire(_dst: *mut T, _src: T) -> T; /// Bitwise nand with the current value, returning the previous value. /// /// The stabilized version of this intrinsic is available on the /// [`AtomicBool`] type via the `fetch_nand` method by passing /// [`Ordering::Release`] as the `order`. For example, [`AtomicBool::fetch_nand`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_nand_release(_dst: *mut T, _src: T) -> T { - unreachable!() -} +pub unsafe fn atomic_nand_release(_dst: *mut T, _src: T) -> T; /// Bitwise nand with the current value, returning the previous value. /// /// The stabilized version of this intrinsic is available on the /// [`AtomicBool`] type via the `fetch_nand` method by passing /// [`Ordering::AcqRel`] as the `order`. For example, [`AtomicBool::fetch_nand`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_nand_acqrel(_dst: *mut T, _src: T) -> T { - unreachable!() -} +pub unsafe fn atomic_nand_acqrel(_dst: *mut T, _src: T) -> T; /// Bitwise nand with the current value, returning the previous value. /// /// The stabilized version of this intrinsic is available on the /// [`AtomicBool`] type via the `fetch_nand` method by passing /// [`Ordering::Relaxed`] as the `order`. For example, [`AtomicBool::fetch_nand`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_nand_relaxed(_dst: *mut T, _src: T) -> T { - unreachable!() -} +pub unsafe fn atomic_nand_relaxed(_dst: *mut T, _src: T) -> T; /// Bitwise or with the current value, returning the previous value. /// @@ -879,55 +665,40 @@ pub unsafe fn atomic_nand_relaxed(_dst: *mut T, _src: T) -> T { /// [`atomic`] types via the `fetch_or` method by passing /// [`Ordering::SeqCst`] as the `order`. For example, [`AtomicBool::fetch_or`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_or_seqcst(_dst: *mut T, _src: T) -> T { - unreachable!() -} +pub unsafe fn atomic_or_seqcst(_dst: *mut T, _src: T) -> T; /// Bitwise or with the current value, returning the previous value. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] types via the `fetch_or` method by passing /// [`Ordering::Acquire`] as the `order`. For example, [`AtomicBool::fetch_or`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_or_acquire(_dst: *mut T, _src: T) -> T { - unreachable!() -} +pub unsafe fn atomic_or_acquire(_dst: *mut T, _src: T) -> T; /// Bitwise or with the current value, returning the previous value. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] types via the `fetch_or` method by passing /// [`Ordering::Release`] as the `order`. For example, [`AtomicBool::fetch_or`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_or_release(_dst: *mut T, _src: T) -> T { - unreachable!() -} +pub unsafe fn atomic_or_release(_dst: *mut T, _src: T) -> T; /// Bitwise or with the current value, returning the previous value. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] types via the `fetch_or` method by passing /// [`Ordering::AcqRel`] as the `order`. For example, [`AtomicBool::fetch_or`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_or_acqrel(_dst: *mut T, _src: T) -> T { - unreachable!() -} +pub unsafe fn atomic_or_acqrel(_dst: *mut T, _src: T) -> T; /// Bitwise or with the current value, returning the previous value. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] types via the `fetch_or` method by passing /// [`Ordering::Relaxed`] as the `order`. For example, [`AtomicBool::fetch_or`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_or_relaxed(_dst: *mut T, _src: T) -> T { - unreachable!() -} +pub unsafe fn atomic_or_relaxed(_dst: *mut T, _src: T) -> T; /// Bitwise xor with the current value, returning the previous value. /// @@ -935,55 +706,40 @@ pub unsafe fn atomic_or_relaxed(_dst: *mut T, _src: T) -> T { /// [`atomic`] types via the `fetch_xor` method by passing /// [`Ordering::SeqCst`] as the `order`. For example, [`AtomicBool::fetch_xor`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_xor_seqcst(_dst: *mut T, _src: T) -> T { - unreachable!() -} +pub unsafe fn atomic_xor_seqcst(_dst: *mut T, _src: T) -> T; /// Bitwise xor with the current value, returning the previous value. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] types via the `fetch_xor` method by passing /// [`Ordering::Acquire`] as the `order`. For example, [`AtomicBool::fetch_xor`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_xor_acquire(_dst: *mut T, _src: T) -> T { - unreachable!() -} +pub unsafe fn atomic_xor_acquire(_dst: *mut T, _src: T) -> T; /// Bitwise xor with the current value, returning the previous value. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] types via the `fetch_xor` method by passing /// [`Ordering::Release`] as the `order`. For example, [`AtomicBool::fetch_xor`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_xor_release(_dst: *mut T, _src: T) -> T { - unreachable!() -} +pub unsafe fn atomic_xor_release(_dst: *mut T, _src: T) -> T; /// Bitwise xor with the current value, returning the previous value. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] types via the `fetch_xor` method by passing /// [`Ordering::AcqRel`] as the `order`. For example, [`AtomicBool::fetch_xor`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_xor_acqrel(_dst: *mut T, _src: T) -> T { - unreachable!() -} +pub unsafe fn atomic_xor_acqrel(_dst: *mut T, _src: T) -> T; /// Bitwise xor with the current value, returning the previous value. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] types via the `fetch_xor` method by passing /// [`Ordering::Relaxed`] as the `order`. For example, [`AtomicBool::fetch_xor`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_xor_relaxed(_dst: *mut T, _src: T) -> T { - unreachable!() -} +pub unsafe fn atomic_xor_relaxed(_dst: *mut T, _src: T) -> T; /// Maximum with the current value using a signed comparison. /// @@ -991,55 +747,40 @@ pub unsafe fn atomic_xor_relaxed(_dst: *mut T, _src: T) -> T { /// [`atomic`] signed integer types via the `fetch_max` method by passing /// [`Ordering::SeqCst`] as the `order`. For example, [`AtomicI32::fetch_max`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_max_seqcst(_dst: *mut T, _src: T) -> T { - unreachable!() -} +pub unsafe fn atomic_max_seqcst(_dst: *mut T, _src: T) -> T; /// Maximum with the current value using a signed comparison. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] signed integer types via the `fetch_max` method by passing /// [`Ordering::Acquire`] as the `order`. For example, [`AtomicI32::fetch_max`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_max_acquire(_dst: *mut T, _src: T) -> T { - unreachable!() -} +pub unsafe fn atomic_max_acquire(_dst: *mut T, _src: T) -> T; /// Maximum with the current value using a signed comparison. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] signed integer types via the `fetch_max` method by passing /// [`Ordering::Release`] as the `order`. For example, [`AtomicI32::fetch_max`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_max_release(_dst: *mut T, _src: T) -> T { - unreachable!() -} +pub unsafe fn atomic_max_release(_dst: *mut T, _src: T) -> T; /// Maximum with the current value using a signed comparison. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] signed integer types via the `fetch_max` method by passing /// [`Ordering::AcqRel`] as the `order`. For example, [`AtomicI32::fetch_max`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_max_acqrel(_dst: *mut T, _src: T) -> T { - unreachable!() -} +pub unsafe fn atomic_max_acqrel(_dst: *mut T, _src: T) -> T; /// Maximum with the current value. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] signed integer types via the `fetch_max` method by passing /// [`Ordering::Relaxed`] as the `order`. For example, [`AtomicI32::fetch_max`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_max_relaxed(_dst: *mut T, _src: T) -> T { - unreachable!() -} +pub unsafe fn atomic_max_relaxed(_dst: *mut T, _src: T) -> T; /// Minimum with the current value using a signed comparison. /// @@ -1047,55 +788,40 @@ pub unsafe fn atomic_max_relaxed(_dst: *mut T, _src: T) -> T { /// [`atomic`] signed integer types via the `fetch_min` method by passing /// [`Ordering::SeqCst`] as the `order`. For example, [`AtomicI32::fetch_min`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_min_seqcst(_dst: *mut T, _src: T) -> T { - unreachable!() -} +pub unsafe fn atomic_min_seqcst(_dst: *mut T, _src: T) -> T; /// Minimum with the current value using a signed comparison. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] signed integer types via the `fetch_min` method by passing /// [`Ordering::Acquire`] as the `order`. For example, [`AtomicI32::fetch_min`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_min_acquire(_dst: *mut T, _src: T) -> T { - unreachable!() -} +pub unsafe fn atomic_min_acquire(_dst: *mut T, _src: T) -> T; /// Minimum with the current value using a signed comparison. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] signed integer types via the `fetch_min` method by passing /// [`Ordering::Release`] as the `order`. For example, [`AtomicI32::fetch_min`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_min_release(_dst: *mut T, _src: T) -> T { - unreachable!() -} +pub unsafe fn atomic_min_release(_dst: *mut T, _src: T) -> T; /// Minimum with the current value using a signed comparison. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] signed integer types via the `fetch_min` method by passing /// [`Ordering::AcqRel`] as the `order`. For example, [`AtomicI32::fetch_min`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_min_acqrel(_dst: *mut T, _src: T) -> T { - unreachable!() -} +pub unsafe fn atomic_min_acqrel(_dst: *mut T, _src: T) -> T; /// Minimum with the current value using a signed comparison. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] signed integer types via the `fetch_min` method by passing /// [`Ordering::Relaxed`] as the `order`. For example, [`AtomicI32::fetch_min`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_min_relaxed(_dst: *mut T, _src: T) -> T { - unreachable!() -} +pub unsafe fn atomic_min_relaxed(_dst: *mut T, _src: T) -> T; /// Minimum with the current value using an unsigned comparison. /// @@ -1103,55 +829,40 @@ pub unsafe fn atomic_min_relaxed(_dst: *mut T, _src: T) -> T { /// [`atomic`] unsigned integer types via the `fetch_min` method by passing /// [`Ordering::SeqCst`] as the `order`. For example, [`AtomicU32::fetch_min`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_umin_seqcst(_dst: *mut T, _src: T) -> T { - unreachable!() -} +pub unsafe fn atomic_umin_seqcst(_dst: *mut T, _src: T) -> T; /// Minimum with the current value using an unsigned comparison. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] unsigned integer types via the `fetch_min` method by passing /// [`Ordering::Acquire`] as the `order`. For example, [`AtomicU32::fetch_min`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_umin_acquire(_dst: *mut T, _src: T) -> T { - unreachable!() -} +pub unsafe fn atomic_umin_acquire(_dst: *mut T, _src: T) -> T; /// Minimum with the current value using an unsigned comparison. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] unsigned integer types via the `fetch_min` method by passing /// [`Ordering::Release`] as the `order`. For example, [`AtomicU32::fetch_min`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_umin_release(_dst: *mut T, _src: T) -> T { - unreachable!() -} +pub unsafe fn atomic_umin_release(_dst: *mut T, _src: T) -> T; /// Minimum with the current value using an unsigned comparison. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] unsigned integer types via the `fetch_min` method by passing /// [`Ordering::AcqRel`] as the `order`. For example, [`AtomicU32::fetch_min`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_umin_acqrel(_dst: *mut T, _src: T) -> T { - unreachable!() -} +pub unsafe fn atomic_umin_acqrel(_dst: *mut T, _src: T) -> T; /// Minimum with the current value using an unsigned comparison. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] unsigned integer types via the `fetch_min` method by passing /// [`Ordering::Relaxed`] as the `order`. For example, [`AtomicU32::fetch_min`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_umin_relaxed(_dst: *mut T, _src: T) -> T { - unreachable!() -} +pub unsafe fn atomic_umin_relaxed(_dst: *mut T, _src: T) -> T; /// Maximum with the current value using an unsigned comparison. /// @@ -1159,55 +870,40 @@ pub unsafe fn atomic_umin_relaxed(_dst: *mut T, _src: T) -> T { /// [`atomic`] unsigned integer types via the `fetch_max` method by passing /// [`Ordering::SeqCst`] as the `order`. For example, [`AtomicU32::fetch_max`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_umax_seqcst(_dst: *mut T, _src: T) -> T { - unreachable!() -} +pub unsafe fn atomic_umax_seqcst(_dst: *mut T, _src: T) -> T; /// Maximum with the current value using an unsigned comparison. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] unsigned integer types via the `fetch_max` method by passing /// [`Ordering::Acquire`] as the `order`. For example, [`AtomicU32::fetch_max`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_umax_acquire(_dst: *mut T, _src: T) -> T { - unreachable!() -} +pub unsafe fn atomic_umax_acquire(_dst: *mut T, _src: T) -> T; /// Maximum with the current value using an unsigned comparison. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] unsigned integer types via the `fetch_max` method by passing /// [`Ordering::Release`] as the `order`. For example, [`AtomicU32::fetch_max`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_umax_release(_dst: *mut T, _src: T) -> T { - unreachable!() -} +pub unsafe fn atomic_umax_release(_dst: *mut T, _src: T) -> T; /// Maximum with the current value using an unsigned comparison. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] unsigned integer types via the `fetch_max` method by passing /// [`Ordering::AcqRel`] as the `order`. For example, [`AtomicU32::fetch_max`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_umax_acqrel(_dst: *mut T, _src: T) -> T { - unreachable!() -} +pub unsafe fn atomic_umax_acqrel(_dst: *mut T, _src: T) -> T; /// Maximum with the current value using an unsigned comparison. /// /// The stabilized version of this intrinsic is available on the /// [`atomic`] unsigned integer types via the `fetch_max` method by passing /// [`Ordering::Relaxed`] as the `order`. For example, [`AtomicU32::fetch_max`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_umax_relaxed(_dst: *mut T, _src: T) -> T { - unreachable!() -} +pub unsafe fn atomic_umax_relaxed(_dst: *mut T, _src: T) -> T; /// An atomic fence. /// @@ -1215,44 +911,32 @@ pub unsafe fn atomic_umax_relaxed(_dst: *mut T, _src: T) -> T { /// [`atomic::fence`] by passing [`Ordering::SeqCst`] /// as the `order`. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_fence_seqcst() { - unreachable!() -} +pub unsafe fn atomic_fence_seqcst(); /// An atomic fence. /// /// The stabilized version of this intrinsic is available in /// [`atomic::fence`] by passing [`Ordering::Acquire`] /// as the `order`. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_fence_acquire() { - unreachable!() -} +pub unsafe fn atomic_fence_acquire(); /// An atomic fence. /// /// The stabilized version of this intrinsic is available in /// [`atomic::fence`] by passing [`Ordering::Release`] /// as the `order`. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_fence_release() { - unreachable!() -} +pub unsafe fn atomic_fence_release(); /// An atomic fence. /// /// The stabilized version of this intrinsic is available in /// [`atomic::fence`] by passing [`Ordering::AcqRel`] /// as the `order`. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_fence_acqrel() { - unreachable!() -} +pub unsafe fn atomic_fence_acqrel(); /// A compiler-only memory barrier. /// @@ -1265,11 +949,8 @@ pub unsafe fn atomic_fence_acqrel() { /// [`atomic::compiler_fence`] by passing [`Ordering::SeqCst`] /// as the `order`. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_singlethreadfence_seqcst() { - unreachable!() -} +pub unsafe fn atomic_singlethreadfence_seqcst(); /// A compiler-only memory barrier. /// /// Memory accesses will never be reordered across this barrier by the @@ -1281,11 +962,8 @@ pub unsafe fn atomic_singlethreadfence_seqcst() { /// [`atomic::compiler_fence`] by passing [`Ordering::Acquire`] /// as the `order`. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_singlethreadfence_acquire() { - unreachable!() -} +pub unsafe fn atomic_singlethreadfence_acquire(); /// A compiler-only memory barrier. /// /// Memory accesses will never be reordered across this barrier by the @@ -1297,11 +975,8 @@ pub unsafe fn atomic_singlethreadfence_acquire() { /// [`atomic::compiler_fence`] by passing [`Ordering::Release`] /// as the `order`. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_singlethreadfence_release() { - unreachable!() -} +pub unsafe fn atomic_singlethreadfence_release(); /// A compiler-only memory barrier. /// /// Memory accesses will never be reordered across this barrier by the @@ -1313,11 +988,8 @@ pub unsafe fn atomic_singlethreadfence_release() { /// [`atomic::compiler_fence`] by passing [`Ordering::AcqRel`] /// as the `order`. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn atomic_singlethreadfence_acqrel() { - unreachable!() -} +pub unsafe fn atomic_singlethreadfence_acqrel(); /// The `prefetch` intrinsic is a hint to the code generator to insert a prefetch instruction /// if supported; otherwise, it is a no-op. @@ -1329,11 +1001,8 @@ pub unsafe fn atomic_singlethreadfence_acqrel() { /// /// This intrinsic does not have a stable counterpart. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn prefetch_read_data(_data: *const T, _locality: i32) { - unreachable!() -} +pub unsafe fn prefetch_read_data(_data: *const T, _locality: i32); /// The `prefetch` intrinsic is a hint to the code generator to insert a prefetch instruction /// if supported; otherwise, it is a no-op. /// Prefetches have no effect on the behavior of the program but can change its performance @@ -1344,11 +1013,8 @@ pub unsafe fn prefetch_read_data(_data: *const T, _locality: i32) { /// /// This intrinsic does not have a stable counterpart. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn prefetch_write_data(_data: *const T, _locality: i32) { - unreachable!() -} +pub unsafe fn prefetch_write_data(_data: *const T, _locality: i32); /// The `prefetch` intrinsic is a hint to the code generator to insert a prefetch instruction /// if supported; otherwise, it is a no-op. /// Prefetches have no effect on the behavior of the program but can change its performance @@ -1359,11 +1025,8 @@ pub unsafe fn prefetch_write_data(_data: *const T, _locality: i32) { /// /// This intrinsic does not have a stable counterpart. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn prefetch_read_instruction(_data: *const T, _locality: i32) { - unreachable!() -} +pub unsafe fn prefetch_read_instruction(_data: *const T, _locality: i32); /// The `prefetch` intrinsic is a hint to the code generator to insert a prefetch instruction /// if supported; otherwise, it is a no-op. /// Prefetches have no effect on the behavior of the program but can change its performance @@ -1374,21 +1037,15 @@ pub unsafe fn prefetch_read_instruction(_data: *const T, _locality: i32) { /// /// This intrinsic does not have a stable counterpart. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn prefetch_write_instruction(_data: *const T, _locality: i32) { - unreachable!() -} +pub unsafe fn prefetch_write_instruction(_data: *const T, _locality: i32); /// Executes a breakpoint trap, for inspection by a debugger. /// /// This intrinsic does not have a stable counterpart. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub fn breakpoint() { - unreachable!() -} +pub fn breakpoint(); /// Magic intrinsic that derives its meaning from attributes /// attached to the function. @@ -1401,10 +1058,7 @@ pub fn breakpoint() { /// This intrinsic should not be used outside of the compiler. #[rustc_nounwind] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub fn rustc_peek(_: T) -> T { - unreachable!() -} +pub fn rustc_peek(_: T) -> T; /// Aborts the execution of the process. /// @@ -1423,10 +1077,7 @@ pub fn rustc_peek(_: T) -> T { /// `SIGBUS`. The precise behavior is not guaranteed and not stable. #[rustc_nounwind] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub fn abort() -> ! { - unreachable!() -} +pub fn abort() -> !; /// Informs the optimizer that this point in the code is not reachable, /// enabling further optimizations. @@ -1439,10 +1090,7 @@ pub fn abort() -> ! { #[rustc_intrinsic_const_stable_indirect] #[rustc_nounwind] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const unsafe fn unreachable() -> ! { - unreachable!() -} +pub const unsafe fn unreachable() -> !; /// Informs the optimizer that a condition is always true. /// If the condition is false, the behavior is undefined. @@ -1554,10 +1202,7 @@ pub fn select_unpredictable(b: bool, true_val: T, false_val: T) -> T { #[rustc_intrinsic_const_stable_indirect] #[rustc_nounwind] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const fn assert_inhabited() { - unreachable!() -} +pub const fn assert_inhabited(); /// A guard for unsafe functions that cannot ever be executed if `T` does not permit /// zero-initialization: This will statically either panic, or do nothing. @@ -1566,10 +1211,7 @@ pub const fn assert_inhabited() { #[rustc_intrinsic_const_stable_indirect] #[rustc_nounwind] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const fn assert_zero_valid() { - unreachable!() -} +pub const fn assert_zero_valid(); /// A guard for `std::mem::uninitialized`. This will statically either panic, or do nothing. /// @@ -1577,10 +1219,7 @@ pub const fn assert_zero_valid() { #[rustc_intrinsic_const_stable_indirect] #[rustc_nounwind] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const fn assert_mem_uninitialized_valid() { - unreachable!() -} +pub const fn assert_mem_uninitialized_valid(); /// Gets a reference to a static `Location` indicating where it was called. /// @@ -1593,10 +1232,7 @@ pub const fn assert_mem_uninitialized_valid() { #[rustc_intrinsic_const_stable_indirect] #[rustc_nounwind] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const fn caller_location() -> &'static crate::panic::Location<'static> { - unreachable!() -} +pub const fn caller_location() -> &'static crate::panic::Location<'static>; /// Moves a value out of scope without running drop glue. /// @@ -1610,10 +1246,7 @@ pub const fn caller_location() -> &'static crate::panic::Location<'static> { #[rustc_intrinsic_const_stable_indirect] #[rustc_nounwind] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const fn forget(_: T) { - unreachable!() -} +pub const fn forget(_: T); /// Reinterprets the bits of a value of one type as another type. /// @@ -1703,12 +1336,12 @@ pub const fn forget(_: T) { /// ``` /// struct R<'a>(&'a i32); /// unsafe fn extend_lifetime<'b>(r: R<'b>) -> R<'static> { -/// std::mem::transmute::, R<'static>>(r) +/// unsafe { std::mem::transmute::, R<'static>>(r) } /// } /// /// unsafe fn shorten_invariant_lifetime<'b, 'c>(r: &'b mut R<'static>) /// -> &'b mut R<'c> { -/// std::mem::transmute::<&'b mut R<'static>, &'b mut R<'c>>(r) +/// unsafe { std::mem::transmute::<&'b mut R<'static>, &'b mut R<'c>>(r) } /// } /// ``` /// @@ -1901,19 +1534,12 @@ pub const fn forget(_: T) { /// } /// ``` #[stable(feature = "rust1", since = "1.0.0")] -#[cfg_attr(bootstrap, rustc_allowed_through_unstable_modules)] -#[cfg_attr( - not(bootstrap), - rustc_allowed_through_unstable_modules = "import this function via `std::mem` instead" -)] +#[rustc_allowed_through_unstable_modules = "import this function via `std::mem` instead"] #[rustc_const_stable(feature = "const_transmute", since = "1.56.0")] #[rustc_diagnostic_item = "transmute"] #[rustc_nounwind] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const unsafe fn transmute(_src: Src) -> Dst { - unreachable!() -} +pub const unsafe fn transmute(_src: Src) -> Dst; /// Like [`transmute`], but even less checked at compile-time: rather than /// giving an error for `size_of::() != size_of::()`, it's @@ -1927,10 +1553,7 @@ pub const unsafe fn transmute(_src: Src) -> Dst { #[rustc_intrinsic_const_stable_indirect] #[rustc_nounwind] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const unsafe fn transmute_unchecked(_src: Src) -> Dst { - unreachable!() -} +pub const unsafe fn transmute_unchecked(_src: Src) -> Dst; /// Returns `true` if the actual type given as `T` requires drop /// glue; returns `false` if the actual type provided for `T` @@ -1948,10 +1571,7 @@ pub const unsafe fn transmute_unchecked(_src: Src) -> Dst { #[rustc_intrinsic_const_stable_indirect] #[rustc_nounwind] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const fn needs_drop() -> bool { - unreachable!() -} +pub const fn needs_drop() -> bool; /// Calculates the offset from a pointer. /// @@ -1973,10 +1593,7 @@ pub const fn needs_drop() -> bool { #[rustc_intrinsic_const_stable_indirect] #[rustc_nounwind] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const unsafe fn offset(_dst: Ptr, _offset: Delta) -> Ptr { - unreachable!() -} +pub const unsafe fn offset(_dst: Ptr, _offset: Delta) -> Ptr; /// Calculates the offset from a pointer, potentially wrapping. /// @@ -1995,10 +1612,7 @@ pub const unsafe fn offset(_dst: Ptr, _offset: Delta) -> Ptr { #[rustc_intrinsic_const_stable_indirect] #[rustc_nounwind] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const unsafe fn arith_offset(_dst: *const T, _offset: isize) -> *const T { - unreachable!() -} +pub const unsafe fn arith_offset(_dst: *const T, _offset: isize) -> *const T; /// Masks out bits of the pointer according to a mask. /// @@ -2010,10 +1624,7 @@ pub const unsafe fn arith_offset(_dst: *const T, _offset: isize) -> *const T /// Consider using [`pointer::mask`] instead. #[rustc_nounwind] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub fn ptr_mask(_ptr: *const T, _mask: usize) -> *const T { - unreachable!() -} +pub fn ptr_mask(_ptr: *const T, _mask: usize) -> *const T; /// Equivalent to the appropriate `llvm.memcpy.p0i8.0i8.*` intrinsic, with /// a size of `count` * `size_of::()` and an alignment of @@ -2024,11 +1635,8 @@ pub fn ptr_mask(_ptr: *const T, _mask: usize) -> *const T { /// /// This intrinsic does not have a stable counterpart. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn volatile_copy_nonoverlapping_memory(_dst: *mut T, _src: *const T, _count: usize) { - unreachable!() -} +pub unsafe fn volatile_copy_nonoverlapping_memory(_dst: *mut T, _src: *const T, _count: usize); /// Equivalent to the appropriate `llvm.memmove.p0i8.0i8.*` intrinsic, with /// a size of `count * size_of::()` and an alignment of /// `min_align_of::()` @@ -2038,11 +1646,8 @@ pub unsafe fn volatile_copy_nonoverlapping_memory(_dst: *mut T, _src: *const /// /// This intrinsic does not have a stable counterpart. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn volatile_copy_memory(_dst: *mut T, _src: *const T, _count: usize) { - unreachable!() -} +pub unsafe fn volatile_copy_memory(_dst: *mut T, _src: *const T, _count: usize); /// Equivalent to the appropriate `llvm.memset.p0i8.*` intrinsic, with a /// size of `count * size_of::()` and an alignment of /// `min_align_of::()`. @@ -2052,504 +1657,357 @@ pub unsafe fn volatile_copy_memory(_dst: *mut T, _src: *const T, _count: usiz /// /// This intrinsic does not have a stable counterpart. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn volatile_set_memory(_dst: *mut T, _val: u8, _count: usize) { - unreachable!() -} +pub unsafe fn volatile_set_memory(_dst: *mut T, _val: u8, _count: usize); /// Performs a volatile load from the `src` pointer. /// /// The stabilized version of this intrinsic is [`core::ptr::read_volatile`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn volatile_load(_src: *const T) -> T { - unreachable!() -} +pub unsafe fn volatile_load(_src: *const T) -> T; /// Performs a volatile store to the `dst` pointer. /// /// The stabilized version of this intrinsic is [`core::ptr::write_volatile`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn volatile_store(_dst: *mut T, _val: T) { - unreachable!() -} +pub unsafe fn volatile_store(_dst: *mut T, _val: T); /// Performs a volatile load from the `src` pointer /// The pointer is not required to be aligned. /// /// This intrinsic does not have a stable counterpart. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] #[rustc_diagnostic_item = "intrinsics_unaligned_volatile_load"] -pub unsafe fn unaligned_volatile_load(_src: *const T) -> T { - unreachable!() -} +pub unsafe fn unaligned_volatile_load(_src: *const T) -> T; /// Performs a volatile store to the `dst` pointer. /// The pointer is not required to be aligned. /// /// This intrinsic does not have a stable counterpart. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] #[rustc_diagnostic_item = "intrinsics_unaligned_volatile_store"] -pub unsafe fn unaligned_volatile_store(_dst: *mut T, _val: T) { - unreachable!() -} +pub unsafe fn unaligned_volatile_store(_dst: *mut T, _val: T); /// Returns the square root of an `f16` /// /// The stabilized version of this intrinsic is /// [`f16::sqrt`](../../std/primitive.f16.html#method.sqrt) #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn sqrtf16(_x: f16) -> f16 { - unreachable!() -} +pub unsafe fn sqrtf16(_x: f16) -> f16; /// Returns the square root of an `f32` /// /// The stabilized version of this intrinsic is /// [`f32::sqrt`](../../std/primitive.f32.html#method.sqrt) #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn sqrtf32(_x: f32) -> f32 { - unreachable!() -} +pub unsafe fn sqrtf32(_x: f32) -> f32; /// Returns the square root of an `f64` /// /// The stabilized version of this intrinsic is /// [`f64::sqrt`](../../std/primitive.f64.html#method.sqrt) #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn sqrtf64(_x: f64) -> f64 { - unreachable!() -} +pub unsafe fn sqrtf64(_x: f64) -> f64; /// Returns the square root of an `f128` /// /// The stabilized version of this intrinsic is /// [`f128::sqrt`](../../std/primitive.f128.html#method.sqrt) #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn sqrtf128(_x: f128) -> f128 { - unreachable!() -} +pub unsafe fn sqrtf128(_x: f128) -> f128; /// Raises an `f16` to an integer power. /// /// The stabilized version of this intrinsic is /// [`f16::powi`](../../std/primitive.f16.html#method.powi) #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn powif16(_a: f16, _x: i32) -> f16 { - unreachable!() -} +pub unsafe fn powif16(_a: f16, _x: i32) -> f16; /// Raises an `f32` to an integer power. /// /// The stabilized version of this intrinsic is /// [`f32::powi`](../../std/primitive.f32.html#method.powi) #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn powif32(_a: f32, _x: i32) -> f32 { - unreachable!() -} +pub unsafe fn powif32(_a: f32, _x: i32) -> f32; /// Raises an `f64` to an integer power. /// /// The stabilized version of this intrinsic is /// [`f64::powi`](../../std/primitive.f64.html#method.powi) #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn powif64(_a: f64, _x: i32) -> f64 { - unreachable!() -} +pub unsafe fn powif64(_a: f64, _x: i32) -> f64; /// Raises an `f128` to an integer power. /// /// The stabilized version of this intrinsic is /// [`f128::powi`](../../std/primitive.f128.html#method.powi) #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn powif128(_a: f128, _x: i32) -> f128 { - unreachable!() -} +pub unsafe fn powif128(_a: f128, _x: i32) -> f128; /// Returns the sine of an `f16`. /// /// The stabilized version of this intrinsic is /// [`f16::sin`](../../std/primitive.f16.html#method.sin) #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn sinf16(_x: f16) -> f16 { - unreachable!() -} +pub unsafe fn sinf16(_x: f16) -> f16; /// Returns the sine of an `f32`. /// /// The stabilized version of this intrinsic is /// [`f32::sin`](../../std/primitive.f32.html#method.sin) #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn sinf32(_x: f32) -> f32 { - unreachable!() -} +pub unsafe fn sinf32(_x: f32) -> f32; /// Returns the sine of an `f64`. /// /// The stabilized version of this intrinsic is /// [`f64::sin`](../../std/primitive.f64.html#method.sin) #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn sinf64(_x: f64) -> f64 { - unreachable!() -} +pub unsafe fn sinf64(_x: f64) -> f64; /// Returns the sine of an `f128`. /// /// The stabilized version of this intrinsic is /// [`f128::sin`](../../std/primitive.f128.html#method.sin) #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn sinf128(_x: f128) -> f128 { - unreachable!() -} +pub unsafe fn sinf128(_x: f128) -> f128; /// Returns the cosine of an `f16`. /// /// The stabilized version of this intrinsic is /// [`f16::cos`](../../std/primitive.f16.html#method.cos) #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn cosf16(_x: f16) -> f16 { - unreachable!() -} +pub unsafe fn cosf16(_x: f16) -> f16; /// Returns the cosine of an `f32`. /// /// The stabilized version of this intrinsic is /// [`f32::cos`](../../std/primitive.f32.html#method.cos) #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn cosf32(_x: f32) -> f32 { - unreachable!() -} +pub unsafe fn cosf32(_x: f32) -> f32; /// Returns the cosine of an `f64`. /// /// The stabilized version of this intrinsic is /// [`f64::cos`](../../std/primitive.f64.html#method.cos) #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn cosf64(_x: f64) -> f64 { - unreachable!() -} +pub unsafe fn cosf64(_x: f64) -> f64; /// Returns the cosine of an `f128`. /// /// The stabilized version of this intrinsic is /// [`f128::cos`](../../std/primitive.f128.html#method.cos) #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn cosf128(_x: f128) -> f128 { - unreachable!() -} +pub unsafe fn cosf128(_x: f128) -> f128; /// Raises an `f16` to an `f16` power. /// /// The stabilized version of this intrinsic is /// [`f16::powf`](../../std/primitive.f16.html#method.powf) #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn powf16(_a: f16, _x: f16) -> f16 { - unreachable!() -} +pub unsafe fn powf16(_a: f16, _x: f16) -> f16; /// Raises an `f32` to an `f32` power. /// /// The stabilized version of this intrinsic is /// [`f32::powf`](../../std/primitive.f32.html#method.powf) #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn powf32(_a: f32, _x: f32) -> f32 { - unreachable!() -} +pub unsafe fn powf32(_a: f32, _x: f32) -> f32; /// Raises an `f64` to an `f64` power. /// /// The stabilized version of this intrinsic is /// [`f64::powf`](../../std/primitive.f64.html#method.powf) #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn powf64(_a: f64, _x: f64) -> f64 { - unreachable!() -} +pub unsafe fn powf64(_a: f64, _x: f64) -> f64; /// Raises an `f128` to an `f128` power. /// /// The stabilized version of this intrinsic is /// [`f128::powf`](../../std/primitive.f128.html#method.powf) #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn powf128(_a: f128, _x: f128) -> f128 { - unreachable!() -} +pub unsafe fn powf128(_a: f128, _x: f128) -> f128; /// Returns the exponential of an `f16`. /// /// The stabilized version of this intrinsic is /// [`f16::exp`](../../std/primitive.f16.html#method.exp) #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn expf16(_x: f16) -> f16 { - unreachable!() -} +pub unsafe fn expf16(_x: f16) -> f16; /// Returns the exponential of an `f32`. /// /// The stabilized version of this intrinsic is /// [`f32::exp`](../../std/primitive.f32.html#method.exp) #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn expf32(_x: f32) -> f32 { - unreachable!() -} +pub unsafe fn expf32(_x: f32) -> f32; /// Returns the exponential of an `f64`. /// /// The stabilized version of this intrinsic is /// [`f64::exp`](../../std/primitive.f64.html#method.exp) #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn expf64(_x: f64) -> f64 { - unreachable!() -} +pub unsafe fn expf64(_x: f64) -> f64; /// Returns the exponential of an `f128`. /// /// The stabilized version of this intrinsic is /// [`f128::exp`](../../std/primitive.f128.html#method.exp) #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn expf128(_x: f128) -> f128 { - unreachable!() -} +pub unsafe fn expf128(_x: f128) -> f128; /// Returns 2 raised to the power of an `f16`. /// /// The stabilized version of this intrinsic is /// [`f16::exp2`](../../std/primitive.f16.html#method.exp2) #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn exp2f16(_x: f16) -> f16 { - unreachable!() -} +pub unsafe fn exp2f16(_x: f16) -> f16; /// Returns 2 raised to the power of an `f32`. /// /// The stabilized version of this intrinsic is /// [`f32::exp2`](../../std/primitive.f32.html#method.exp2) #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn exp2f32(_x: f32) -> f32 { - unreachable!() -} +pub unsafe fn exp2f32(_x: f32) -> f32; /// Returns 2 raised to the power of an `f64`. /// /// The stabilized version of this intrinsic is /// [`f64::exp2`](../../std/primitive.f64.html#method.exp2) #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn exp2f64(_x: f64) -> f64 { - unreachable!() -} +pub unsafe fn exp2f64(_x: f64) -> f64; /// Returns 2 raised to the power of an `f128`. /// /// The stabilized version of this intrinsic is /// [`f128::exp2`](../../std/primitive.f128.html#method.exp2) #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn exp2f128(_x: f128) -> f128 { - unreachable!() -} +pub unsafe fn exp2f128(_x: f128) -> f128; /// Returns the natural logarithm of an `f16`. /// /// The stabilized version of this intrinsic is /// [`f16::ln`](../../std/primitive.f16.html#method.ln) #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn logf16(_x: f16) -> f16 { - unreachable!() -} +pub unsafe fn logf16(_x: f16) -> f16; /// Returns the natural logarithm of an `f32`. /// /// The stabilized version of this intrinsic is /// [`f32::ln`](../../std/primitive.f32.html#method.ln) #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn logf32(_x: f32) -> f32 { - unreachable!() -} +pub unsafe fn logf32(_x: f32) -> f32; /// Returns the natural logarithm of an `f64`. /// /// The stabilized version of this intrinsic is /// [`f64::ln`](../../std/primitive.f64.html#method.ln) #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn logf64(_x: f64) -> f64 { - unreachable!() -} +pub unsafe fn logf64(_x: f64) -> f64; /// Returns the natural logarithm of an `f128`. /// /// The stabilized version of this intrinsic is /// [`f128::ln`](../../std/primitive.f128.html#method.ln) #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn logf128(_x: f128) -> f128 { - unreachable!() -} +pub unsafe fn logf128(_x: f128) -> f128; /// Returns the base 10 logarithm of an `f16`. /// /// The stabilized version of this intrinsic is /// [`f16::log10`](../../std/primitive.f16.html#method.log10) #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn log10f16(_x: f16) -> f16 { - unreachable!() -} +pub unsafe fn log10f16(_x: f16) -> f16; /// Returns the base 10 logarithm of an `f32`. /// /// The stabilized version of this intrinsic is /// [`f32::log10`](../../std/primitive.f32.html#method.log10) #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn log10f32(_x: f32) -> f32 { - unreachable!() -} +pub unsafe fn log10f32(_x: f32) -> f32; /// Returns the base 10 logarithm of an `f64`. /// /// The stabilized version of this intrinsic is /// [`f64::log10`](../../std/primitive.f64.html#method.log10) #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn log10f64(_x: f64) -> f64 { - unreachable!() -} +pub unsafe fn log10f64(_x: f64) -> f64; /// Returns the base 10 logarithm of an `f128`. /// /// The stabilized version of this intrinsic is /// [`f128::log10`](../../std/primitive.f128.html#method.log10) #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn log10f128(_x: f128) -> f128 { - unreachable!() -} +pub unsafe fn log10f128(_x: f128) -> f128; /// Returns the base 2 logarithm of an `f16`. /// /// The stabilized version of this intrinsic is /// [`f16::log2`](../../std/primitive.f16.html#method.log2) #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn log2f16(_x: f16) -> f16 { - unreachable!() -} +pub unsafe fn log2f16(_x: f16) -> f16; /// Returns the base 2 logarithm of an `f32`. /// /// The stabilized version of this intrinsic is /// [`f32::log2`](../../std/primitive.f32.html#method.log2) #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn log2f32(_x: f32) -> f32 { - unreachable!() -} +pub unsafe fn log2f32(_x: f32) -> f32; /// Returns the base 2 logarithm of an `f64`. /// /// The stabilized version of this intrinsic is /// [`f64::log2`](../../std/primitive.f64.html#method.log2) #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn log2f64(_x: f64) -> f64 { - unreachable!() -} +pub unsafe fn log2f64(_x: f64) -> f64; /// Returns the base 2 logarithm of an `f128`. /// /// The stabilized version of this intrinsic is /// [`f128::log2`](../../std/primitive.f128.html#method.log2) #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn log2f128(_x: f128) -> f128 { - unreachable!() -} +pub unsafe fn log2f128(_x: f128) -> f128; /// Returns `a * b + c` for `f16` values. /// /// The stabilized version of this intrinsic is /// [`f16::mul_add`](../../std/primitive.f16.html#method.mul_add) #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn fmaf16(_a: f16, _b: f16, _c: f16) -> f16 { - unreachable!() -} +pub unsafe fn fmaf16(_a: f16, _b: f16, _c: f16) -> f16; /// Returns `a * b + c` for `f32` values. /// /// The stabilized version of this intrinsic is /// [`f32::mul_add`](../../std/primitive.f32.html#method.mul_add) #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn fmaf32(_a: f32, _b: f32, _c: f32) -> f32 { - unreachable!() -} +pub unsafe fn fmaf32(_a: f32, _b: f32, _c: f32) -> f32; /// Returns `a * b + c` for `f64` values. /// /// The stabilized version of this intrinsic is /// [`f64::mul_add`](../../std/primitive.f64.html#method.mul_add) #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn fmaf64(_a: f64, _b: f64, _c: f64) -> f64 { - unreachable!() -} +pub unsafe fn fmaf64(_a: f64, _b: f64, _c: f64) -> f64; /// Returns `a * b + c` for `f128` values. /// /// The stabilized version of this intrinsic is /// [`f128::mul_add`](../../std/primitive.f128.html#method.mul_add) #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn fmaf128(_a: f128, _b: f128, _c: f128) -> f128 { - unreachable!() -} +pub unsafe fn fmaf128(_a: f128, _b: f128, _c: f128) -> f128; /// Returns `a * b + c` for `f16` values, non-deterministically executing /// either a fused multiply-add or two operations with rounding of the @@ -2562,11 +2020,8 @@ pub unsafe fn fmaf128(_a: f128, _b: f128, _c: f128) -> f128 { /// is selected, and that may depend on optimization level and context, for /// example. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn fmuladdf16(_a: f16, _b: f16, _c: f16) -> f16 { - unreachable!() -} +pub unsafe fn fmuladdf16(_a: f16, _b: f16, _c: f16) -> f16; /// Returns `a * b + c` for `f32` values, non-deterministically executing /// either a fused multiply-add or two operations with rounding of the /// intermediate result. @@ -2578,11 +2033,8 @@ pub unsafe fn fmuladdf16(_a: f16, _b: f16, _c: f16) -> f16 { /// is selected, and that may depend on optimization level and context, for /// example. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn fmuladdf32(_a: f32, _b: f32, _c: f32) -> f32 { - unreachable!() -} +pub unsafe fn fmuladdf32(_a: f32, _b: f32, _c: f32) -> f32; /// Returns `a * b + c` for `f64` values, non-deterministically executing /// either a fused multiply-add or two operations with rounding of the /// intermediate result. @@ -2594,11 +2046,8 @@ pub unsafe fn fmuladdf32(_a: f32, _b: f32, _c: f32) -> f32 { /// is selected, and that may depend on optimization level and context, for /// example. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn fmuladdf64(_a: f64, _b: f64, _c: f64) -> f64 { - unreachable!() -} +pub unsafe fn fmuladdf64(_a: f64, _b: f64, _c: f64) -> f64; /// Returns `a * b + c` for `f128` values, non-deterministically executing /// either a fused multiply-add or two operations with rounding of the /// intermediate result. @@ -2610,239 +2059,190 @@ pub unsafe fn fmuladdf64(_a: f64, _b: f64, _c: f64) -> f64 { /// is selected, and that may depend on optimization level and context, for /// example. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn fmuladdf128(_a: f128, _b: f128, _c: f128) -> f128 { - unreachable!() -} +pub unsafe fn fmuladdf128(_a: f128, _b: f128, _c: f128) -> f128; /// Returns the largest integer less than or equal to an `f16`. /// /// The stabilized version of this intrinsic is /// [`f16::floor`](../../std/primitive.f16.html#method.floor) #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn floorf16(_x: f16) -> f16 { - unreachable!() -} +pub unsafe fn floorf16(_x: f16) -> f16; /// Returns the largest integer less than or equal to an `f32`. /// /// The stabilized version of this intrinsic is /// [`f32::floor`](../../std/primitive.f32.html#method.floor) #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn floorf32(_x: f32) -> f32 { - unreachable!() -} +pub unsafe fn floorf32(_x: f32) -> f32; /// Returns the largest integer less than or equal to an `f64`. /// /// The stabilized version of this intrinsic is /// [`f64::floor`](../../std/primitive.f64.html#method.floor) #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn floorf64(_x: f64) -> f64 { - unreachable!() -} +pub unsafe fn floorf64(_x: f64) -> f64; /// Returns the largest integer less than or equal to an `f128`. /// /// The stabilized version of this intrinsic is /// [`f128::floor`](../../std/primitive.f128.html#method.floor) #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn floorf128(_x: f128) -> f128 { - unreachable!() -} +pub unsafe fn floorf128(_x: f128) -> f128; /// Returns the smallest integer greater than or equal to an `f16`. /// /// The stabilized version of this intrinsic is /// [`f16::ceil`](../../std/primitive.f16.html#method.ceil) #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn ceilf16(_x: f16) -> f16 { - unreachable!() -} +pub unsafe fn ceilf16(_x: f16) -> f16; /// Returns the smallest integer greater than or equal to an `f32`. /// /// The stabilized version of this intrinsic is /// [`f32::ceil`](../../std/primitive.f32.html#method.ceil) #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn ceilf32(_x: f32) -> f32 { - unreachable!() -} +pub unsafe fn ceilf32(_x: f32) -> f32; /// Returns the smallest integer greater than or equal to an `f64`. /// /// The stabilized version of this intrinsic is /// [`f64::ceil`](../../std/primitive.f64.html#method.ceil) #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn ceilf64(_x: f64) -> f64 { - unreachable!() -} +pub unsafe fn ceilf64(_x: f64) -> f64; /// Returns the smallest integer greater than or equal to an `f128`. /// /// The stabilized version of this intrinsic is /// [`f128::ceil`](../../std/primitive.f128.html#method.ceil) #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn ceilf128(_x: f128) -> f128 { - unreachable!() -} +pub unsafe fn ceilf128(_x: f128) -> f128; /// Returns the integer part of an `f16`. /// /// The stabilized version of this intrinsic is /// [`f16::trunc`](../../std/primitive.f16.html#method.trunc) #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn truncf16(_x: f16) -> f16 { - unreachable!() -} +pub unsafe fn truncf16(_x: f16) -> f16; /// Returns the integer part of an `f32`. /// /// The stabilized version of this intrinsic is /// [`f32::trunc`](../../std/primitive.f32.html#method.trunc) #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn truncf32(_x: f32) -> f32 { - unreachable!() -} +pub unsafe fn truncf32(_x: f32) -> f32; /// Returns the integer part of an `f64`. /// /// The stabilized version of this intrinsic is /// [`f64::trunc`](../../std/primitive.f64.html#method.trunc) #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn truncf64(_x: f64) -> f64 { - unreachable!() -} +pub unsafe fn truncf64(_x: f64) -> f64; /// Returns the integer part of an `f128`. /// /// The stabilized version of this intrinsic is /// [`f128::trunc`](../../std/primitive.f128.html#method.trunc) #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn truncf128(_x: f128) -> f128 { - unreachable!() -} +pub unsafe fn truncf128(_x: f128) -> f128; -/// Returns the nearest integer to an `f16`. Changing the rounding mode is not possible in Rust, -/// so this rounds half-way cases to the number with an even least significant digit. -/// -/// May raise an inexact floating-point exception if the argument is not an integer. -/// However, Rust assumes floating-point exceptions cannot be observed, so these exceptions -/// cannot actually be utilized from Rust code. -/// In other words, this intrinsic is equivalent in behavior to `nearbyintf16` and `roundevenf16`. +/// Returns the nearest integer to an `f16`. Rounds half-way cases to the number with an even +/// least significant digit. /// /// The stabilized version of this intrinsic is /// [`f16::round_ties_even`](../../std/primitive.f16.html#method.round_ties_even) #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn rintf16(_x: f16) -> f16 { - unreachable!() +#[cfg(not(bootstrap))] +pub fn round_ties_even_f16(_x: f16) -> f16; + +/// To be removed on next bootstrap bump. +#[cfg(bootstrap)] +pub fn round_ties_even_f16(x: f16) -> f16 { + #[rustc_intrinsic] + #[rustc_nounwind] + unsafe fn rintf16(_x: f16) -> f16; + + // SAFETY: this intrinsic isn't actually unsafe + unsafe { rintf16(x) } } -/// Returns the nearest integer to an `f32`. Changing the rounding mode is not possible in Rust, -/// so this rounds half-way cases to the number with an even least significant digit. -/// -/// May raise an inexact floating-point exception if the argument is not an integer. -/// However, Rust assumes floating-point exceptions cannot be observed, so these exceptions -/// cannot actually be utilized from Rust code. -/// In other words, this intrinsic is equivalent in behavior to `nearbyintf32` and `roundevenf32`. + +/// Returns the nearest integer to an `f32`. Rounds half-way cases to the number with an even +/// least significant digit. /// /// The stabilized version of this intrinsic is /// [`f32::round_ties_even`](../../std/primitive.f32.html#method.round_ties_even) #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn rintf32(_x: f32) -> f32 { - unreachable!() +#[cfg(not(bootstrap))] +pub fn round_ties_even_f32(_x: f32) -> f32; + +/// To be removed on next bootstrap bump. +#[cfg(bootstrap)] +pub fn round_ties_even_f32(x: f32) -> f32 { + #[rustc_intrinsic] + #[rustc_nounwind] + unsafe fn rintf32(_x: f32) -> f32; + + // SAFETY: this intrinsic isn't actually unsafe + unsafe { rintf32(x) } } -/// Returns the nearest integer to an `f64`. Changing the rounding mode is not possible in Rust, -/// so this rounds half-way cases to the number with an even least significant digit. -/// -/// May raise an inexact floating-point exception if the argument is not an integer. -/// However, Rust assumes floating-point exceptions cannot be observed, so these exceptions -/// cannot actually be utilized from Rust code. -/// In other words, this intrinsic is equivalent in behavior to `nearbyintf64` and `roundevenf64`. + +/// Provided for compatibility with stdarch. DO NOT USE. +#[inline(always)] +pub unsafe fn rintf32(x: f32) -> f32 { + round_ties_even_f32(x) +} + +/// Returns the nearest integer to an `f64`. Rounds half-way cases to the number with an even +/// least significant digit. /// /// The stabilized version of this intrinsic is /// [`f64::round_ties_even`](../../std/primitive.f64.html#method.round_ties_even) #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn rintf64(_x: f64) -> f64 { - unreachable!() +#[cfg(not(bootstrap))] +pub fn round_ties_even_f64(_x: f64) -> f64; + +/// To be removed on next bootstrap bump. +#[cfg(bootstrap)] +pub fn round_ties_even_f64(x: f64) -> f64 { + #[rustc_intrinsic] + #[rustc_nounwind] + unsafe fn rintf64(_x: f64) -> f64; + + // SAFETY: this intrinsic isn't actually unsafe + unsafe { rintf64(x) } } -/// Returns the nearest integer to an `f128`. Changing the rounding mode is not possible in Rust, -/// so this rounds half-way cases to the number with an even least significant digit. -/// -/// May raise an inexact floating-point exception if the argument is not an integer. -/// However, Rust assumes floating-point exceptions cannot be observed, so these exceptions -/// cannot actually be utilized from Rust code. -/// In other words, this intrinsic is equivalent in behavior to `nearbyintf128` and `roundevenf128`. + +/// Provided for compatibility with stdarch. DO NOT USE. +#[inline(always)] +pub unsafe fn rintf64(x: f64) -> f64 { + round_ties_even_f64(x) +} + +/// Returns the nearest integer to an `f128`. Rounds half-way cases to the number with an even +/// least significant digit. /// /// The stabilized version of this intrinsic is /// [`f128::round_ties_even`](../../std/primitive.f128.html#method.round_ties_even) #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn rintf128(_x: f128) -> f128 { - unreachable!() -} +#[cfg(not(bootstrap))] +pub fn round_ties_even_f128(_x: f128) -> f128; -/// Returns the nearest integer to an `f16`. Changing the rounding mode is not possible in Rust, -/// so this rounds half-way cases to the number with an even least significant digit. -/// -/// This intrinsic does not have a stable counterpart. -#[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -#[rustc_nounwind] -pub unsafe fn nearbyintf16(_x: f16) -> f16 { - unreachable!() -} -/// Returns the nearest integer to an `f32`. Changing the rounding mode is not possible in Rust, -/// so this rounds half-way cases to the number with an even least significant digit. -/// -/// This intrinsic does not have a stable counterpart. -#[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -#[rustc_nounwind] -pub unsafe fn nearbyintf32(_x: f32) -> f32 { - unreachable!() -} -/// Returns the nearest integer to an `f64`. Changing the rounding mode is not possible in Rust, -/// so this rounds half-way cases to the number with an even least significant digit. -/// -/// This intrinsic does not have a stable counterpart. -#[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -#[rustc_nounwind] -pub unsafe fn nearbyintf64(_x: f64) -> f64 { - unreachable!() -} -/// Returns the nearest integer to an `f128`. Changing the rounding mode is not possible in Rust, -/// so this rounds half-way cases to the number with an even least significant digit. -/// -/// This intrinsic does not have a stable counterpart. -#[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -#[rustc_nounwind] -pub unsafe fn nearbyintf128(_x: f128) -> f128 { - unreachable!() +/// To be removed on next bootstrap bump. +#[cfg(bootstrap)] +pub fn round_ties_even_f128(x: f128) -> f128 { + #[rustc_intrinsic] + #[rustc_nounwind] + unsafe fn rintf128(_x: f128) -> f128; + + // SAFETY: this intrinsic isn't actually unsafe + unsafe { rintf128(x) } } /// Returns the nearest integer to an `f16`. Rounds half-way cases away from zero. @@ -2850,198 +2250,112 @@ pub unsafe fn nearbyintf128(_x: f128) -> f128 { /// The stabilized version of this intrinsic is /// [`f16::round`](../../std/primitive.f16.html#method.round) #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn roundf16(_x: f16) -> f16 { - unreachable!() -} +pub unsafe fn roundf16(_x: f16) -> f16; /// Returns the nearest integer to an `f32`. Rounds half-way cases away from zero. /// /// The stabilized version of this intrinsic is /// [`f32::round`](../../std/primitive.f32.html#method.round) #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn roundf32(_x: f32) -> f32 { - unreachable!() -} +pub unsafe fn roundf32(_x: f32) -> f32; /// Returns the nearest integer to an `f64`. Rounds half-way cases away from zero. /// /// The stabilized version of this intrinsic is /// [`f64::round`](../../std/primitive.f64.html#method.round) #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn roundf64(_x: f64) -> f64 { - unreachable!() -} +pub unsafe fn roundf64(_x: f64) -> f64; /// Returns the nearest integer to an `f128`. Rounds half-way cases away from zero. /// /// The stabilized version of this intrinsic is /// [`f128::round`](../../std/primitive.f128.html#method.round) #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn roundf128(_x: f128) -> f128 { - unreachable!() -} - -/// Returns the nearest integer to an `f16`. Rounds half-way cases to the number -/// with an even least significant digit. -/// -/// This intrinsic does not have a stable counterpart. -#[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -#[rustc_nounwind] -pub unsafe fn roundevenf16(_x: f16) -> f16 { - unreachable!() -} -/// Returns the nearest integer to an `f32`. Rounds half-way cases to the number -/// with an even least significant digit. -/// -/// This intrinsic does not have a stable counterpart. -#[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -#[rustc_nounwind] -pub unsafe fn roundevenf32(_x: f32) -> f32 { - unreachable!() -} -/// Returns the nearest integer to an `f64`. Rounds half-way cases to the number -/// with an even least significant digit. -/// -/// This intrinsic does not have a stable counterpart. -#[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -#[rustc_nounwind] -pub unsafe fn roundevenf64(_x: f64) -> f64 { - unreachable!() -} -/// Returns the nearest integer to an `f128`. Rounds half-way cases to the number -/// with an even least significant digit. -/// -/// This intrinsic does not have a stable counterpart. -#[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -#[rustc_nounwind] -pub unsafe fn roundevenf128(_x: f128) -> f128 { - unreachable!() -} +pub unsafe fn roundf128(_x: f128) -> f128; /// Float addition that allows optimizations based on algebraic rules. /// May assume inputs are finite. /// /// This intrinsic does not have a stable counterpart. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn fadd_fast(_a: T, _b: T) -> T { - unreachable!() -} +pub unsafe fn fadd_fast(_a: T, _b: T) -> T; /// Float subtraction that allows optimizations based on algebraic rules. /// May assume inputs are finite. /// /// This intrinsic does not have a stable counterpart. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn fsub_fast(_a: T, _b: T) -> T { - unreachable!() -} +pub unsafe fn fsub_fast(_a: T, _b: T) -> T; /// Float multiplication that allows optimizations based on algebraic rules. /// May assume inputs are finite. /// /// This intrinsic does not have a stable counterpart. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn fmul_fast(_a: T, _b: T) -> T { - unreachable!() -} +pub unsafe fn fmul_fast(_a: T, _b: T) -> T; /// Float division that allows optimizations based on algebraic rules. /// May assume inputs are finite. /// /// This intrinsic does not have a stable counterpart. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn fdiv_fast(_a: T, _b: T) -> T { - unreachable!() -} +pub unsafe fn fdiv_fast(_a: T, _b: T) -> T; /// Float remainder that allows optimizations based on algebraic rules. /// May assume inputs are finite. /// /// This intrinsic does not have a stable counterpart. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn frem_fast(_a: T, _b: T) -> T { - unreachable!() -} +pub unsafe fn frem_fast(_a: T, _b: T) -> T; /// Converts with LLVM’s fptoui/fptosi, which may return undef for values out of range /// () /// /// Stabilized as [`f32::to_int_unchecked`] and [`f64::to_int_unchecked`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn float_to_int_unchecked(_value: Float) -> Int { - unreachable!() -} +pub unsafe fn float_to_int_unchecked(_value: Float) -> Int; /// Float addition that allows optimizations based on algebraic rules. /// /// This intrinsic does not have a stable counterpart. #[rustc_nounwind] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub fn fadd_algebraic(_a: T, _b: T) -> T { - unimplemented!() -} +pub fn fadd_algebraic(_a: T, _b: T) -> T; /// Float subtraction that allows optimizations based on algebraic rules. /// /// This intrinsic does not have a stable counterpart. #[rustc_nounwind] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub fn fsub_algebraic(_a: T, _b: T) -> T { - unimplemented!() -} +pub fn fsub_algebraic(_a: T, _b: T) -> T; /// Float multiplication that allows optimizations based on algebraic rules. /// /// This intrinsic does not have a stable counterpart. #[rustc_nounwind] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub fn fmul_algebraic(_a: T, _b: T) -> T { - unimplemented!() -} +pub fn fmul_algebraic(_a: T, _b: T) -> T; /// Float division that allows optimizations based on algebraic rules. /// /// This intrinsic does not have a stable counterpart. #[rustc_nounwind] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub fn fdiv_algebraic(_a: T, _b: T) -> T { - unimplemented!() -} +pub fn fdiv_algebraic(_a: T, _b: T) -> T; /// Float remainder that allows optimizations based on algebraic rules. /// /// This intrinsic does not have a stable counterpart. #[rustc_nounwind] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub fn frem_algebraic(_a: T, _b: T) -> T { - unimplemented!() -} +pub fn frem_algebraic(_a: T, _b: T) -> T; /// Returns the number of bits set in an integer type `T` /// @@ -3056,10 +2370,7 @@ pub fn frem_algebraic(_a: T, _b: T) -> T { #[rustc_intrinsic_const_stable_indirect] #[rustc_nounwind] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const fn ctpop(_x: T) -> u32 { - unimplemented!() -} +pub const fn ctpop(_x: T) -> u32; /// Returns the number of leading unset bits (zeroes) in an integer type `T`. /// @@ -3100,10 +2411,7 @@ pub const fn ctpop(_x: T) -> u32 { #[rustc_intrinsic_const_stable_indirect] #[rustc_nounwind] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const fn ctlz(_x: T) -> u32 { - unimplemented!() -} +pub const fn ctlz(_x: T) -> u32; /// Like `ctlz`, but extra-unsafe as it returns `undef` when /// given an `x` with value `0`. @@ -3125,10 +2433,7 @@ pub const fn ctlz(_x: T) -> u32 { #[rustc_intrinsic_const_stable_indirect] #[rustc_nounwind] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const unsafe fn ctlz_nonzero(_x: T) -> u32 { - unimplemented!() -} +pub const unsafe fn ctlz_nonzero(_x: T) -> u32; /// Returns the number of trailing unset bits (zeroes) in an integer type `T`. /// @@ -3169,10 +2474,7 @@ pub const unsafe fn ctlz_nonzero(_x: T) -> u32 { #[rustc_intrinsic_const_stable_indirect] #[rustc_nounwind] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const fn cttz(_x: T) -> u32 { - unimplemented!() -} +pub const fn cttz(_x: T) -> u32; /// Like `cttz`, but extra-unsafe as it returns `undef` when /// given an `x` with value `0`. @@ -3194,10 +2496,7 @@ pub const fn cttz(_x: T) -> u32 { #[rustc_intrinsic_const_stable_indirect] #[rustc_nounwind] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const unsafe fn cttz_nonzero(_x: T) -> u32 { - unimplemented!() -} +pub const unsafe fn cttz_nonzero(_x: T) -> u32; /// Reverses the bytes in an integer type `T`. /// @@ -3212,10 +2511,7 @@ pub const unsafe fn cttz_nonzero(_x: T) -> u32 { #[rustc_intrinsic_const_stable_indirect] #[rustc_nounwind] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const fn bswap(_x: T) -> T { - unimplemented!() -} +pub const fn bswap(_x: T) -> T; /// Reverses the bits in an integer type `T`. /// @@ -3230,10 +2526,7 @@ pub const fn bswap(_x: T) -> T { #[rustc_intrinsic_const_stable_indirect] #[rustc_nounwind] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const fn bitreverse(_x: T) -> T { - unimplemented!() -} +pub const fn bitreverse(_x: T) -> T; /// Does a three-way comparison between the two integer arguments. /// @@ -3243,10 +2536,7 @@ pub const fn bitreverse(_x: T) -> T { /// /// The stabilized version of this intrinsic is [`Ord::cmp`]. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const fn three_way_compare(_lhs: T, _rhss: T) -> crate::cmp::Ordering { - unimplemented!() -} +pub const fn three_way_compare(_lhs: T, _rhss: T) -> crate::cmp::Ordering; /// Combine two values which have no bits in common. /// @@ -3260,7 +2550,7 @@ pub const fn three_way_compare(_lhs: T, _rhss: T) -> crate::cmp::Orderi /// Otherwise it's immediate UB. #[rustc_const_unstable(feature = "disjoint_bitor", issue = "135758")] #[rustc_nounwind] -#[cfg_attr(not(bootstrap), rustc_intrinsic)] +#[rustc_intrinsic] #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces #[miri::intrinsic_fallback_is_spec] // the fallbacks all `assume` to tell Miri pub const unsafe fn disjoint_bitor(a: T, b: T) -> T { @@ -3281,10 +2571,7 @@ pub const unsafe fn disjoint_bitor(a: T, b: T #[rustc_intrinsic_const_stable_indirect] #[rustc_nounwind] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const fn add_with_overflow(_x: T, _y: T) -> (T, bool) { - unimplemented!() -} +pub const fn add_with_overflow(_x: T, _y: T) -> (T, bool); /// Performs checked integer subtraction /// @@ -3299,10 +2586,7 @@ pub const fn add_with_overflow(_x: T, _y: T) -> (T, bool) { #[rustc_intrinsic_const_stable_indirect] #[rustc_nounwind] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const fn sub_with_overflow(_x: T, _y: T) -> (T, bool) { - unimplemented!() -} +pub const fn sub_with_overflow(_x: T, _y: T) -> (T, bool); /// Performs checked integer multiplication /// @@ -3317,10 +2601,7 @@ pub const fn sub_with_overflow(_x: T, _y: T) -> (T, bool) { #[rustc_intrinsic_const_stable_indirect] #[rustc_nounwind] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const fn mul_with_overflow(_x: T, _y: T) -> (T, bool) { - unimplemented!() -} +pub const fn mul_with_overflow(_x: T, _y: T) -> (T, bool); /// Performs full-width multiplication and addition with a carry: /// `multiplier * multiplicand + addend + carry`. @@ -3356,10 +2637,7 @@ pub const fn carrying_mul_add, /// This intrinsic does not have a stable counterpart. #[rustc_nounwind] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const unsafe fn exact_div(_x: T, _y: T) -> T { - unimplemented!() -} +pub const unsafe fn exact_div(_x: T, _y: T) -> T; /// Performs an unchecked division, resulting in undefined behavior /// where `y == 0` or `x == T::MIN && y == -1` @@ -3370,10 +2648,7 @@ pub const unsafe fn exact_div(_x: T, _y: T) -> T { #[rustc_intrinsic_const_stable_indirect] #[rustc_nounwind] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const unsafe fn unchecked_div(_x: T, _y: T) -> T { - unimplemented!() -} +pub const unsafe fn unchecked_div(_x: T, _y: T) -> T; /// Returns the remainder of an unchecked division, resulting in /// undefined behavior when `y == 0` or `x == T::MIN && y == -1` /// @@ -3383,10 +2658,7 @@ pub const unsafe fn unchecked_div(_x: T, _y: T) -> T { #[rustc_intrinsic_const_stable_indirect] #[rustc_nounwind] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const unsafe fn unchecked_rem(_x: T, _y: T) -> T { - unimplemented!() -} +pub const unsafe fn unchecked_rem(_x: T, _y: T) -> T; /// Performs an unchecked left shift, resulting in undefined behavior when /// `y < 0` or `y >= N`, where N is the width of T in bits. @@ -3397,10 +2669,7 @@ pub const unsafe fn unchecked_rem(_x: T, _y: T) -> T { #[rustc_intrinsic_const_stable_indirect] #[rustc_nounwind] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const unsafe fn unchecked_shl(_x: T, _y: U) -> T { - unimplemented!() -} +pub const unsafe fn unchecked_shl(_x: T, _y: U) -> T; /// Performs an unchecked right shift, resulting in undefined behavior when /// `y < 0` or `y >= N`, where N is the width of T in bits. /// @@ -3410,10 +2679,7 @@ pub const unsafe fn unchecked_shl(_x: T, _y: U) -> T { #[rustc_intrinsic_const_stable_indirect] #[rustc_nounwind] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const unsafe fn unchecked_shr(_x: T, _y: U) -> T { - unimplemented!() -} +pub const unsafe fn unchecked_shr(_x: T, _y: U) -> T; /// Returns the result of an unchecked addition, resulting in /// undefined behavior when `x + y > T::MAX` or `x + y < T::MIN`. @@ -3423,10 +2689,7 @@ pub const unsafe fn unchecked_shr(_x: T, _y: U) -> T { #[rustc_intrinsic_const_stable_indirect] #[rustc_nounwind] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const unsafe fn unchecked_add(_x: T, _y: T) -> T { - unimplemented!() -} +pub const unsafe fn unchecked_add(_x: T, _y: T) -> T; /// Returns the result of an unchecked subtraction, resulting in /// undefined behavior when `x - y > T::MAX` or `x - y < T::MIN`. @@ -3436,10 +2699,7 @@ pub const unsafe fn unchecked_add(_x: T, _y: T) -> T { #[rustc_intrinsic_const_stable_indirect] #[rustc_nounwind] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const unsafe fn unchecked_sub(_x: T, _y: T) -> T { - unimplemented!() -} +pub const unsafe fn unchecked_sub(_x: T, _y: T) -> T; /// Returns the result of an unchecked multiplication, resulting in /// undefined behavior when `x * y > T::MAX` or `x * y < T::MIN`. @@ -3449,10 +2709,7 @@ pub const unsafe fn unchecked_sub(_x: T, _y: T) -> T { #[rustc_intrinsic_const_stable_indirect] #[rustc_nounwind] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const unsafe fn unchecked_mul(_x: T, _y: T) -> T { - unimplemented!() -} +pub const unsafe fn unchecked_mul(_x: T, _y: T) -> T; /// Performs rotate left. /// @@ -3467,10 +2724,7 @@ pub const unsafe fn unchecked_mul(_x: T, _y: T) -> T { #[rustc_intrinsic_const_stable_indirect] #[rustc_nounwind] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const fn rotate_left(_x: T, _shift: u32) -> T { - unimplemented!() -} +pub const fn rotate_left(_x: T, _shift: u32) -> T; /// Performs rotate right. /// @@ -3485,10 +2739,7 @@ pub const fn rotate_left(_x: T, _shift: u32) -> T { #[rustc_intrinsic_const_stable_indirect] #[rustc_nounwind] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const fn rotate_right(_x: T, _shift: u32) -> T { - unimplemented!() -} +pub const fn rotate_right(_x: T, _shift: u32) -> T; /// Returns (a + b) mod 2N, where N is the width of T in bits. /// @@ -3503,10 +2754,7 @@ pub const fn rotate_right(_x: T, _shift: u32) -> T { #[rustc_intrinsic_const_stable_indirect] #[rustc_nounwind] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const fn wrapping_add(_a: T, _b: T) -> T { - unimplemented!() -} +pub const fn wrapping_add(_a: T, _b: T) -> T; /// Returns (a - b) mod 2N, where N is the width of T in bits. /// /// Note that, unlike most intrinsics, this is safe to call; @@ -3520,10 +2768,7 @@ pub const fn wrapping_add(_a: T, _b: T) -> T { #[rustc_intrinsic_const_stable_indirect] #[rustc_nounwind] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const fn wrapping_sub(_a: T, _b: T) -> T { - unimplemented!() -} +pub const fn wrapping_sub(_a: T, _b: T) -> T; /// Returns (a * b) mod 2N, where N is the width of T in bits. /// /// Note that, unlike most intrinsics, this is safe to call; @@ -3537,10 +2782,7 @@ pub const fn wrapping_sub(_a: T, _b: T) -> T { #[rustc_intrinsic_const_stable_indirect] #[rustc_nounwind] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const fn wrapping_mul(_a: T, _b: T) -> T { - unimplemented!() -} +pub const fn wrapping_mul(_a: T, _b: T) -> T; /// Computes `a + b`, saturating at numeric bounds. /// @@ -3555,10 +2797,7 @@ pub const fn wrapping_mul(_a: T, _b: T) -> T { #[rustc_intrinsic_const_stable_indirect] #[rustc_nounwind] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const fn saturating_add(_a: T, _b: T) -> T { - unimplemented!() -} +pub const fn saturating_add(_a: T, _b: T) -> T; /// Computes `a - b`, saturating at numeric bounds. /// /// Note that, unlike most intrinsics, this is safe to call; @@ -3572,10 +2811,7 @@ pub const fn saturating_add(_a: T, _b: T) -> T { #[rustc_intrinsic_const_stable_indirect] #[rustc_nounwind] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const fn saturating_sub(_a: T, _b: T) -> T { - unimplemented!() -} +pub const fn saturating_sub(_a: T, _b: T) -> T; /// This is an implementation detail of [`crate::ptr::read`] and should /// not be used anywhere else. See its comments for why this exists. @@ -3586,10 +2822,7 @@ pub const fn saturating_sub(_a: T, _b: T) -> T { #[rustc_intrinsic_const_stable_indirect] #[rustc_nounwind] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const unsafe fn read_via_copy(_ptr: *const T) -> T { - unimplemented!() -} +pub const unsafe fn read_via_copy(_ptr: *const T) -> T; /// This is an implementation detail of [`crate::ptr::write`] and should /// not be used anywhere else. See its comments for why this exists. @@ -3600,10 +2833,7 @@ pub const unsafe fn read_via_copy(_ptr: *const T) -> T { #[rustc_intrinsic_const_stable_indirect] #[rustc_nounwind] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const unsafe fn write_via_move(_ptr: *mut T, _value: T) { - unimplemented!() -} +pub const unsafe fn write_via_move(_ptr: *mut T, _value: T); /// Returns the value of the discriminant for the variant in 'v'; /// if `T` has no discriminant, returns `0`. @@ -3617,10 +2847,7 @@ pub const unsafe fn write_via_move(_ptr: *mut T, _value: T) { #[rustc_intrinsic_const_stable_indirect] #[rustc_nounwind] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const fn discriminant_value(_v: &T) -> ::Discriminant { - unimplemented!() -} +pub const fn discriminant_value(_v: &T) -> ::Discriminant; /// Rust's "try catch" construct for unwinding. Invokes the function pointer `try_fn` with the /// data pointer `data`, and calls `catch_fn` if unwinding occurs while `try_fn` runs. @@ -3639,15 +2866,12 @@ pub const fn discriminant_value(_v: &T) -> ::Discrimin /// For more information, see the compiler's source, as well as the documentation for the stable /// version of this intrinsic, `std::panic::catch_unwind`. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] pub unsafe fn catch_unwind( _try_fn: fn(*mut u8), _data: *mut u8, _catch_fn: fn(*mut u8, *mut u8), -) -> i32 { - unreachable!() -} +) -> i32; /// Emits a `nontemporal` store, which gives a hint to the CPU that the data should not be held /// in cache. Except for performance, this is fully equivalent to `ptr.write(val)`. @@ -3656,28 +2880,20 @@ pub unsafe fn catch_unwind( /// exists, that operation is *not* equivalent to `ptr.write(val)` (`MOVNT` writes can be reordered /// in ways that are not allowed for regular writes). #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn nontemporal_store(_ptr: *mut T, _val: T) { - unreachable!() -} +pub unsafe fn nontemporal_store(_ptr: *mut T, _val: T); /// See documentation of `<*const T>::offset_from` for details. #[rustc_intrinsic_const_stable_indirect] #[rustc_nounwind] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const unsafe fn ptr_offset_from(_ptr: *const T, _base: *const T) -> isize { - unimplemented!() -} +pub const unsafe fn ptr_offset_from(_ptr: *const T, _base: *const T) -> isize; /// See documentation of `<*const T>::sub_ptr` for details. #[rustc_nounwind] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const unsafe fn ptr_offset_from_unsigned(_ptr: *const T, _base: *const T) -> usize { - unimplemented!() -} +#[rustc_intrinsic_const_stable_indirect] +pub const unsafe fn ptr_offset_from_unsigned(_ptr: *const T, _base: *const T) -> usize; /// See documentation of `<*const T>::guaranteed_eq` for details. /// Returns `2` if the result is unknown. @@ -3717,10 +2933,7 @@ pub const fn ptr_guaranteed_cmp(ptr: *const T, other: *const T) -> u8 { /// which is UB if any of their inputs are `undef`.) #[rustc_nounwind] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const unsafe fn raw_eq(_a: &T, _b: &T) -> bool { - unimplemented!() -} +pub const unsafe fn raw_eq(_a: &T, _b: &T) -> bool; /// Lexicographically compare `[left, left + bytes)` and `[right, right + bytes)` /// as unsigned bytes, returning negative if `left` is less, zero if all the @@ -3738,21 +2951,15 @@ pub const unsafe fn raw_eq(_a: &T, _b: &T) -> bool { /// [valid]: crate::ptr#safety #[rustc_nounwind] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const unsafe fn compare_bytes(_left: *const u8, _right: *const u8, _bytes: usize) -> i32 { - unimplemented!() -} +pub const unsafe fn compare_bytes(_left: *const u8, _right: *const u8, _bytes: usize) -> i32; /// See documentation of [`std::hint::black_box`] for details. /// /// [`std::hint::black_box`]: crate::hint::black_box #[rustc_nounwind] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_intrinsic_const_stable_indirect] -pub const fn black_box(_dummy: T) -> T { - unimplemented!() -} +pub const fn black_box(_dummy: T) -> T; /// Selects which function to call depending on the context. /// @@ -3808,7 +3015,6 @@ pub const fn black_box(_dummy: T) -> T { /// otherwise, that principle should not be violated. #[rustc_const_unstable(feature = "const_eval_select", issue = "124625")] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] pub const fn const_eval_select( _arg: ARG, _called_in_const: F, @@ -3816,10 +3022,7 @@ pub const fn const_eval_select( ) -> RET where G: FnOnce, - F: FnOnce, -{ - unreachable!() -} + F: FnOnce; /// A macro to make it easier to invoke const_eval_select. Use as follows: /// ```rust,ignore (just a macro example) @@ -4070,7 +3273,6 @@ pub const unsafe fn const_deallocate(_ptr: *mut u8, _size: usize, _align: usize) /// of not prematurely commiting at compile-time to whether contract /// checking is turned on, so that we can specify contracts in libstd /// and let an end user opt into turning them on. -#[cfg(not(bootstrap))] #[rustc_const_unstable(feature = "contracts_internals", issue = "128044" /* compiler-team#759 */)] #[unstable(feature = "contracts_internals", issue = "128044" /* compiler-team#759 */)] #[inline(always)] @@ -4086,7 +3288,6 @@ pub const fn contract_checks() -> bool { /// /// By default, if `contract_checks` is enabled, this will panic with no unwind if the condition /// returns false. -#[cfg(not(bootstrap))] #[unstable(feature = "contracts_internals", issue = "128044" /* compiler-team#759 */)] #[lang = "contract_check_requires"] #[rustc_intrinsic] @@ -4101,7 +3302,6 @@ pub fn contract_check_requires bool>(cond: C) { /// /// By default, if `contract_checks` is enabled, this will panic with no unwind if the condition /// returns false. -#[cfg(not(bootstrap))] #[unstable(feature = "contracts_internals", issue = "128044" /* compiler-team#759 */)] #[rustc_intrinsic] pub fn contract_check_ensures<'a, Ret, C: Fn(&'a Ret) -> bool>(ret: &'a Ret, cond: C) { @@ -4118,10 +3318,7 @@ pub fn contract_check_ensures<'a, Ret, C: Fn(&'a Ret) -> bool>(ret: &'a Ret, con #[rustc_nounwind] #[unstable(feature = "core_intrinsics", issue = "none")] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub unsafe fn vtable_size(_ptr: *const ()) -> usize { - unreachable!() -} +pub unsafe fn vtable_size(_ptr: *const ()) -> usize; /// The intrinsic will return the alignment stored in that vtable. /// @@ -4131,10 +3328,7 @@ pub unsafe fn vtable_size(_ptr: *const ()) -> usize { #[rustc_nounwind] #[unstable(feature = "core_intrinsics", issue = "none")] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub unsafe fn vtable_align(_ptr: *const ()) -> usize { - unreachable!() -} +pub unsafe fn vtable_align(_ptr: *const ()) -> usize; /// The size of a type in bytes. /// @@ -4151,10 +3345,7 @@ pub unsafe fn vtable_align(_ptr: *const ()) -> usize { #[unstable(feature = "core_intrinsics", issue = "none")] #[rustc_intrinsic_const_stable_indirect] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const fn size_of() -> usize { - unreachable!() -} +pub const fn size_of() -> usize; /// The minimum alignment of a type. /// @@ -4168,10 +3359,7 @@ pub const fn size_of() -> usize { #[unstable(feature = "core_intrinsics", issue = "none")] #[rustc_intrinsic_const_stable_indirect] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const fn min_align_of() -> usize { - unreachable!() -} +pub const fn min_align_of() -> usize; /// The preferred alignment of a type. /// @@ -4180,10 +3368,7 @@ pub const fn min_align_of() -> usize { #[rustc_nounwind] #[unstable(feature = "core_intrinsics", issue = "none")] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const unsafe fn pref_align_of() -> usize { - unreachable!() -} +pub const unsafe fn pref_align_of() -> usize; /// Returns the number of variants of the type `T` cast to a `usize`; /// if `T` has no variants, returns `0`. Uninhabited variants will be counted. @@ -4197,10 +3382,7 @@ pub const unsafe fn pref_align_of() -> usize { #[rustc_nounwind] #[unstable(feature = "core_intrinsics", issue = "none")] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const fn variant_count() -> usize { - unreachable!() -} +pub const fn variant_count() -> usize; /// The size of the referenced value in bytes. /// @@ -4212,11 +3394,8 @@ pub const fn variant_count() -> usize { #[rustc_nounwind] #[unstable(feature = "core_intrinsics", issue = "none")] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_intrinsic_const_stable_indirect] -pub const unsafe fn size_of_val(_ptr: *const T) -> usize { - unreachable!() -} +pub const unsafe fn size_of_val(_ptr: *const T) -> usize; /// The required alignment of the referenced value. /// @@ -4228,11 +3407,8 @@ pub const unsafe fn size_of_val(_ptr: *const T) -> usize { #[rustc_nounwind] #[unstable(feature = "core_intrinsics", issue = "none")] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_intrinsic_const_stable_indirect] -pub const unsafe fn min_align_of_val(_ptr: *const T) -> usize { - unreachable!() -} +pub const unsafe fn min_align_of_val(_ptr: *const T) -> usize; /// Gets a static string slice containing the name of a type. /// @@ -4245,10 +3421,7 @@ pub const unsafe fn min_align_of_val(_ptr: *const T) -> usize { #[rustc_nounwind] #[unstable(feature = "core_intrinsics", issue = "none")] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const fn type_name() -> &'static str { - unreachable!() -} +pub const fn type_name() -> &'static str; /// Gets an identifier which is globally unique to the specified type. This /// function will return the same value for a type regardless of whichever @@ -4263,10 +3436,7 @@ pub const fn type_name() -> &'static str { #[rustc_nounwind] #[unstable(feature = "core_intrinsics", issue = "none")] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const fn type_id() -> u128 { - unreachable!() -} +pub const fn type_id() -> u128; /// Lowers in MIR to `Rvalue::Aggregate` with `AggregateKind::RawPtr`. /// @@ -4277,12 +3447,7 @@ pub const fn type_id() -> u128 { #[unstable(feature = "core_intrinsics", issue = "none")] #[rustc_intrinsic_const_stable_indirect] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const fn aggregate_raw_ptr, D, M>(_data: D, _meta: M) -> P { - // To implement a fallback we'd have to assume the layout of the pointer, - // but the whole point of this intrinsic is that we shouldn't do that. - unreachable!() -} +pub const fn aggregate_raw_ptr, D, M>(_data: D, _meta: M) -> P; #[unstable(feature = "core_intrinsics", issue = "none")] pub trait AggregateRawPtr { @@ -4302,12 +3467,7 @@ impl AggregateRawPtr<*mut T> for *mut P { #[unstable(feature = "core_intrinsics", issue = "none")] #[rustc_intrinsic_const_stable_indirect] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const fn ptr_metadata + ?Sized, M>(_ptr: *const P) -> M { - // To implement a fallback we'd have to assume the layout of the pointer, - // but the whole point of this intrinsic is that we shouldn't do that. - unreachable!() -} +pub const fn ptr_metadata + ?Sized, M>(_ptr: *const P) -> M; // Some functions are defined here because they accidentally got made // available in this module on stable. See . @@ -4400,11 +3560,7 @@ pub const fn ptr_metadata + ?Sized, M>(_ptr: *cons /// [`Vec::append`]: ../../std/vec/struct.Vec.html#method.append #[doc(alias = "memcpy")] #[stable(feature = "rust1", since = "1.0.0")] -#[cfg_attr(bootstrap, rustc_allowed_through_unstable_modules)] -#[cfg_attr( - not(bootstrap), - rustc_allowed_through_unstable_modules = "import this function via `std::mem` instead" -)] +#[rustc_allowed_through_unstable_modules = "import this function via `std::mem` instead"] #[rustc_const_stable(feature = "const_intrinsic_copy", since = "1.83.0")] #[inline(always)] #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces @@ -4413,10 +3569,7 @@ pub const unsafe fn copy_nonoverlapping(src: *const T, dst: *mut T, count: us #[rustc_intrinsic_const_stable_indirect] #[rustc_nounwind] #[rustc_intrinsic] - #[rustc_intrinsic_must_be_overridden] - const unsafe fn copy_nonoverlapping(_src: *const T, _dst: *mut T, _count: usize) { - unreachable!() - } + const unsafe fn copy_nonoverlapping(_src: *const T, _dst: *mut T, _count: usize); ub_checks::assert_unsafe_precondition!( check_language_ub, @@ -4498,21 +3651,17 @@ pub const unsafe fn copy_nonoverlapping(src: *const T, dst: *mut T, count: us /// /// // SAFETY: Our precondition ensures the source is aligned and valid, /// // and `Vec::with_capacity` ensures that we have usable space to write them. -/// ptr::copy(ptr, dst.as_mut_ptr(), elts); +/// unsafe { ptr::copy(ptr, dst.as_mut_ptr(), elts); } /// /// // SAFETY: We created it with this much capacity earlier, /// // and the previous `copy` has initialized these elements. -/// dst.set_len(elts); +/// unsafe { dst.set_len(elts); } /// dst /// } /// ``` #[doc(alias = "memmove")] #[stable(feature = "rust1", since = "1.0.0")] -#[cfg_attr(bootstrap, rustc_allowed_through_unstable_modules)] -#[cfg_attr( - not(bootstrap), - rustc_allowed_through_unstable_modules = "import this function via `std::mem` instead" -)] +#[rustc_allowed_through_unstable_modules = "import this function via `std::mem` instead"] #[rustc_const_stable(feature = "const_intrinsic_copy", since = "1.83.0")] #[inline(always)] #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces @@ -4521,10 +3670,7 @@ pub const unsafe fn copy(src: *const T, dst: *mut T, count: usize) { #[rustc_intrinsic_const_stable_indirect] #[rustc_nounwind] #[rustc_intrinsic] - #[rustc_intrinsic_must_be_overridden] - const unsafe fn copy(_src: *const T, _dst: *mut T, _count: usize) { - unreachable!() - } + const unsafe fn copy(_src: *const T, _dst: *mut T, _count: usize); // SAFETY: the safety contract for `copy` must be upheld by the caller. unsafe { @@ -4595,11 +3741,7 @@ pub const unsafe fn copy(src: *const T, dst: *mut T, count: usize) { /// ``` #[doc(alias = "memset")] #[stable(feature = "rust1", since = "1.0.0")] -#[cfg_attr(bootstrap, rustc_allowed_through_unstable_modules)] -#[cfg_attr( - not(bootstrap), - rustc_allowed_through_unstable_modules = "import this function via `std::mem` instead" -)] +#[rustc_allowed_through_unstable_modules = "import this function via `std::mem` instead"] #[rustc_const_stable(feature = "const_ptr_write", since = "1.83.0")] #[inline(always)] #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces @@ -4608,10 +3750,7 @@ pub const unsafe fn write_bytes(dst: *mut T, val: u8, count: usize) { #[rustc_intrinsic_const_stable_indirect] #[rustc_nounwind] #[rustc_intrinsic] - #[rustc_intrinsic_must_be_overridden] - const unsafe fn write_bytes(_dst: *mut T, _val: u8, _count: usize) { - unreachable!() - } + const unsafe fn write_bytes(_dst: *mut T, _val: u8, _count: usize); // SAFETY: the safety contract for `write_bytes` must be upheld by the caller. unsafe { @@ -4639,10 +3778,7 @@ pub const unsafe fn write_bytes(dst: *mut T, val: u8, count: usize) { /// [`f16::min`] #[rustc_nounwind] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const fn minnumf16(_x: f16, _y: f16) -> f16 { - unimplemented!(); -} +pub const fn minnumf16(_x: f16, _y: f16) -> f16; /// Returns the minimum of two `f32` values. /// @@ -4656,10 +3792,7 @@ pub const fn minnumf16(_x: f16, _y: f16) -> f16 { #[rustc_nounwind] #[rustc_intrinsic_const_stable_indirect] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const fn minnumf32(_x: f32, _y: f32) -> f32 { - unimplemented!(); -} +pub const fn minnumf32(_x: f32, _y: f32) -> f32; /// Returns the minimum of two `f64` values. /// @@ -4673,10 +3806,7 @@ pub const fn minnumf32(_x: f32, _y: f32) -> f32 { #[rustc_nounwind] #[rustc_intrinsic_const_stable_indirect] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const fn minnumf64(_x: f64, _y: f64) -> f64 { - unimplemented!(); -} +pub const fn minnumf64(_x: f64, _y: f64) -> f64; /// Returns the minimum of two `f128` values. /// @@ -4689,10 +3819,7 @@ pub const fn minnumf64(_x: f64, _y: f64) -> f64 { /// [`f128::min`] #[rustc_nounwind] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const fn minnumf128(_x: f128, _y: f128) -> f128 { - unimplemented!(); -} +pub const fn minnumf128(_x: f128, _y: f128) -> f128; /// Returns the maximum of two `f16` values. /// @@ -4705,10 +3832,7 @@ pub const fn minnumf128(_x: f128, _y: f128) -> f128 { /// [`f16::max`] #[rustc_nounwind] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const fn maxnumf16(_x: f16, _y: f16) -> f16 { - unimplemented!(); -} +pub const fn maxnumf16(_x: f16, _y: f16) -> f16; /// Returns the maximum of two `f32` values. /// @@ -4722,10 +3846,7 @@ pub const fn maxnumf16(_x: f16, _y: f16) -> f16 { #[rustc_nounwind] #[rustc_intrinsic_const_stable_indirect] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const fn maxnumf32(_x: f32, _y: f32) -> f32 { - unimplemented!(); -} +pub const fn maxnumf32(_x: f32, _y: f32) -> f32; /// Returns the maximum of two `f64` values. /// @@ -4739,10 +3860,7 @@ pub const fn maxnumf32(_x: f32, _y: f32) -> f32 { #[rustc_nounwind] #[rustc_intrinsic_const_stable_indirect] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const fn maxnumf64(_x: f64, _y: f64) -> f64 { - unimplemented!(); -} +pub const fn maxnumf64(_x: f64, _y: f64) -> f64; /// Returns the maximum of two `f128` values. /// @@ -4755,10 +3873,7 @@ pub const fn maxnumf64(_x: f64, _y: f64) -> f64 { /// [`f128::max`] #[rustc_nounwind] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const fn maxnumf128(_x: f128, _y: f128) -> f128 { - unimplemented!(); -} +pub const fn maxnumf128(_x: f128, _y: f128) -> f128; /// Returns the absolute value of an `f16`. /// @@ -4766,10 +3881,7 @@ pub const fn maxnumf128(_x: f128, _y: f128) -> f128 { /// [`f16::abs`](../../std/primitive.f16.html#method.abs) #[rustc_nounwind] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const unsafe fn fabsf16(_x: f16) -> f16 { - unimplemented!(); -} +pub const unsafe fn fabsf16(_x: f16) -> f16; /// Returns the absolute value of an `f32`. /// @@ -4778,10 +3890,7 @@ pub const unsafe fn fabsf16(_x: f16) -> f16 { #[rustc_nounwind] #[rustc_intrinsic_const_stable_indirect] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const unsafe fn fabsf32(_x: f32) -> f32 { - unimplemented!(); -} +pub const unsafe fn fabsf32(_x: f32) -> f32; /// Returns the absolute value of an `f64`. /// @@ -4790,10 +3899,7 @@ pub const unsafe fn fabsf32(_x: f32) -> f32 { #[rustc_nounwind] #[rustc_intrinsic_const_stable_indirect] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const unsafe fn fabsf64(_x: f64) -> f64 { - unimplemented!(); -} +pub const unsafe fn fabsf64(_x: f64) -> f64; /// Returns the absolute value of an `f128`. /// @@ -4801,10 +3907,7 @@ pub const unsafe fn fabsf64(_x: f64) -> f64 { /// [`f128::abs`](../../std/primitive.f128.html#method.abs) #[rustc_nounwind] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const unsafe fn fabsf128(_x: f128) -> f128 { - unimplemented!(); -} +pub const unsafe fn fabsf128(_x: f128) -> f128; /// Copies the sign from `y` to `x` for `f16` values. /// @@ -4812,10 +3915,7 @@ pub const unsafe fn fabsf128(_x: f128) -> f128 { /// [`f16::copysign`](../../std/primitive.f16.html#method.copysign) #[rustc_nounwind] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const unsafe fn copysignf16(_x: f16, _y: f16) -> f16 { - unimplemented!(); -} +pub const unsafe fn copysignf16(_x: f16, _y: f16) -> f16; /// Copies the sign from `y` to `x` for `f32` values. /// @@ -4824,10 +3924,7 @@ pub const unsafe fn copysignf16(_x: f16, _y: f16) -> f16 { #[rustc_nounwind] #[rustc_intrinsic_const_stable_indirect] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const unsafe fn copysignf32(_x: f32, _y: f32) -> f32 { - unimplemented!(); -} +pub const unsafe fn copysignf32(_x: f32, _y: f32) -> f32; /// Copies the sign from `y` to `x` for `f64` values. /// /// The stabilized version of this intrinsic is @@ -4835,10 +3932,7 @@ pub const unsafe fn copysignf32(_x: f32, _y: f32) -> f32 { #[rustc_nounwind] #[rustc_intrinsic_const_stable_indirect] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const unsafe fn copysignf64(_x: f64, _y: f64) -> f64 { - unimplemented!(); -} +pub const unsafe fn copysignf64(_x: f64, _y: f64) -> f64; /// Copies the sign from `y` to `x` for `f128` values. /// @@ -4846,16 +3940,13 @@ pub const unsafe fn copysignf64(_x: f64, _y: f64) -> f64 { /// [`f128::copysign`](../../std/primitive.f128.html#method.copysign) #[rustc_nounwind] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const unsafe fn copysignf128(_x: f128, _y: f128) -> f128 { - unimplemented!(); -} +pub const unsafe fn copysignf128(_x: f128, _y: f128) -> f128; /// Inform Miri that a given pointer definitely has a certain alignment. #[cfg(miri)] #[rustc_allow_const_fn_unstable(const_eval_select)] pub(crate) const fn miri_promise_symbolic_alignment(ptr: *const (), align: usize) { - extern "Rust" { + unsafe extern "Rust" { /// Miri-provided extern function to promise that a given pointer is properly aligned for /// "symbolic" alignment checks. Will fail if the pointer is not actually aligned or `align` is /// not a power of two. Has no effect when alignment checks are concrete (which is the default). diff --git a/core/src/intrinsics/simd.rs b/core/src/intrinsics/simd.rs index e59d3aff37999..3881cf90ad729 100644 --- a/core/src/intrinsics/simd.rs +++ b/core/src/intrinsics/simd.rs @@ -10,11 +10,8 @@ /// /// `idx` must be in-bounds of the vector. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn simd_insert(_x: T, _idx: u32, _val: U) -> T { - unreachable!() -} +pub const unsafe fn simd_insert(_x: T, _idx: u32, _val: U) -> T; /// Extracts an element from a vector. /// @@ -24,41 +21,29 @@ pub unsafe fn simd_insert(_x: T, _idx: u32, _val: U) -> T { /// /// `idx` must be in-bounds of the vector. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn simd_extract(_x: T, _idx: u32) -> U { - unreachable!() -} +pub const unsafe fn simd_extract(_x: T, _idx: u32) -> U; /// Adds two simd vectors elementwise. /// /// `T` must be a vector of integer or floating point primitive types. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn simd_add(_x: T, _y: T) -> T { - unreachable!() -} +pub unsafe fn simd_add(_x: T, _y: T) -> T; /// Subtracts `rhs` from `lhs` elementwise. /// /// `T` must be a vector of integer or floating point primitive types. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn simd_sub(_lhs: T, _rhs: T) -> T { - unreachable!() -} +pub unsafe fn simd_sub(_lhs: T, _rhs: T) -> T; /// Multiplies two simd vectors elementwise. /// /// `T` must be a vector of integer or floating point primitive types. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn simd_mul(_x: T, _y: T) -> T { - unreachable!() -} +pub unsafe fn simd_mul(_x: T, _y: T) -> T; /// Divides `lhs` by `rhs` elementwise. /// @@ -68,11 +53,8 @@ pub unsafe fn simd_mul(_x: T, _y: T) -> T { /// For integers, `rhs` must not contain any zero elements. /// Additionally for signed integers, `::MIN / -1` is undefined behavior. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn simd_div(_lhs: T, _rhs: T) -> T { - unreachable!() -} +pub unsafe fn simd_div(_lhs: T, _rhs: T) -> T; /// Returns remainder of two vectors elementwise. /// @@ -82,11 +64,8 @@ pub unsafe fn simd_div(_lhs: T, _rhs: T) -> T { /// For integers, `rhs` must not contain any zero elements. /// Additionally for signed integers, `::MIN / -1` is undefined behavior. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn simd_rem(_lhs: T, _rhs: T) -> T { - unreachable!() -} +pub unsafe fn simd_rem(_lhs: T, _rhs: T) -> T; /// Shifts vector left elementwise, with UB on overflow. /// @@ -98,11 +77,8 @@ pub unsafe fn simd_rem(_lhs: T, _rhs: T) -> T { /// /// Each element of `rhs` must be less than `::BITS`. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn simd_shl(_lhs: T, _rhs: T) -> T { - unreachable!() -} +pub unsafe fn simd_shl(_lhs: T, _rhs: T) -> T; /// Shifts vector right elementwise, with UB on overflow. /// @@ -114,41 +90,29 @@ pub unsafe fn simd_shl(_lhs: T, _rhs: T) -> T { /// /// Each element of `rhs` must be less than `::BITS`. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn simd_shr(_lhs: T, _rhs: T) -> T { - unreachable!() -} +pub unsafe fn simd_shr(_lhs: T, _rhs: T) -> T; /// "Ands" vectors elementwise. /// /// `T` must be a vector of integer primitive types. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn simd_and(_x: T, _y: T) -> T { - unreachable!() -} +pub unsafe fn simd_and(_x: T, _y: T) -> T; /// "Ors" vectors elementwise. /// /// `T` must be a vector of integer primitive types. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn simd_or(_x: T, _y: T) -> T { - unreachable!() -} +pub unsafe fn simd_or(_x: T, _y: T) -> T; /// "Exclusive ors" vectors elementwise. /// /// `T` must be a vector of integer primitive types. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn simd_xor(_x: T, _y: T) -> T { - unreachable!() -} +pub unsafe fn simd_xor(_x: T, _y: T) -> T; /// Numerically casts a vector, elementwise. /// @@ -169,11 +133,8 @@ pub unsafe fn simd_xor(_x: T, _y: T) -> T { /// * Not be infinite /// * Be representable in the return type, after truncating off its fractional part #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn simd_cast(_x: T) -> U { - unreachable!() -} +pub unsafe fn simd_cast(_x: T) -> U; /// Numerically casts a vector, elementwise. /// @@ -187,11 +148,8 @@ pub unsafe fn simd_cast(_x: T) -> U { /// When casting integers to floats, the result is rounded. /// Otherwise, truncates or extends the value, maintaining the sign for signed integers. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn simd_as(_x: T) -> U { - unreachable!() -} +pub unsafe fn simd_as(_x: T) -> U; /// Negates a vector elementwise. /// @@ -199,21 +157,15 @@ pub unsafe fn simd_as(_x: T) -> U { /// /// Rust panics for `-::Min` due to overflow, but it is not UB with this intrinsic. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn simd_neg(_x: T) -> T { - unreachable!() -} +pub unsafe fn simd_neg(_x: T) -> T; /// Returns absolute value of a vector, elementwise. /// /// `T` must be a vector of floating-point primitive types. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn simd_fabs(_x: T) -> T { - unreachable!() -} +pub unsafe fn simd_fabs(_x: T) -> T; /// Returns the minimum of two vectors, elementwise. /// @@ -221,11 +173,8 @@ pub unsafe fn simd_fabs(_x: T) -> T { /// /// Follows IEEE-754 `minNum` semantics. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn simd_fmin(_x: T, _y: T) -> T { - unreachable!() -} +pub unsafe fn simd_fmin(_x: T, _y: T) -> T; /// Returns the maximum of two vectors, elementwise. /// @@ -233,11 +182,8 @@ pub unsafe fn simd_fmin(_x: T, _y: T) -> T { /// /// Follows IEEE-754 `maxNum` semantics. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn simd_fmax(_x: T, _y: T) -> T { - unreachable!() -} +pub unsafe fn simd_fmax(_x: T, _y: T) -> T; /// Tests elementwise equality of two vectors. /// @@ -247,11 +193,8 @@ pub unsafe fn simd_fmax(_x: T, _y: T) -> T { /// /// Returns `0` for false and `!0` for true. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn simd_eq(_x: T, _y: T) -> U { - unreachable!() -} +pub unsafe fn simd_eq(_x: T, _y: T) -> U; /// Tests elementwise inequality equality of two vectors. /// @@ -261,11 +204,8 @@ pub unsafe fn simd_eq(_x: T, _y: T) -> U { /// /// Returns `0` for false and `!0` for true. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn simd_ne(_x: T, _y: T) -> U { - unreachable!() -} +pub unsafe fn simd_ne(_x: T, _y: T) -> U; /// Tests if `x` is less than `y`, elementwise. /// @@ -275,11 +215,8 @@ pub unsafe fn simd_ne(_x: T, _y: T) -> U { /// /// Returns `0` for false and `!0` for true. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn simd_lt(_x: T, _y: T) -> U { - unreachable!() -} +pub unsafe fn simd_lt(_x: T, _y: T) -> U; /// Tests if `x` is less than or equal to `y`, elementwise. /// @@ -289,11 +226,8 @@ pub unsafe fn simd_lt(_x: T, _y: T) -> U { /// /// Returns `0` for false and `!0` for true. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn simd_le(_x: T, _y: T) -> U { - unreachable!() -} +pub unsafe fn simd_le(_x: T, _y: T) -> U; /// Tests if `x` is greater than `y`, elementwise. /// @@ -303,11 +237,8 @@ pub unsafe fn simd_le(_x: T, _y: T) -> U { /// /// Returns `0` for false and `!0` for true. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn simd_gt(_x: T, _y: T) -> U { - unreachable!() -} +pub unsafe fn simd_gt(_x: T, _y: T) -> U; /// Tests if `x` is greater than or equal to `y`, elementwise. /// @@ -317,11 +248,8 @@ pub unsafe fn simd_gt(_x: T, _y: T) -> U { /// /// Returns `0` for false and `!0` for true. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn simd_ge(_x: T, _y: T) -> U { - unreachable!() -} +pub unsafe fn simd_ge(_x: T, _y: T) -> U; /// Shuffles two vectors by const indices. /// @@ -336,11 +264,8 @@ pub unsafe fn simd_ge(_x: T, _y: T) -> U { /// is the concatenation of `x` and `y`. It is a compile-time error if `idx[i]` is out-of-bounds /// of `xy`. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn simd_shuffle(_x: T, _y: T, _idx: U) -> V { - unreachable!() -} +pub unsafe fn simd_shuffle(_x: T, _y: T, _idx: U) -> V; /// Reads a vector of pointers. /// @@ -360,11 +285,8 @@ pub unsafe fn simd_shuffle(_x: T, _y: T, _idx: U) -> V { /// /// `mask` must only contain `0` or `!0` values. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn simd_gather(_val: T, _ptr: U, _mask: V) -> T { - unreachable!() -} +pub unsafe fn simd_gather(_val: T, _ptr: U, _mask: V) -> T; /// Writes to a vector of pointers. /// @@ -387,11 +309,8 @@ pub unsafe fn simd_gather(_val: T, _ptr: U, _mask: V) -> T { /// /// `mask` must only contain `0` or `!0` values. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn simd_scatter(_val: T, _ptr: U, _mask: V) { - unreachable!() -} +pub unsafe fn simd_scatter(_val: T, _ptr: U, _mask: V); /// Reads a vector of pointers. /// @@ -413,11 +332,8 @@ pub unsafe fn simd_scatter(_val: T, _ptr: U, _mask: V) { /// /// `mask` must only contain `0` or `!0` values. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn simd_masked_load(_mask: V, _ptr: U, _val: T) -> T { - unreachable!() -} +pub unsafe fn simd_masked_load(_mask: V, _ptr: U, _val: T) -> T; /// Writes to a vector of pointers. /// @@ -438,21 +354,15 @@ pub unsafe fn simd_masked_load(_mask: V, _ptr: U, _val: T) -> T { /// /// `mask` must only contain `0` or `!0` values. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn simd_masked_store(_mask: V, _ptr: U, _val: T) { - unreachable!() -} +pub unsafe fn simd_masked_store(_mask: V, _ptr: U, _val: T); /// Adds two simd vectors elementwise, with saturation. /// /// `T` must be a vector of integer primitive types. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn simd_saturating_add(_x: T, _y: T) -> T { - unreachable!() -} +pub unsafe fn simd_saturating_add(_x: T, _y: T) -> T; /// Subtracts two simd vectors elementwise, with saturation. /// @@ -460,11 +370,8 @@ pub unsafe fn simd_saturating_add(_x: T, _y: T) -> T { /// /// Subtract `rhs` from `lhs`. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn simd_saturating_sub(_lhs: T, _rhs: T) -> T { - unreachable!() -} +pub unsafe fn simd_saturating_sub(_lhs: T, _rhs: T) -> T; /// Adds elements within a vector from left to right. /// @@ -474,11 +381,8 @@ pub unsafe fn simd_saturating_sub(_lhs: T, _rhs: T) -> T { /// /// Starting with the value `y`, add the elements of `x` and accumulate. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn simd_reduce_add_ordered(_x: T, _y: U) -> U { - unreachable!() -} +pub unsafe fn simd_reduce_add_ordered(_x: T, _y: U) -> U; /// Adds elements within a vector in arbitrary order. May also be re-associated with /// unordered additions on the inputs/outputs. @@ -487,11 +391,8 @@ pub unsafe fn simd_reduce_add_ordered(_x: T, _y: U) -> U { /// /// `U` must be the element type of `T`. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn simd_reduce_add_unordered(_x: T) -> U { - unreachable!() -} +pub unsafe fn simd_reduce_add_unordered(_x: T) -> U; /// Multiplies elements within a vector from left to right. /// @@ -501,11 +402,8 @@ pub unsafe fn simd_reduce_add_unordered(_x: T) -> U { /// /// Starting with the value `y`, multiply the elements of `x` and accumulate. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn simd_reduce_mul_ordered(_x: T, _y: U) -> U { - unreachable!() -} +pub unsafe fn simd_reduce_mul_ordered(_x: T, _y: U) -> U; /// Multiplies elements within a vector in arbitrary order. May also be re-associated with /// unordered additions on the inputs/outputs. @@ -514,11 +412,8 @@ pub unsafe fn simd_reduce_mul_ordered(_x: T, _y: U) -> U { /// /// `U` must be the element type of `T`. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn simd_reduce_mul_unordered(_x: T) -> U { - unreachable!() -} +pub unsafe fn simd_reduce_mul_unordered(_x: T) -> U; /// Checks if all mask values are true. /// @@ -527,11 +422,8 @@ pub unsafe fn simd_reduce_mul_unordered(_x: T) -> U { /// # Safety /// `x` must contain only `0` or `!0`. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn simd_reduce_all(_x: T) -> bool { - unreachable!() -} +pub unsafe fn simd_reduce_all(_x: T) -> bool; /// Checks if any mask value is true. /// @@ -540,11 +432,8 @@ pub unsafe fn simd_reduce_all(_x: T) -> bool { /// # Safety /// `x` must contain only `0` or `!0`. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn simd_reduce_any(_x: T) -> bool { - unreachable!() -} +pub unsafe fn simd_reduce_any(_x: T) -> bool; /// Returns the maximum element of a vector. /// @@ -554,11 +443,8 @@ pub unsafe fn simd_reduce_any(_x: T) -> bool { /// /// For floating-point values, uses IEEE-754 `maxNum`. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn simd_reduce_max(_x: T) -> U { - unreachable!() -} +pub unsafe fn simd_reduce_max(_x: T) -> U; /// Returns the minimum element of a vector. /// @@ -568,11 +454,8 @@ pub unsafe fn simd_reduce_max(_x: T) -> U { /// /// For floating-point values, uses IEEE-754 `minNum`. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn simd_reduce_min(_x: T) -> U { - unreachable!() -} +pub unsafe fn simd_reduce_min(_x: T) -> U; /// Logical "ands" all elements together. /// @@ -580,11 +463,8 @@ pub unsafe fn simd_reduce_min(_x: T) -> U { /// /// `U` must be the element type of `T`. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn simd_reduce_and(_x: T) -> U { - unreachable!() -} +pub unsafe fn simd_reduce_and(_x: T) -> U; /// Logical "ors" all elements together. /// @@ -592,11 +472,8 @@ pub unsafe fn simd_reduce_and(_x: T) -> U { /// /// `U` must be the element type of `T`. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn simd_reduce_or(_x: T) -> U { - unreachable!() -} +pub unsafe fn simd_reduce_or(_x: T) -> U; /// Logical "exclusive ors" all elements together. /// @@ -604,11 +481,8 @@ pub unsafe fn simd_reduce_or(_x: T) -> U { /// /// `U` must be the element type of `T`. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn simd_reduce_xor(_x: T) -> U { - unreachable!() -} +pub unsafe fn simd_reduce_xor(_x: T) -> U; /// Truncates an integer vector to a bitmask. /// @@ -644,11 +518,8 @@ pub unsafe fn simd_reduce_xor(_x: T) -> U { /// # Safety /// `x` must contain only `0` and `!0`. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn simd_bitmask(_x: T) -> U { - unreachable!() -} +pub unsafe fn simd_bitmask(_x: T) -> U; /// Selects elements from a mask. /// @@ -663,11 +534,8 @@ pub unsafe fn simd_bitmask(_x: T) -> U { /// # Safety /// `mask` must only contain `0` and `!0`. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn simd_select(_mask: M, _if_true: T, _if_false: T) -> T { - unreachable!() -} +pub unsafe fn simd_select(_mask: M, _if_true: T, _if_false: T) -> T; /// Selects elements from a bitmask. /// @@ -684,11 +552,8 @@ pub unsafe fn simd_select(_mask: M, _if_true: T, _if_false: T) -> T { /// # Safety /// Padding bits must be all zero. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn simd_select_bitmask(_m: M, _yes: T, _no: T) -> T { - unreachable!() -} +pub unsafe fn simd_select_bitmask(_m: M, _yes: T, _no: T) -> T; /// Calculates the offset from a pointer vector elementwise, potentially /// wrapping. @@ -699,21 +564,15 @@ pub unsafe fn simd_select_bitmask(_m: M, _yes: T, _no: T) -> T { /// /// Operates as if by `::wrapping_offset`. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn simd_arith_offset(_ptr: T, _offset: U) -> T { - unreachable!() -} +pub unsafe fn simd_arith_offset(_ptr: T, _offset: U) -> T; /// Casts a vector of pointers. /// /// `T` and `U` must be vectors of pointers with the same number of elements. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn simd_cast_ptr(_ptr: T) -> U { - unreachable!() -} +pub unsafe fn simd_cast_ptr(_ptr: T) -> U; /// Exposes a vector of pointers as a vector of addresses. /// @@ -721,11 +580,8 @@ pub unsafe fn simd_cast_ptr(_ptr: T) -> U { /// /// `U` must be a vector of `usize` with the same length as `T`. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn simd_expose_provenance(_ptr: T) -> U { - unreachable!() -} +pub unsafe fn simd_expose_provenance(_ptr: T) -> U; /// Creates a vector of pointers from a vector of addresses. /// @@ -733,123 +589,87 @@ pub unsafe fn simd_expose_provenance(_ptr: T) -> U { /// /// `U` must be a vector of pointers, with the same length as `T`. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn simd_with_exposed_provenance(_addr: T) -> U { - unreachable!() -} +pub unsafe fn simd_with_exposed_provenance(_addr: T) -> U; /// Swaps bytes of each element. /// /// `T` must be a vector of integers. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn simd_bswap(_x: T) -> T { - unreachable!() -} +pub unsafe fn simd_bswap(_x: T) -> T; /// Reverses bits of each element. /// /// `T` must be a vector of integers. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn simd_bitreverse(_x: T) -> T { - unreachable!() -} +pub unsafe fn simd_bitreverse(_x: T) -> T; /// Counts the leading zeros of each element. /// /// `T` must be a vector of integers. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn simd_ctlz(_x: T) -> T { - unreachable!() -} +pub unsafe fn simd_ctlz(_x: T) -> T; /// Counts the number of ones in each element. /// /// `T` must be a vector of integers. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn simd_ctpop(_x: T) -> T { - unreachable!() -} +pub unsafe fn simd_ctpop(_x: T) -> T; /// Counts the trailing zeros of each element. /// /// `T` must be a vector of integers. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn simd_cttz(_x: T) -> T { - unreachable!() -} +pub unsafe fn simd_cttz(_x: T) -> T; /// Rounds up each element to the next highest integer-valued float. /// /// `T` must be a vector of floats. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn simd_ceil(_x: T) -> T { - unreachable!() -} +pub unsafe fn simd_ceil(_x: T) -> T; /// Rounds down each element to the next lowest integer-valued float. /// /// `T` must be a vector of floats. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn simd_floor(_x: T) -> T { - unreachable!() -} +pub unsafe fn simd_floor(_x: T) -> T; /// Rounds each element to the closest integer-valued float. /// Ties are resolved by rounding away from 0. /// /// `T` must be a vector of floats. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn simd_round(_x: T) -> T { - unreachable!() -} +pub unsafe fn simd_round(_x: T) -> T; /// Returns the integer part of each element as an integer-valued float. /// In other words, non-integer values are truncated towards zero. /// /// `T` must be a vector of floats. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn simd_trunc(_x: T) -> T { - unreachable!() -} +pub unsafe fn simd_trunc(_x: T) -> T; /// Takes the square root of each element. /// /// `T` must be a vector of floats. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn simd_fsqrt(_x: T) -> T { - unreachable!() -} +pub unsafe fn simd_fsqrt(_x: T) -> T; /// Computes `(x*y) + z` for each element, but without any intermediate rounding. /// /// `T` must be a vector of floats. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn simd_fma(_x: T, _y: T, _z: T) -> T { - unreachable!() -} +pub unsafe fn simd_fma(_x: T, _y: T, _z: T) -> T; /// Computes `(x*y) + z` for each element, non-deterministically executing either /// a fused multiply-add or two operations with rounding of the intermediate result. @@ -863,78 +683,54 @@ pub unsafe fn simd_fma(_x: T, _y: T, _z: T) -> T { /// /// `T` must be a vector of floats. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn simd_relaxed_fma(_x: T, _y: T, _z: T) -> T { - unreachable!() -} +pub unsafe fn simd_relaxed_fma(_x: T, _y: T, _z: T) -> T; // Computes the sine of each element. /// /// `T` must be a vector of floats. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn simd_fsin(_a: T) -> T { - unreachable!() -} +pub unsafe fn simd_fsin(_a: T) -> T; // Computes the cosine of each element. /// /// `T` must be a vector of floats. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn simd_fcos(_a: T) -> T { - unreachable!() -} +pub unsafe fn simd_fcos(_a: T) -> T; // Computes the exponential function of each element. /// /// `T` must be a vector of floats. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn simd_fexp(_a: T) -> T { - unreachable!() -} +pub unsafe fn simd_fexp(_a: T) -> T; // Computes 2 raised to the power of each element. /// /// `T` must be a vector of floats. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn simd_fexp2(_a: T) -> T { - unreachable!() -} +pub unsafe fn simd_fexp2(_a: T) -> T; // Computes the base 10 logarithm of each element. /// /// `T` must be a vector of floats. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn simd_flog10(_a: T) -> T { - unreachable!() -} +pub unsafe fn simd_flog10(_a: T) -> T; // Computes the base 2 logarithm of each element. /// /// `T` must be a vector of floats. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn simd_flog2(_a: T) -> T { - unreachable!() -} +pub unsafe fn simd_flog2(_a: T) -> T; // Computes the natural logarithm of each element. /// /// `T` must be a vector of floats. #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] #[rustc_nounwind] -pub unsafe fn simd_flog(_a: T) -> T { - unreachable!() -} +pub unsafe fn simd_flog(_a: T) -> T; diff --git a/core/src/iter/adapters/zip.rs b/core/src/iter/adapters/zip.rs index 0c38811590877..8090c98e7edb7 100644 --- a/core/src/iter/adapters/zip.rs +++ b/core/src/iter/adapters/zip.rs @@ -556,13 +556,13 @@ impl A>(gen: F) -> OnceWith { - OnceWith { gen: Some(gen) } +pub fn once_with A>(make: F) -> OnceWith { + OnceWith { make: Some(make) } } /// An iterator that yields a single element of type `A` by @@ -70,13 +70,13 @@ pub fn once_with A>(gen: F) -> OnceWith { #[derive(Clone)] #[stable(feature = "iter_once_with", since = "1.43.0")] pub struct OnceWith { - gen: Option, + make: Option, } #[stable(feature = "iter_once_with_debug", since = "1.68.0")] impl fmt::Debug for OnceWith { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - if self.gen.is_some() { + if self.make.is_some() { f.write_str("OnceWith(Some(_))") } else { f.write_str("OnceWith(None)") @@ -90,13 +90,13 @@ impl A> Iterator for OnceWith { #[inline] fn next(&mut self) -> Option { - let f = self.gen.take()?; + let f = self.make.take()?; Some(f()) } #[inline] fn size_hint(&self) -> (usize, Option) { - self.gen.iter().size_hint() + self.make.iter().size_hint() } } @@ -110,7 +110,7 @@ impl A> DoubleEndedIterator for OnceWith { #[stable(feature = "iter_once_with", since = "1.43.0")] impl A> ExactSizeIterator for OnceWith { fn len(&self) -> usize { - self.gen.iter().len() + self.make.iter().len() } } diff --git a/core/src/lib.rs b/core/src/lib.rs index 49ce1bbcf3980..db68f472c42f6 100644 --- a/core/src/lib.rs +++ b/core/src/lib.rs @@ -192,7 +192,6 @@ #![feature(staged_api)] #![feature(stmt_expr_attributes)] #![feature(strict_provenance_lints)] -#![feature(target_feature_11)] #![feature(trait_alias)] #![feature(transparent_unions)] #![feature(try_blocks)] @@ -248,7 +247,6 @@ pub mod autodiff { pub use crate::macros::builtin::autodiff; } -#[cfg(not(bootstrap))] #[unstable(feature = "contracts", issue = "128044")] pub mod contracts; diff --git a/core/src/macros/mod.rs b/core/src/macros/mod.rs index 4c6fd196bd31c..16200184422b9 100644 --- a/core/src/macros/mod.rs +++ b/core/src/macros/mod.rs @@ -196,95 +196,6 @@ pub macro assert_matches { }, } -/// A macro for defining `#[cfg]` match-like statements. -/// -/// It is similar to the `if/elif` C preprocessor macro by allowing definition of a cascade of -/// `#[cfg]` cases, emitting the implementation which matches first. -/// -/// This allows you to conveniently provide a long list `#[cfg]`'d blocks of code -/// without having to rewrite each clause multiple times. -/// -/// Trailing `_` wildcard match arms are **optional** and they indicate a fallback branch when -/// all previous declarations do not evaluate to true. -/// -/// # Example -/// -/// ``` -/// #![feature(cfg_match)] -/// -/// cfg_match! { -/// cfg(unix) => { -/// fn foo() { /* unix specific functionality */ } -/// } -/// cfg(target_pointer_width = "32") => { -/// fn foo() { /* non-unix, 32-bit functionality */ } -/// } -/// _ => { -/// fn foo() { /* fallback implementation */ } -/// } -/// } -/// ``` -#[cfg(bootstrap)] -#[unstable(feature = "cfg_match", issue = "115585")] -#[rustc_diagnostic_item = "cfg_match"] -pub macro cfg_match { - // with a final wildcard - ( - $(cfg($initial_meta:meta) => { $($initial_tokens:tt)* })+ - _ => { $($extra_tokens:tt)* } - ) => { - cfg_match! { - @__items (); - $((($initial_meta) ($($initial_tokens)*)),)+ - (() ($($extra_tokens)*)), - } - }, - - // without a final wildcard - ( - $(cfg($extra_meta:meta) => { $($extra_tokens:tt)* })* - ) => { - cfg_match! { - @__items (); - $((($extra_meta) ($($extra_tokens)*)),)* - } - }, - - // Internal and recursive macro to emit all the items - // - // Collects all the previous cfgs in a list at the beginning, so they can be - // negated. After the semicolon is all the remaining items. - (@__items ($($_:meta,)*);) => {}, - ( - @__items ($($no:meta,)*); - (($($yes:meta)?) ($($tokens:tt)*)), - $($rest:tt,)* - ) => { - // Emit all items within one block, applying an appropriate #[cfg]. The - // #[cfg] will require all `$yes` matchers specified and must also negate - // all previous matchers. - #[cfg(all( - $($yes,)? - not(any($($no),*)) - ))] - cfg_match! { @__identity $($tokens)* } - - // Recurse to emit all other items in `$rest`, and when we do so add all - // our `$yes` matchers to the list of `$no` matchers as future emissions - // will have to negate everything we just matched as well. - cfg_match! { - @__items ($($no,)* $($yes,)?); - $($rest,)* - } - }, - - // Internal macro to make __apply work out right for different match types, - // because of how macros match/expand stuff. - (@__identity $($tokens:tt)*) => { - $($tokens)* - } -} - /// A macro for defining `#[cfg]` match-like statements. /// /// It is similar to the `if/elif` C preprocessor macro by allowing definition of a cascade of @@ -324,7 +235,6 @@ pub macro cfg_match { /// _ => { "Behind every successful diet is an unwatched pizza" } /// }}; /// ``` -#[cfg(not(bootstrap))] #[unstable(feature = "cfg_match", issue = "115585")] #[rustc_diagnostic_item = "cfg_match"] pub macro cfg_match { @@ -1782,7 +1692,6 @@ pub(crate) mod builtin { /// The attribute carries an argument token-tree which is /// eventually parsed as a unary closure expression that is /// invoked on a reference to the return value. - #[cfg(not(bootstrap))] #[unstable(feature = "contracts", issue = "128044")] #[allow_internal_unstable(contracts_internals)] #[rustc_builtin_macro] @@ -1795,7 +1704,6 @@ pub(crate) mod builtin { /// The attribute carries an argument token-tree which is /// eventually parsed as an boolean expression with access to the /// function's formal parameters - #[cfg(not(bootstrap))] #[unstable(feature = "contracts", issue = "128044")] #[allow_internal_unstable(contracts_internals)] #[rustc_builtin_macro] diff --git a/core/src/marker.rs b/core/src/marker.rs index 1a8ef20dd7b9d..b0571bf7247af 100644 --- a/core/src/marker.rs +++ b/core/src/marker.rs @@ -453,6 +453,23 @@ impl Copy for ! {} #[stable(feature = "rust1", since = "1.0.0")] impl Copy for &T {} +/// Marker trait for the types that are allowed in union fields, unsafe fields, +/// and unsafe binder types. +/// +/// Implemented for: +/// * `&T`, `&mut T` for all `T`, +/// * `ManuallyDrop` for all `T`, +/// * tuples and arrays whose elements implement `BikeshedGuaranteedNoDrop`, +/// * or otherwise, all types that are `Copy`. +/// +/// Notably, this doesn't include all trivially-destructible types for semver +/// reasons. +/// +/// Bikeshed name for now. +#[unstable(feature = "bikeshed_guaranteed_no_drop", issue = "none")] +#[lang = "bikeshed_guaranteed_no_drop"] +pub trait BikeshedGuaranteedNoDrop {} + /// Types for which it is safe to share references between threads. /// /// This trait is automatically implemented when the compiler determines @@ -1284,8 +1301,22 @@ pub trait FnPtr: Copy + Clone { /// } /// ``` #[rustc_builtin_macro(CoercePointee, attributes(pointee))] -#[allow_internal_unstable(dispatch_from_dyn, coerce_unsized, unsize)] +#[allow_internal_unstable(dispatch_from_dyn, coerce_unsized, unsize, coerce_pointee_validated)] +#[cfg_attr(not(test), rustc_diagnostic_item = "CoercePointee")] #[unstable(feature = "derive_coerce_pointee", issue = "123430")] pub macro CoercePointee($item:item) { /* compiler built-in */ } + +/// A trait that is implemented for ADTs with `derive(CoercePointee)` so that +/// the compiler can enforce the derive impls are valid post-expansion, since +/// the derive has stricter requirements than if the impls were written by hand. +/// +/// This trait is not intended to be implemented by users or used other than +/// validation, so it should never be stabilized. +#[lang = "coerce_pointee_validated"] +#[unstable(feature = "coerce_pointee_validated", issue = "none")] +#[doc(hidden)] +pub trait CoercePointeeValidated { + /* compiler built-in */ +} diff --git a/core/src/mem/maybe_uninit.rs b/core/src/mem/maybe_uninit.rs index 0d8c3ef906bf0..067371c1b58ab 100644 --- a/core/src/mem/maybe_uninit.rs +++ b/core/src/mem/maybe_uninit.rs @@ -98,7 +98,7 @@ use crate::{fmt, intrinsics, ptr, slice}; /// /// unsafe fn make_vec(out: *mut Vec) { /// // `write` does not drop the old contents, which is important. -/// out.write(vec![1, 2, 3]); +/// unsafe { out.write(vec![1, 2, 3]); } /// } /// /// let mut v = MaybeUninit::uninit(); @@ -331,42 +331,6 @@ impl MaybeUninit { MaybeUninit { uninit: () } } - /// Creates a new array of `MaybeUninit` items, in an uninitialized state. - /// - /// Note: in a future Rust version this method may become unnecessary - /// when Rust allows - /// [inline const expressions](https://github.com/rust-lang/rust/issues/76001). - /// The example below could then use `let mut buf = [const { MaybeUninit::::uninit() }; 32];`. - /// - /// # Examples - /// - /// ```no_run - /// #![feature(maybe_uninit_uninit_array, maybe_uninit_slice)] - /// - /// use std::mem::MaybeUninit; - /// - /// extern "C" { - /// fn read_into_buffer(ptr: *mut u8, max_len: usize) -> usize; - /// } - /// - /// /// Returns a (possibly smaller) slice of data that was actually read - /// fn read(buf: &mut [MaybeUninit]) -> &[u8] { - /// unsafe { - /// let len = read_into_buffer(buf.as_mut_ptr() as *mut u8, buf.len()); - /// buf[..len].assume_init_ref() - /// } - /// } - /// - /// let mut buf: [MaybeUninit; 32] = MaybeUninit::uninit_array(); - /// let data = read(&mut buf); - /// ``` - #[unstable(feature = "maybe_uninit_uninit_array", issue = "96097")] - #[must_use] - #[inline(always)] - pub const fn uninit_array() -> [Self; N] { - [const { MaybeUninit::uninit() }; N] - } - /// Creates a new `MaybeUninit` in an uninitialized state, with the memory being /// filled with `0` bytes. It depends on `T` whether that already makes for /// proper initialization. For example, `MaybeUninit::zeroed()` is initialized, @@ -844,7 +808,7 @@ impl MaybeUninit { /// # #![allow(unexpected_cfgs)] /// use std::mem::MaybeUninit; /// - /// # unsafe extern "C" fn initialize_buffer(buf: *mut [u8; 1024]) { *buf = [0; 1024] } + /// # unsafe extern "C" fn initialize_buffer(buf: *mut [u8; 1024]) { unsafe { *buf = [0; 1024] } } /// # #[cfg(FALSE)] /// extern "C" { /// /// Initializes *all* the bytes of the input buffer. @@ -1041,7 +1005,6 @@ impl MaybeUninit { /// Deprecated version of [`slice::assume_init_ref`]. #[unstable(feature = "maybe_uninit_slice", issue = "63569")] - #[rustc_const_unstable(feature = "maybe_uninit_slice", issue = "63569")] #[deprecated( note = "replaced by inherent assume_init_ref method; will eventually be removed", since = "1.83.0" @@ -1053,7 +1016,6 @@ impl MaybeUninit { /// Deprecated version of [`slice::assume_init_mut`]. #[unstable(feature = "maybe_uninit_slice", issue = "63569")] - #[rustc_const_unstable(feature = "maybe_uninit_slice", issue = "63569")] #[deprecated( note = "replaced by inherent assume_init_mut method; will eventually be removed", since = "1.83.0" @@ -1326,7 +1288,6 @@ impl [MaybeUninit] { /// /// [`write_clone_of_slice`]: slice::write_clone_of_slice #[unstable(feature = "maybe_uninit_write_slice", issue = "79995")] - #[rustc_const_unstable(feature = "maybe_uninit_write_slice", issue = "79995")] pub const fn write_copy_of_slice(&mut self, src: &[T]) -> &mut [T] where T: Copy, diff --git a/core/src/mem/transmutability.rs b/core/src/mem/transmutability.rs index 6a4f84c849cb1..7b920d7a777ca 100644 --- a/core/src/mem/transmutability.rs +++ b/core/src/mem/transmutability.rs @@ -32,7 +32,7 @@ use crate::marker::{ConstParamTy_, UnsizedConstParamTy}; /// src: ManuallyDrop::new(src), /// }; /// -/// let dst = transmute.dst; +/// let dst = unsafe { transmute.dst }; /// /// ManuallyDrop::into_inner(dst) /// } diff --git a/core/src/net/ip_addr.rs b/core/src/net/ip_addr.rs index b11ba05685352..8e4417ec461b8 100644 --- a/core/src/net/ip_addr.rs +++ b/core/src/net/ip_addr.rs @@ -451,6 +451,28 @@ impl IpAddr { IpAddr::V6(v6) => v6.to_canonical(), } } + + /// Returns the eight-bit integers this address consists of as a slice. + /// + /// # Examples + /// + /// ``` + /// #![feature(ip_as_octets)] + /// + /// use std::net::{Ipv4Addr, Ipv6Addr, IpAddr}; + /// + /// assert_eq!(IpAddr::V4(Ipv4Addr::LOCALHOST).as_octets(), &[127, 0, 0, 1]); + /// assert_eq!(IpAddr::V6(Ipv6Addr::LOCALHOST).as_octets(), + /// &[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) + /// ``` + #[unstable(feature = "ip_as_octets", issue = "137259")] + #[inline] + pub const fn as_octets(&self) -> &[u8] { + match self { + IpAddr::V4(ip) => ip.as_octets().as_slice(), + IpAddr::V6(ip) => ip.as_octets().as_slice(), + } + } } impl Ipv4Addr { @@ -616,6 +638,25 @@ impl Ipv4Addr { Ipv4Addr { octets } } + /// Returns the four eight-bit integers that make up this address + /// as a slice. + /// + /// # Examples + /// + /// ``` + /// #![feature(ip_as_octets)] + /// + /// use std::net::Ipv4Addr; + /// + /// let addr = Ipv4Addr::new(127, 0, 0, 1); + /// assert_eq!(addr.as_octets(), &[127, 0, 0, 1]); + /// ``` + #[unstable(feature = "ip_as_octets", issue = "137259")] + #[inline] + pub const fn as_octets(&self) -> &[u8; 4] { + &self.octets + } + /// Returns [`true`] for the special 'unspecified' address (`0.0.0.0`). /// /// This property is defined in _UNIX Network Programming, Second Edition_, @@ -2001,6 +2042,25 @@ impl Ipv6Addr { pub const fn from_octets(octets: [u8; 16]) -> Ipv6Addr { Ipv6Addr { octets } } + + /// Returns the sixteen eight-bit integers the IPv6 address consists of + /// as a slice. + /// + /// # Examples + /// + /// ``` + /// #![feature(ip_as_octets)] + /// + /// use std::net::Ipv6Addr; + /// + /// assert_eq!(Ipv6Addr::new(0xff00, 0, 0, 0, 0, 0, 0, 0).as_octets(), + /// &[255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) + /// ``` + #[unstable(feature = "ip_as_octets", issue = "137259")] + #[inline] + pub const fn as_octets(&self) -> &[u8; 16] { + &self.octets + } } /// Writes an Ipv6Addr, conforming to the canonical style described by diff --git a/core/src/num/f32.rs b/core/src/num/f32.rs index 4d42997369ffb..a200fd5318669 100644 --- a/core/src/num/f32.rs +++ b/core/src/num/f32.rs @@ -741,8 +741,8 @@ impl f32 { /// [`MAX`]: Self::MAX #[inline] #[doc(alias = "nextUp")] - #[stable(feature = "float_next_up_down", since = "CURRENT_RUSTC_VERSION")] - #[rustc_const_stable(feature = "float_next_up_down", since = "CURRENT_RUSTC_VERSION")] + #[stable(feature = "float_next_up_down", since = "1.86.0")] + #[rustc_const_stable(feature = "float_next_up_down", since = "1.86.0")] pub const fn next_up(self) -> Self { // Some targets violate Rust's assumption of IEEE semantics, e.g. by flushing // denormals to zero. This is in general unsound and unsupported, but here @@ -792,8 +792,8 @@ impl f32 { /// [`MAX`]: Self::MAX #[inline] #[doc(alias = "nextDown")] - #[stable(feature = "float_next_up_down", since = "CURRENT_RUSTC_VERSION")] - #[rustc_const_stable(feature = "float_next_up_down", since = "CURRENT_RUSTC_VERSION")] + #[stable(feature = "float_next_up_down", since = "1.86.0")] + #[rustc_const_stable(feature = "float_next_up_down", since = "1.86.0")] pub const fn next_down(self) -> Self { // Some targets violate Rust's assumption of IEEE semantics, e.g. by flushing // denormals to zero. This is in general unsound and unsupported, but here diff --git a/core/src/num/f64.rs b/core/src/num/f64.rs index 907971d303ffc..de63a462b61ac 100644 --- a/core/src/num/f64.rs +++ b/core/src/num/f64.rs @@ -758,8 +758,8 @@ impl f64 { /// [`MAX`]: Self::MAX #[inline] #[doc(alias = "nextUp")] - #[stable(feature = "float_next_up_down", since = "CURRENT_RUSTC_VERSION")] - #[rustc_const_stable(feature = "float_next_up_down", since = "CURRENT_RUSTC_VERSION")] + #[stable(feature = "float_next_up_down", since = "1.86.0")] + #[rustc_const_stable(feature = "float_next_up_down", since = "1.86.0")] pub const fn next_up(self) -> Self { // Some targets violate Rust's assumption of IEEE semantics, e.g. by flushing // denormals to zero. This is in general unsound and unsupported, but here @@ -809,8 +809,8 @@ impl f64 { /// [`MAX`]: Self::MAX #[inline] #[doc(alias = "nextDown")] - #[stable(feature = "float_next_up_down", since = "CURRENT_RUSTC_VERSION")] - #[rustc_const_stable(feature = "float_next_up_down", since = "CURRENT_RUSTC_VERSION")] + #[stable(feature = "float_next_up_down", since = "1.86.0")] + #[rustc_const_stable(feature = "float_next_up_down", since = "1.86.0")] pub const fn next_down(self) -> Self { // Some targets violate Rust's assumption of IEEE semantics, e.g. by flushing // denormals to zero. This is in general unsound and unsupported, but here diff --git a/core/src/num/int_macros.rs b/core/src/num/int_macros.rs index 96a290ad5a09d..7d99aaa173143 100644 --- a/core/src/num/int_macros.rs +++ b/core/src/num/int_macros.rs @@ -183,6 +183,52 @@ macro_rules! int_impl { (self as $UnsignedT).trailing_ones() } + /// Returns `self` with only the most significant bit set, or `0` if + /// the input is `0`. + /// + /// # Examples + /// + /// Basic usage: + /// + /// ``` + /// #![feature(isolate_most_least_significant_one)] + /// + #[doc = concat!("let n: ", stringify!($SelfT), " = 0b_01100100;")] + /// + /// assert_eq!(n.isolate_most_significant_one(), 0b_01000000); + #[doc = concat!("assert_eq!(0_", stringify!($SelfT), ".isolate_most_significant_one(), 0);")] + /// ``` + #[unstable(feature = "isolate_most_least_significant_one", issue = "136909")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] + #[inline(always)] + pub const fn isolate_most_significant_one(self) -> Self { + self & (((1 as $SelfT) << (<$SelfT>::BITS - 1)).wrapping_shr(self.leading_zeros())) + } + + /// Returns `self` with only the least significant bit set, or `0` if + /// the input is `0`. + /// + /// # Examples + /// + /// Basic usage: + /// + /// ``` + /// #![feature(isolate_most_least_significant_one)] + /// + #[doc = concat!("let n: ", stringify!($SelfT), " = 0b_01100100;")] + /// + /// assert_eq!(n.isolate_least_significant_one(), 0b_00000100); + #[doc = concat!("assert_eq!(0_", stringify!($SelfT), ".isolate_least_significant_one(), 0);")] + /// ``` + #[unstable(feature = "isolate_most_least_significant_one", issue = "136909")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] + #[inline(always)] + pub const fn isolate_least_significant_one(self) -> Self { + self & self.wrapping_neg() + } + /// Returns the bit pattern of `self` reinterpreted as an unsigned integer of the same size. /// /// This produces the same result as an `as` cast, but ensures that the bit-width remains @@ -193,13 +239,13 @@ macro_rules! int_impl { /// Basic usage: /// /// ``` - /// #![feature(integer_sign_cast)] /// #[doc = concat!("let n = -1", stringify!($SelfT), ";")] /// #[doc = concat!("assert_eq!(n.cast_unsigned(), ", stringify!($UnsignedT), "::MAX);")] /// ``` - #[unstable(feature = "integer_sign_cast", issue = "125882")] + #[stable(feature = "integer_sign_cast", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "integer_sign_cast", since = "CURRENT_RUSTC_VERSION")] #[must_use = "this returns the result of the operation, \ without modifying the original"] #[inline(always)] @@ -1306,11 +1352,11 @@ macro_rules! int_impl { /// /// Basic usage: /// ``` - /// #![feature(unbounded_shifts)] #[doc = concat!("assert_eq!(0x1", stringify!($SelfT), ".unbounded_shl(4), 0x10);")] #[doc = concat!("assert_eq!(0x1", stringify!($SelfT), ".unbounded_shl(129), 0);")] /// ``` - #[unstable(feature = "unbounded_shifts", issue = "129375")] + #[stable(feature = "unbounded_shifts", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "unbounded_shifts", since = "CURRENT_RUSTC_VERSION")] #[must_use = "this returns the result of the operation, \ without modifying the original"] #[inline] @@ -1428,12 +1474,12 @@ macro_rules! int_impl { /// /// Basic usage: /// ``` - /// #![feature(unbounded_shifts)] #[doc = concat!("assert_eq!(0x10", stringify!($SelfT), ".unbounded_shr(4), 0x1);")] #[doc = concat!("assert_eq!(0x10", stringify!($SelfT), ".unbounded_shr(129), 0);")] #[doc = concat!("assert_eq!(", stringify!($SelfT), "::MIN.unbounded_shr(129), -1);")] /// ``` - #[unstable(feature = "unbounded_shifts", issue = "129375")] + #[stable(feature = "unbounded_shifts", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "unbounded_shifts", since = "CURRENT_RUSTC_VERSION")] #[must_use = "this returns the result of the operation, \ without modifying the original"] #[inline] diff --git a/core/src/num/mod.rs b/core/src/num/mod.rs index 55f4ccd958e77..80a38a6013dd0 100644 --- a/core/src/num/mod.rs +++ b/core/src/num/mod.rs @@ -163,14 +163,14 @@ macro_rules! midpoint_impl { /// # Examples /// /// ``` - /// #![feature(num_midpoint_signed)] #[doc = concat!("assert_eq!(0", stringify!($SelfT), ".midpoint(4), 2);")] #[doc = concat!("assert_eq!((-1", stringify!($SelfT), ").midpoint(2), 0);")] #[doc = concat!("assert_eq!((-7", stringify!($SelfT), ").midpoint(0), -3);")] #[doc = concat!("assert_eq!(0", stringify!($SelfT), ".midpoint(-7), -3);")] #[doc = concat!("assert_eq!(0", stringify!($SelfT), ".midpoint(7), 3);")] /// ``` - #[unstable(feature = "num_midpoint_signed", issue = "110840")] + #[stable(feature = "num_midpoint_signed", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "num_midpoint_signed", since = "CURRENT_RUSTC_VERSION")] #[must_use = "this returns the result of the operation, \ without modifying the original"] #[inline] @@ -215,14 +215,14 @@ macro_rules! midpoint_impl { /// # Examples /// /// ``` - /// #![feature(num_midpoint_signed)] #[doc = concat!("assert_eq!(0", stringify!($SelfT), ".midpoint(4), 2);")] #[doc = concat!("assert_eq!((-1", stringify!($SelfT), ").midpoint(2), 0);")] #[doc = concat!("assert_eq!((-7", stringify!($SelfT), ").midpoint(0), -3);")] #[doc = concat!("assert_eq!(0", stringify!($SelfT), ".midpoint(-7), -3);")] #[doc = concat!("assert_eq!(0", stringify!($SelfT), ".midpoint(7), 3);")] /// ``` - #[unstable(feature = "num_midpoint_signed", issue = "110840")] + #[stable(feature = "num_midpoint_signed", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "num_midpoint_signed", since = "CURRENT_RUSTC_VERSION")] #[must_use = "this returns the result of the operation, \ without modifying the original"] #[inline] diff --git a/core/src/num/niche_types.rs b/core/src/num/niche_types.rs index 096713c318f8d..47ff4254e533b 100644 --- a/core/src/num/niche_types.rs +++ b/core/src/num/niche_types.rs @@ -32,6 +32,16 @@ macro_rules! define_valid_range_type { }; impl $name { + #[inline] + pub const fn new(val: $int) -> Option { + if (val as $uint) >= ($low as $uint) && (val as $uint) <= ($high as $uint) { + // SAFETY: just checked the inclusive range + Some(unsafe { $name(val) }) + } else { + None + } + } + /// Constructs an instance of this type from the underlying integer /// primitive without checking whether its zero. /// diff --git a/core/src/num/nonzero.rs b/core/src/num/nonzero.rs index a115acf42b126..a967b72c4fa9b 100644 --- a/core/src/num/nonzero.rs +++ b/core/src/num/nonzero.rs @@ -605,6 +605,70 @@ macro_rules! nonzero_integer { } } + /// Returns `self` with only the most significant bit set. + /// + /// # Example + /// + /// Basic usage: + /// + /// ``` + /// #![feature(isolate_most_least_significant_one)] + /// + /// # use core::num::NonZero; + /// # fn main() { test().unwrap(); } + /// # fn test() -> Option<()> { + #[doc = concat!("let a = NonZero::<", stringify!($Int), ">::new(0b_01100100)?;")] + #[doc = concat!("let b = NonZero::<", stringify!($Int), ">::new(0b_01000000)?;")] + /// + /// assert_eq!(a.isolate_most_significant_one(), b); + /// # Some(()) + /// # } + /// ``` + #[unstable(feature = "isolate_most_least_significant_one", issue = "136909")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] + #[inline(always)] + pub const fn isolate_most_significant_one(self) -> Self { + let n = self.get() & (((1 as $Int) << (<$Int>::BITS - 1)).wrapping_shr(self.leading_zeros())); + + // SAFETY: + // `self` is non-zero, so masking to preserve only the most + // significant set bit will result in a non-zero `n`. + unsafe { NonZero::new_unchecked(n) } + } + + /// Returns `self` with only the least significant bit set. + /// + /// # Example + /// + /// Basic usage: + /// + /// ``` + /// #![feature(isolate_most_least_significant_one)] + /// + /// # use core::num::NonZero; + /// # fn main() { test().unwrap(); } + /// # fn test() -> Option<()> { + #[doc = concat!("let a = NonZero::<", stringify!($Int), ">::new(0b_01100100)?;")] + #[doc = concat!("let b = NonZero::<", stringify!($Int), ">::new(0b_00000100)?;")] + /// + /// assert_eq!(a.isolate_least_significant_one(), b); + /// # Some(()) + /// # } + /// ``` + #[unstable(feature = "isolate_most_least_significant_one", issue = "136909")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] + #[inline(always)] + pub const fn isolate_least_significant_one(self) -> Self { + let n = self.get(); + let n = n & n.wrapping_neg(); + + // SAFETY: `self` is non-zero, so `self` with only its least + // significant set bit will remain non-zero. + unsafe { NonZero::new_unchecked(n) } + } + /// Returns the number of ones in the binary representation of `self`. /// /// # Examples @@ -612,8 +676,6 @@ macro_rules! nonzero_integer { /// Basic usage: /// /// ``` - /// #![feature(non_zero_count_ones)] - /// /// # use std::num::NonZero; /// # /// # fn main() { test().unwrap(); } @@ -627,7 +689,8 @@ macro_rules! nonzero_integer { /// # } /// ``` /// - #[unstable(feature = "non_zero_count_ones", issue = "120287")] + #[stable(feature = "non_zero_count_ones", since = "1.86.0")] + #[rustc_const_stable(feature = "non_zero_count_ones", since = "1.86.0")] #[doc(alias = "popcount")] #[doc(alias = "popcnt")] #[must_use = "this returns the result of the operation, \ @@ -1634,14 +1697,14 @@ macro_rules! nonzero_integer_signedness_dependent_methods { /// Basic usage: /// /// ``` - /// #![feature(integer_sign_cast)] /// # use std::num::NonZero; /// #[doc = concat!("let n = NonZero::<", stringify!($Int), ">::MAX;")] /// #[doc = concat!("assert_eq!(n.cast_signed(), NonZero::new(-1", stringify!($Sint), ").unwrap());")] /// ``` - #[unstable(feature = "integer_sign_cast", issue = "125882")] + #[stable(feature = "integer_sign_cast", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "integer_sign_cast", since = "CURRENT_RUSTC_VERSION")] #[must_use = "this returns the result of the operation, \ without modifying the original"] #[inline(always)] @@ -2073,14 +2136,14 @@ macro_rules! nonzero_integer_signedness_dependent_methods { /// Basic usage: /// /// ``` - /// #![feature(integer_sign_cast)] /// # use std::num::NonZero; /// #[doc = concat!("let n = NonZero::new(-1", stringify!($Int), ").unwrap();")] /// #[doc = concat!("assert_eq!(n.cast_unsigned(), NonZero::<", stringify!($Uint), ">::MAX);")] /// ``` - #[unstable(feature = "integer_sign_cast", issue = "125882")] + #[stable(feature = "integer_sign_cast", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "integer_sign_cast", since = "CURRENT_RUSTC_VERSION")] #[must_use = "this returns the result of the operation, \ without modifying the original"] #[inline(always)] diff --git a/core/src/num/uint_macros.rs b/core/src/num/uint_macros.rs index 29f6791ee6ad2..405c71121caad 100644 --- a/core/src/num/uint_macros.rs +++ b/core/src/num/uint_macros.rs @@ -213,6 +213,52 @@ macro_rules! uint_impl { (!self).trailing_zeros() } + /// Returns `self` with only the most significant bit set, or `0` if + /// the input is `0`. + /// + /// # Examples + /// + /// Basic usage: + /// + /// ``` + /// #![feature(isolate_most_least_significant_one)] + /// + #[doc = concat!("let n: ", stringify!($SelfT), " = 0b_01100100;")] + /// + /// assert_eq!(n.isolate_most_significant_one(), 0b_01000000); + #[doc = concat!("assert_eq!(0_", stringify!($SelfT), ".isolate_most_significant_one(), 0);")] + /// ``` + #[unstable(feature = "isolate_most_least_significant_one", issue = "136909")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] + #[inline(always)] + pub const fn isolate_most_significant_one(self) -> Self { + self & (((1 as $SelfT) << (<$SelfT>::BITS - 1)).wrapping_shr(self.leading_zeros())) + } + + /// Returns `self` with only the least significant bit set, or `0` if + /// the input is `0`. + /// + /// # Examples + /// + /// Basic usage: + /// + /// ``` + /// #![feature(isolate_most_least_significant_one)] + /// + #[doc = concat!("let n: ", stringify!($SelfT), " = 0b_01100100;")] + /// + /// assert_eq!(n.isolate_least_significant_one(), 0b_00000100); + #[doc = concat!("assert_eq!(0_", stringify!($SelfT), ".isolate_least_significant_one(), 0);")] + /// ``` + #[unstable(feature = "isolate_most_least_significant_one", issue = "136909")] + #[must_use = "this returns the result of the operation, \ + without modifying the original"] + #[inline(always)] + pub const fn isolate_least_significant_one(self) -> Self { + self & self.wrapping_neg() + } + /// Returns the bit pattern of `self` reinterpreted as a signed integer of the same size. /// /// This produces the same result as an `as` cast, but ensures that the bit-width remains @@ -223,13 +269,12 @@ macro_rules! uint_impl { /// Basic usage: /// /// ``` - /// #![feature(integer_sign_cast)] - /// #[doc = concat!("let n = ", stringify!($SelfT), "::MAX;")] /// #[doc = concat!("assert_eq!(n.cast_signed(), -1", stringify!($SignedT), ");")] /// ``` - #[unstable(feature = "integer_sign_cast", issue = "125882")] + #[stable(feature = "integer_sign_cast", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "integer_sign_cast", since = "CURRENT_RUSTC_VERSION")] #[must_use = "this returns the result of the operation, \ without modifying the original"] #[inline(always)] @@ -1568,11 +1613,11 @@ macro_rules! uint_impl { /// /// Basic usage: /// ``` - /// #![feature(unbounded_shifts)] #[doc = concat!("assert_eq!(0x1", stringify!($SelfT), ".unbounded_shl(4), 0x10);")] #[doc = concat!("assert_eq!(0x1", stringify!($SelfT), ".unbounded_shl(129), 0);")] /// ``` - #[unstable(feature = "unbounded_shifts", issue = "129375")] + #[stable(feature = "unbounded_shifts", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "unbounded_shifts", since = "CURRENT_RUSTC_VERSION")] #[must_use = "this returns the result of the operation, \ without modifying the original"] #[inline] @@ -1689,11 +1734,11 @@ macro_rules! uint_impl { /// /// Basic usage: /// ``` - /// #![feature(unbounded_shifts)] #[doc = concat!("assert_eq!(0x10", stringify!($SelfT), ".unbounded_shr(4), 0x1);")] #[doc = concat!("assert_eq!(0x10", stringify!($SelfT), ".unbounded_shr(129), 0);")] /// ``` - #[unstable(feature = "unbounded_shifts", issue = "129375")] + #[stable(feature = "unbounded_shifts", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "unbounded_shifts", since = "CURRENT_RUSTC_VERSION")] #[must_use = "this returns the result of the operation, \ without modifying the original"] #[inline] @@ -3275,14 +3320,14 @@ macro_rules! uint_impl { /// Basic usage: /// /// ``` - /// #![feature(unsigned_is_multiple_of)] #[doc = concat!("assert!(6_", stringify!($SelfT), ".is_multiple_of(2));")] #[doc = concat!("assert!(!5_", stringify!($SelfT), ".is_multiple_of(2));")] /// #[doc = concat!("assert!(0_", stringify!($SelfT), ".is_multiple_of(0));")] #[doc = concat!("assert!(!6_", stringify!($SelfT), ".is_multiple_of(0));")] /// ``` - #[unstable(feature = "unsigned_is_multiple_of", issue = "128101")] + #[stable(feature = "unsigned_is_multiple_of", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "unsigned_is_multiple_of", since = "CURRENT_RUSTC_VERSION")] #[must_use] #[inline] #[rustc_inherit_overflow_checks] diff --git a/core/src/ops/arith.rs b/core/src/ops/arith.rs index fe7ff2d9ede6a..54d79beca95ab 100644 --- a/core/src/ops/arith.rs +++ b/core/src/ops/arith.rs @@ -96,6 +96,7 @@ pub trait Add { macro_rules! add_impl { ($($t:ty)*) => ($( #[stable(feature = "rust1", since = "1.0.0")] + #[rustc_const_unstable(feature = "const_ops", issue = "90080")] impl const Add for $t { type Output = $t; diff --git a/core/src/ops/control_flow.rs b/core/src/ops/control_flow.rs index c8fcee5c140f5..8993e14fcd379 100644 --- a/core/src/ops/control_flow.rs +++ b/core/src/ops/control_flow.rs @@ -229,6 +229,27 @@ impl ControlFlow { } } +impl ControlFlow { + /// Extracts the value `T` that is wrapped by `ControlFlow`. + /// + /// # Examples + /// + /// ``` + /// #![feature(control_flow_into_value)] + /// use std::ops::ControlFlow; + /// + /// assert_eq!(ControlFlow::::Break(1024).into_value(), 1024); + /// assert_eq!(ControlFlow::::Continue(512).into_value(), 512); + /// ``` + #[unstable(feature = "control_flow_into_value", issue = "137461")] + #[rustc_allow_const_fn_unstable(const_precise_live_drops)] + pub const fn into_value(self) -> T { + match self { + ControlFlow::Continue(x) | ControlFlow::Break(x) => x, + } + } +} + /// These are used only as part of implementing the iterator adapters. /// They have mediocre names and non-obvious semantics, so aren't /// currently on a path to potential stabilization. diff --git a/core/src/ops/deref.rs b/core/src/ops/deref.rs index 11490ea2bfcb4..e74f5443ac2d8 100644 --- a/core/src/ops/deref.rs +++ b/core/src/ops/deref.rs @@ -150,6 +150,7 @@ pub trait Deref { } #[stable(feature = "rust1", since = "1.0.0")] +#[rustc_const_unstable(feature = "const_deref", issue = "88955")] impl const Deref for &T { type Target = T; @@ -163,6 +164,7 @@ impl const Deref for &T { impl !DerefMut for &T {} #[stable(feature = "rust1", since = "1.0.0")] +#[rustc_const_unstable(feature = "const_deref", issue = "88955")] impl const Deref for &mut T { type Target = T; @@ -273,6 +275,7 @@ pub trait DerefMut: ~const Deref { } #[stable(feature = "rust1", since = "1.0.0")] +#[rustc_const_unstable(feature = "const_deref", issue = "88955")] impl const DerefMut for &mut T { fn deref_mut(&mut self) -> &mut T { *self diff --git a/core/src/ops/mod.rs b/core/src/ops/mod.rs index 7b2ced2cc4bdc..627a875d9f724 100644 --- a/core/src/ops/mod.rs +++ b/core/src/ops/mod.rs @@ -182,6 +182,8 @@ pub use self::function::{Fn, FnMut, FnOnce}; #[stable(feature = "rust1", since = "1.0.0")] pub use self::index::{Index, IndexMut}; pub(crate) use self::index_range::IndexRange; +#[unstable(feature = "range_into_bounds", issue = "136903")] +pub use self::range::IntoBounds; #[stable(feature = "inclusive_range", since = "1.26.0")] pub use self::range::{Bound, RangeBounds, RangeInclusive, RangeToInclusive}; #[unstable(feature = "one_sided_range", issue = "69780")] diff --git a/core/src/ops/range.rs b/core/src/ops/range.rs index 42e07a0e51da4..e0c442e529215 100644 --- a/core/src/ops/range.rs +++ b/core/src/ops/range.rs @@ -771,13 +771,11 @@ pub trait RangeBounds { /// # Examples /// /// ``` - /// # fn main() { /// use std::ops::Bound::*; /// use std::ops::RangeBounds; /// /// assert_eq!((..10).start_bound(), Unbounded); /// assert_eq!((3..10).start_bound(), Included(&3)); - /// # } /// ``` #[stable(feature = "collections_range", since = "1.28.0")] fn start_bound(&self) -> Bound<&T>; @@ -789,13 +787,11 @@ pub trait RangeBounds { /// # Examples /// /// ``` - /// # fn main() { /// use std::ops::Bound::*; /// use std::ops::RangeBounds; /// /// assert_eq!((3..).end_bound(), Unbounded); /// assert_eq!((3..10).end_bound(), Excluded(&10)); - /// # } /// ``` #[stable(feature = "collections_range", since = "1.28.0")] fn end_bound(&self) -> Bound<&T>; @@ -829,6 +825,164 @@ pub trait RangeBounds { Unbounded => true, }) } + + /// Returns `true` if the range contains no items. + /// One-sided ranges (`RangeFrom`, etc) always return `true`. + /// + /// # Examples + /// + /// ``` + /// #![feature(range_bounds_is_empty)] + /// use std::ops::RangeBounds; + /// + /// assert!(!(3..).is_empty()); + /// assert!(!(..2).is_empty()); + /// assert!(!RangeBounds::is_empty(&(3..5))); + /// assert!( RangeBounds::is_empty(&(3..3))); + /// assert!( RangeBounds::is_empty(&(3..2))); + /// ``` + /// + /// The range is empty if either side is incomparable: + /// + /// ``` + /// #![feature(range_bounds_is_empty)] + /// use std::ops::RangeBounds; + /// + /// assert!(!RangeBounds::is_empty(&(3.0..5.0))); + /// assert!( RangeBounds::is_empty(&(3.0..f32::NAN))); + /// assert!( RangeBounds::is_empty(&(f32::NAN..5.0))); + /// ``` + /// + /// But never empty is either side is unbounded: + /// + /// ``` + /// #![feature(range_bounds_is_empty)] + /// use std::ops::RangeBounds; + /// + /// assert!(!(..0).is_empty()); + /// assert!(!(i32::MAX..).is_empty()); + /// assert!(!RangeBounds::::is_empty(&(..))); + /// ``` + /// + /// `(Excluded(a), Excluded(b))` is only empty if `a >= b`: + /// + /// ``` + /// #![feature(range_bounds_is_empty)] + /// use std::ops::Bound::*; + /// use std::ops::RangeBounds; + /// + /// assert!(!(Excluded(1), Excluded(3)).is_empty()); + /// assert!(!(Excluded(1), Excluded(2)).is_empty()); + /// assert!( (Excluded(1), Excluded(1)).is_empty()); + /// assert!( (Excluded(2), Excluded(1)).is_empty()); + /// assert!( (Excluded(3), Excluded(1)).is_empty()); + /// ``` + #[unstable(feature = "range_bounds_is_empty", issue = "137300")] + fn is_empty(&self) -> bool + where + T: PartialOrd, + { + !match (self.start_bound(), self.end_bound()) { + (Unbounded, _) | (_, Unbounded) => true, + (Included(start), Excluded(end)) + | (Excluded(start), Included(end)) + | (Excluded(start), Excluded(end)) => start < end, + (Included(start), Included(end)) => start <= end, + } + } +} + +/// Used to convert a range into start and end bounds, consuming the +/// range by value. +/// +/// `IntoBounds` is implemented by Rust’s built-in range types, produced +/// by range syntax like `..`, `a..`, `..b`, `..=c`, `d..e`, or `f..=g`. +#[unstable(feature = "range_into_bounds", issue = "136903")] +pub trait IntoBounds: RangeBounds { + /// Convert this range into the start and end bounds. + /// Returns `(start_bound, end_bound)`. + /// + /// # Examples + /// + /// ``` + /// #![feature(range_into_bounds)] + /// use std::ops::Bound::*; + /// use std::ops::IntoBounds; + /// + /// assert_eq!((0..5).into_bounds(), (Included(0), Excluded(5))); + /// assert_eq!((..=7).into_bounds(), (Unbounded, Included(7))); + /// ``` + fn into_bounds(self) -> (Bound, Bound); + + /// Compute the intersection of `self` and `other`. + /// + /// # Examples + /// + /// ``` + /// #![feature(range_into_bounds)] + /// use std::ops::Bound::*; + /// use std::ops::IntoBounds; + /// + /// assert_eq!((3..).intersect(..5), (Included(3), Excluded(5))); + /// assert_eq!((-12..387).intersect(0..256), (Included(0), Excluded(256))); + /// assert_eq!((1..5).intersect(..), (Included(1), Excluded(5))); + /// assert_eq!((1..=9).intersect(0..10), (Included(1), Included(9))); + /// assert_eq!((7..=13).intersect(8..13), (Included(8), Excluded(13))); + /// ``` + /// + /// Combine with `is_empty` to determine if two ranges overlap. + /// + /// ``` + /// #![feature(range_into_bounds)] + /// #![feature(range_bounds_is_empty)] + /// use std::ops::{RangeBounds, IntoBounds}; + /// + /// assert!(!(3..).intersect(..5).is_empty()); + /// assert!(!(-12..387).intersect(0..256).is_empty()); + /// assert!((1..5).intersect(6..).is_empty()); + /// ``` + fn intersect(self, other: R) -> (Bound, Bound) + where + Self: Sized, + T: Ord, + R: Sized + IntoBounds, + { + let (self_start, self_end) = IntoBounds::into_bounds(self); + let (other_start, other_end) = IntoBounds::into_bounds(other); + + let start = match (self_start, other_start) { + (Included(a), Included(b)) => Included(Ord::max(a, b)), + (Excluded(a), Excluded(b)) => Excluded(Ord::max(a, b)), + (Unbounded, Unbounded) => Unbounded, + + (x, Unbounded) | (Unbounded, x) => x, + + (Included(i), Excluded(e)) | (Excluded(e), Included(i)) => { + if i > e { + Included(i) + } else { + Excluded(e) + } + } + }; + let end = match (self_end, other_end) { + (Included(a), Included(b)) => Included(Ord::min(a, b)), + (Excluded(a), Excluded(b)) => Excluded(Ord::min(a, b)), + (Unbounded, Unbounded) => Unbounded, + + (x, Unbounded) | (Unbounded, x) => x, + + (Included(i), Excluded(e)) | (Excluded(e), Included(i)) => { + if i < e { + Included(i) + } else { + Excluded(e) + } + } + }; + + (start, end) + } } use self::Bound::{Excluded, Included, Unbounded}; @@ -843,6 +997,13 @@ impl RangeBounds for RangeFull { } } +#[unstable(feature = "range_into_bounds", issue = "136903")] +impl IntoBounds for RangeFull { + fn into_bounds(self) -> (Bound, Bound) { + (Unbounded, Unbounded) + } +} + #[stable(feature = "collections_range", since = "1.28.0")] impl RangeBounds for RangeFrom { fn start_bound(&self) -> Bound<&T> { @@ -853,6 +1014,13 @@ impl RangeBounds for RangeFrom { } } +#[unstable(feature = "range_into_bounds", issue = "136903")] +impl IntoBounds for RangeFrom { + fn into_bounds(self) -> (Bound, Bound) { + (Included(self.start), Unbounded) + } +} + #[stable(feature = "collections_range", since = "1.28.0")] impl RangeBounds for RangeTo { fn start_bound(&self) -> Bound<&T> { @@ -863,6 +1031,13 @@ impl RangeBounds for RangeTo { } } +#[unstable(feature = "range_into_bounds", issue = "136903")] +impl IntoBounds for RangeTo { + fn into_bounds(self) -> (Bound, Bound) { + (Unbounded, Excluded(self.end)) + } +} + #[stable(feature = "collections_range", since = "1.28.0")] impl RangeBounds for Range { fn start_bound(&self) -> Bound<&T> { @@ -873,6 +1048,13 @@ impl RangeBounds for Range { } } +#[unstable(feature = "range_into_bounds", issue = "136903")] +impl IntoBounds for Range { + fn into_bounds(self) -> (Bound, Bound) { + (Included(self.start), Excluded(self.end)) + } +} + #[stable(feature = "collections_range", since = "1.28.0")] impl RangeBounds for RangeInclusive { fn start_bound(&self) -> Bound<&T> { @@ -889,6 +1071,22 @@ impl RangeBounds for RangeInclusive { } } +#[unstable(feature = "range_into_bounds", issue = "136903")] +impl IntoBounds for RangeInclusive { + fn into_bounds(self) -> (Bound, Bound) { + ( + Included(self.start), + if self.exhausted { + // When the iterator is exhausted, we usually have start == end, + // but we want the range to appear empty, containing nothing. + Excluded(self.end) + } else { + Included(self.end) + }, + ) + } +} + #[stable(feature = "collections_range", since = "1.28.0")] impl RangeBounds for RangeToInclusive { fn start_bound(&self) -> Bound<&T> { @@ -899,6 +1097,13 @@ impl RangeBounds for RangeToInclusive { } } +#[unstable(feature = "range_into_bounds", issue = "136903")] +impl IntoBounds for RangeToInclusive { + fn into_bounds(self) -> (Bound, Bound) { + (Unbounded, Included(self.end)) + } +} + #[stable(feature = "collections_range", since = "1.28.0")] impl RangeBounds for (Bound, Bound) { fn start_bound(&self) -> Bound<&T> { @@ -918,6 +1123,13 @@ impl RangeBounds for (Bound, Bound) { } } +#[unstable(feature = "range_into_bounds", issue = "136903")] +impl IntoBounds for (Bound, Bound) { + fn into_bounds(self) -> (Bound, Bound) { + self + } +} + #[stable(feature = "collections_range", since = "1.28.0")] impl<'a, T: ?Sized + 'a> RangeBounds for (Bound<&'a T>, Bound<&'a T>) { fn start_bound(&self) -> Bound<&T> { diff --git a/core/src/panicking.rs b/core/src/panicking.rs index b97f19e1baa93..33ad59916e391 100644 --- a/core/src/panicking.rs +++ b/core/src/panicking.rs @@ -59,7 +59,7 @@ pub const fn panic_fmt(fmt: fmt::Arguments<'_>) -> ! { // NOTE This function never crosses the FFI boundary; it's a Rust-to-Rust call // that gets resolved to the `#[panic_handler]` function. - extern "Rust" { + unsafe extern "Rust" { #[lang = "panic_impl"] fn panic_impl(pi: &PanicInfo<'_>) -> !; } @@ -100,7 +100,7 @@ pub const fn panic_nounwind_fmt(fmt: fmt::Arguments<'_>, force_no_backtrace: boo // NOTE This function never crosses the FFI boundary; it's a Rust-to-Rust call // that gets resolved to the `#[panic_handler]` function. - extern "Rust" { + unsafe extern "Rust" { #[lang = "panic_impl"] fn panic_impl(pi: &PanicInfo<'_>) -> !; } @@ -294,7 +294,7 @@ fn panic_misaligned_pointer_dereference(required: usize, found: usize) -> ! { #[cfg_attr(not(feature = "panic_immediate_abort"), inline(never), cold, optimize(size))] #[cfg_attr(feature = "panic_immediate_abort", inline)] #[track_caller] -#[cfg_attr(not(bootstrap), lang = "panic_null_pointer_dereference")] // needed by codegen for panic on null pointer deref +#[lang = "panic_null_pointer_dereference"] // needed by codegen for panic on null pointer deref #[rustc_nounwind] // `CheckNull` MIR pass requires this function to never unwind fn panic_null_pointer_dereference() -> ! { if cfg!(feature = "panic_immediate_abort") { diff --git a/core/src/pin.rs b/core/src/pin.rs index 2a0bf89fcf7a9..7fcd19f67ee2d 100644 --- a/core/src/pin.rs +++ b/core/src/pin.rs @@ -1240,8 +1240,8 @@ impl Pin { /// points to is pinned, that is a violation of the API contract and may lead to undefined /// behavior in later (even safe) operations. /// - /// By using this method, you are also making a promise about the [`Deref`] and - /// [`DerefMut`] implementations of `Ptr`, if they exist. Most importantly, they + /// By using this method, you are also making a promise about the [`Deref`], + /// [`DerefMut`], and [`Drop`] implementations of `Ptr`, if they exist. Most importantly, they /// must not move out of their `self` arguments: `Pin::as_mut` and `Pin::as_ref` /// will call `DerefMut::deref_mut` and `Deref::deref` *on the pointer type `Ptr`* /// and expect these methods to uphold the pinning invariants. diff --git a/core/src/prelude/mod.rs b/core/src/prelude/mod.rs index 0ab97f5bbd50e..590ffd64b5bff 100644 --- a/core/src/prelude/mod.rs +++ b/core/src/prelude/mod.rs @@ -9,16 +9,7 @@ #![stable(feature = "core_prelude", since = "1.4.0")] -mod common; - -/// The first version of the prelude of The Rust Standard Library. -/// -/// See the [module-level documentation](self) for more. -#[stable(feature = "rust1", since = "1.0.0")] -pub mod v1 { - #[stable(feature = "rust1", since = "1.0.0")] - pub use super::common::*; -} +pub mod v1; /// The 2015 version of the core prelude. /// @@ -64,7 +55,8 @@ pub mod rust_2021 { #[stable(feature = "prelude_2024", since = "1.85.0")] pub mod rust_2024 { #[stable(feature = "rust1", since = "1.0.0")] - pub use super::common::*; + #[doc(no_inline)] + pub use super::v1::*; #[stable(feature = "prelude_2021", since = "1.55.0")] #[doc(no_inline)] diff --git a/core/src/prelude/common.rs b/core/src/prelude/v1.rs similarity index 97% rename from core/src/prelude/common.rs rename to core/src/prelude/v1.rs index 8b116cecb5295..50fd67e839557 100644 --- a/core/src/prelude/common.rs +++ b/core/src/prelude/v1.rs @@ -1,7 +1,9 @@ -//! Items common to the prelude of all editions. +//! The first version of the core prelude. //! //! See the [module-level documentation](super) for more. +#![stable(feature = "core_prelude", since = "1.4.0")] + // No formatting: this file is nothing but re-exports, and their order is worth preserving. #![cfg_attr(rustfmt, rustfmt::skip)] diff --git a/core/src/ptr/const_ptr.rs b/core/src/ptr/const_ptr.rs index 0c6eaf60d0480..8db620596dde7 100644 --- a/core/src/ptr/const_ptr.rs +++ b/core/src/ptr/const_ptr.rs @@ -723,14 +723,13 @@ impl *const T { /// to [`sub`](#method.sub)). The following are all equivalent, assuming /// that their safety preconditions are met: /// ```rust - /// # #![feature(ptr_sub_ptr)] - /// # unsafe fn blah(ptr: *const i32, origin: *const i32, count: usize) -> bool { - /// ptr.sub_ptr(origin) == count + /// # unsafe fn blah(ptr: *const i32, origin: *const i32, count: usize) -> bool { unsafe { + /// ptr.offset_from_unsigned(origin) == count /// # && /// origin.add(count) == ptr /// # && /// ptr.sub(count) == origin - /// # } + /// # } } /// ``` /// /// # Safety @@ -752,26 +751,24 @@ impl *const T { /// # Examples /// /// ``` - /// #![feature(ptr_sub_ptr)] - /// /// let a = [0; 5]; /// let ptr1: *const i32 = &a[1]; /// let ptr2: *const i32 = &a[3]; /// unsafe { - /// assert_eq!(ptr2.sub_ptr(ptr1), 2); + /// assert_eq!(ptr2.offset_from_unsigned(ptr1), 2); /// assert_eq!(ptr1.add(2), ptr2); /// assert_eq!(ptr2.sub(2), ptr1); - /// assert_eq!(ptr2.sub_ptr(ptr2), 0); + /// assert_eq!(ptr2.offset_from_unsigned(ptr2), 0); /// } /// /// // This would be incorrect, as the pointers are not correctly ordered: - /// // ptr1.sub_ptr(ptr2) + /// // ptr1.offset_from_unsigned(ptr2) /// ``` - #[unstable(feature = "ptr_sub_ptr", issue = "95892")] - #[rustc_const_unstable(feature = "const_ptr_sub_ptr", issue = "95892")] + #[stable(feature = "ptr_sub_ptr", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "const_ptr_sub_ptr", since = "CURRENT_RUSTC_VERSION")] #[inline] #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces - pub const unsafe fn sub_ptr(self, origin: *const T) -> usize + pub const unsafe fn offset_from_unsigned(self, origin: *const T) -> usize where T: Sized, { @@ -789,7 +786,7 @@ impl *const T { ub_checks::assert_unsafe_precondition!( check_language_ub, - "ptr::sub_ptr requires `self >= origin`", + "ptr::offset_from_unsigned requires `self >= origin`", ( this: *const () = self as *const (), origin: *const () = origin as *const (), @@ -807,18 +804,18 @@ impl *const T { /// units of **bytes**. /// /// This is purely a convenience for casting to a `u8` pointer and - /// using [`sub_ptr`][pointer::sub_ptr] on it. See that method for + /// using [`sub_ptr`][pointer::offset_from_unsigned] on it. See that method for /// documentation and safety requirements. /// /// For non-`Sized` pointees this operation considers only the data pointers, /// ignoring the metadata. - #[unstable(feature = "ptr_sub_ptr", issue = "95892")] - #[rustc_const_unstable(feature = "const_ptr_sub_ptr", issue = "95892")] + #[stable(feature = "ptr_sub_ptr", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "const_ptr_sub_ptr", since = "CURRENT_RUSTC_VERSION")] #[inline] #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces - pub const unsafe fn byte_sub_ptr(self, origin: *const U) -> usize { + pub const unsafe fn byte_offset_from_unsigned(self, origin: *const U) -> usize { // SAFETY: the caller must uphold the safety contract for `sub_ptr`. - unsafe { self.cast::().sub_ptr(origin.cast::()) } + unsafe { self.cast::().offset_from_unsigned(origin.cast::()) } } /// Returns whether two pointers are guaranteed to be equal. diff --git a/core/src/ptr/metadata.rs b/core/src/ptr/metadata.rs index e93b5658e2436..9eee29d485f41 100644 --- a/core/src/ptr/metadata.rs +++ b/core/src/ptr/metadata.rs @@ -155,7 +155,7 @@ pub struct DynMetadata { _phantom: crate::marker::PhantomData, } -extern "C" { +unsafe extern "C" { /// Opaque type for accessing vtables. /// /// Private implementation detail of `DynMetadata::size_of` etc. diff --git a/core/src/ptr/mod.rs b/core/src/ptr/mod.rs index e1348552b65c3..eb99be817a2ca 100644 --- a/core/src/ptr/mod.rs +++ b/core/src/ptr/mod.rs @@ -1070,7 +1070,7 @@ pub const unsafe fn swap(x: *mut T, y: *mut T) { #[rustc_diagnostic_item = "ptr_swap_nonoverlapping"] pub const unsafe fn swap_nonoverlapping(x: *mut T, y: *mut T, count: usize) { ub_checks::assert_unsafe_precondition!( - check_language_ub, + check_library_ub, "ptr::swap_nonoverlapping requires that both pointer arguments are aligned and non-null \ and the specified memory ranges do not overlap", ( diff --git a/core/src/ptr/mut_ptr.rs b/core/src/ptr/mut_ptr.rs index d1b0104c0fa92..5a64f12ca99ff 100644 --- a/core/src/ptr/mut_ptr.rs +++ b/core/src/ptr/mut_ptr.rs @@ -895,14 +895,13 @@ impl *mut T { /// to [`sub`](#method.sub)). The following are all equivalent, assuming /// that their safety preconditions are met: /// ```rust - /// # #![feature(ptr_sub_ptr)] - /// # unsafe fn blah(ptr: *mut i32, origin: *mut i32, count: usize) -> bool { - /// ptr.sub_ptr(origin) == count + /// # unsafe fn blah(ptr: *mut i32, origin: *mut i32, count: usize) -> bool { unsafe { + /// ptr.offset_from_unsigned(origin) == count /// # && /// origin.add(count) == ptr /// # && /// ptr.sub(count) == origin - /// # } + /// # } } /// ``` /// /// # Safety @@ -924,32 +923,30 @@ impl *mut T { /// # Examples /// /// ``` - /// #![feature(ptr_sub_ptr)] - /// /// let mut a = [0; 5]; /// let p: *mut i32 = a.as_mut_ptr(); /// unsafe { /// let ptr1: *mut i32 = p.add(1); /// let ptr2: *mut i32 = p.add(3); /// - /// assert_eq!(ptr2.sub_ptr(ptr1), 2); + /// assert_eq!(ptr2.offset_from_unsigned(ptr1), 2); /// assert_eq!(ptr1.add(2), ptr2); /// assert_eq!(ptr2.sub(2), ptr1); - /// assert_eq!(ptr2.sub_ptr(ptr2), 0); + /// assert_eq!(ptr2.offset_from_unsigned(ptr2), 0); /// } /// /// // This would be incorrect, as the pointers are not correctly ordered: /// // ptr1.offset_from(ptr2) - #[unstable(feature = "ptr_sub_ptr", issue = "95892")] - #[rustc_const_unstable(feature = "const_ptr_sub_ptr", issue = "95892")] + #[stable(feature = "ptr_sub_ptr", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "const_ptr_sub_ptr", since = "CURRENT_RUSTC_VERSION")] #[inline] #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces - pub const unsafe fn sub_ptr(self, origin: *const T) -> usize + pub const unsafe fn offset_from_unsigned(self, origin: *const T) -> usize where T: Sized, { // SAFETY: the caller must uphold the safety contract for `sub_ptr`. - unsafe { (self as *const T).sub_ptr(origin) } + unsafe { (self as *const T).offset_from_unsigned(origin) } } /// Calculates the distance between two pointers within the same allocation, *where it's known that @@ -957,18 +954,18 @@ impl *mut T { /// units of **bytes**. /// /// This is purely a convenience for casting to a `u8` pointer and - /// using [`sub_ptr`][pointer::sub_ptr] on it. See that method for + /// using [`sub_ptr`][pointer::offset_from_unsigned] on it. See that method for /// documentation and safety requirements. /// /// For non-`Sized` pointees this operation considers only the data pointers, /// ignoring the metadata. - #[unstable(feature = "ptr_sub_ptr", issue = "95892")] - #[rustc_const_unstable(feature = "const_ptr_sub_ptr", issue = "95892")] + #[stable(feature = "ptr_sub_ptr", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "const_ptr_sub_ptr", since = "CURRENT_RUSTC_VERSION")] #[inline] #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces - pub const unsafe fn byte_sub_ptr(self, origin: *mut U) -> usize { + pub const unsafe fn byte_offset_from_unsigned(self, origin: *mut U) -> usize { // SAFETY: the caller must uphold the safety contract for `byte_sub_ptr`. - unsafe { (self as *const T).byte_sub_ptr(origin) } + unsafe { (self as *const T).byte_offset_from_unsigned(origin) } } /// Adds an unsigned offset to a pointer. diff --git a/core/src/ptr/non_null.rs b/core/src/ptr/non_null.rs index d93069d384edd..7abd3ddaa9efc 100644 --- a/core/src/ptr/non_null.rs +++ b/core/src/ptr/non_null.rs @@ -856,14 +856,13 @@ impl NonNull { /// to [`sub`](#method.sub)). The following are all equivalent, assuming /// that their safety preconditions are met: /// ```rust - /// # #![feature(ptr_sub_ptr)] - /// # unsafe fn blah(ptr: std::ptr::NonNull, origin: std::ptr::NonNull, count: usize) -> bool { - /// ptr.sub_ptr(origin) == count + /// # unsafe fn blah(ptr: std::ptr::NonNull, origin: std::ptr::NonNull, count: usize) -> bool { unsafe { + /// ptr.offset_from_unsigned(origin) == count /// # && /// origin.add(count) == ptr /// # && /// ptr.sub(count) == origin - /// # } + /// # } } /// ``` /// /// # Safety @@ -885,32 +884,31 @@ impl NonNull { /// # Examples /// /// ``` - /// #![feature(ptr_sub_ptr)] /// use std::ptr::NonNull; /// /// let a = [0; 5]; /// let ptr1: NonNull = NonNull::from(&a[1]); /// let ptr2: NonNull = NonNull::from(&a[3]); /// unsafe { - /// assert_eq!(ptr2.sub_ptr(ptr1), 2); + /// assert_eq!(ptr2.offset_from_unsigned(ptr1), 2); /// assert_eq!(ptr1.add(2), ptr2); /// assert_eq!(ptr2.sub(2), ptr1); - /// assert_eq!(ptr2.sub_ptr(ptr2), 0); + /// assert_eq!(ptr2.offset_from_unsigned(ptr2), 0); /// } /// /// // This would be incorrect, as the pointers are not correctly ordered: - /// // ptr1.sub_ptr(ptr2) + /// // ptr1.offset_from_unsigned(ptr2) /// ``` #[inline] #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces - #[unstable(feature = "ptr_sub_ptr", issue = "95892")] - #[rustc_const_unstable(feature = "const_ptr_sub_ptr", issue = "95892")] - pub const unsafe fn sub_ptr(self, subtracted: NonNull) -> usize + #[stable(feature = "ptr_sub_ptr", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "const_ptr_sub_ptr", since = "CURRENT_RUSTC_VERSION")] + pub const unsafe fn offset_from_unsigned(self, subtracted: NonNull) -> usize where T: Sized, { // SAFETY: the caller must uphold the safety contract for `sub_ptr`. - unsafe { self.as_ptr().sub_ptr(subtracted.as_ptr()) } + unsafe { self.as_ptr().offset_from_unsigned(subtracted.as_ptr()) } } /// Calculates the distance between two pointers within the same allocation, *where it's known that @@ -918,18 +916,18 @@ impl NonNull { /// units of **bytes**. /// /// This is purely a convenience for casting to a `u8` pointer and - /// using [`sub_ptr`][NonNull::sub_ptr] on it. See that method for + /// using [`sub_ptr`][NonNull::offset_from_unsigned] on it. See that method for /// documentation and safety requirements. /// /// For non-`Sized` pointees this operation considers only the data pointers, /// ignoring the metadata. #[inline(always)] #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces - #[unstable(feature = "ptr_sub_ptr", issue = "95892")] - #[rustc_const_unstable(feature = "const_ptr_sub_ptr", issue = "95892")] - pub const unsafe fn byte_sub_ptr(self, origin: NonNull) -> usize { + #[stable(feature = "ptr_sub_ptr", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "const_ptr_sub_ptr", since = "CURRENT_RUSTC_VERSION")] + pub const unsafe fn byte_offset_from_unsigned(self, origin: NonNull) -> usize { // SAFETY: the caller must uphold the safety contract for `byte_sub_ptr`. - unsafe { self.as_ptr().byte_sub_ptr(origin.as_ptr()) } + unsafe { self.as_ptr().byte_offset_from_unsigned(origin.as_ptr()) } } /// Reads the value from `self` without moving it. This leaves the diff --git a/core/src/range.rs b/core/src/range.rs index 6a62928873fe8..2276112a27bb3 100644 --- a/core/src/range.rs +++ b/core/src/range.rs @@ -31,7 +31,9 @@ pub use iter::{IterRange, IterRangeFrom, IterRangeInclusive}; #[doc(inline)] pub use crate::iter::Step; #[doc(inline)] -pub use crate::ops::{Bound, OneSidedRange, RangeBounds, RangeFull, RangeTo, RangeToInclusive}; +pub use crate::ops::{ + Bound, IntoBounds, OneSidedRange, RangeBounds, RangeFull, RangeTo, RangeToInclusive, +}; /// A (half-open) range bounded inclusively below and exclusively above /// (`start..end` in a future edition). @@ -48,7 +50,7 @@ pub use crate::ops::{Bound, OneSidedRange, RangeBounds, RangeFull, RangeTo, Rang /// assert_eq!(Range::from(3..5), Range { start: 3, end: 5 }); /// assert_eq!(3 + 4 + 5, Range::from(3..6).into_iter().sum()); /// ``` -#[cfg_attr(not(bootstrap), lang = "RangeCopy")] +#[lang = "RangeCopy"] #[derive(Clone, Copy, Default, PartialEq, Eq, Hash)] #[unstable(feature = "new_range_api", issue = "125687")] pub struct Range { @@ -175,6 +177,14 @@ impl RangeBounds for Range<&T> { } } +// #[unstable(feature = "range_into_bounds", issue = "136903")] +#[unstable(feature = "new_range_api", issue = "125687")] +impl IntoBounds for Range { + fn into_bounds(self) -> (Bound, Bound) { + (Included(self.start), Excluded(self.end)) + } +} + #[unstable(feature = "new_range_api", issue = "125687")] impl From> for legacy::Range { #[inline] @@ -206,7 +216,7 @@ impl From> for Range { /// assert_eq!(RangeInclusive::from(3..=5), RangeInclusive { start: 3, end: 5 }); /// assert_eq!(3 + 4 + 5, RangeInclusive::from(3..=5).into_iter().sum()); /// ``` -#[cfg_attr(not(bootstrap), lang = "RangeInclusiveCopy")] +#[lang = "RangeInclusiveCopy"] #[derive(Clone, Copy, PartialEq, Eq, Hash)] #[unstable(feature = "new_range_api", issue = "125687")] pub struct RangeInclusive { @@ -343,6 +353,14 @@ impl RangeBounds for RangeInclusive<&T> { } } +// #[unstable(feature = "range_into_bounds", issue = "136903")] +#[unstable(feature = "new_range_api", issue = "125687")] +impl IntoBounds for RangeInclusive { + fn into_bounds(self) -> (Bound, Bound) { + (Included(self.start), Included(self.end)) + } +} + #[unstable(feature = "new_range_api", issue = "125687")] impl From> for legacy::RangeInclusive { #[inline] @@ -390,7 +408,7 @@ impl From> for RangeInclusive { /// assert_eq!(RangeFrom::from(2..), core::range::RangeFrom { start: 2 }); /// assert_eq!(2 + 3 + 4, RangeFrom::from(2..).into_iter().take(3).sum()); /// ``` -#[cfg_attr(not(bootstrap), lang = "RangeFromCopy")] +#[lang = "RangeFromCopy"] #[derive(Clone, Copy, PartialEq, Eq, Hash)] #[unstable(feature = "new_range_api", issue = "125687")] pub struct RangeFrom { @@ -479,6 +497,14 @@ impl RangeBounds for RangeFrom<&T> { } } +// #[unstable(feature = "range_into_bounds", issue = "136903")] +#[unstable(feature = "new_range_api", issue = "125687")] +impl IntoBounds for RangeFrom { + fn into_bounds(self) -> (Bound, Bound) { + (Included(self.start), Unbounded) + } +} + #[unstable(feature = "new_range_api", issue = "125687")] impl From> for legacy::RangeFrom { #[inline] diff --git a/core/src/slice/iter/macros.rs b/core/src/slice/iter/macros.rs index 830debe02ea2b..7c1ed3fe8a246 100644 --- a/core/src/slice/iter/macros.rs +++ b/core/src/slice/iter/macros.rs @@ -30,7 +30,7 @@ macro_rules! if_zst { $zst_body } else { // SAFETY: for non-ZSTs, the type invariant ensures it cannot be null - let $end = unsafe { *(&raw const $this.end_or_len).cast::>() }; + let $end = unsafe { mem::transmute::<*const T, NonNull>($this.end_or_len) }; $other_body } }}; @@ -54,7 +54,7 @@ macro_rules! len { // To get rid of some bounds checks (see `position`), we use ptr_sub instead of // offset_from (Tested by `codegen/slice-position-bounds-check`.) // SAFETY: by the type invariant pointers are aligned and `start <= end` - unsafe { end.sub_ptr($self.ptr) } + unsafe { end.offset_from_unsigned($self.ptr) } }, ) }}; @@ -154,16 +154,39 @@ macro_rules! iterator { #[inline] fn next(&mut self) -> Option<$elem> { - // could be implemented with slices, but this avoids bounds checks + // intentionally not using the helpers because this is + // one of the most mono'd things in the library. - // SAFETY: The call to `next_unchecked` is - // safe since we check if the iterator is empty first. + let ptr = self.ptr; + let end_or_len = self.end_or_len; + // SAFETY: See inner comments. (For some reason having multiple + // block breaks inlining this -- if you can fix that please do!) unsafe { - if is_empty!(self) { - None + if T::IS_ZST { + let len = end_or_len.addr(); + if len == 0 { + return None; + } + // SAFETY: just checked that it's not zero, so subtracting one + // cannot wrap. (Ideally this would be `checked_sub`, which + // does the same thing internally, but as of 2025-02 that + // doesn't optimize quite as small in MIR.) + self.end_or_len = without_provenance_mut(len.unchecked_sub(1)); } else { - Some(self.next_unchecked()) + // SAFETY: by type invariant, the `end_or_len` field is always + // non-null for a non-ZST pointee. (This transmute ensures we + // get `!nonnull` metadata on the load of the field.) + if ptr == crate::intrinsics::transmute::<$ptr, NonNull>(end_or_len) { + return None; + } + // SAFETY: since it's not empty, per the check above, moving + // forward one keeps us inside the slice, and this is valid. + self.ptr = ptr.add(1); } + // SAFETY: Now that we know it wasn't empty and we've moved past + // the first one (to avoid giving a duplicate `&mut` next time), + // we can give out a reference to it. + Some({ptr}.$into_ref()) } } diff --git a/core/src/slice/mod.rs b/core/src/slice/mod.rs index fe9d7c10db28c..7a2764206e8db 100644 --- a/core/src/slice/mod.rs +++ b/core/src/slice/mod.rs @@ -956,7 +956,6 @@ impl [T] { /// [`swap`]: slice::swap /// [undefined behavior]: https://doc.rust-lang.org/reference/behavior-considered-undefined.html #[unstable(feature = "slice_swap_unchecked", issue = "88539")] - #[rustc_const_unstable(feature = "slice_swap_unchecked", issue = "88539")] pub const unsafe fn swap_unchecked(&mut self, a: usize, b: usize) { assert_unsafe_precondition!( check_library_ub, @@ -2928,10 +2927,17 @@ impl [T] { /// This sort is unstable (i.e., may reorder equal elements), in-place (i.e., does not /// allocate), and *O*(*n* \* log(*n*)) worst-case. /// - /// If the implementation of [`Ord`] for `T` does not implement a [total order] the resulting - /// order of elements in the slice is unspecified. All original elements will remain in the - /// slice and any possible modifications via interior mutability are observed in the input. Same - /// is true if the implementation of [`Ord`] for `T` panics. + /// If the implementation of [`Ord`] for `T` does not implement a [total order], the function + /// may panic; even if the function exits normally, the resulting order of elements in the slice + /// is unspecified. See also the note on panicking below. + /// + /// For example `|a, b| (a - b).cmp(a)` is a comparison function that is neither transitive nor + /// reflexive nor total, `a < b < c < a` with `a = 1, b = 2, c = 3`. For more information and + /// examples see the [`Ord`] documentation. + /// + /// + /// All original elements will remain in the slice and any possible modifications via interior + /// mutability are observed in the input. Same is true if the implementation of [`Ord`] for `T` panics. /// /// Sorting types that only implement [`PartialOrd`] such as [`f32`] and [`f64`] require /// additional precautions. For example, `f32::NAN != f32::NAN`, which doesn't fulfill the @@ -2954,7 +2960,8 @@ impl [T] { /// /// # Panics /// - /// May panic if the implementation of [`Ord`] for `T` does not implement a [total order]. + /// May panic if the implementation of [`Ord`] for `T` does not implement a [total order], or if + /// the [`Ord`] implementation panics. /// /// # Examples /// @@ -2982,15 +2989,17 @@ impl [T] { /// This sort is unstable (i.e., may reorder equal elements), in-place (i.e., does not /// allocate), and *O*(*n* \* log(*n*)) worst-case. /// - /// If the comparison function `compare` does not implement a [total order] the resulting order - /// of elements in the slice is unspecified. All original elements will remain in the slice and - /// any possible modifications via interior mutability are observed in the input. Same is true - /// if `compare` panics. + /// If the comparison function `compare` does not implement a [total order], the function + /// may panic; even if the function exits normally, the resulting order of elements in the slice + /// is unspecified. See also the note on panicking below. /// /// For example `|a, b| (a - b).cmp(a)` is a comparison function that is neither transitive nor /// reflexive nor total, `a < b < c < a` with `a = 1, b = 2, c = 3`. For more information and /// examples see the [`Ord`] documentation. /// + /// All original elements will remain in the slice and any possible modifications via interior + /// mutability are observed in the input. Same is true if `compare` panics. + /// /// # Current implementation /// /// The current implementation is based on [ipnsort] by Lukas Bergdoll and Orson Peters, which @@ -3003,7 +3012,8 @@ impl [T] { /// /// # Panics /// - /// May panic if `compare` does not implement a [total order]. + /// May panic if the `compare` does not implement a [total order], or if + /// the `compare` itself panics. /// /// # Examples /// @@ -3034,10 +3044,16 @@ impl [T] { /// This sort is unstable (i.e., may reorder equal elements), in-place (i.e., does not /// allocate), and *O*(*n* \* log(*n*)) worst-case. /// - /// If the implementation of [`Ord`] for `K` does not implement a [total order] the resulting - /// order of elements in the slice is unspecified. All original elements will remain in the - /// slice and any possible modifications via interior mutability are observed in the input. Same - /// is true if the implementation of [`Ord`] for `K` panics. + /// If the implementation of [`Ord`] for `K` does not implement a [total order], the function + /// may panic; even if the function exits normally, the resulting order of elements in the slice + /// is unspecified. See also the note on panicking below. + /// + /// For example `|a, b| (a - b).cmp(a)` is a comparison function that is neither transitive nor + /// reflexive nor total, `a < b < c < a` with `a = 1, b = 2, c = 3`. For more information and + /// examples see the [`Ord`] documentation. + /// + /// All original elements will remain in the slice and any possible modifications via interior + /// mutability are observed in the input. Same is true if the implementation of [`Ord`] for `K` panics. /// /// # Current implementation /// @@ -3051,7 +3067,8 @@ impl [T] { /// /// # Panics /// - /// May panic if the implementation of [`Ord`] for `K` does not implement a [total order]. + /// May panic if the implementation of [`Ord`] for `K` does not implement a [total order], or if + /// the [`Ord`] implementation panics. /// /// # Examples /// @@ -3716,6 +3733,7 @@ impl [T] { #[inline] #[stable(feature = "copy_from_slice", since = "1.9.0")] #[rustc_const_unstable(feature = "const_copy_from_slice", issue = "131415")] + #[rustc_const_stable_indirect] #[track_caller] pub const fn copy_from_slice(&mut self, src: &[T]) where @@ -4531,7 +4549,7 @@ impl [T] { /// to single elements, while if passed an array of ranges it gives back an array of /// mutable references to slices. /// - /// For a safe alternative see [`get_many_mut`]. + /// For a safe alternative see [`get_disjoint_mut`]. /// /// # Safety /// @@ -4541,19 +4559,17 @@ impl [T] { /// # Examples /// /// ``` - /// #![feature(get_many_mut)] - /// /// let x = &mut [1, 2, 4]; /// /// unsafe { - /// let [a, b] = x.get_many_unchecked_mut([0, 2]); + /// let [a, b] = x.get_disjoint_unchecked_mut([0, 2]); /// *a *= 10; /// *b *= 100; /// } /// assert_eq!(x, &[10, 2, 400]); /// /// unsafe { - /// let [a, b] = x.get_many_unchecked_mut([0..1, 1..3]); + /// let [a, b] = x.get_disjoint_unchecked_mut([0..1, 1..3]); /// a[0] = 8; /// b[0] = 88; /// b[1] = 888; @@ -4561,7 +4577,7 @@ impl [T] { /// assert_eq!(x, &[8, 88, 888]); /// /// unsafe { - /// let [a, b] = x.get_many_unchecked_mut([1..=2, 0..=0]); + /// let [a, b] = x.get_disjoint_unchecked_mut([1..=2, 0..=0]); /// a[0] = 11; /// a[1] = 111; /// b[0] = 1; @@ -4569,16 +4585,16 @@ impl [T] { /// assert_eq!(x, &[1, 11, 111]); /// ``` /// - /// [`get_many_mut`]: slice::get_many_mut + /// [`get_disjoint_mut`]: slice::get_disjoint_mut /// [undefined behavior]: https://doc.rust-lang.org/reference/behavior-considered-undefined.html - #[unstable(feature = "get_many_mut", issue = "104642")] + #[stable(feature = "get_many_mut", since = "1.86.0")] #[inline] - pub unsafe fn get_many_unchecked_mut( + pub unsafe fn get_disjoint_unchecked_mut( &mut self, indices: [I; N], ) -> [&mut I::Output; N] where - I: GetManyMutIndex + SliceIndex, + I: GetDisjointMutIndex + SliceIndex, { // NB: This implementation is written as it is because any variation of // `indices.map(|i| self.get_unchecked_mut(i))` would make miri unhappy, @@ -4617,42 +4633,40 @@ impl [T] { /// # Examples /// /// ``` - /// #![feature(get_many_mut)] - /// /// let v = &mut [1, 2, 3]; - /// if let Ok([a, b]) = v.get_many_mut([0, 2]) { + /// if let Ok([a, b]) = v.get_disjoint_mut([0, 2]) { /// *a = 413; /// *b = 612; /// } /// assert_eq!(v, &[413, 2, 612]); /// - /// if let Ok([a, b]) = v.get_many_mut([0..1, 1..3]) { + /// if let Ok([a, b]) = v.get_disjoint_mut([0..1, 1..3]) { /// a[0] = 8; /// b[0] = 88; /// b[1] = 888; /// } /// assert_eq!(v, &[8, 88, 888]); /// - /// if let Ok([a, b]) = v.get_many_mut([1..=2, 0..=0]) { + /// if let Ok([a, b]) = v.get_disjoint_mut([1..=2, 0..=0]) { /// a[0] = 11; /// a[1] = 111; /// b[0] = 1; /// } /// assert_eq!(v, &[1, 11, 111]); /// ``` - #[unstable(feature = "get_many_mut", issue = "104642")] + #[stable(feature = "get_many_mut", since = "1.86.0")] #[inline] - pub fn get_many_mut( + pub fn get_disjoint_mut( &mut self, indices: [I; N], - ) -> Result<[&mut I::Output; N], GetManyMutError> + ) -> Result<[&mut I::Output; N], GetDisjointMutError> where - I: GetManyMutIndex + SliceIndex, + I: GetDisjointMutIndex + SliceIndex, { - get_many_check_valid(&indices, self.len())?; - // SAFETY: The `get_many_check_valid()` call checked that all indices + get_disjoint_check_valid(&indices, self.len())?; + // SAFETY: The `get_disjoint_check_valid()` call checked that all indices // are disjunct and in bounds. - unsafe { Ok(self.get_many_unchecked_mut(indices)) } + unsafe { Ok(self.get_disjoint_unchecked_mut(indices)) } } /// Returns the index that an element reference points to. @@ -4800,7 +4814,7 @@ impl [[T; N]] { /// assert!(empty_slice_of_arrays.as_flattened().is_empty()); /// ``` #[stable(feature = "slice_flatten", since = "1.80.0")] - #[rustc_const_unstable(feature = "const_slice_flatten", issue = "95629")] + #[rustc_const_stable(feature = "const_slice_flatten", since = "CURRENT_RUSTC_VERSION")] pub const fn as_flattened(&self) -> &[T] { let len = if T::IS_ZST { self.len().checked_mul(N).expect("slice len overflow") @@ -4837,7 +4851,7 @@ impl [[T; N]] { /// assert_eq!(array, [[6, 7, 8], [9, 10, 11], [12, 13, 14]]); /// ``` #[stable(feature = "slice_flatten", since = "1.80.0")] - #[rustc_const_unstable(feature = "const_slice_flatten", issue = "95629")] + #[rustc_const_stable(feature = "const_slice_flatten", since = "CURRENT_RUSTC_VERSION")] pub const fn as_flattened_mut(&mut self) -> &mut [T] { let len = if T::IS_ZST { self.len().checked_mul(N).expect("slice len overflow") @@ -4994,26 +5008,26 @@ impl SlicePattern for [T; N] { /// This will do `binomial(N + 1, 2) = N * (N + 1) / 2 = 0, 1, 3, 6, 10, ..` /// comparison operations. #[inline] -fn get_many_check_valid( +fn get_disjoint_check_valid( indices: &[I; N], len: usize, -) -> Result<(), GetManyMutError> { +) -> Result<(), GetDisjointMutError> { // NB: The optimizer should inline the loops into a sequence // of instructions without additional branching. for (i, idx) in indices.iter().enumerate() { if !idx.is_in_bounds(len) { - return Err(GetManyMutError::IndexOutOfBounds); + return Err(GetDisjointMutError::IndexOutOfBounds); } for idx2 in &indices[..i] { if idx.is_overlapping(idx2) { - return Err(GetManyMutError::OverlappingIndices); + return Err(GetDisjointMutError::OverlappingIndices); } } } Ok(()) } -/// The error type returned by [`get_many_mut`][`slice::get_many_mut`]. +/// The error type returned by [`get_disjoint_mut`][`slice::get_disjoint_mut`]. /// /// It indicates one of two possible errors: /// - An index is out-of-bounds. @@ -5023,74 +5037,75 @@ fn get_many_check_valid( /// # Examples /// /// ``` -/// #![feature(get_many_mut)] -/// use std::slice::GetManyMutError; +/// use std::slice::GetDisjointMutError; /// /// let v = &mut [1, 2, 3]; -/// assert_eq!(v.get_many_mut([0, 999]), Err(GetManyMutError::IndexOutOfBounds)); -/// assert_eq!(v.get_many_mut([1, 1]), Err(GetManyMutError::OverlappingIndices)); +/// assert_eq!(v.get_disjoint_mut([0, 999]), Err(GetDisjointMutError::IndexOutOfBounds)); +/// assert_eq!(v.get_disjoint_mut([1, 1]), Err(GetDisjointMutError::OverlappingIndices)); /// ``` -#[unstable(feature = "get_many_mut", issue = "104642")] +#[stable(feature = "get_many_mut", since = "1.86.0")] #[derive(Debug, Clone, PartialEq, Eq)] -pub enum GetManyMutError { +pub enum GetDisjointMutError { /// An index provided was out-of-bounds for the slice. IndexOutOfBounds, /// Two indices provided were overlapping. OverlappingIndices, } -#[unstable(feature = "get_many_mut", issue = "104642")] -impl fmt::Display for GetManyMutError { +#[stable(feature = "get_many_mut", since = "1.86.0")] +impl fmt::Display for GetDisjointMutError { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let msg = match self { - GetManyMutError::IndexOutOfBounds => "an index is out of bounds", - GetManyMutError::OverlappingIndices => "there were overlapping indices", + GetDisjointMutError::IndexOutOfBounds => "an index is out of bounds", + GetDisjointMutError::OverlappingIndices => "there were overlapping indices", }; fmt::Display::fmt(msg, f) } } -mod private_get_many_mut_index { +mod private_get_disjoint_mut_index { use super::{Range, RangeInclusive, range}; - #[unstable(feature = "get_many_mut_helpers", issue = "none")] + #[unstable(feature = "get_disjoint_mut_helpers", issue = "none")] pub trait Sealed {} - #[unstable(feature = "get_many_mut_helpers", issue = "none")] + #[unstable(feature = "get_disjoint_mut_helpers", issue = "none")] impl Sealed for usize {} - #[unstable(feature = "get_many_mut_helpers", issue = "none")] + #[unstable(feature = "get_disjoint_mut_helpers", issue = "none")] impl Sealed for Range {} - #[unstable(feature = "get_many_mut_helpers", issue = "none")] + #[unstable(feature = "get_disjoint_mut_helpers", issue = "none")] impl Sealed for RangeInclusive {} - #[unstable(feature = "get_many_mut_helpers", issue = "none")] + #[unstable(feature = "get_disjoint_mut_helpers", issue = "none")] impl Sealed for range::Range {} - #[unstable(feature = "get_many_mut_helpers", issue = "none")] + #[unstable(feature = "get_disjoint_mut_helpers", issue = "none")] impl Sealed for range::RangeInclusive {} } -/// A helper trait for `<[T]>::get_many_mut()`. +/// A helper trait for `<[T]>::get_disjoint_mut()`. /// /// # Safety /// /// If `is_in_bounds()` returns `true` and `is_overlapping()` returns `false`, /// it must be safe to index the slice with the indices. -#[unstable(feature = "get_many_mut_helpers", issue = "none")] -pub unsafe trait GetManyMutIndex: Clone + private_get_many_mut_index::Sealed { +#[unstable(feature = "get_disjoint_mut_helpers", issue = "none")] +pub unsafe trait GetDisjointMutIndex: + Clone + private_get_disjoint_mut_index::Sealed +{ /// Returns `true` if `self` is in bounds for `len` slice elements. - #[unstable(feature = "get_many_mut_helpers", issue = "none")] + #[unstable(feature = "get_disjoint_mut_helpers", issue = "none")] fn is_in_bounds(&self, len: usize) -> bool; /// Returns `true` if `self` overlaps with `other`. /// /// Note that we don't consider zero-length ranges to overlap at the beginning or the end, /// but do consider them to overlap in the middle. - #[unstable(feature = "get_many_mut_helpers", issue = "none")] + #[unstable(feature = "get_disjoint_mut_helpers", issue = "none")] fn is_overlapping(&self, other: &Self) -> bool; } -#[unstable(feature = "get_many_mut_helpers", issue = "none")] +#[unstable(feature = "get_disjoint_mut_helpers", issue = "none")] // SAFETY: We implement `is_in_bounds()` and `is_overlapping()` correctly. -unsafe impl GetManyMutIndex for usize { +unsafe impl GetDisjointMutIndex for usize { #[inline] fn is_in_bounds(&self, len: usize) -> bool { *self < len @@ -5102,9 +5117,9 @@ unsafe impl GetManyMutIndex for usize { } } -#[unstable(feature = "get_many_mut_helpers", issue = "none")] +#[unstable(feature = "get_disjoint_mut_helpers", issue = "none")] // SAFETY: We implement `is_in_bounds()` and `is_overlapping()` correctly. -unsafe impl GetManyMutIndex for Range { +unsafe impl GetDisjointMutIndex for Range { #[inline] fn is_in_bounds(&self, len: usize) -> bool { (self.start <= self.end) & (self.end <= len) @@ -5116,9 +5131,9 @@ unsafe impl GetManyMutIndex for Range { } } -#[unstable(feature = "get_many_mut_helpers", issue = "none")] +#[unstable(feature = "get_disjoint_mut_helpers", issue = "none")] // SAFETY: We implement `is_in_bounds()` and `is_overlapping()` correctly. -unsafe impl GetManyMutIndex for RangeInclusive { +unsafe impl GetDisjointMutIndex for RangeInclusive { #[inline] fn is_in_bounds(&self, len: usize) -> bool { (self.start <= self.end) & (self.end < len) @@ -5130,9 +5145,9 @@ unsafe impl GetManyMutIndex for RangeInclusive { } } -#[unstable(feature = "get_many_mut_helpers", issue = "none")] +#[unstable(feature = "get_disjoint_mut_helpers", issue = "none")] // SAFETY: We implement `is_in_bounds()` and `is_overlapping()` correctly. -unsafe impl GetManyMutIndex for range::Range { +unsafe impl GetDisjointMutIndex for range::Range { #[inline] fn is_in_bounds(&self, len: usize) -> bool { Range::from(*self).is_in_bounds(len) @@ -5144,9 +5159,9 @@ unsafe impl GetManyMutIndex for range::Range { } } -#[unstable(feature = "get_many_mut_helpers", issue = "none")] +#[unstable(feature = "get_disjoint_mut_helpers", issue = "none")] // SAFETY: We implement `is_in_bounds()` and `is_overlapping()` correctly. -unsafe impl GetManyMutIndex for range::RangeInclusive { +unsafe impl GetDisjointMutIndex for range::RangeInclusive { #[inline] fn is_in_bounds(&self, len: usize) -> bool { RangeInclusive::from(*self).is_in_bounds(len) diff --git a/core/src/slice/raw.rs b/core/src/slice/raw.rs index 319b76899bf8e..e24b52cff82e1 100644 --- a/core/src/slice/raw.rs +++ b/core/src/slice/raw.rs @@ -272,7 +272,7 @@ pub const fn from_mut(s: &mut T) -> &mut [T] { #[rustc_const_unstable(feature = "const_slice_from_ptr_range", issue = "89792")] pub const unsafe fn from_ptr_range<'a, T>(range: Range<*const T>) -> &'a [T] { // SAFETY: the caller must uphold the safety contract for `from_ptr_range`. - unsafe { from_raw_parts(range.start, range.end.sub_ptr(range.start)) } + unsafe { from_raw_parts(range.start, range.end.offset_from_unsigned(range.start)) } } /// Forms a mutable slice from a pointer range. @@ -342,5 +342,5 @@ pub const unsafe fn from_ptr_range<'a, T>(range: Range<*const T>) -> &'a [T] { #[rustc_const_unstable(feature = "const_slice_from_mut_ptr_range", issue = "89792")] pub const unsafe fn from_mut_ptr_range<'a, T>(range: Range<*mut T>) -> &'a mut [T] { // SAFETY: the caller must uphold the safety contract for `from_mut_ptr_range`. - unsafe { from_raw_parts_mut(range.start, range.end.sub_ptr(range.start)) } + unsafe { from_raw_parts_mut(range.start, range.end.offset_from_unsigned(range.start)) } } diff --git a/core/src/slice/sort/shared/pivot.rs b/core/src/slice/sort/shared/pivot.rs index 255a1eb6c88a8..3aace484b6a89 100644 --- a/core/src/slice/sort/shared/pivot.rs +++ b/core/src/slice/sort/shared/pivot.rs @@ -31,9 +31,9 @@ pub fn choose_pivot bool>(v: &[T], is_less: &mut F) -> us let c = v_base.add(len_div_8 * 7); // [7*floor(n/8), 8*floor(n/8)) if len < PSEUDO_MEDIAN_REC_THRESHOLD { - median3(&*a, &*b, &*c, is_less).sub_ptr(v_base) + median3(&*a, &*b, &*c, is_less).offset_from_unsigned(v_base) } else { - median3_rec(a, b, c, len_div_8, is_less).sub_ptr(v_base) + median3_rec(a, b, c, len_div_8, is_less).offset_from_unsigned(v_base) } } } diff --git a/core/src/slice/sort/shared/smallsort.rs b/core/src/slice/sort/shared/smallsort.rs index 09f898309bd65..f6dcf42ba6037 100644 --- a/core/src/slice/sort/shared/smallsort.rs +++ b/core/src/slice/sort/shared/smallsort.rs @@ -387,7 +387,7 @@ unsafe fn swap_if_less(v_base: *mut T, a_pos: usize, b_pos: usize, is_less where F: FnMut(&T, &T) -> bool, { - // SAFETY: the caller must guarantee that `a` and `b` each added to `v_base` yield valid + // SAFETY: the caller must guarantee that `a_pos` and `b_pos` each added to `v_base` yield valid // pointers into `v_base`, and are properly aligned, and part of the same allocation. unsafe { let v_a = v_base.add(a_pos); @@ -404,16 +404,16 @@ where // The equivalent code with a branch would be: // // if should_swap { - // ptr::swap(left, right, 1); + // ptr::swap(v_a, v_b, 1); // } // The goal is to generate cmov instructions here. - let left_swap = if should_swap { v_b } else { v_a }; - let right_swap = if should_swap { v_a } else { v_b }; + let v_a_swap = should_swap.select_unpredictable(v_b, v_a); + let v_b_swap = should_swap.select_unpredictable(v_a, v_b); - let right_swap_tmp = ManuallyDrop::new(ptr::read(right_swap)); - ptr::copy(left_swap, v_a, 1); - ptr::copy_nonoverlapping(&*right_swap_tmp, v_b, 1); + let v_b_swap_tmp = ManuallyDrop::new(ptr::read(v_b_swap)); + ptr::copy(v_a_swap, v_a, 1); + ptr::copy_nonoverlapping(&*v_b_swap_tmp, v_b, 1); } } @@ -640,26 +640,21 @@ pub unsafe fn sort4_stable bool>( // 1, 1 | c b a d let c3 = is_less(&*c, &*a); let c4 = is_less(&*d, &*b); - let min = select(c3, c, a); - let max = select(c4, b, d); - let unknown_left = select(c3, a, select(c4, c, b)); - let unknown_right = select(c4, d, select(c3, b, c)); + let min = c3.select_unpredictable(c, a); + let max = c4.select_unpredictable(b, d); + let unknown_left = c3.select_unpredictable(a, c4.select_unpredictable(c, b)); + let unknown_right = c4.select_unpredictable(d, c3.select_unpredictable(b, c)); // Sort the last two unknown elements. let c5 = is_less(&*unknown_right, &*unknown_left); - let lo = select(c5, unknown_right, unknown_left); - let hi = select(c5, unknown_left, unknown_right); + let lo = c5.select_unpredictable(unknown_right, unknown_left); + let hi = c5.select_unpredictable(unknown_left, unknown_right); ptr::copy_nonoverlapping(min, dst, 1); ptr::copy_nonoverlapping(lo, dst.add(1), 1); ptr::copy_nonoverlapping(hi, dst.add(2), 1); ptr::copy_nonoverlapping(max, dst.add(3), 1); } - - #[inline(always)] - fn select(cond: bool, if_true: *const T, if_false: *const T) -> *const T { - if cond { if_true } else { if_false } - } } /// SAFETY: The caller MUST guarantee that `v_base` is valid for 8 reads and diff --git a/core/src/slice/sort/stable/merge.rs b/core/src/slice/sort/stable/merge.rs index 0cb21740795b7..bb2747bfc78ac 100644 --- a/core/src/slice/sort/stable/merge.rs +++ b/core/src/slice/sort/stable/merge.rs @@ -143,7 +143,7 @@ impl Drop for MergeState { // leave the input slice `v` with each original element and all possible // modifications observed. unsafe { - let len = self.end.sub_ptr(self.start); + let len = self.end.offset_from_unsigned(self.start); ptr::copy_nonoverlapping(self.start, self.dst, len); } } diff --git a/core/src/slice/sort/unstable/quicksort.rs b/core/src/slice/sort/unstable/quicksort.rs index 4feef5deeb0fb..bb9f90fc881a0 100644 --- a/core/src/slice/sort/unstable/quicksort.rs +++ b/core/src/slice/sort/unstable/quicksort.rs @@ -224,7 +224,7 @@ where left = left.add(1); } - left.sub_ptr(v_base) + left.offset_from_unsigned(v_base) // `gap_opt` goes out of scope and overwrites the last wrong-side element on the right side // with the first wrong-side element of the left side that was initially overwritten by the diff --git a/core/src/str/converts.rs b/core/src/str/converts.rs index de68f80aa0c8e..1276d9014f0ef 100644 --- a/core/src/str/converts.rs +++ b/core/src/str/converts.rs @@ -126,7 +126,7 @@ pub const fn from_utf8(v: &[u8]) -> Result<&str, Utf8Error> { /// See the docs for [`Utf8Error`] for more details on the kinds of /// errors that can be returned. #[stable(feature = "str_mut_extras", since = "1.20.0")] -#[rustc_const_unstable(feature = "const_str_from_utf8", issue = "91006")] +#[rustc_const_stable(feature = "const_str_from_utf8", since = "CURRENT_RUSTC_VERSION")] #[rustc_diagnostic_item = "str_from_utf8_mut"] pub const fn from_utf8_mut(v: &mut [u8]) -> Result<&mut str, Utf8Error> { // FIXME(const-hack): This should use `?` again, once it's `const` diff --git a/core/src/str/mod.rs b/core/src/str/mod.rs index 5b258a7c844fe..83ad10db2da45 100644 --- a/core/src/str/mod.rs +++ b/core/src/str/mod.rs @@ -198,8 +198,6 @@ impl str { /// Basic usage: /// /// ``` - /// use std::str; - /// /// // some bytes, in a vector /// let sparkle_heart = vec![240, 159, 146, 150]; /// @@ -207,14 +205,12 @@ impl str { /// let sparkle_heart = str::from_utf8(&sparkle_heart)?; /// /// assert_eq!("💖", sparkle_heart); - /// # Ok::<_, str::Utf8Error>(()) + /// # Ok::<_, std::str::Utf8Error>(()) /// ``` /// /// Incorrect bytes: /// /// ``` - /// use std::str; - /// /// // some invalid bytes, in a vector /// let sparkle_heart = vec![0, 159, 146, 150]; /// @@ -227,8 +223,6 @@ impl str { /// A "stack allocated string": /// /// ``` - /// use std::str; - /// /// // some bytes, in a stack-allocated array /// let sparkle_heart = [240, 159, 146, 150]; /// @@ -237,7 +231,9 @@ impl str { /// /// assert_eq!("💖", sparkle_heart); /// ``` - #[unstable(feature = "inherent_str_constructors", issue = "131114")] + #[stable(feature = "inherent_str_constructors", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "inherent_str_constructors", since = "CURRENT_RUSTC_VERSION")] + #[rustc_diagnostic_item = "str_inherent_from_utf8"] pub const fn from_utf8(v: &[u8]) -> Result<&str, Utf8Error> { converts::from_utf8(v) } @@ -249,8 +245,6 @@ impl str { /// Basic usage: /// /// ``` - /// use std::str; - /// /// // "Hello, Rust!" as a mutable vector /// let mut hellorust = vec![72, 101, 108, 108, 111, 44, 32, 82, 117, 115, 116, 33]; /// @@ -263,8 +257,6 @@ impl str { /// Incorrect bytes: /// /// ``` - /// use std::str; - /// /// // Some invalid bytes in a mutable vector /// let mut invalid = vec![128, 223]; /// @@ -272,8 +264,9 @@ impl str { /// ``` /// See the docs for [`Utf8Error`] for more details on the kinds of /// errors that can be returned. - #[unstable(feature = "inherent_str_constructors", issue = "131114")] - #[rustc_const_unstable(feature = "const_str_from_utf8", issue = "91006")] + #[stable(feature = "inherent_str_constructors", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "const_str_from_utf8", since = "CURRENT_RUSTC_VERSION")] + #[rustc_diagnostic_item = "str_inherent_from_utf8_mut"] pub const fn from_utf8_mut(v: &mut [u8]) -> Result<&mut str, Utf8Error> { converts::from_utf8_mut(v) } @@ -292,8 +285,6 @@ impl str { /// Basic usage: /// /// ``` - /// use std::str; - /// /// // some bytes, in a vector /// let sparkle_heart = vec![240, 159, 146, 150]; /// @@ -305,7 +296,9 @@ impl str { /// ``` #[inline] #[must_use] - #[unstable(feature = "inherent_str_constructors", issue = "131114")] + #[stable(feature = "inherent_str_constructors", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "inherent_str_constructors", since = "CURRENT_RUSTC_VERSION")] + #[rustc_diagnostic_item = "str_inherent_from_utf8_unchecked"] pub const unsafe fn from_utf8_unchecked(v: &[u8]) -> &str { // SAFETY: converts::from_utf8_unchecked has the same safety requirements as this function. unsafe { converts::from_utf8_unchecked(v) } @@ -321,8 +314,6 @@ impl str { /// Basic usage: /// /// ``` - /// use std::str; - /// /// let mut heart = vec![240, 159, 146, 150]; /// let heart = unsafe { str::from_utf8_unchecked_mut(&mut heart) }; /// @@ -330,7 +321,9 @@ impl str { /// ``` #[inline] #[must_use] - #[unstable(feature = "inherent_str_constructors", issue = "131114")] + #[stable(feature = "inherent_str_constructors", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "inherent_str_constructors", since = "CURRENT_RUSTC_VERSION")] + #[rustc_diagnostic_item = "str_inherent_from_utf8_unchecked_mut"] pub const unsafe fn from_utf8_unchecked_mut(v: &mut [u8]) -> &mut str { // SAFETY: converts::from_utf8_unchecked_mut has the same safety requirements as this function. unsafe { converts::from_utf8_unchecked_mut(v) } @@ -361,7 +354,7 @@ impl str { /// ``` #[must_use] #[stable(feature = "is_char_boundary", since = "1.9.0")] - #[rustc_const_unstable(feature = "const_is_char_boundary", issue = "131516")] + #[rustc_const_stable(feature = "const_is_char_boundary", since = "1.86.0")] #[inline] pub const fn is_char_boundary(&self, index: usize) -> bool { // 0 is always ok. @@ -818,7 +811,7 @@ impl str { #[inline] #[must_use] #[stable(feature = "str_split_at", since = "1.4.0")] - #[rustc_const_unstable(feature = "const_str_split_at", issue = "131518")] + #[rustc_const_stable(feature = "const_str_split_at", since = "1.86.0")] pub const fn split_at(&self, mid: usize) -> (&str, &str) { match self.split_at_checked(mid) { None => slice_error_fail(self, 0, mid), @@ -859,7 +852,7 @@ impl str { #[inline] #[must_use] #[stable(feature = "str_split_at", since = "1.4.0")] - #[rustc_const_unstable(feature = "const_str_split_at", issue = "131518")] + #[rustc_const_stable(feature = "const_str_split_at", since = "1.86.0")] pub const fn split_at_mut(&mut self, mid: usize) -> (&mut str, &mut str) { // is_char_boundary checks that the index is in [0, .len()] if self.is_char_boundary(mid) { @@ -899,7 +892,7 @@ impl str { #[inline] #[must_use] #[stable(feature = "split_at_checked", since = "1.80.0")] - #[rustc_const_unstable(feature = "const_str_split_at", issue = "131518")] + #[rustc_const_stable(feature = "const_str_split_at", since = "1.86.0")] pub const fn split_at_checked(&self, mid: usize) -> Option<(&str, &str)> { // is_char_boundary checks that the index is in [0, .len()] if self.is_char_boundary(mid) { @@ -940,7 +933,7 @@ impl str { #[inline] #[must_use] #[stable(feature = "split_at_checked", since = "1.80.0")] - #[rustc_const_unstable(feature = "const_str_split_at", issue = "131518")] + #[rustc_const_stable(feature = "const_str_split_at", since = "1.86.0")] pub const fn split_at_mut_checked(&mut self, mid: usize) -> Option<(&mut str, &mut str)> { // is_char_boundary checks that the index is in [0, .len()] if self.is_char_boundary(mid) { diff --git a/core/src/str/pattern.rs b/core/src/str/pattern.rs index 52e2364893eb1..2d941adfd859c 100644 --- a/core/src/str/pattern.rs +++ b/core/src/str/pattern.rs @@ -38,6 +38,7 @@ issue = "27721" )] +use crate::char::MAX_LEN_UTF8; use crate::cmp::Ordering; use crate::convert::TryInto as _; use crate::slice::memchr; @@ -561,8 +562,8 @@ impl Pattern for char { type Searcher<'a> = CharSearcher<'a>; #[inline] - fn into_searcher(self, haystack: &str) -> Self::Searcher<'_> { - let mut utf8_encoded = [0; 4]; + fn into_searcher<'a>(self, haystack: &'a str) -> Self::Searcher<'a> { + let mut utf8_encoded = [0; MAX_LEN_UTF8]; let utf8_size = self .encode_utf8(&mut utf8_encoded) .len() diff --git a/core/src/task/wake.rs b/core/src/task/wake.rs index 4c51ca0a5e437..3f57b04753a6b 100644 --- a/core/src/task/wake.rs +++ b/core/src/task/wake.rs @@ -40,17 +40,14 @@ impl RawWaker { /// of the `vtable` as the first parameter. /// /// It is important to consider that the `data` pointer must point to a - /// thread safe type such as an `[Arc]` + /// thread safe type such as an `Arc` /// when used to construct a [`Waker`]. This restriction is lifted when /// constructing a [`LocalWaker`], which allows using types that do not implement - /// [Send] + [Sync] like `[Rc]`. + /// [Send] + [Sync] like `Rc`. /// /// The `vtable` customizes the behavior of a `Waker` which gets created /// from a `RawWaker`. For each operation on the `Waker`, the associated /// function in the `vtable` of the underlying `RawWaker` will be called. - /// - /// [`Arc`]: std::sync::Arc - /// [`Rc`]: std::rc::Rc #[inline] #[rustc_promotable] #[stable(feature = "futures_api", since = "1.36.0")] diff --git a/core/src/time.rs b/core/src/time.rs index 22bd46c567eaa..8b211b442eab6 100644 --- a/core/src/time.rs +++ b/core/src/time.rs @@ -1168,6 +1168,7 @@ impl Div for Duration { type Output = Duration; #[inline] + #[track_caller] fn div(self, rhs: u32) -> Duration { self.checked_div(rhs).expect("divide by zero error when dividing duration by scalar") } @@ -1176,6 +1177,7 @@ impl Div for Duration { #[stable(feature = "time_augmented_assignment", since = "1.9.0")] impl DivAssign for Duration { #[inline] + #[track_caller] fn div_assign(&mut self, rhs: u32) { *self = *self / rhs; } diff --git a/core/src/ub_checks.rs b/core/src/ub_checks.rs index b289f6026ffcb..9eb71922218f3 100644 --- a/core/src/ub_checks.rs +++ b/core/src/ub_checks.rs @@ -65,9 +65,9 @@ macro_rules! assert_unsafe_precondition { #[rustc_nounwind] const fn precondition_check($($name:$ty),*) { if !$e { - ::core::panicking::panic_nounwind( - concat!("unsafe precondition(s) violated: ", $message) - ); + ::core::panicking::panic_nounwind(concat!("unsafe precondition(s) violated: ", $message, + "\n\nThis indicates a bug in the program. \ + This Undefined Behavior check is optional, and cannot be relied on for safety.")); } } diff --git a/coretests/Cargo.toml b/coretests/Cargo.toml index ec940abea1171..e44f01d347b3d 100644 --- a/coretests/Cargo.toml +++ b/coretests/Cargo.toml @@ -6,7 +6,7 @@ repository = "https://github.com/rust-lang/rust.git" description = "Tests for the Rust Core Library" autotests = false autobenches = false -edition = "2021" +edition = "2024" [lib] path = "lib.rs" @@ -23,5 +23,5 @@ path = "benches/lib.rs" test = true [dev-dependencies] -rand = { version = "0.8.5", default-features = false } -rand_xorshift = { version = "0.3.0", default-features = false } +rand = { version = "0.9.0", default-features = false } +rand_xorshift = { version = "0.4.0", default-features = false } diff --git a/coretests/benches/num/int_log/mod.rs b/coretests/benches/num/int_log/mod.rs index e5874ddf03b5b..171d7e31cdb1a 100644 --- a/coretests/benches/num/int_log/mod.rs +++ b/coretests/benches/num/int_log/mod.rs @@ -21,7 +21,7 @@ macro_rules! int_log10_bench { /* Exponentially distributed random numbers from the whole range of the type. */ let numbers: Vec<$t> = (0..256) .map(|_| { - let x = rng.gen::<$t>() >> rng.gen_range(0..<$t>::BITS); + let x = rng.random::<$t>() >> rng.random_range(0..<$t>::BITS); if x != 0 { x } else { 1 } }) .collect(); @@ -38,7 +38,7 @@ macro_rules! int_log10_bench { /* Exponentially distributed random numbers from the range 0..256. */ let numbers: Vec<$t> = (0..256) .map(|_| { - let x = (rng.gen::() >> rng.gen_range(0..u8::BITS)) as $t; + let x = (rng.random::() >> rng.random_range(0..u8::BITS)) as $t; if x != 0 { x } else { 1 } }) .collect(); @@ -65,7 +65,7 @@ macro_rules! int_log_bench { /* Exponentially distributed random numbers from the whole range of the type. */ let numbers: Vec<$t> = (0..256) .map(|_| { - let x = rng.gen::<$t>() >> rng.gen_range(0..<$t>::BITS); + let x = rng.random::<$t>() >> rng.random_range(0..<$t>::BITS); if x >= 2 { x } else { 2 } }) .collect(); @@ -84,7 +84,7 @@ macro_rules! int_log_bench { /* Exponentially distributed random numbers from the range 0..256. */ let numbers: Vec<$t> = (0..256) .map(|_| { - let x = (rng.gen::() >> rng.gen_range(0..u8::BITS)) as $t; + let x = (rng.random::() >> rng.random_range(0..u8::BITS)) as $t; if x >= 2 { x } else { 2 } }) .collect(); diff --git a/coretests/benches/num/int_pow/mod.rs b/coretests/benches/num/int_pow/mod.rs index 46f47028d56e6..6b603d2f7b3b4 100644 --- a/coretests/benches/num/int_pow/mod.rs +++ b/coretests/benches/num/int_pow/mod.rs @@ -15,9 +15,9 @@ macro_rules! pow_bench_template { // reference through black_box outside of the loop. let mut rng = crate::bench_rng(); let base_array: [IntType; ITERATIONS] = - core::array::from_fn(|_| rng.gen_range((-MAX_BASE..=MAX_BASE))); + core::array::from_fn(|_| rng.random_range((-MAX_BASE..=MAX_BASE))); let exp_array: [u32; ITERATIONS] = - core::array::from_fn(|_| rng.gen_range((0..=EXPONENT_MAX))); + core::array::from_fn(|_| rng.random_range((0..=EXPONENT_MAX))); bench.iter(|| { #[allow(unused, unused_mut)] diff --git a/coretests/benches/num/int_sqrt/mod.rs b/coretests/benches/num/int_sqrt/mod.rs index e47b92e866eff..05cb3c5383b27 100644 --- a/coretests/benches/num/int_sqrt/mod.rs +++ b/coretests/benches/num/int_sqrt/mod.rs @@ -20,7 +20,7 @@ macro_rules! int_sqrt_bench { let mut rng = crate::bench_rng(); /* Exponentially distributed random numbers from the whole range of the type. */ let numbers: Vec<$t> = - (0..256).map(|_| rng.gen::<$t>() >> rng.gen_range(0..<$t>::BITS)).collect(); + (0..256).map(|_| rng.random::<$t>() >> rng.random_range(0..<$t>::BITS)).collect(); bench.iter(|| { for x in &numbers { black_box(black_box(x).isqrt()); @@ -32,8 +32,9 @@ macro_rules! int_sqrt_bench { fn $random_small(bench: &mut Bencher) { let mut rng = crate::bench_rng(); /* Exponentially distributed random numbers from the range 0..256. */ - let numbers: Vec<$t> = - (0..256).map(|_| (rng.gen::() >> rng.gen_range(0..u8::BITS)) as $t).collect(); + let numbers: Vec<$t> = (0..256) + .map(|_| (rng.random::() >> rng.random_range(0..u8::BITS)) as $t) + .collect(); bench.iter(|| { for x in &numbers { black_box(black_box(x).isqrt()); @@ -45,7 +46,7 @@ macro_rules! int_sqrt_bench { fn $random_uniform(bench: &mut Bencher) { let mut rng = crate::bench_rng(); /* Exponentially distributed random numbers from the whole range of the type. */ - let numbers: Vec<$t> = (0..256).map(|_| rng.gen::<$t>()).collect(); + let numbers: Vec<$t> = (0..256).map(|_| rng.random::<$t>()).collect(); bench.iter(|| { for x in &numbers { black_box(black_box(x).isqrt()); diff --git a/coretests/benches/slice.rs b/coretests/benches/slice.rs index 29a66b6219976..71027981d94a1 100644 --- a/coretests/benches/slice.rs +++ b/coretests/benches/slice.rs @@ -94,7 +94,7 @@ fn binary_search_l3_worst_case(b: &mut Bencher) { struct Rgb(#[allow(dead_code)] u8, #[allow(dead_code)] u8, #[allow(dead_code)] u8); impl Rgb { - fn gen(i: usize) -> Self { + fn new(i: usize) -> Self { Rgb(i as u8, (i as u8).wrapping_add(7), (i as u8).wrapping_add(42)) } } @@ -115,7 +115,7 @@ macro_rules! rotate { } rotate!(rotate_u8, 32, |i| i as u8); -rotate!(rotate_rgb, 32, Rgb::gen); +rotate!(rotate_rgb, 32, Rgb::new); rotate!(rotate_usize, 32, |i| i); rotate!(rotate_16_usize_4, 16, |i| [i; 4]); rotate!(rotate_16_usize_5, 16, |i| [i; 5]); @@ -142,8 +142,8 @@ macro_rules! swap_with_slice { swap_with_slice!(swap_with_slice_u8_30, 30, |i| i as u8); swap_with_slice!(swap_with_slice_u8_3000, 3000, |i| i as u8); -swap_with_slice!(swap_with_slice_rgb_30, 30, Rgb::gen); -swap_with_slice!(swap_with_slice_rgb_3000, 3000, Rgb::gen); +swap_with_slice!(swap_with_slice_rgb_30, 30, Rgb::new); +swap_with_slice!(swap_with_slice_rgb_3000, 3000, Rgb::new); swap_with_slice!(swap_with_slice_usize_30, 30, |i| i); swap_with_slice!(swap_with_slice_usize_3000, 3000, |i| i); swap_with_slice!(swap_with_slice_4x_usize_30, 30, |i| [i; 4]); diff --git a/coretests/tests/any.rs b/coretests/tests/any.rs index 25002617d0bbd..117ef0042380d 100644 --- a/coretests/tests/any.rs +++ b/coretests/tests/any.rs @@ -118,6 +118,14 @@ fn any_unsized() { is_any::<[i32]>(); } +#[cfg(feature = "debug_typeid")] +#[test] +fn debug_typeid_includes_name() { + let type_id = TypeId::of::<[usize; 2]>(); + let debug_str = format!("{type_id:?}"); + assert!(debug_str.ends_with("= [usize; 2])"), "{debug_str:?} did not match"); +} + #[test] fn distinct_type_names() { // https://github.com/rust-lang/rust/issues/84666 diff --git a/coretests/tests/ascii_char.rs b/coretests/tests/ascii_char.rs index 75b5fd4b9e61d..f5a15a9469f3f 100644 --- a/coretests/tests/ascii_char.rs +++ b/coretests/tests/ascii_char.rs @@ -26,3 +26,15 @@ fn test_debug_control() { assert_eq!(want, format!("{chr:?}"), "byte: {byte}"); } } + +/// Tests Extend implementation for ascii::Char. +#[test] +fn test_extend() { + let mut s = String::from("abc"); + s.extend_one(Char::SmallD); + assert_eq!(s, String::from("abcd")); + + let mut s = String::from("abc"); + s.extend(Char::CapitalA..=Char::CapitalC); + assert_eq!(s, String::from("abcABC")); +} diff --git a/coretests/tests/char.rs b/coretests/tests/char.rs index 6422387e9560b..153fb36925e66 100644 --- a/coretests/tests/char.rs +++ b/coretests/tests/char.rs @@ -1,3 +1,4 @@ +use std::char::MAX_LEN_UTF8; use std::str::FromStr; use std::{char, str}; @@ -259,7 +260,7 @@ fn test_escape_unicode() { #[test] fn test_encode_utf8() { fn check(input: char, expect: &[u8]) { - let mut buf = [0; 4]; + let mut buf = [0; MAX_LEN_UTF8]; let ptr = buf.as_ptr(); let s = input.encode_utf8(&mut buf); assert_eq!(s.as_ptr() as usize, ptr as usize); diff --git a/coretests/tests/io/borrowed_buf.rs b/coretests/tests/io/borrowed_buf.rs index a5dd4e525777a..fbd3864dcac14 100644 --- a/coretests/tests/io/borrowed_buf.rs +++ b/coretests/tests/io/borrowed_buf.rs @@ -145,7 +145,7 @@ fn cursor_set_init() { assert_eq!(rbuf.unfilled().init_ref().len(), 8); assert_eq!(rbuf.unfilled().init_mut().len(), 8); assert_eq!(rbuf.unfilled().uninit_mut().len(), 8); - assert_eq!(unsafe { rbuf.unfilled().as_mut() }.len(), 16); + assert_eq!(unsafe { rbuf.unfilled().as_mut().len() }, 16); rbuf.unfilled().advance(4); @@ -163,5 +163,5 @@ fn cursor_set_init() { assert_eq!(rbuf.unfilled().init_ref().len(), 8); assert_eq!(rbuf.unfilled().init_mut().len(), 8); assert_eq!(rbuf.unfilled().uninit_mut().len(), 4); - assert_eq!(unsafe { rbuf.unfilled().as_mut() }.len(), 12); + assert_eq!(unsafe { rbuf.unfilled().as_mut().len() }, 12); } diff --git a/coretests/tests/lib.rs b/coretests/tests/lib.rs index f1bbed3de3017..4f21ae5013b66 100644 --- a/coretests/tests/lib.rs +++ b/coretests/tests/lib.rs @@ -13,6 +13,7 @@ #![feature(bigint_helper_methods)] #![feature(bstr)] #![feature(cell_update)] +#![feature(char_max_len)] #![feature(clone_to_uninit)] #![feature(const_eval_select)] #![feature(const_swap_nonoverlapping)] @@ -27,6 +28,7 @@ #![feature(duration_constructors)] #![feature(error_generic_member_access)] #![feature(exact_size_is_empty)] +#![feature(extend_one)] #![feature(extern_types)] #![feature(float_minimum_maximum)] #![feature(flt2dec)] @@ -35,7 +37,6 @@ #![feature(freeze)] #![feature(future_join)] #![feature(generic_assert_internals)] -#![feature(get_many_mut)] #![feature(hasher_prefixfree_extras)] #![feature(hashmap_internals)] #![feature(inline_const_pat)] @@ -43,6 +44,7 @@ #![feature(ip)] #![feature(ip_from)] #![feature(is_ascii_octdigit)] +#![feature(isolate_most_least_significant_one)] #![feature(iter_advance_by)] #![feature(iter_array_chunks)] #![feature(iter_chain)] @@ -62,7 +64,6 @@ #![feature(maybe_uninit_write_slice)] #![feature(min_specialization)] #![feature(never_type)] -#![feature(num_midpoint_signed)] #![feature(numfmt)] #![feature(pattern)] #![feature(pointer_is_aligned_to)] @@ -86,7 +87,6 @@ #![feature(try_blocks)] #![feature(try_find)] #![feature(try_trait_v2)] -#![feature(unsigned_is_multiple_of)] #![feature(unsize)] #![feature(unsized_tuple_coercion)] #![feature(unwrap_infallible)] @@ -153,10 +153,7 @@ mod intrinsics; mod io; mod iter; mod lazy; -#[cfg(not(bootstrap))] mod macros; -#[cfg(bootstrap)] -mod macros_bootstrap; mod manually_drop; mod mem; mod net; diff --git a/coretests/tests/macros_bootstrap.rs b/coretests/tests/macros_bootstrap.rs deleted file mode 100644 index f10ef862c5dd9..0000000000000 --- a/coretests/tests/macros_bootstrap.rs +++ /dev/null @@ -1,193 +0,0 @@ -#![allow(unused_must_use)] - -#[allow(dead_code)] -trait Trait { - fn blah(&self); -} - -#[allow(dead_code)] -struct Struct; - -impl Trait for Struct { - cfg_match! { - cfg(feature = "blah") => { - fn blah(&self) { - unimplemented!(); - } - } - _ => { - fn blah(&self) { - unimplemented!(); - } - } - } -} - -#[test] -fn assert_eq_trailing_comma() { - assert_eq!(1, 1,); -} - -#[test] -fn assert_escape() { - assert!(r#"☃\backslash"#.contains("\\")); -} - -#[test] -fn assert_ne_trailing_comma() { - assert_ne!(1, 2,); -} - -#[rustfmt::skip] -#[test] -fn matches_leading_pipe() { - matches!(1, | 1 | 2 | 3); -} - -#[test] -fn cfg_match_basic() { - cfg_match! { - cfg(target_pointer_width = "64") => { fn f0_() -> bool { true }} - } - - cfg_match! { - cfg(unix) => { fn f1_() -> bool { true }} - cfg(any(target_os = "macos", target_os = "linux")) => { fn f1_() -> bool { false }} - } - - cfg_match! { - cfg(target_pointer_width = "32") => { fn f2_() -> bool { false }} - cfg(target_pointer_width = "64") => { fn f2_() -> bool { true }} - } - - cfg_match! { - cfg(target_pointer_width = "16") => { fn f3_() -> i32 { 1 }} - _ => { fn f3_() -> i32 { 2 }} - } - - #[cfg(target_pointer_width = "64")] - assert!(f0_()); - - #[cfg(unix)] - assert!(f1_()); - - #[cfg(target_pointer_width = "32")] - assert!(!f2_()); - #[cfg(target_pointer_width = "64")] - assert!(f2_()); - - #[cfg(not(target_pointer_width = "16"))] - assert_eq!(f3_(), 2); -} - -#[test] -fn cfg_match_debug_assertions() { - cfg_match! { - cfg(debug_assertions) => { - assert!(cfg!(debug_assertions)); - assert_eq!(4, 2+2); - } - _ => { - assert!(cfg!(not(debug_assertions))); - assert_eq!(10, 5+5); - } - } -} - -#[cfg(target_pointer_width = "64")] -#[test] -fn cfg_match_no_duplication_on_64() { - cfg_match! { - cfg(windows) => { - fn foo() {} - } - cfg(unix) => { - fn foo() {} - } - cfg(target_pointer_width = "64") => { - fn foo() {} - } - } - foo(); -} - -#[test] -fn cfg_match_options() { - cfg_match! { - cfg(test) => { - use core::option::Option as Option2; - fn works1() -> Option2 { Some(1) } - } - _ => { fn works1() -> Option { None } } - } - - cfg_match! { - cfg(feature = "foo") => { fn works2() -> bool { false } } - cfg(test) => { fn works2() -> bool { true } } - _ => { fn works2() -> bool { false } } - } - - cfg_match! { - cfg(feature = "foo") => { fn works3() -> bool { false } } - _ => { fn works3() -> bool { true } } - } - - cfg_match! { - cfg(test) => { - use core::option::Option as Option3; - fn works4() -> Option3 { Some(1) } - } - } - - cfg_match! { - cfg(feature = "foo") => { fn works5() -> bool { false } } - cfg(test) => { fn works5() -> bool { true } } - } - - assert!(works1().is_some()); - assert!(works2()); - assert!(works3()); - assert!(works4().is_some()); - assert!(works5()); -} - -#[test] -fn cfg_match_two_functions() { - cfg_match! { - cfg(target_pointer_width = "64") => { - fn foo1() {} - fn bar1() {} - } - _ => { - fn foo2() {} - fn bar2() {} - } - } - - #[cfg(target_pointer_width = "64")] - { - foo1(); - bar1(); - } - #[cfg(not(target_pointer_width = "64"))] - { - foo2(); - bar2(); - } -} - -fn _accepts_expressions() -> i32 { - cfg_match! { - cfg(unix) => { 1 } - _ => { 2 } - } -} - -fn _allows_stmt_expr_attributes() { - let one = 1; - let two = 2; - cfg_match! { - cfg(unix) => { one * two; } - _ => { one + two; } - } -} diff --git a/coretests/tests/mem.rs b/coretests/tests/mem.rs index 1b5c5fc82a69d..9cb94ca3b0ff0 100644 --- a/coretests/tests/mem.rs +++ b/coretests/tests/mem.rs @@ -648,7 +648,7 @@ fn offset_of_dst() { z: dyn Trait, } - extern "C" { + unsafe extern "C" { type Extern; } diff --git a/coretests/tests/nonzero.rs b/coretests/tests/nonzero.rs index 43c279053d829..bdc5701d9fd23 100644 --- a/coretests/tests/nonzero.rs +++ b/coretests/tests/nonzero.rs @@ -321,6 +321,106 @@ fn nonzero_trailing_zeros() { assert_eq!(TRAILING_ZEROS, 2); } +#[test] +fn test_nonzero_isolate_most_significant_one() { + // Signed most significant one + macro_rules! nonzero_int_impl { + ($($T:ty),+) => { + $( + { + const BITS: $T = -1; + const MOST_SIG_ONE: $T = 1 << (<$T>::BITS - 1); + + // Right shift the most significant one through each + // bit position, starting with all bits set + let mut i = 0; + while i < <$T>::BITS { + assert_eq!( + NonZero::<$T>::new(BITS >> i).unwrap().isolate_most_significant_one(), + NonZero::<$T>::new(MOST_SIG_ONE >> i).unwrap().isolate_most_significant_one() + ); + i += 1; + } + } + )+ + }; + } + + // Unsigned most significant one + macro_rules! nonzero_uint_impl { + ($($T:ty),+) => { + $( + { + const BITS: $T = <$T>::MAX; + const MOST_SIG_ONE: $T = 1 << (<$T>::BITS - 1); + + let mut i = 0; + while i < <$T>::BITS { + assert_eq!( + NonZero::<$T>::new(BITS >> i).unwrap().isolate_most_significant_one(), + NonZero::<$T>::new(MOST_SIG_ONE >> i).unwrap().isolate_most_significant_one(), + ); + i += 1; + } + } + )+ + }; + } + + nonzero_int_impl!(i8, i16, i32, i64, i128, isize); + nonzero_uint_impl!(u8, u16, u32, u64, u128, usize); +} + +#[test] +fn test_nonzero_isolate_least_significant_one() { + // Signed least significant one + macro_rules! nonzero_int_impl { + ($($T:ty),+) => { + $( + { + const BITS: $T = -1; + const LEAST_SIG_ONE: $T = 1; + + // Left shift the least significant one through each + // bit position, starting with all bits set + let mut i = 0; + while i < <$T>::BITS { + assert_eq!( + NonZero::<$T>::new(BITS << i).unwrap().isolate_least_significant_one(), + NonZero::<$T>::new(LEAST_SIG_ONE << i).unwrap().isolate_least_significant_one() + ); + i += 1; + } + } + )+ + }; + } + + // Unsigned least significant one + macro_rules! nonzero_uint_impl { + ($($T:ty),+) => { + $( + { + const BITS: $T = <$T>::MAX; + const LEAST_SIG_ONE: $T = 1; + + let mut i = 0; + while i < <$T>::BITS { + assert_eq!( + NonZero::<$T>::new(BITS << i).unwrap().isolate_least_significant_one(), + NonZero::<$T>::new(LEAST_SIG_ONE << i).unwrap().isolate_least_significant_one(), + ); + i += 1; + } + } + )+ + }; + } + + nonzero_int_impl!(i8, i16, i32, i64, i128, isize); + nonzero_uint_impl!(u8, u16, u32, u64, u128, usize); +} + #[test] fn test_nonzero_uint_div() { let nz = NonZero::new(1).unwrap(); diff --git a/coretests/tests/num/flt2dec/mod.rs b/coretests/tests/num/flt2dec/mod.rs index 3d82522481316..6041923117c2a 100644 --- a/coretests/tests/num/flt2dec/mod.rs +++ b/coretests/tests/num/flt2dec/mod.rs @@ -80,7 +80,7 @@ fn ldexp_f32(a: f32, b: i32) -> f32 { } fn ldexp_f64(a: f64, b: i32) -> f64 { - extern "C" { + unsafe extern "C" { fn ldexp(x: f64, n: i32) -> f64; } // SAFETY: assuming a correct `ldexp` has been supplied, the given arguments cannot possibly diff --git a/coretests/tests/num/flt2dec/random.rs b/coretests/tests/num/flt2dec/random.rs index 90042ae03bf7d..586b49df7d9b2 100644 --- a/coretests/tests/num/flt2dec/random.rs +++ b/coretests/tests/num/flt2dec/random.rs @@ -5,7 +5,7 @@ use core::num::flt2dec::{DecodableFloat, Decoded, FullDecoded, MAX_SIG_DIGITS, d use std::mem::MaybeUninit; use std::str; -use rand::distributions::{Distribution, Uniform}; +use rand::distr::{Distribution, Uniform}; pub fn decode_finite(v: T) -> Decoded { match decode(v).1 { @@ -85,7 +85,7 @@ where G: for<'a> FnMut(&Decoded, &'a mut [MaybeUninit]) -> (&'a [u8], i16), { let mut rng = crate::test_rng(); - let f32_range = Uniform::new(0x0000_0001u32, 0x7f80_0000); + let f32_range = Uniform::new(0x0000_0001u32, 0x7f80_0000).unwrap(); iterate("f32_random_equivalence_test", k, n, f, g, |_| { let x = f32::from_bits(f32_range.sample(&mut rng)); decode_finite(x) @@ -98,7 +98,7 @@ where G: for<'a> FnMut(&Decoded, &'a mut [MaybeUninit]) -> (&'a [u8], i16), { let mut rng = crate::test_rng(); - let f64_range = Uniform::new(0x0000_0000_0000_0001u64, 0x7ff0_0000_0000_0000); + let f64_range = Uniform::new(0x0000_0000_0000_0001u64, 0x7ff0_0000_0000_0000).unwrap(); iterate("f64_random_equivalence_test", k, n, f, g, |_| { let x = f64::from_bits(f64_range.sample(&mut rng)); decode_finite(x) diff --git a/coretests/tests/num/int_log.rs b/coretests/tests/num/int_log.rs index 60902752dab64..e8d35fc21ce6e 100644 --- a/coretests/tests/num/int_log.rs +++ b/coretests/tests/num/int_log.rs @@ -1,5 +1,13 @@ //! Tests for the `Integer::{ilog,log2,log10}` methods. +/// Rounds the argument down to the next integer, except that we account for potential imprecision +/// in the input, so if `f` is very close to an integer, it will round to that. +fn round_down_imprecise(f: f32) -> u32 { + // Rounds up for values less than 16*EPSILON below an integer, + // and rounds down for everything else. + (f + 16.0 * f32::EPSILON) as u32 +} + #[test] fn checked_ilog() { assert_eq!(999u32.checked_ilog(10), Some(2)); @@ -25,15 +33,24 @@ fn checked_ilog() { } #[cfg(not(miri))] // Miri is too slow for i in 1..=i16::MAX { - assert_eq!(i.checked_ilog(13), Some((i as f32).log(13.0) as u32), "checking {i}"); + assert_eq!( + i.checked_ilog(13), + Some(round_down_imprecise((i as f32).log(13.0))), + "checking {i}" + ); } #[cfg(not(miri))] // Miri is too slow for i in 1..=u16::MAX { - assert_eq!(i.checked_ilog(13), Some((i as f32).log(13.0) as u32), "checking {i}"); + assert_eq!( + i.checked_ilog(13), + Some(round_down_imprecise((i as f32).log(13.0))), + "checking {i}" + ); } } #[test] +#[cfg_attr(miri, ignore)] // FIXME test is broken on Miri: https://github.com/rust-lang/rust/issues/137591 fn checked_ilog2() { assert_eq!(5u32.checked_ilog2(), Some(2)); assert_eq!(0u64.checked_ilog2(), None); @@ -45,25 +62,34 @@ fn checked_ilog2() { assert_eq!(0i8.checked_ilog2(), None); assert_eq!(0i16.checked_ilog2(), None); - assert_eq!(8192u16.checked_ilog2(), Some((8192f32).log2() as u32)); - assert_eq!(32768u16.checked_ilog2(), Some((32768f32).log2() as u32)); - assert_eq!(8192i16.checked_ilog2(), Some((8192f32).log2() as u32)); + assert_eq!(8192u16.checked_ilog2(), Some(round_down_imprecise((8192f32).log2()))); + assert_eq!(32768u16.checked_ilog2(), Some(round_down_imprecise((32768f32).log2()))); + assert_eq!(8192i16.checked_ilog2(), Some(round_down_imprecise((8192f32).log2()))); for i in 1..=u8::MAX { - assert_eq!(i.checked_ilog2(), Some((i as f32).log2() as u32), "checking {i}"); + assert_eq!( + i.checked_ilog2(), + Some(round_down_imprecise((i as f32).log2())), + "checking {i}" + ); } #[cfg(not(miri))] // Miri is too slow for i in 1..=u16::MAX { - // Guard against Android's imprecise f32::ilog2 implementation. - if i != 8192 && i != 32768 { - assert_eq!(i.checked_ilog2(), Some((i as f32).log2() as u32), "checking {i}"); - } + assert_eq!( + i.checked_ilog2(), + Some(round_down_imprecise((i as f32).log2())), + "checking {i}" + ); } for i in i8::MIN..=0 { assert_eq!(i.checked_ilog2(), None, "checking {i}"); } for i in 1..=i8::MAX { - assert_eq!(i.checked_ilog2(), Some((i as f32).log2() as u32), "checking {i}"); + assert_eq!( + i.checked_ilog2(), + Some(round_down_imprecise((i as f32).log2())), + "checking {i}" + ); } #[cfg(not(miri))] // Miri is too slow for i in i16::MIN..=0 { @@ -71,10 +97,11 @@ fn checked_ilog2() { } #[cfg(not(miri))] // Miri is too slow for i in 1..=i16::MAX { - // Guard against Android's imprecise f32::ilog2 implementation. - if i != 8192 { - assert_eq!(i.checked_ilog2(), Some((i as f32).log2() as u32), "checking {i}"); - } + assert_eq!( + i.checked_ilog2(), + Some(round_down_imprecise((i as f32).log2())), + "checking {i}" + ); } } @@ -91,15 +118,27 @@ fn checked_ilog10() { } #[cfg(not(miri))] // Miri is too slow for i in 1..=i16::MAX { - assert_eq!(i.checked_ilog10(), Some((i as f32).log10() as u32), "checking {i}"); + assert_eq!( + i.checked_ilog10(), + Some(round_down_imprecise((i as f32).log10())), + "checking {i}" + ); } #[cfg(not(miri))] // Miri is too slow for i in 1..=u16::MAX { - assert_eq!(i.checked_ilog10(), Some((i as f32).log10() as u32), "checking {i}"); + assert_eq!( + i.checked_ilog10(), + Some(round_down_imprecise((i as f32).log10())), + "checking {i}" + ); } #[cfg(not(miri))] // Miri is too slow for i in 1..=100_000u32 { - assert_eq!(i.checked_ilog10(), Some((i as f32).log10() as u32), "checking {i}"); + assert_eq!( + i.checked_ilog10(), + Some(round_down_imprecise((i as f32).log10())), + "checking {i}" + ); } } diff --git a/coretests/tests/num/int_macros.rs b/coretests/tests/num/int_macros.rs index f13b836378b9e..bbf19d2b444f9 100644 --- a/coretests/tests/num/int_macros.rs +++ b/coretests/tests/num/int_macros.rs @@ -192,6 +192,40 @@ macro_rules! int_module { } } + #[test] + fn test_isolate_most_significant_one() { + const BITS: $T = -1; + const MOST_SIG_ONE: $T = 1 << (<$T>::BITS - 1); + + // Right shift the most significant one through each + // bit position, starting with all bits set + let mut i = 0; + while i < <$T>::BITS { + assert_eq!( + (BITS >> i).isolate_most_significant_one(), + (MOST_SIG_ONE >> i).isolate_most_significant_one() + ); + i += 1; + } + } + + #[test] + fn test_isolate_least_significant_one() { + const BITS: $T = -1; + const LEAST_SIG_ONE: $T = 1; + + // Left shift the least significant one through each + // bit position, starting with all bits set + let mut i = 0; + while i < <$T>::BITS { + assert_eq!( + (BITS << i).isolate_least_significant_one(), + (LEAST_SIG_ONE << i).isolate_least_significant_one() + ); + i += 1; + } + } + #[test] fn test_from_str() { fn from_str(t: &str) -> Option { @@ -478,5 +512,169 @@ macro_rules! int_module { assert_eq_const_safe!(<$T>::midpoint(6, <$T>::MAX), <$T>::MAX / 2 + 3); } } + + // test_unbounded_sh* constants + const SHIFT_AMOUNT_OVERFLOW: u32 = <$T>::BITS; + const SHIFT_AMOUNT_OVERFLOW2: u32 = <$T>::BITS + 3; + const SHIFT_AMOUNT_OVERFLOW3: u32 = <$T>::BITS << 2; + + const SHIFT_AMOUNT_TEST_ONE: u32 = <$T>::BITS >> 1; + const SHIFT_AMOUNT_TEST_TWO: u32 = <$T>::BITS >> 3; + const SHIFT_AMOUNT_TEST_THREE: u32 = (<$T>::BITS >> 1) - 1; + const SHIFT_AMOUNT_TEST_FOUR: u32 = <$T>::BITS - 1; + + test_runtime_and_compiletime! { + fn test_unbounded_shl() { + // <$T>::MIN + assert_eq_const_safe!(<$T>::unbounded_shl(<$T>::MIN, SHIFT_AMOUNT_TEST_ONE), (<$T>::MIN << SHIFT_AMOUNT_TEST_ONE)); + assert_eq_const_safe!(<$T>::unbounded_shl(<$T>::MIN, SHIFT_AMOUNT_TEST_TWO), (<$T>::MIN << SHIFT_AMOUNT_TEST_TWO)); + assert_eq_const_safe!(<$T>::unbounded_shl(<$T>::MIN, SHIFT_AMOUNT_TEST_THREE), (<$T>::MIN << SHIFT_AMOUNT_TEST_THREE)); + assert_eq_const_safe!(<$T>::unbounded_shl(<$T>::MIN, SHIFT_AMOUNT_TEST_FOUR), (<$T>::MIN << SHIFT_AMOUNT_TEST_FOUR)); + assert_eq_const_safe!(<$T>::unbounded_shl(<$T>::MIN, 1), (<$T>::MIN << 1)); + assert_eq_const_safe!(<$T>::unbounded_shl(<$T>::MIN, 3), (<$T>::MIN << 3)); + assert_eq_const_safe!(<$T>::unbounded_shl(<$T>::MIN, 5), (<$T>::MIN << 5)); + assert_eq_const_safe!(<$T>::unbounded_shl(<$T>::MIN, SHIFT_AMOUNT_OVERFLOW), 0); + assert_eq_const_safe!(<$T>::unbounded_shl(<$T>::MIN, SHIFT_AMOUNT_OVERFLOW2), 0); + assert_eq_const_safe!(<$T>::unbounded_shl(<$T>::MIN, SHIFT_AMOUNT_OVERFLOW3), 0); + + // <$T>::MAX + assert_eq_const_safe!(<$T>::unbounded_shl(<$T>::MAX, SHIFT_AMOUNT_TEST_ONE), (<$T>::MAX << SHIFT_AMOUNT_TEST_ONE)); + assert_eq_const_safe!(<$T>::unbounded_shl(<$T>::MAX, SHIFT_AMOUNT_TEST_TWO), (<$T>::MAX << SHIFT_AMOUNT_TEST_TWO)); + assert_eq_const_safe!(<$T>::unbounded_shl(<$T>::MAX, SHIFT_AMOUNT_TEST_THREE), (<$T>::MAX << SHIFT_AMOUNT_TEST_THREE)); + assert_eq_const_safe!(<$T>::unbounded_shl(<$T>::MAX, SHIFT_AMOUNT_TEST_FOUR), (<$T>::MAX << SHIFT_AMOUNT_TEST_FOUR)); + assert_eq_const_safe!(<$T>::unbounded_shl(<$T>::MAX, 1), (<$T>::MAX << 1)); + assert_eq_const_safe!(<$T>::unbounded_shl(<$T>::MAX, 3), (<$T>::MAX << 3)); + assert_eq_const_safe!(<$T>::unbounded_shl(<$T>::MAX, 5), (<$T>::MAX << 5)); + assert_eq_const_safe!(<$T>::unbounded_shl(<$T>::MAX, SHIFT_AMOUNT_OVERFLOW), 0); + assert_eq_const_safe!(<$T>::unbounded_shl(<$T>::MAX, SHIFT_AMOUNT_OVERFLOW2), 0); + assert_eq_const_safe!(<$T>::unbounded_shl(<$T>::MAX, SHIFT_AMOUNT_OVERFLOW3), 0); + + // 1 + assert_eq_const_safe!(<$T>::unbounded_shl(1, SHIFT_AMOUNT_TEST_ONE), (1 << SHIFT_AMOUNT_TEST_ONE)); + assert_eq_const_safe!(<$T>::unbounded_shl(1, SHIFT_AMOUNT_TEST_TWO), (1 << SHIFT_AMOUNT_TEST_TWO)); + assert_eq_const_safe!(<$T>::unbounded_shl(1, SHIFT_AMOUNT_TEST_THREE), (1 << SHIFT_AMOUNT_TEST_THREE)); + assert_eq_const_safe!(<$T>::unbounded_shl(1, SHIFT_AMOUNT_TEST_FOUR), (1 << SHIFT_AMOUNT_TEST_FOUR)); + assert_eq_const_safe!(<$T>::unbounded_shl(1, 1), (1 << 1)); + assert_eq_const_safe!(<$T>::unbounded_shl(1, 3), (1 << 3)); + assert_eq_const_safe!(<$T>::unbounded_shl(1, 5), (1 << 5)); + assert_eq_const_safe!(<$T>::unbounded_shl(1, SHIFT_AMOUNT_OVERFLOW), 0); + assert_eq_const_safe!(<$T>::unbounded_shl(1, SHIFT_AMOUNT_OVERFLOW), 0); + assert_eq_const_safe!(<$T>::unbounded_shl(1, SHIFT_AMOUNT_OVERFLOW2), 0); + assert_eq_const_safe!(<$T>::unbounded_shl(1, SHIFT_AMOUNT_OVERFLOW3), 0); + + // -1 + assert_eq_const_safe!(<$T>::unbounded_shl(-1, SHIFT_AMOUNT_TEST_ONE), (-1 << SHIFT_AMOUNT_TEST_ONE)); + assert_eq_const_safe!(<$T>::unbounded_shl(-1, SHIFT_AMOUNT_TEST_TWO), (-1 << SHIFT_AMOUNT_TEST_TWO)); + assert_eq_const_safe!(<$T>::unbounded_shl(-1, SHIFT_AMOUNT_TEST_THREE), (-1 << SHIFT_AMOUNT_TEST_THREE)); + assert_eq_const_safe!(<$T>::unbounded_shl(-1, SHIFT_AMOUNT_TEST_FOUR), (-1 << SHIFT_AMOUNT_TEST_FOUR)); + assert_eq_const_safe!(<$T>::unbounded_shl(-1, 1), (-1 << 1)); + assert_eq_const_safe!(<$T>::unbounded_shl(-1, 3), (-1 << 3)); + assert_eq_const_safe!(<$T>::unbounded_shl(-1, 5), (-1 << 5)); + assert_eq_const_safe!(<$T>::unbounded_shl(-1, SHIFT_AMOUNT_OVERFLOW), 0); + assert_eq_const_safe!(<$T>::unbounded_shl(-1, SHIFT_AMOUNT_OVERFLOW), 0); + assert_eq_const_safe!(<$T>::unbounded_shl(-1, SHIFT_AMOUNT_OVERFLOW2), 0); + assert_eq_const_safe!(<$T>::unbounded_shl(-1, SHIFT_AMOUNT_OVERFLOW3), 0); + + // 8 + assert_eq_const_safe!(<$T>::unbounded_shl(8, SHIFT_AMOUNT_TEST_ONE), (8 << SHIFT_AMOUNT_TEST_ONE)); + assert_eq_const_safe!(<$T>::unbounded_shl(8, SHIFT_AMOUNT_TEST_TWO), (8 << SHIFT_AMOUNT_TEST_TWO)); + assert_eq_const_safe!(<$T>::unbounded_shl(8, SHIFT_AMOUNT_TEST_THREE), (8 << SHIFT_AMOUNT_TEST_THREE)); + assert_eq_const_safe!(<$T>::unbounded_shl(8, SHIFT_AMOUNT_TEST_FOUR), (8 << SHIFT_AMOUNT_TEST_FOUR)); + assert_eq_const_safe!(<$T>::unbounded_shl(8, 1), (8 << 1)); + assert_eq_const_safe!(<$T>::unbounded_shl(8, 3), (8 << 3)); + assert_eq_const_safe!(<$T>::unbounded_shl(8, 5), (8 << 5)); + assert_eq_const_safe!(<$T>::unbounded_shl(8, SHIFT_AMOUNT_OVERFLOW), 0); + assert_eq_const_safe!(<$T>::unbounded_shl(8, SHIFT_AMOUNT_OVERFLOW2), 0); + assert_eq_const_safe!(<$T>::unbounded_shl(8, SHIFT_AMOUNT_OVERFLOW3), 0); + + // 17 + assert_eq_const_safe!(<$T>::unbounded_shl(17, SHIFT_AMOUNT_TEST_ONE), (17 << SHIFT_AMOUNT_TEST_ONE)); + assert_eq_const_safe!(<$T>::unbounded_shl(17, SHIFT_AMOUNT_TEST_TWO), (17 << SHIFT_AMOUNT_TEST_TWO)); + assert_eq_const_safe!(<$T>::unbounded_shl(17, SHIFT_AMOUNT_TEST_THREE), (17 << SHIFT_AMOUNT_TEST_THREE)); + assert_eq_const_safe!(<$T>::unbounded_shl(17, SHIFT_AMOUNT_TEST_FOUR), (17 << SHIFT_AMOUNT_TEST_FOUR)); + assert_eq_const_safe!(<$T>::unbounded_shl(17, 1), (17 << 1)); + assert_eq_const_safe!(<$T>::unbounded_shl(17, 3), (17 << 3)); + assert_eq_const_safe!(<$T>::unbounded_shl(17, 5), (17 << 5)); + assert_eq_const_safe!(<$T>::unbounded_shl(17, SHIFT_AMOUNT_OVERFLOW), 0); + assert_eq_const_safe!(<$T>::unbounded_shl(17, SHIFT_AMOUNT_OVERFLOW2), 0); + assert_eq_const_safe!(<$T>::unbounded_shl(17, SHIFT_AMOUNT_OVERFLOW3), 0); + } + + fn test_unbounded_shr() { + // <$T>::MIN + assert_eq_const_safe!(<$T>::unbounded_shr(<$T>::MIN, SHIFT_AMOUNT_TEST_ONE), (<$T>::MIN >> SHIFT_AMOUNT_TEST_ONE)); + assert_eq_const_safe!(<$T>::unbounded_shr(<$T>::MIN, SHIFT_AMOUNT_TEST_TWO), (<$T>::MIN >> SHIFT_AMOUNT_TEST_TWO)); + assert_eq_const_safe!(<$T>::unbounded_shr(<$T>::MIN, SHIFT_AMOUNT_TEST_THREE), (<$T>::MIN >> SHIFT_AMOUNT_TEST_THREE)); + assert_eq_const_safe!(<$T>::unbounded_shr(<$T>::MIN, SHIFT_AMOUNT_TEST_FOUR), (<$T>::MIN >> SHIFT_AMOUNT_TEST_FOUR)); + assert_eq_const_safe!(<$T>::unbounded_shr(<$T>::MIN, 1), (<$T>::MIN >> 1)); + assert_eq_const_safe!(<$T>::unbounded_shr(<$T>::MIN, 3), (<$T>::MIN >> 3)); + assert_eq_const_safe!(<$T>::unbounded_shr(<$T>::MIN, 5), (<$T>::MIN >> 5)); + assert_eq_const_safe!(<$T>::unbounded_shr(<$T>::MIN, SHIFT_AMOUNT_OVERFLOW), -1); + assert_eq_const_safe!(<$T>::unbounded_shr(<$T>::MIN, SHIFT_AMOUNT_OVERFLOW2), -1); + assert_eq_const_safe!(<$T>::unbounded_shr(<$T>::MIN, SHIFT_AMOUNT_OVERFLOW3), -1); + + // <$T>::MAX + assert_eq_const_safe!(<$T>::unbounded_shr(<$T>::MAX, SHIFT_AMOUNT_TEST_ONE), (<$T>::MAX >> SHIFT_AMOUNT_TEST_ONE)); + assert_eq_const_safe!(<$T>::unbounded_shr(<$T>::MAX, SHIFT_AMOUNT_TEST_TWO), (<$T>::MAX >> SHIFT_AMOUNT_TEST_TWO)); + assert_eq_const_safe!(<$T>::unbounded_shr(<$T>::MAX, SHIFT_AMOUNT_TEST_THREE), (<$T>::MAX >> SHIFT_AMOUNT_TEST_THREE)); + assert_eq_const_safe!(<$T>::unbounded_shr(<$T>::MAX, SHIFT_AMOUNT_TEST_FOUR), (<$T>::MAX >> SHIFT_AMOUNT_TEST_FOUR)); + assert_eq_const_safe!(<$T>::unbounded_shr(<$T>::MAX, 1), (<$T>::MAX >> 1)); + assert_eq_const_safe!(<$T>::unbounded_shr(<$T>::MAX, 3), (<$T>::MAX >> 3)); + assert_eq_const_safe!(<$T>::unbounded_shr(<$T>::MAX, 5), (<$T>::MAX >> 5)); + assert_eq_const_safe!(<$T>::unbounded_shr(<$T>::MAX, SHIFT_AMOUNT_OVERFLOW), 0); + assert_eq_const_safe!(<$T>::unbounded_shr(<$T>::MAX, SHIFT_AMOUNT_OVERFLOW2), 0); + assert_eq_const_safe!(<$T>::unbounded_shr(<$T>::MAX, SHIFT_AMOUNT_OVERFLOW3), 0); + + // 1 + assert_eq_const_safe!(<$T>::unbounded_shr(1, SHIFT_AMOUNT_TEST_ONE), (1 >> SHIFT_AMOUNT_TEST_ONE)); + assert_eq_const_safe!(<$T>::unbounded_shr(1, SHIFT_AMOUNT_TEST_TWO), (1 >> SHIFT_AMOUNT_TEST_TWO)); + assert_eq_const_safe!(<$T>::unbounded_shr(1, SHIFT_AMOUNT_TEST_THREE), (1 >> SHIFT_AMOUNT_TEST_THREE)); + assert_eq_const_safe!(<$T>::unbounded_shr(1, SHIFT_AMOUNT_TEST_FOUR), (1 >> SHIFT_AMOUNT_TEST_FOUR)); + assert_eq_const_safe!(<$T>::unbounded_shr(1, 1), (1 >> 1)); + assert_eq_const_safe!(<$T>::unbounded_shr(1, 3), (1 >> 3)); + assert_eq_const_safe!(<$T>::unbounded_shr(1, 5), (1 >> 5)); + assert_eq_const_safe!(<$T>::unbounded_shr(1, SHIFT_AMOUNT_OVERFLOW), 0); + assert_eq_const_safe!(<$T>::unbounded_shr(1, SHIFT_AMOUNT_OVERFLOW), 0); + assert_eq_const_safe!(<$T>::unbounded_shr(1, SHIFT_AMOUNT_OVERFLOW2), 0); + assert_eq_const_safe!(<$T>::unbounded_shr(1, SHIFT_AMOUNT_OVERFLOW3), 0); + + // -1 + assert_eq_const_safe!(<$T>::unbounded_shr(-1, SHIFT_AMOUNT_TEST_ONE), (-1 >> SHIFT_AMOUNT_TEST_ONE)); + assert_eq_const_safe!(<$T>::unbounded_shr(-1, SHIFT_AMOUNT_TEST_TWO), (-1 >> SHIFT_AMOUNT_TEST_TWO)); + assert_eq_const_safe!(<$T>::unbounded_shr(-1, SHIFT_AMOUNT_TEST_THREE), (-1 >> SHIFT_AMOUNT_TEST_THREE)); + assert_eq_const_safe!(<$T>::unbounded_shr(-1, SHIFT_AMOUNT_TEST_FOUR), (-1 >> SHIFT_AMOUNT_TEST_FOUR)); + assert_eq_const_safe!(<$T>::unbounded_shr(-1, 1), (-1 >> 1)); + assert_eq_const_safe!(<$T>::unbounded_shr(-1, 3), (-1 >> 3)); + assert_eq_const_safe!(<$T>::unbounded_shr(-1, 5), (-1 >> 5)); + assert_eq_const_safe!(<$T>::unbounded_shr(-1, SHIFT_AMOUNT_OVERFLOW), -1); + assert_eq_const_safe!(<$T>::unbounded_shr(-1, SHIFT_AMOUNT_OVERFLOW), -1); + assert_eq_const_safe!(<$T>::unbounded_shr(-1, SHIFT_AMOUNT_OVERFLOW2), -1); + assert_eq_const_safe!(<$T>::unbounded_shr(-1, SHIFT_AMOUNT_OVERFLOW3), -1); + + // 8 + assert_eq_const_safe!(<$T>::unbounded_shr(8, SHIFT_AMOUNT_TEST_ONE), (8 >> SHIFT_AMOUNT_TEST_ONE)); + assert_eq_const_safe!(<$T>::unbounded_shr(8, SHIFT_AMOUNT_TEST_TWO), (8 >> SHIFT_AMOUNT_TEST_TWO)); + assert_eq_const_safe!(<$T>::unbounded_shr(8, SHIFT_AMOUNT_TEST_THREE), (8 >> SHIFT_AMOUNT_TEST_THREE)); + assert_eq_const_safe!(<$T>::unbounded_shr(8, SHIFT_AMOUNT_TEST_FOUR), (8 >> SHIFT_AMOUNT_TEST_FOUR)); + assert_eq_const_safe!(<$T>::unbounded_shr(8, 1), (8 >> 1)); + assert_eq_const_safe!(<$T>::unbounded_shr(8, 3), (8 >> 3)); + assert_eq_const_safe!(<$T>::unbounded_shr(8, 5), (8 >> 5)); + assert_eq_const_safe!(<$T>::unbounded_shr(8, SHIFT_AMOUNT_OVERFLOW), 0); + assert_eq_const_safe!(<$T>::unbounded_shr(8, SHIFT_AMOUNT_OVERFLOW2), 0); + assert_eq_const_safe!(<$T>::unbounded_shr(8, SHIFT_AMOUNT_OVERFLOW3), 0); + + // 17 + assert_eq_const_safe!(<$T>::unbounded_shr(17, SHIFT_AMOUNT_TEST_ONE), (17 >> SHIFT_AMOUNT_TEST_ONE)); + assert_eq_const_safe!(<$T>::unbounded_shr(17, SHIFT_AMOUNT_TEST_TWO), (17 >> SHIFT_AMOUNT_TEST_TWO)); + assert_eq_const_safe!(<$T>::unbounded_shr(17, SHIFT_AMOUNT_TEST_THREE), (17 >> SHIFT_AMOUNT_TEST_THREE)); + assert_eq_const_safe!(<$T>::unbounded_shr(17, SHIFT_AMOUNT_TEST_FOUR), (17 >> SHIFT_AMOUNT_TEST_FOUR)); + assert_eq_const_safe!(<$T>::unbounded_shr(17, 1), (17 >> 1)); + assert_eq_const_safe!(<$T>::unbounded_shr(17, 3), (17 >> 3)); + assert_eq_const_safe!(<$T>::unbounded_shr(17, 5), (17 >> 5)); + assert_eq_const_safe!(<$T>::unbounded_shr(17, SHIFT_AMOUNT_OVERFLOW), 0); + assert_eq_const_safe!(<$T>::unbounded_shr(17, SHIFT_AMOUNT_OVERFLOW2), 0); + assert_eq_const_safe!(<$T>::unbounded_shr(17, SHIFT_AMOUNT_OVERFLOW3), 0); + } + } }; } diff --git a/coretests/tests/num/uint_macros.rs b/coretests/tests/num/uint_macros.rs index 99a2d4cd462b1..d09eb97b17e06 100644 --- a/coretests/tests/num/uint_macros.rs +++ b/coretests/tests/num/uint_macros.rs @@ -141,6 +141,40 @@ macro_rules! uint_module { } } + #[test] + fn test_isolate_most_significant_one() { + const BITS: $T = <$T>::MAX; + const MOST_SIG_ONE: $T = 1 << (<$T>::BITS - 1); + + // Right shift the most significant one through each + // bit position, starting with all bits set + let mut i = 0; + while i < <$T>::BITS { + assert_eq!( + (BITS >> i).isolate_most_significant_one(), + (MOST_SIG_ONE >> i).isolate_most_significant_one(), + ); + i += 1; + } + } + + #[test] + fn test_isolate_least_significant_one() { + const BITS: $T = <$T>::MAX; + const LEAST_SIG_ONE: $T = 1; + + // Left shift the least significant one through each + // bit position, starting with all bits set + let mut i = 0; + while i < <$T>::BITS { + assert_eq!( + (BITS << i).isolate_least_significant_one(), + (LEAST_SIG_ONE << i).isolate_least_significant_one(), + ); + i += 1; + } + } + fn from_str(t: &str) -> Option { core::str::FromStr::from_str(t).ok() } @@ -317,5 +351,169 @@ macro_rules! uint_module { assert_eq_const_safe!(<$T>::midpoint(6, <$T>::MAX), (<$T>::MAX - <$T>::MIN) / 2 + 3); } } + + // test_unbounded_sh* constants + const SHIFT_AMOUNT_OVERFLOW: u32 = <$T>::BITS; + const SHIFT_AMOUNT_OVERFLOW2: u32 = <$T>::BITS + 3; + const SHIFT_AMOUNT_OVERFLOW3: u32 = <$T>::BITS << 2; + + const SHIFT_AMOUNT_TEST_ONE: u32 = <$T>::BITS >> 1; + const SHIFT_AMOUNT_TEST_TWO: u32 = <$T>::BITS >> 3; + const SHIFT_AMOUNT_TEST_THREE: u32 = (<$T>::BITS >> 1) - 1; + const SHIFT_AMOUNT_TEST_FOUR: u32 = <$T>::BITS - 1; + + test_runtime_and_compiletime! { + fn test_unbounded_shl() { + // <$T>::MIN + assert_eq_const_safe!(<$T>::unbounded_shl(<$T>::MIN, SHIFT_AMOUNT_TEST_ONE), (<$T>::MIN << SHIFT_AMOUNT_TEST_ONE)); + assert_eq_const_safe!(<$T>::unbounded_shl(<$T>::MIN, SHIFT_AMOUNT_TEST_TWO), (<$T>::MIN << SHIFT_AMOUNT_TEST_TWO)); + assert_eq_const_safe!(<$T>::unbounded_shl(<$T>::MIN, SHIFT_AMOUNT_TEST_THREE), (<$T>::MIN << SHIFT_AMOUNT_TEST_THREE)); + assert_eq_const_safe!(<$T>::unbounded_shl(<$T>::MIN, SHIFT_AMOUNT_TEST_FOUR), (<$T>::MIN << SHIFT_AMOUNT_TEST_FOUR)); + assert_eq_const_safe!(<$T>::unbounded_shl(<$T>::MIN, 1), (<$T>::MIN << 1)); + assert_eq_const_safe!(<$T>::unbounded_shl(<$T>::MIN, 3), (<$T>::MIN << 3)); + assert_eq_const_safe!(<$T>::unbounded_shl(<$T>::MIN, 5), (<$T>::MIN << 5)); + assert_eq_const_safe!(<$T>::unbounded_shl(<$T>::MIN, SHIFT_AMOUNT_OVERFLOW), 0); + assert_eq_const_safe!(<$T>::unbounded_shl(<$T>::MIN, SHIFT_AMOUNT_OVERFLOW2), 0); + assert_eq_const_safe!(<$T>::unbounded_shl(<$T>::MIN, SHIFT_AMOUNT_OVERFLOW3), 0); + + // <$T>::MAX + assert_eq_const_safe!(<$T>::unbounded_shl(<$T>::MAX, SHIFT_AMOUNT_TEST_ONE), (<$T>::MAX << SHIFT_AMOUNT_TEST_ONE)); + assert_eq_const_safe!(<$T>::unbounded_shl(<$T>::MAX, SHIFT_AMOUNT_TEST_TWO), (<$T>::MAX << SHIFT_AMOUNT_TEST_TWO)); + assert_eq_const_safe!(<$T>::unbounded_shl(<$T>::MAX, SHIFT_AMOUNT_TEST_THREE), (<$T>::MAX << SHIFT_AMOUNT_TEST_THREE)); + assert_eq_const_safe!(<$T>::unbounded_shl(<$T>::MAX, SHIFT_AMOUNT_TEST_FOUR), (<$T>::MAX << SHIFT_AMOUNT_TEST_FOUR)); + assert_eq_const_safe!(<$T>::unbounded_shl(<$T>::MAX, 1), (<$T>::MAX << 1)); + assert_eq_const_safe!(<$T>::unbounded_shl(<$T>::MAX, 3), (<$T>::MAX << 3)); + assert_eq_const_safe!(<$T>::unbounded_shl(<$T>::MAX, 5), (<$T>::MAX << 5)); + assert_eq_const_safe!(<$T>::unbounded_shl(<$T>::MAX, SHIFT_AMOUNT_OVERFLOW), 0); + assert_eq_const_safe!(<$T>::unbounded_shl(<$T>::MAX, SHIFT_AMOUNT_OVERFLOW2), 0); + assert_eq_const_safe!(<$T>::unbounded_shl(<$T>::MAX, SHIFT_AMOUNT_OVERFLOW3), 0); + + // 1 + assert_eq_const_safe!(<$T>::unbounded_shl(1, SHIFT_AMOUNT_TEST_ONE), (1 << SHIFT_AMOUNT_TEST_ONE)); + assert_eq_const_safe!(<$T>::unbounded_shl(1, SHIFT_AMOUNT_TEST_TWO), (1 << SHIFT_AMOUNT_TEST_TWO)); + assert_eq_const_safe!(<$T>::unbounded_shl(1, SHIFT_AMOUNT_TEST_THREE), (1 << SHIFT_AMOUNT_TEST_THREE)); + assert_eq_const_safe!(<$T>::unbounded_shl(1, SHIFT_AMOUNT_TEST_FOUR), (1 << SHIFT_AMOUNT_TEST_FOUR)); + assert_eq_const_safe!(<$T>::unbounded_shl(1, 1), (1 << 1)); + assert_eq_const_safe!(<$T>::unbounded_shl(1, 3), (1 << 3)); + assert_eq_const_safe!(<$T>::unbounded_shl(1, 5), (1 << 5)); + assert_eq_const_safe!(<$T>::unbounded_shl(1, SHIFT_AMOUNT_OVERFLOW), 0); + assert_eq_const_safe!(<$T>::unbounded_shl(1, SHIFT_AMOUNT_OVERFLOW), 0); + assert_eq_const_safe!(<$T>::unbounded_shl(1, SHIFT_AMOUNT_OVERFLOW2), 0); + assert_eq_const_safe!(<$T>::unbounded_shl(1, SHIFT_AMOUNT_OVERFLOW3), 0); + + // !0 + assert_eq_const_safe!(<$T>::unbounded_shl(!0, SHIFT_AMOUNT_TEST_ONE), (!0 << SHIFT_AMOUNT_TEST_ONE)); + assert_eq_const_safe!(<$T>::unbounded_shl(!0, SHIFT_AMOUNT_TEST_TWO), (!0 << SHIFT_AMOUNT_TEST_TWO)); + assert_eq_const_safe!(<$T>::unbounded_shl(!0, SHIFT_AMOUNT_TEST_THREE), (!0 << SHIFT_AMOUNT_TEST_THREE)); + assert_eq_const_safe!(<$T>::unbounded_shl(!0, SHIFT_AMOUNT_TEST_FOUR), (!0 << SHIFT_AMOUNT_TEST_FOUR)); + assert_eq_const_safe!(<$T>::unbounded_shl(!0, 1), (!0 << 1)); + assert_eq_const_safe!(<$T>::unbounded_shl(!0, 3), (!0 << 3)); + assert_eq_const_safe!(<$T>::unbounded_shl(!0, 5), (!0 << 5)); + assert_eq_const_safe!(<$T>::unbounded_shl(!0, SHIFT_AMOUNT_OVERFLOW), 0); + assert_eq_const_safe!(<$T>::unbounded_shl(!0, SHIFT_AMOUNT_OVERFLOW), 0); + assert_eq_const_safe!(<$T>::unbounded_shl(!0, SHIFT_AMOUNT_OVERFLOW2), 0); + assert_eq_const_safe!(<$T>::unbounded_shl(!0, SHIFT_AMOUNT_OVERFLOW3), 0); + + // 8 + assert_eq_const_safe!(<$T>::unbounded_shl(8, SHIFT_AMOUNT_TEST_ONE), (8 << SHIFT_AMOUNT_TEST_ONE)); + assert_eq_const_safe!(<$T>::unbounded_shl(8, SHIFT_AMOUNT_TEST_TWO), (8 << SHIFT_AMOUNT_TEST_TWO)); + assert_eq_const_safe!(<$T>::unbounded_shl(8, SHIFT_AMOUNT_TEST_THREE), (8 << SHIFT_AMOUNT_TEST_THREE)); + assert_eq_const_safe!(<$T>::unbounded_shl(8, SHIFT_AMOUNT_TEST_FOUR), (8 << SHIFT_AMOUNT_TEST_FOUR)); + assert_eq_const_safe!(<$T>::unbounded_shl(8, 1), (8 << 1)); + assert_eq_const_safe!(<$T>::unbounded_shl(8, 3), (8 << 3)); + assert_eq_const_safe!(<$T>::unbounded_shl(8, 5), (8 << 5)); + assert_eq_const_safe!(<$T>::unbounded_shl(8, SHIFT_AMOUNT_OVERFLOW), 0); + assert_eq_const_safe!(<$T>::unbounded_shl(8, SHIFT_AMOUNT_OVERFLOW2), 0); + assert_eq_const_safe!(<$T>::unbounded_shl(8, SHIFT_AMOUNT_OVERFLOW3), 0); + + // 17 + assert_eq_const_safe!(<$T>::unbounded_shl(17, SHIFT_AMOUNT_TEST_ONE), (17 << SHIFT_AMOUNT_TEST_ONE)); + assert_eq_const_safe!(<$T>::unbounded_shl(17, SHIFT_AMOUNT_TEST_TWO), (17 << SHIFT_AMOUNT_TEST_TWO)); + assert_eq_const_safe!(<$T>::unbounded_shl(17, SHIFT_AMOUNT_TEST_THREE), (17 << SHIFT_AMOUNT_TEST_THREE)); + assert_eq_const_safe!(<$T>::unbounded_shl(17, SHIFT_AMOUNT_TEST_FOUR), (17 << SHIFT_AMOUNT_TEST_FOUR)); + assert_eq_const_safe!(<$T>::unbounded_shl(17, 1), (17 << 1)); + assert_eq_const_safe!(<$T>::unbounded_shl(17, 3), (17 << 3)); + assert_eq_const_safe!(<$T>::unbounded_shl(17, 5), (17 << 5)); + assert_eq_const_safe!(<$T>::unbounded_shl(17, SHIFT_AMOUNT_OVERFLOW), 0); + assert_eq_const_safe!(<$T>::unbounded_shl(17, SHIFT_AMOUNT_OVERFLOW2), 0); + assert_eq_const_safe!(<$T>::unbounded_shl(17, SHIFT_AMOUNT_OVERFLOW3), 0); + } + + fn test_unbounded_shr() { + // <$T>::MIN + assert_eq_const_safe!(<$T>::unbounded_shr(<$T>::MIN, SHIFT_AMOUNT_TEST_ONE), (<$T>::MIN >> SHIFT_AMOUNT_TEST_ONE)); + assert_eq_const_safe!(<$T>::unbounded_shr(<$T>::MIN, SHIFT_AMOUNT_TEST_TWO), (<$T>::MIN >> SHIFT_AMOUNT_TEST_TWO)); + assert_eq_const_safe!(<$T>::unbounded_shr(<$T>::MIN, SHIFT_AMOUNT_TEST_THREE), (<$T>::MIN >> SHIFT_AMOUNT_TEST_THREE)); + assert_eq_const_safe!(<$T>::unbounded_shr(<$T>::MIN, SHIFT_AMOUNT_TEST_FOUR), (<$T>::MIN >> SHIFT_AMOUNT_TEST_FOUR)); + assert_eq_const_safe!(<$T>::unbounded_shr(<$T>::MIN, 1), (<$T>::MIN >> 1)); + assert_eq_const_safe!(<$T>::unbounded_shr(<$T>::MIN, 3), (<$T>::MIN >> 3)); + assert_eq_const_safe!(<$T>::unbounded_shr(<$T>::MIN, 5), (<$T>::MIN >> 5)); + assert_eq_const_safe!(<$T>::unbounded_shr(<$T>::MIN, SHIFT_AMOUNT_OVERFLOW), 0); + assert_eq_const_safe!(<$T>::unbounded_shr(<$T>::MIN, SHIFT_AMOUNT_OVERFLOW2), 0); + assert_eq_const_safe!(<$T>::unbounded_shr(<$T>::MIN, SHIFT_AMOUNT_OVERFLOW3), 0); + + // <$T>::MAX + assert_eq_const_safe!(<$T>::unbounded_shr(<$T>::MAX, SHIFT_AMOUNT_TEST_ONE), (<$T>::MAX >> SHIFT_AMOUNT_TEST_ONE)); + assert_eq_const_safe!(<$T>::unbounded_shr(<$T>::MAX, SHIFT_AMOUNT_TEST_TWO), (<$T>::MAX >> SHIFT_AMOUNT_TEST_TWO)); + assert_eq_const_safe!(<$T>::unbounded_shr(<$T>::MAX, SHIFT_AMOUNT_TEST_THREE), (<$T>::MAX >> SHIFT_AMOUNT_TEST_THREE)); + assert_eq_const_safe!(<$T>::unbounded_shr(<$T>::MAX, SHIFT_AMOUNT_TEST_FOUR), (<$T>::MAX >> SHIFT_AMOUNT_TEST_FOUR)); + assert_eq_const_safe!(<$T>::unbounded_shr(<$T>::MAX, 1), (<$T>::MAX >> 1)); + assert_eq_const_safe!(<$T>::unbounded_shr(<$T>::MAX, 3), (<$T>::MAX >> 3)); + assert_eq_const_safe!(<$T>::unbounded_shr(<$T>::MAX, 5), (<$T>::MAX >> 5)); + assert_eq_const_safe!(<$T>::unbounded_shr(<$T>::MAX, SHIFT_AMOUNT_OVERFLOW), 0); + assert_eq_const_safe!(<$T>::unbounded_shr(<$T>::MAX, SHIFT_AMOUNT_OVERFLOW2), 0); + assert_eq_const_safe!(<$T>::unbounded_shr(<$T>::MAX, SHIFT_AMOUNT_OVERFLOW3), 0); + + // 1 + assert_eq_const_safe!(<$T>::unbounded_shr(1, SHIFT_AMOUNT_TEST_ONE), (1 >> SHIFT_AMOUNT_TEST_ONE)); + assert_eq_const_safe!(<$T>::unbounded_shr(1, SHIFT_AMOUNT_TEST_TWO), (1 >> SHIFT_AMOUNT_TEST_TWO)); + assert_eq_const_safe!(<$T>::unbounded_shr(1, SHIFT_AMOUNT_TEST_THREE), (1 >> SHIFT_AMOUNT_TEST_THREE)); + assert_eq_const_safe!(<$T>::unbounded_shr(1, SHIFT_AMOUNT_TEST_FOUR), (1 >> SHIFT_AMOUNT_TEST_FOUR)); + assert_eq_const_safe!(<$T>::unbounded_shr(1, 1), (1 >> 1)); + assert_eq_const_safe!(<$T>::unbounded_shr(1, 3), (1 >> 3)); + assert_eq_const_safe!(<$T>::unbounded_shr(1, 5), (1 >> 5)); + assert_eq_const_safe!(<$T>::unbounded_shr(1, SHIFT_AMOUNT_OVERFLOW), 0); + assert_eq_const_safe!(<$T>::unbounded_shr(1, SHIFT_AMOUNT_OVERFLOW), 0); + assert_eq_const_safe!(<$T>::unbounded_shr(1, SHIFT_AMOUNT_OVERFLOW2), 0); + assert_eq_const_safe!(<$T>::unbounded_shr(1, SHIFT_AMOUNT_OVERFLOW3), 0); + + // !0 + assert_eq_const_safe!(<$T>::unbounded_shr(!0, SHIFT_AMOUNT_TEST_ONE), (!0 >> SHIFT_AMOUNT_TEST_ONE)); + assert_eq_const_safe!(<$T>::unbounded_shr(!0, SHIFT_AMOUNT_TEST_TWO), (!0 >> SHIFT_AMOUNT_TEST_TWO)); + assert_eq_const_safe!(<$T>::unbounded_shr(!0, SHIFT_AMOUNT_TEST_THREE), (!0 >> SHIFT_AMOUNT_TEST_THREE)); + assert_eq_const_safe!(<$T>::unbounded_shr(!0, SHIFT_AMOUNT_TEST_FOUR), (!0 >> SHIFT_AMOUNT_TEST_FOUR)); + assert_eq_const_safe!(<$T>::unbounded_shr(!0, 1), (!0 >> 1)); + assert_eq_const_safe!(<$T>::unbounded_shr(!0, 3), (!0 >> 3)); + assert_eq_const_safe!(<$T>::unbounded_shr(!0, 5), (!0 >> 5)); + assert_eq_const_safe!(<$T>::unbounded_shr(!0, SHIFT_AMOUNT_OVERFLOW), 0); + assert_eq_const_safe!(<$T>::unbounded_shr(!0, SHIFT_AMOUNT_OVERFLOW), 0); + assert_eq_const_safe!(<$T>::unbounded_shr(!0, SHIFT_AMOUNT_OVERFLOW2), 0); + assert_eq_const_safe!(<$T>::unbounded_shr(!0, SHIFT_AMOUNT_OVERFLOW3), 0); + + // 8 + assert_eq_const_safe!(<$T>::unbounded_shr(8, SHIFT_AMOUNT_TEST_ONE), (8 >> SHIFT_AMOUNT_TEST_ONE)); + assert_eq_const_safe!(<$T>::unbounded_shr(8, SHIFT_AMOUNT_TEST_TWO), (8 >> SHIFT_AMOUNT_TEST_TWO)); + assert_eq_const_safe!(<$T>::unbounded_shr(8, SHIFT_AMOUNT_TEST_THREE), (8 >> SHIFT_AMOUNT_TEST_THREE)); + assert_eq_const_safe!(<$T>::unbounded_shr(8, SHIFT_AMOUNT_TEST_FOUR), (8 >> SHIFT_AMOUNT_TEST_FOUR)); + assert_eq_const_safe!(<$T>::unbounded_shr(8, 1), (8 >> 1)); + assert_eq_const_safe!(<$T>::unbounded_shr(8, 3), (8 >> 3)); + assert_eq_const_safe!(<$T>::unbounded_shr(8, 5), (8 >> 5)); + assert_eq_const_safe!(<$T>::unbounded_shr(8, SHIFT_AMOUNT_OVERFLOW), 0); + assert_eq_const_safe!(<$T>::unbounded_shr(8, SHIFT_AMOUNT_OVERFLOW2), 0); + assert_eq_const_safe!(<$T>::unbounded_shr(8, SHIFT_AMOUNT_OVERFLOW3), 0); + + // 17 + assert_eq_const_safe!(<$T>::unbounded_shr(17, SHIFT_AMOUNT_TEST_ONE), (17 >> SHIFT_AMOUNT_TEST_ONE)); + assert_eq_const_safe!(<$T>::unbounded_shr(17, SHIFT_AMOUNT_TEST_TWO), (17 >> SHIFT_AMOUNT_TEST_TWO)); + assert_eq_const_safe!(<$T>::unbounded_shr(17, SHIFT_AMOUNT_TEST_THREE), (17 >> SHIFT_AMOUNT_TEST_THREE)); + assert_eq_const_safe!(<$T>::unbounded_shr(17, SHIFT_AMOUNT_TEST_FOUR), (17 >> SHIFT_AMOUNT_TEST_FOUR)); + assert_eq_const_safe!(<$T>::unbounded_shr(17, 1), (17 >> 1)); + assert_eq_const_safe!(<$T>::unbounded_shr(17, 3), (17 >> 3)); + assert_eq_const_safe!(<$T>::unbounded_shr(17, 5), (17 >> 5)); + assert_eq_const_safe!(<$T>::unbounded_shr(17, SHIFT_AMOUNT_OVERFLOW), 0); + assert_eq_const_safe!(<$T>::unbounded_shr(17, SHIFT_AMOUNT_OVERFLOW2), 0); + assert_eq_const_safe!(<$T>::unbounded_shr(17, SHIFT_AMOUNT_OVERFLOW3), 0); + } + } }; } diff --git a/coretests/tests/pin.rs b/coretests/tests/pin.rs index 026d2ca8de26a..b3fb06e710d44 100644 --- a/coretests/tests/pin.rs +++ b/coretests/tests/pin.rs @@ -28,7 +28,9 @@ fn pin_const() { const fn pin_mut_const() { let _ = Pin::new(&mut 2).into_ref(); let _ = Pin::new(&mut 2).get_mut(); - let _ = unsafe { Pin::new(&mut 2).get_unchecked_mut() }; + unsafe { + let _ = Pin::new(&mut 2).get_unchecked_mut(); + } } pin_mut_const(); diff --git a/coretests/tests/ptr.rs b/coretests/tests/ptr.rs index 345bec345d128..0c9f9b338b0c1 100644 --- a/coretests/tests/ptr.rs +++ b/coretests/tests/ptr.rs @@ -97,7 +97,7 @@ fn test_is_null() { let nmi: *mut dyn ToString = null_mut::(); assert!(nmi.is_null()); - extern "C" { + unsafe extern "C" { type Extern; } let ec: *const Extern = null::(); @@ -308,7 +308,7 @@ fn test_const_nonnull_new() { pub fn test_variadic_fnptr() { use core::ffi; use core::hash::{Hash, SipHasher}; - extern "C" { + unsafe extern "C" { // This needs to use the correct function signature even though it isn't called as some // codegen backends make it UB to declare a function with multiple conflicting signatures // (like LLVM) while others straight up return an error (like Cranelift). @@ -506,7 +506,7 @@ fn offset_from() { fn ptr_metadata() { struct Unit; struct Pair(A, B); - extern "C" { + unsafe extern "C" { type Extern; } let () = metadata(&()); diff --git a/coretests/tests/slice.rs b/coretests/tests/slice.rs index ea5322da3812d..1c5c8a9ebf258 100644 --- a/coretests/tests/slice.rs +++ b/coretests/tests/slice.rs @@ -5,6 +5,8 @@ use core::num::NonZero; use core::ops::{Range, RangeInclusive}; use core::slice; +use rand::seq::IndexedRandom; + #[test] fn test_position() { let b = [1, 2, 3, 5, 5]; @@ -1291,7 +1293,7 @@ fn test_iter_ref_consistency() { fn test(x: T) { let v: &[T] = &[x, x, x]; let v_ptrs: [*const T; 3] = match v { - [ref v1, ref v2, ref v3] => [v1 as *const _, v2 as *const _, v3 as *const _], + [v1, v2, v3] => [v1 as *const _, v2 as *const _, v3 as *const _], _ => unreachable!(), }; let len = v.len(); @@ -1346,7 +1348,7 @@ fn test_iter_ref_consistency() { fn test_mut(x: T) { let v: &mut [T] = &mut [x, x, x]; let v_ptrs: [*mut T; 3] = match v { - [ref v1, ref v2, ref v3] => { + &mut [ref v1, ref v2, ref v3] => { [v1 as *const _ as *mut _, v2 as *const _ as *mut _, v3 as *const _ as *mut _] } _ => unreachable!(), @@ -1808,7 +1810,6 @@ fn select_nth_unstable() { use core::cmp::Ordering::{Equal, Greater, Less}; use rand::Rng; - use rand::seq::SliceRandom; let mut rng = crate::test_rng(); @@ -1818,7 +1819,7 @@ fn select_nth_unstable() { for &modulus in &[5, 10, 1000] { for _ in 0..10 { for i in 0..len { - orig[i] = rng.gen::() % modulus; + orig[i] = rng.random::() % modulus; } let v_sorted = { @@ -2548,14 +2549,14 @@ fn test_flatten_mut_size_overflow() { } #[test] -fn test_get_many_mut_normal_2() { +fn test_get_disjoint_mut_normal_2() { let mut v = vec![1, 2, 3, 4, 5]; - let [a, b] = v.get_many_mut([3, 0]).unwrap(); + let [a, b] = v.get_disjoint_mut([3, 0]).unwrap(); *a += 10; *b += 100; assert_eq!(v, vec![101, 2, 3, 14, 5]); - let [a, b] = v.get_many_mut([0..=1, 2..=2]).unwrap(); + let [a, b] = v.get_disjoint_mut([0..=1, 2..=2]).unwrap(); assert_eq!(a, &mut [101, 2][..]); assert_eq!(b, &mut [3][..]); a[0] += 10; @@ -2565,15 +2566,15 @@ fn test_get_many_mut_normal_2() { } #[test] -fn test_get_many_mut_normal_3() { +fn test_get_disjoint_mut_normal_3() { let mut v = vec![1, 2, 3, 4, 5]; - let [a, b, c] = v.get_many_mut([0, 4, 2]).unwrap(); + let [a, b, c] = v.get_disjoint_mut([0, 4, 2]).unwrap(); *a += 10; *b += 100; *c += 1000; assert_eq!(v, vec![11, 2, 1003, 4, 105]); - let [a, b, c] = v.get_many_mut([0..1, 4..5, 1..4]).unwrap(); + let [a, b, c] = v.get_disjoint_mut([0..1, 4..5, 1..4]).unwrap(); assert_eq!(a, &mut [11][..]); assert_eq!(b, &mut [105][..]); assert_eq!(c, &mut [2, 1003, 4][..]); @@ -2584,80 +2585,80 @@ fn test_get_many_mut_normal_3() { } #[test] -fn test_get_many_mut_empty() { +fn test_get_disjoint_mut_empty() { let mut v = vec![1, 2, 3, 4, 5]; - let [] = v.get_many_mut::([]).unwrap(); - let [] = v.get_many_mut::, 0>([]).unwrap(); - let [] = v.get_many_mut::, 0>([]).unwrap(); + let [] = v.get_disjoint_mut::([]).unwrap(); + let [] = v.get_disjoint_mut::, 0>([]).unwrap(); + let [] = v.get_disjoint_mut::, 0>([]).unwrap(); assert_eq!(v, vec![1, 2, 3, 4, 5]); } #[test] -fn test_get_many_mut_single_first() { +fn test_get_disjoint_mut_single_first() { let mut v = vec![1, 2, 3, 4, 5]; - let [a] = v.get_many_mut([0]).unwrap(); + let [a] = v.get_disjoint_mut([0]).unwrap(); *a += 10; assert_eq!(v, vec![11, 2, 3, 4, 5]); } #[test] -fn test_get_many_mut_single_last() { +fn test_get_disjoint_mut_single_last() { let mut v = vec![1, 2, 3, 4, 5]; - let [a] = v.get_many_mut([4]).unwrap(); + let [a] = v.get_disjoint_mut([4]).unwrap(); *a += 10; assert_eq!(v, vec![1, 2, 3, 4, 15]); } #[test] -fn test_get_many_mut_oob_nonempty() { +fn test_get_disjoint_mut_oob_nonempty() { let mut v = vec![1, 2, 3, 4, 5]; - assert!(v.get_many_mut([5]).is_err()); + assert!(v.get_disjoint_mut([5]).is_err()); } #[test] -fn test_get_many_mut_oob_empty() { +fn test_get_disjoint_mut_oob_empty() { let mut v: Vec = vec![]; - assert!(v.get_many_mut([0]).is_err()); + assert!(v.get_disjoint_mut([0]).is_err()); } #[test] -fn test_get_many_mut_duplicate() { +fn test_get_disjoint_mut_duplicate() { let mut v = vec![1, 2, 3, 4, 5]; - assert!(v.get_many_mut([1, 3, 3, 4]).is_err()); + assert!(v.get_disjoint_mut([1, 3, 3, 4]).is_err()); } #[test] -fn test_get_many_mut_range_oob() { +fn test_get_disjoint_mut_range_oob() { let mut v = vec![1, 2, 3, 4, 5]; - assert!(v.get_many_mut([0..6]).is_err()); - assert!(v.get_many_mut([5..6]).is_err()); - assert!(v.get_many_mut([6..6]).is_err()); - assert!(v.get_many_mut([0..=5]).is_err()); - assert!(v.get_many_mut([0..=6]).is_err()); - assert!(v.get_many_mut([5..=5]).is_err()); + assert!(v.get_disjoint_mut([0..6]).is_err()); + assert!(v.get_disjoint_mut([5..6]).is_err()); + assert!(v.get_disjoint_mut([6..6]).is_err()); + assert!(v.get_disjoint_mut([0..=5]).is_err()); + assert!(v.get_disjoint_mut([0..=6]).is_err()); + assert!(v.get_disjoint_mut([5..=5]).is_err()); } #[test] -fn test_get_many_mut_range_overlapping() { +fn test_get_disjoint_mut_range_overlapping() { let mut v = vec![1, 2, 3, 4, 5]; - assert!(v.get_many_mut([0..1, 0..2]).is_err()); - assert!(v.get_many_mut([0..1, 1..2, 0..1]).is_err()); - assert!(v.get_many_mut([0..3, 1..1]).is_err()); - assert!(v.get_many_mut([0..3, 1..2]).is_err()); - assert!(v.get_many_mut([0..=0, 2..=2, 0..=1]).is_err()); - assert!(v.get_many_mut([0..=4, 0..=0]).is_err()); - assert!(v.get_many_mut([4..=4, 0..=0, 3..=4]).is_err()); + assert!(v.get_disjoint_mut([0..1, 0..2]).is_err()); + assert!(v.get_disjoint_mut([0..1, 1..2, 0..1]).is_err()); + assert!(v.get_disjoint_mut([0..3, 1..1]).is_err()); + assert!(v.get_disjoint_mut([0..3, 1..2]).is_err()); + assert!(v.get_disjoint_mut([0..=0, 2..=2, 0..=1]).is_err()); + assert!(v.get_disjoint_mut([0..=4, 0..=0]).is_err()); + assert!(v.get_disjoint_mut([4..=4, 0..=0, 3..=4]).is_err()); } #[test] -fn test_get_many_mut_range_empty_at_edge() { +fn test_get_disjoint_mut_range_empty_at_edge() { let mut v = vec![1, 2, 3, 4, 5]; assert_eq!( - v.get_many_mut([0..0, 0..5, 5..5]), + v.get_disjoint_mut([0..0, 0..5, 5..5]), Ok([&mut [][..], &mut [1, 2, 3, 4, 5], &mut []]), ); assert_eq!( - v.get_many_mut([0..0, 0..1, 1..1, 1..2, 2..2, 2..3, 3..3, 3..4, 4..4, 4..5, 5..5]), + v.get_disjoint_mut([0..0, 0..1, 1..1, 1..2, 2..2, 2..3, 3..3, 3..4, 4..4, 4..5, 5..5]), Ok([ &mut [][..], &mut [1], diff --git a/library/backtrace b/library/backtrace new file mode 160000 index 0000000000000..f8cc6ac9acc4e --- /dev/null +++ b/library/backtrace @@ -0,0 +1 @@ +Subproject commit f8cc6ac9acc4e663ecd96f9bcf1ff4542636d1b9 diff --git a/library/stdarch b/library/stdarch new file mode 160000 index 0000000000000..684de0d6fef70 --- /dev/null +++ b/library/stdarch @@ -0,0 +1 @@ +Subproject commit 684de0d6fef708cae08214fef9643dd9ec7296e1 diff --git a/panic_abort/src/android.rs b/panic_abort/src/android.rs index 47c22834597de..1cc2077d14bd4 100644 --- a/panic_abort/src/android.rs +++ b/panic_abort/src/android.rs @@ -16,9 +16,10 @@ type SetAbortMessageType = unsafe extern "C" fn(*const libc::c_char) -> (); // Weakly resolve the symbol for android_set_abort_message. This function is only available // for API >= 21. pub(crate) unsafe fn android_set_abort_message(payload: &mut dyn PanicPayload) { - let func_addr = + let func_addr = unsafe { libc::dlsym(libc::RTLD_DEFAULT, ANDROID_SET_ABORT_MESSAGE.as_ptr() as *const libc::c_char) - as usize; + as usize + }; if func_addr == 0 { return; } @@ -37,13 +38,14 @@ pub(crate) unsafe fn android_set_abort_message(payload: &mut dyn PanicPayload) { // Allocate a new buffer to append the null byte. let size = msg.len() + 1usize; - let buf = libc::malloc(size) as *mut libc::c_char; + let buf = unsafe { libc::malloc(size) as *mut libc::c_char }; if buf.is_null() { return; // allocation failure } - copy_nonoverlapping(msg.as_ptr(), buf as *mut u8, msg.len()); - buf.add(msg.len()).write(0); - - let func = transmute::(func_addr); - func(buf); + unsafe { + copy_nonoverlapping(msg.as_ptr(), buf as *mut u8, msg.len()); + buf.add(msg.len()).write(0); + let func = transmute::(func_addr); + func(buf); + } } diff --git a/panic_abort/src/lib.rs b/panic_abort/src/lib.rs index dc2b42bb90ae8..b2ad0f4ac3d04 100644 --- a/panic_abort/src/lib.rs +++ b/panic_abort/src/lib.rs @@ -15,6 +15,7 @@ #![feature(staged_api)] #![feature(rustc_attrs)] #![allow(internal_features)] +#![deny(unsafe_op_in_unsafe_fn)] #[cfg(target_os = "android")] mod android; @@ -36,16 +37,22 @@ pub unsafe extern "C" fn __rust_panic_cleanup(_: *mut u8) -> *mut (dyn Any + Sen pub unsafe fn __rust_start_panic(_payload: &mut dyn PanicPayload) -> u32 { // Android has the ability to attach a message as part of the abort. #[cfg(target_os = "android")] - android::android_set_abort_message(_payload); + unsafe { + android::android_set_abort_message(_payload); + } #[cfg(target_os = "zkvm")] - zkvm::zkvm_set_abort_message(_payload); + unsafe { + zkvm::zkvm_set_abort_message(_payload); + } - abort(); + unsafe { + abort(); + } cfg_if::cfg_if! { if #[cfg(any(unix, target_os = "solid_asp3"))] { unsafe fn abort() -> ! { - libc::abort(); + unsafe { libc::abort(); } } } else if #[cfg(any(target_os = "hermit", all(target_vendor = "fortanix", target_env = "sgx"), @@ -54,10 +61,10 @@ pub unsafe fn __rust_start_panic(_payload: &mut dyn PanicPayload) -> u32 { ))] { unsafe fn abort() -> ! { // call std::sys::abort_internal - extern "C" { + unsafe extern "C" { pub fn __rust_abort() -> !; } - __rust_abort(); + unsafe { __rust_abort(); } } } else if #[cfg(all(windows, not(miri)))] { // On Windows, use the processor-specific __fastfail mechanism. In Windows 8 @@ -75,11 +82,17 @@ pub unsafe fn __rust_start_panic(_payload: &mut dyn PanicPayload) -> u32 { const FAST_FAIL_FATAL_APP_EXIT: usize = 7; cfg_if::cfg_if! { if #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] { - core::arch::asm!("int $$0x29", in("ecx") FAST_FAIL_FATAL_APP_EXIT, options(noreturn, nostack)); + unsafe { + core::arch::asm!("int $$0x29", in("ecx") FAST_FAIL_FATAL_APP_EXIT, options(noreturn, nostack)); + } } else if #[cfg(all(target_arch = "arm", target_feature = "thumb-mode"))] { - core::arch::asm!(".inst 0xDEFB", in("r0") FAST_FAIL_FATAL_APP_EXIT, options(noreturn, nostack)); + unsafe { + core::arch::asm!(".inst 0xDEFB", in("r0") FAST_FAIL_FATAL_APP_EXIT, options(noreturn, nostack)); + } } else if #[cfg(any(target_arch = "aarch64", target_arch = "arm64ec"))] { - core::arch::asm!("brk 0xF003", in("x0") FAST_FAIL_FATAL_APP_EXIT, options(noreturn, nostack)); + unsafe { + core::arch::asm!("brk 0xF003", in("x0") FAST_FAIL_FATAL_APP_EXIT, options(noreturn, nostack)); + } } else { core::intrinsics::abort(); } @@ -87,13 +100,13 @@ pub unsafe fn __rust_start_panic(_payload: &mut dyn PanicPayload) -> u32 { } } else if #[cfg(target_os = "teeos")] { mod teeos { - extern "C" { + unsafe extern "C" { pub fn TEE_Panic(code: u32) -> !; } } unsafe fn abort() -> ! { - teeos::TEE_Panic(1); + unsafe { teeos::TEE_Panic(1); } } } else { unsafe fn abort() -> ! { diff --git a/panic_abort/src/zkvm.rs b/panic_abort/src/zkvm.rs index a6a02abf10976..7b1e89c6a8e63 100644 --- a/panic_abort/src/zkvm.rs +++ b/panic_abort/src/zkvm.rs @@ -16,9 +16,11 @@ pub(crate) unsafe fn zkvm_set_abort_message(payload: &mut dyn PanicPayload) { return; } - extern "C" { + unsafe extern "C" { fn sys_panic(msg_ptr: *const u8, len: usize) -> !; } - sys_panic(msg.as_ptr(), msg.len()); + unsafe { + sys_panic(msg.as_ptr(), msg.len()); + } } diff --git a/panic_unwind/src/emcc.rs b/panic_unwind/src/emcc.rs index 86906b46d66ba..1569c26c9de47 100644 --- a/panic_unwind/src/emcc.rs +++ b/panic_unwind/src/emcc.rs @@ -21,7 +21,7 @@ struct TypeInfo { } unsafe impl Sync for TypeInfo {} -extern "C" { +unsafe extern "C" { // The leading `\x01` byte here is actually a magical signal to LLVM to // *not* apply any other mangling like prefixing with a `_` character. // @@ -71,42 +71,46 @@ pub(crate) unsafe fn cleanup(ptr: *mut u8) -> Box { ptr: *mut u8, is_rust_panic: bool, } - let catch_data = &*(ptr as *mut CatchData); + unsafe { + let catch_data = &*(ptr as *mut CatchData); - let adjusted_ptr = __cxa_begin_catch(catch_data.ptr as *mut libc::c_void) as *mut Exception; - if !catch_data.is_rust_panic { - super::__rust_foreign_exception(); - } + let adjusted_ptr = __cxa_begin_catch(catch_data.ptr as *mut libc::c_void) as *mut Exception; + if !catch_data.is_rust_panic { + super::__rust_foreign_exception(); + } - let canary = (&raw const (*adjusted_ptr).canary).read(); - if !ptr::eq(canary, &EXCEPTION_TYPE_INFO) { - super::__rust_foreign_exception(); - } + let canary = (&raw const (*adjusted_ptr).canary).read(); + if !ptr::eq(canary, &EXCEPTION_TYPE_INFO) { + super::__rust_foreign_exception(); + } - let was_caught = (*adjusted_ptr).caught.swap(true, Ordering::Relaxed); - if was_caught { - // Since cleanup() isn't allowed to panic, we just abort instead. - intrinsics::abort(); + let was_caught = (*adjusted_ptr).caught.swap(true, Ordering::Relaxed); + if was_caught { + // Since cleanup() isn't allowed to panic, we just abort instead. + intrinsics::abort(); + } + let out = (*adjusted_ptr).data.take().unwrap(); + __cxa_end_catch(); + out } - let out = (*adjusted_ptr).data.take().unwrap(); - __cxa_end_catch(); - out } pub(crate) unsafe fn panic(data: Box) -> u32 { - let exception = __cxa_allocate_exception(mem::size_of::()) as *mut Exception; - if exception.is_null() { - return uw::_URC_FATAL_PHASE1_ERROR as u32; + unsafe { + let exception = __cxa_allocate_exception(mem::size_of::()) as *mut Exception; + if exception.is_null() { + return uw::_URC_FATAL_PHASE1_ERROR as u32; + } + ptr::write( + exception, + Exception { + canary: &EXCEPTION_TYPE_INFO, + caught: AtomicBool::new(false), + data: Some(data), + }, + ); + __cxa_throw(exception as *mut _, &EXCEPTION_TYPE_INFO, exception_cleanup); } - ptr::write( - exception, - Exception { - canary: &EXCEPTION_TYPE_INFO, - caught: AtomicBool::new(false), - data: Some(data), - }, - ); - __cxa_throw(exception as *mut _, &EXCEPTION_TYPE_INFO, exception_cleanup); } extern "C" fn exception_cleanup(ptr: *mut libc::c_void) -> *mut libc::c_void { @@ -119,7 +123,7 @@ extern "C" fn exception_cleanup(ptr: *mut libc::c_void) -> *mut libc::c_void { } } -extern "C" { +unsafe extern "C" { fn __cxa_allocate_exception(thrown_size: libc::size_t) -> *mut libc::c_void; fn __cxa_begin_catch(thrown_exception: *mut libc::c_void) -> *mut libc::c_void; fn __cxa_end_catch(); diff --git a/panic_unwind/src/gcc.rs b/panic_unwind/src/gcc.rs index e478f6c5fc86c..5f95870069dc5 100644 --- a/panic_unwind/src/gcc.rs +++ b/panic_unwind/src/gcc.rs @@ -69,7 +69,7 @@ pub(crate) unsafe fn panic(data: Box) -> u32 { cause: data, }); let exception_param = Box::into_raw(exception) as *mut uw::_Unwind_Exception; - return uw::_Unwind_RaiseException(exception_param) as u32; + return unsafe { uw::_Unwind_RaiseException(exception_param) as u32 }; extern "C" fn exception_cleanup( _unwind_code: uw::_Unwind_Reason_Code, @@ -83,26 +83,28 @@ pub(crate) unsafe fn panic(data: Box) -> u32 { } pub(crate) unsafe fn cleanup(ptr: *mut u8) -> Box { - let exception = ptr as *mut uw::_Unwind_Exception; - if (*exception).exception_class != RUST_EXCEPTION_CLASS { - uw::_Unwind_DeleteException(exception); - super::__rust_foreign_exception(); - } + unsafe { + let exception = ptr as *mut uw::_Unwind_Exception; + if (*exception).exception_class != RUST_EXCEPTION_CLASS { + uw::_Unwind_DeleteException(exception); + super::__rust_foreign_exception(); + } - let exception = exception.cast::(); - // Just access the canary field, avoid accessing the entire `Exception` as - // it can be a foreign Rust exception. - let canary = (&raw const (*exception).canary).read(); - if !ptr::eq(canary, &CANARY) { - // A foreign Rust exception, treat it slightly differently from other - // foreign exceptions, because call into `_Unwind_DeleteException` will - // call into `__rust_drop_panic` which produces a confusing - // "Rust panic must be rethrown" message. - super::__rust_foreign_exception(); - } + let exception = exception.cast::(); + // Just access the canary field, avoid accessing the entire `Exception` as + // it can be a foreign Rust exception. + let canary = (&raw const (*exception).canary).read(); + if !ptr::eq(canary, &CANARY) { + // A foreign Rust exception, treat it slightly differently from other + // foreign exceptions, because call into `_Unwind_DeleteException` will + // call into `__rust_drop_panic` which produces a confusing + // "Rust panic must be rethrown" message. + super::__rust_foreign_exception(); + } - let exception = Box::from_raw(exception as *mut Exception); - exception.cause + let exception = Box::from_raw(exception as *mut Exception); + exception.cause + } } // Rust's exception class identifier. This is used by personality routines to diff --git a/panic_unwind/src/hermit.rs b/panic_unwind/src/hermit.rs index 7e08ad66577f1..8f4562d07fc4e 100644 --- a/panic_unwind/src/hermit.rs +++ b/panic_unwind/src/hermit.rs @@ -6,15 +6,19 @@ use alloc::boxed::Box; use core::any::Any; pub(crate) unsafe fn cleanup(_ptr: *mut u8) -> Box { - extern "C" { + unsafe extern "C" { fn __rust_abort() -> !; } - __rust_abort(); + unsafe { + __rust_abort(); + } } pub(crate) unsafe fn panic(_data: Box) -> u32 { - extern "C" { + unsafe extern "C" { fn __rust_abort() -> !; } - __rust_abort(); + unsafe { + __rust_abort(); + } } diff --git a/panic_unwind/src/lib.rs b/panic_unwind/src/lib.rs index d682816419565..a284633ea2fc7 100644 --- a/panic_unwind/src/lib.rs +++ b/panic_unwind/src/lib.rs @@ -14,6 +14,7 @@ #![no_std] #![unstable(feature = "panic_unwind", issue = "32837")] #![doc(issue_tracker_base_url = "https://github.com/rust-lang/rust/issues/")] +#![feature(cfg_emscripten_wasm_eh)] #![feature(core_intrinsics)] #![feature(lang_items)] #![feature(panic_unwind)] @@ -25,8 +26,8 @@ // `real_imp` is unused with Miri, so silence warnings. #![cfg_attr(miri, allow(dead_code))] #![allow(internal_features)] -#![cfg_attr(not(bootstrap), feature(cfg_emscripten_wasm_eh))] #![warn(unreachable_pub)] +#![deny(unsafe_op_in_unsafe_fn)] use alloc::boxed::Box; use core::any::Any; @@ -75,7 +76,7 @@ cfg_if::cfg_if! { } } -extern "C" { +unsafe extern "C" { /// Handler in std called when a panic object is dropped outside of /// `catch_unwind`. fn __rust_drop_panic() -> !; @@ -87,14 +88,16 @@ extern "C" { #[rustc_std_internal_symbol] #[allow(improper_ctypes_definitions)] pub unsafe extern "C" fn __rust_panic_cleanup(payload: *mut u8) -> *mut (dyn Any + Send + 'static) { - Box::into_raw(imp::cleanup(payload)) + unsafe { Box::into_raw(imp::cleanup(payload)) } } // Entry point for raising an exception, just delegates to the platform-specific // implementation. #[rustc_std_internal_symbol] pub unsafe fn __rust_start_panic(payload: &mut dyn PanicPayload) -> u32 { - let payload = Box::from_raw(payload.take_box()); + unsafe { + let payload = Box::from_raw(payload.take_box()); - imp::panic(payload) + imp::panic(payload) + } } diff --git a/panic_unwind/src/miri.rs b/panic_unwind/src/miri.rs index a86f0e91eefcc..d6d4af8218d31 100644 --- a/panic_unwind/src/miri.rs +++ b/panic_unwind/src/miri.rs @@ -7,7 +7,7 @@ use core::any::Any; // Must be pointer-sized. type Payload = Box>; -extern "Rust" { +unsafe extern "Rust" { /// Miri-provided extern function to begin unwinding. fn miri_start_unwind(payload: *mut u8) -> !; } @@ -16,11 +16,11 @@ pub(crate) unsafe fn panic(payload: Box) -> u32 { // The payload we pass to `miri_start_unwind` will be exactly the argument we get // in `cleanup` below. So we just box it up once, to get something pointer-sized. let payload_box: Payload = Box::new(payload); - miri_start_unwind(Box::into_raw(payload_box) as *mut u8) + unsafe { miri_start_unwind(Box::into_raw(payload_box) as *mut u8) } } pub(crate) unsafe fn cleanup(payload_box: *mut u8) -> Box { // Recover the underlying `Box`. - let payload_box: Payload = Box::from_raw(payload_box as *mut _); + let payload_box: Payload = unsafe { Box::from_raw(payload_box as *mut _) }; *payload_box } diff --git a/panic_unwind/src/seh.rs b/panic_unwind/src/seh.rs index 21bfe74e1a259..3a95b940221c2 100644 --- a/panic_unwind/src/seh.rs +++ b/panic_unwind/src/seh.rs @@ -135,7 +135,7 @@ mod imp { #[derive(Copy, Clone)] pub(super) struct ptr_t(u32); - extern "C" { + unsafe extern "C" { static __ImageBase: u8; } @@ -229,7 +229,7 @@ static mut CATCHABLE_TYPE: _CatchableType = _CatchableType { copyFunction: ptr_t::null(), }; -extern "C" { +unsafe extern "C" { // The leading `\x01` byte here is actually a magical signal to LLVM to // *not* apply any other mangling like prefixing with a `_` character. // @@ -268,9 +268,11 @@ static mut TYPE_DESCRIPTOR: _TypeDescriptor = _TypeDescriptor { macro_rules! define_cleanup { ($abi:tt $abi2:tt) => { unsafe extern $abi fn exception_cleanup(e: *mut Exception) { - if let Exception { data: Some(b), .. } = e.read() { - drop(b); - super::__rust_drop_panic(); + unsafe { + if let Exception { data: Some(b), .. } = e.read() { + drop(b); + super::__rust_drop_panic(); + } } } unsafe extern $abi2 fn exception_copy( @@ -322,45 +324,51 @@ pub(crate) unsafe fn panic(data: Box) -> u32 { // // In any case, we basically need to do something like this until we can // express more operations in statics (and we may never be able to). - atomic_store_seqcst( - (&raw mut THROW_INFO.pmfnUnwind).cast(), - ptr_t::new(exception_cleanup as *mut u8).raw(), - ); - atomic_store_seqcst( - (&raw mut THROW_INFO.pCatchableTypeArray).cast(), - ptr_t::new((&raw mut CATCHABLE_TYPE_ARRAY).cast()).raw(), - ); - atomic_store_seqcst( - (&raw mut CATCHABLE_TYPE_ARRAY.arrayOfCatchableTypes[0]).cast(), - ptr_t::new((&raw mut CATCHABLE_TYPE).cast()).raw(), - ); - atomic_store_seqcst( - (&raw mut CATCHABLE_TYPE.pType).cast(), - ptr_t::new((&raw mut TYPE_DESCRIPTOR).cast()).raw(), - ); - atomic_store_seqcst( - (&raw mut CATCHABLE_TYPE.copyFunction).cast(), - ptr_t::new(exception_copy as *mut u8).raw(), - ); - - extern "system-unwind" { + unsafe { + atomic_store_seqcst( + (&raw mut THROW_INFO.pmfnUnwind).cast(), + ptr_t::new(exception_cleanup as *mut u8).raw(), + ); + atomic_store_seqcst( + (&raw mut THROW_INFO.pCatchableTypeArray).cast(), + ptr_t::new((&raw mut CATCHABLE_TYPE_ARRAY).cast()).raw(), + ); + atomic_store_seqcst( + (&raw mut CATCHABLE_TYPE_ARRAY.arrayOfCatchableTypes[0]).cast(), + ptr_t::new((&raw mut CATCHABLE_TYPE).cast()).raw(), + ); + atomic_store_seqcst( + (&raw mut CATCHABLE_TYPE.pType).cast(), + ptr_t::new((&raw mut TYPE_DESCRIPTOR).cast()).raw(), + ); + atomic_store_seqcst( + (&raw mut CATCHABLE_TYPE.copyFunction).cast(), + ptr_t::new(exception_copy as *mut u8).raw(), + ); + } + + unsafe extern "system-unwind" { fn _CxxThrowException(pExceptionObject: *mut c_void, pThrowInfo: *mut u8) -> !; } - _CxxThrowException(throw_ptr, (&raw mut THROW_INFO) as *mut _); + unsafe { + _CxxThrowException(throw_ptr, (&raw mut THROW_INFO) as *mut _); + } } pub(crate) unsafe fn cleanup(payload: *mut u8) -> Box { - // A null payload here means that we got here from the catch (...) of - // __rust_try. This happens when a non-Rust foreign exception is caught. - if payload.is_null() { - super::__rust_foreign_exception(); - } - let exception = payload as *mut Exception; - let canary = (&raw const (*exception).canary).read(); - if !core::ptr::eq(canary, &raw const TYPE_DESCRIPTOR) { - // A foreign Rust exception. - super::__rust_foreign_exception(); + unsafe { + // A null payload here means that we got here from the catch (...) of + // __rust_try. This happens when a non-Rust foreign exception is caught. + if payload.is_null() { + super::__rust_foreign_exception(); + } + let exception = payload as *mut Exception; + let canary = (&raw const (*exception).canary).read(); + if !core::ptr::eq(canary, &raw const TYPE_DESCRIPTOR) { + // A foreign Rust exception. + super::__rust_foreign_exception(); + } + (*exception).data.take().unwrap() } - (*exception).data.take().unwrap() } diff --git a/portable-simd/.github/workflows/ci.yml b/portable-simd/.github/workflows/ci.yml index b292be2d6f999..3984d8f0d8d99 100644 --- a/portable-simd/.github/workflows/ci.yml +++ b/portable-simd/.github/workflows/ci.yml @@ -9,6 +9,7 @@ on: env: CARGO_NET_RETRY: 10 RUSTUP_MAX_RETRIES: 10 + PROPTEST_CASES: 64 jobs: rustfmt: @@ -16,12 +17,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - name: Setup Rust - run: | - rustup update nightly --no-self-update - rustup default nightly - rustup component add rustfmt + - uses: actions/checkout@v4 - name: Run rustfmt run: cargo fmt --all -- --check @@ -37,7 +33,9 @@ jobs: - i686-unknown-linux-gnu - i586-unknown-linux-gnu - aarch64-unknown-linux-gnu + - arm64ec-pc-windows-msvc - armv7-unknown-linux-gnueabihf + - loongarch64-unknown-linux-gnu # non-nightly since https://github.com/rust-lang/rust/pull/113274 # - mips-unknown-linux-gnu # - mips64-unknown-linux-gnuabi64 @@ -49,13 +47,9 @@ jobs: - wasm32-unknown-unknown steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Setup Rust - run: | - rustup update nightly --no-self-update - rustup default nightly - rustup target add ${{ matrix.target }} - rustup component add clippy + run: rustup target add ${{ matrix.target }} - name: Run Clippy run: cargo clippy --all-targets --target ${{ matrix.target }} @@ -65,26 +59,19 @@ jobs: strategy: fail-fast: false matrix: - target: [x86_64-pc-windows-msvc, i686-pc-windows-msvc, i586-pc-windows-msvc, x86_64-unknown-linux-gnu, x86_64-apple-darwin] + target: [x86_64-pc-windows-msvc, i686-pc-windows-msvc, i586-pc-windows-msvc, x86_64-unknown-linux-gnu] # `default` means we use the default target config for the target, # `native` means we run with `-Ctarget-cpu=native`, and anything else is # an arg to `-Ctarget-feature` target_feature: [default, native, +sse3, +ssse3, +sse4.1, +sse4.2, +avx, +avx2] exclude: - # The macos runners seem to only reliably support up to `avx`. - - { target: x86_64-apple-darwin, target_feature: +avx2 } - # These features are statically known to be present for all 64 bit - # macs, and thus are covered by the `default` test - - { target: x86_64-apple-darwin, target_feature: +sse3 } - - { target: x86_64-apple-darwin, target_feature: +ssse3 } # -Ctarget-cpu=native sounds like bad-news if target != host - { target: i686-pc-windows-msvc, target_feature: native } - { target: i586-pc-windows-msvc, target_feature: native } include: # Populate the `matrix.os` field - - { target: x86_64-apple-darwin, os: macos-latest } - { target: x86_64-unknown-linux-gnu, os: ubuntu-latest } - { target: x86_64-pc-windows-msvc, os: windows-latest } - { target: i686-pc-windows-msvc, os: windows-latest } @@ -98,12 +85,9 @@ jobs: # avx512vl, but occasionally doesn't. Maybe one day we can enable it. steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Setup Rust - run: | - rustup update nightly --no-self-update - rustup default nightly - rustup target add ${{ matrix.target }} + run: rustup target add ${{ matrix.target }} - name: Configure RUSTFLAGS shell: bash @@ -145,6 +129,35 @@ jobs: run: cargo doc --verbose --target=${{ matrix.target }} env: RUSTDOCFLAGS: -Dwarnings + + macos-tests: + name: ${{ matrix.target }} + runs-on: macos-latest + strategy: + fail-fast: false + matrix: + target: + - aarch64-apple-darwin + - x86_64-apple-darwin + steps: + - uses: actions/checkout@v4 + - name: Setup Rust + run: rustup target add ${{ matrix.target }} + + - name: Configure RUSTFLAGS + shell: bash + run: echo "RUSTFLAGS=-Dwarnings" >> $GITHUB_ENV + + - name: Test (debug) + run: cargo test --verbose --target=${{ matrix.target }} + + - name: Test (release) + run: cargo test --verbose --target=${{ matrix.target }} --release + + - name: Generate docs + run: cargo doc --verbose --target=${{ matrix.target }} + env: + RUSTDOCFLAGS: -Dwarnings wasm-tests: name: "wasm (firefox, ${{ matrix.name }})" @@ -155,11 +168,7 @@ jobs: - { name: default, RUSTFLAGS: "" } - { name: simd128, RUSTFLAGS: "-C target-feature=+simd128" } steps: - - uses: actions/checkout@v2 - - name: Setup Rust - run: | - rustup update nightly --no-self-update - rustup default nightly + - uses: actions/checkout@v4 - name: Install wasm-pack run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh - name: Test (debug) @@ -174,6 +183,8 @@ jobs: cross-tests: name: "${{ matrix.target_feature }} on ${{ matrix.target }} (via cross)" runs-on: ubuntu-latest + env: + PROPTEST_CASES: 16 strategy: fail-fast: false @@ -185,6 +196,7 @@ jobs: - powerpc-unknown-linux-gnu - powerpc64le-unknown-linux-gnu # includes altivec by default - riscv64gc-unknown-linux-gnu + - loongarch64-unknown-linux-gnu # MIPS uses a nonstandard binary representation for NaNs which makes it worth testing # non-nightly since https://github.com/rust-lang/rust/pull/113274 # - mips-unknown-linux-gnu @@ -201,24 +213,14 @@ jobs: # - { target: riscv64gc-unknown-linux-gnu, target_feature: "+v,+zvl128b" } steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Setup Rust - run: | - rustup update nightly --no-self-update - rustup default nightly - rustup target add ${{ matrix.target }} - rustup component add rust-src + run: rustup target add ${{ matrix.target }} - name: Install Cross - # Equivalent to `cargo install cross`, but downloading a prebuilt - # binary. Ideally we wouldn't hardcode a version, but the version number - # being part of the tarball means we can't just use the download/latest - # URL :( + # Install the latest git version for newer targets. run: | - CROSS_URL=https://github.com/cross-rs/cross/releases/download/v0.2.5/cross-x86_64-unknown-linux-gnu.tar.gz - mkdir -p "$HOME/.bin" - curl -sfSL --retry-delay 10 --retry 5 "${CROSS_URL}" | tar zxf - -C "$HOME/.bin" - echo "$HOME/.bin" >> $GITHUB_PATH + cargo install cross --git https://github.com/cross-rs/cross --rev 4090beca3cfffa44371a5bba524de3a578aa46c3 - name: Configure Emulated CPUs run: | @@ -242,34 +244,11 @@ jobs: - name: Test (release) run: cross test --verbose --target=${{ matrix.target }} --release - features: - name: "Test cargo features (${{ matrix.simd }} × ${{ matrix.features }})" + miri: runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - simd: - - "" - - "avx512" - features: - - "" - - "--features std" - - "--features all_lane_counts" - - "--all-features" - + env: + PROPTEST_CASES: 16 steps: - - uses: actions/checkout@v2 - - name: Setup Rust - run: | - rustup update nightly --no-self-update - rustup default nightly - - name: Detect AVX512 - run: echo "CPU_FEATURE=$(lscpu | grep -o avx512[a-z]* | sed s/avx/+avx/ | tr '\n' ',' )" >> $GITHUB_ENV - - name: Check build - if: ${{ matrix.simd == '' }} - run: RUSTFLAGS="-Dwarnings" cargo test --all-targets --no-default-features ${{ matrix.features }} - - name: Check AVX - if: ${{ matrix.simd == 'avx512' && contains(env.CPU_FEATURE, 'avx512') }} - run: | - echo "Found AVX features: $CPU_FEATURE" - RUSTFLAGS="-Dwarnings -Ctarget-feature=$CPU_FEATURE" cargo test --all-targets --no-default-features ${{ matrix.features }} + - uses: actions/checkout@v4 + - name: Test (Miri) + run: cargo miri test diff --git a/portable-simd/.github/workflows/doc.yml b/portable-simd/.github/workflows/doc.yml index 9d1fa66ccb595..22c2cb3f67f1b 100644 --- a/portable-simd/.github/workflows/doc.yml +++ b/portable-simd/.github/workflows/doc.yml @@ -12,7 +12,7 @@ jobs: steps: - name: Checkout Repository - uses: actions/checkout@v1 + uses: actions/checkout@v4 - name: Setup Rust run: | diff --git a/portable-simd/.gitignore b/portable-simd/.gitignore index ea8c4bf7f35f6..9673e52dcadba 100644 --- a/portable-simd/.gitignore +++ b/portable-simd/.gitignore @@ -1 +1,2 @@ /target +git-subtree.sh diff --git a/portable-simd/Cargo.toml b/portable-simd/Cargo.toml index d1732aaec2f92..21d4584a9f4d9 100644 --- a/portable-simd/Cargo.toml +++ b/portable-simd/Cargo.toml @@ -5,3 +5,9 @@ members = [ "crates/std_float", "crates/test_helpers", ] + +[profile.test.package."*"] +opt-level = 2 + +[profile.test.package.test_helpers] +opt-level = 2 diff --git a/portable-simd/Cross.toml b/portable-simd/Cross.toml new file mode 100644 index 0000000000000..d21e76b92dd1a --- /dev/null +++ b/portable-simd/Cross.toml @@ -0,0 +1,2 @@ +[build.env] +passthrough = ["PROPTEST_CASES"] diff --git a/portable-simd/crates/core_simd/Cargo.toml b/portable-simd/crates/core_simd/Cargo.toml index b4a8fd70f4c0e..a7a6d43b11d3c 100644 --- a/portable-simd/crates/core_simd/Cargo.toml +++ b/portable-simd/crates/core_simd/Cargo.toml @@ -9,10 +9,9 @@ categories = ["hardware-support", "no-std"] license = "MIT OR Apache-2.0" [features] -default = ["as_crate"] +default = ["as_crate", "std"] as_crate = [] std = [] -all_lane_counts = [] [target.'cfg(target_arch = "wasm32")'.dev-dependencies] wasm-bindgen = "0.2" diff --git a/portable-simd/crates/core_simd/src/lane_count.rs b/portable-simd/crates/core_simd/src/lane_count.rs index 4cd7265ed671e..280b27bc9bc6f 100644 --- a/portable-simd/crates/core_simd/src/lane_count.rs +++ b/portable-simd/crates/core_simd/src/lane_count.rs @@ -33,10 +33,8 @@ macro_rules! supported_lane_count { }; } -supported_lane_count!(1, 2, 4, 8, 16, 32, 64); -#[cfg(feature = "all_lane_counts")] supported_lane_count!( - 3, 5, 6, 7, 9, 10, 11, 12, 13, 14, 15, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, - 31, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, - 56, 57, 58, 59, 60, 61, 62, 63 + 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, + 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, + 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64 ); diff --git a/portable-simd/crates/core_simd/src/lib.rs b/portable-simd/crates/core_simd/src/lib.rs index 992a7705e3c52..7f57847c9c234 100644 --- a/portable-simd/crates/core_simd/src/lib.rs +++ b/portable-simd/crates/core_simd/src/lib.rs @@ -1,7 +1,6 @@ #![no_std] #![feature( - const_refs_to_cell, - const_mut_refs, + const_eval_select, convert_float_to_int, core_intrinsics, decl_macro, @@ -26,6 +25,7 @@ all(target_arch = "arm", target_feature = "v7"), feature(stdarch_arm_neon_intrinsics) )] +#![cfg_attr(target_arch = "loongarch64", feature(stdarch_loongarch))] #![cfg_attr( any(target_arch = "powerpc", target_arch = "powerpc64"), feature(stdarch_powerpc) diff --git a/portable-simd/crates/core_simd/src/masks.rs b/portable-simd/crates/core_simd/src/masks.rs index 04de3a968276d..19d45f4d3b31a 100644 --- a/portable-simd/crates/core_simd/src/masks.rs +++ b/portable-simd/crates/core_simd/src/masks.rs @@ -308,48 +308,6 @@ where Self(mask_impl::Mask::from_bitmask_integer(bitmask)) } - /// Creates a bitmask vector from a mask. - /// - /// Each bit is set if the corresponding element in the mask is `true`. - /// The remaining bits are unset. - /// - /// The bits are packed into the first N bits of the vector: - /// ``` - /// # #![feature(portable_simd)] - /// # #[cfg(feature = "as_crate")] use core_simd::simd; - /// # #[cfg(not(feature = "as_crate"))] use core::simd; - /// # use simd::mask32x8; - /// let mask = mask32x8::from_array([true, false, true, false, false, false, true, false]); - /// assert_eq!(mask.to_bitmask_vector()[0], 0b01000101); - /// ``` - #[inline] - #[must_use = "method returns a new integer and does not mutate the original value"] - pub fn to_bitmask_vector(self) -> Simd { - self.0.to_bitmask_vector() - } - - /// Creates a mask from a bitmask vector. - /// - /// For each bit, if it is set, the corresponding element in the mask is set to `true`. - /// - /// The bits are packed into the first N bits of the vector: - /// ``` - /// # #![feature(portable_simd)] - /// # #[cfg(feature = "as_crate")] use core_simd::simd; - /// # #[cfg(not(feature = "as_crate"))] use core::simd; - /// # use simd::{mask32x8, u8x8}; - /// let bitmask = u8x8::from_array([0b01000101, 0, 0, 0, 0, 0, 0, 0]); - /// assert_eq!( - /// mask32x8::from_bitmask_vector(bitmask), - /// mask32x8::from_array([true, false, true, false, false, false, true, false]), - /// ); - /// ``` - #[inline] - #[must_use = "method returns a new mask and does not mutate the original value"] - pub fn from_bitmask_vector(bitmask: Simd) -> Self { - Self(mask_impl::Mask::from_bitmask_vector(bitmask)) - } - /// Finds the index of the first set element. /// /// ``` @@ -443,7 +401,6 @@ where LaneCount: SupportedLaneCount, { #[inline] - #[must_use = "method returns a defaulted mask with all elements set to false (0)"] fn default() -> Self { Self::splat(false) } @@ -455,7 +412,6 @@ where LaneCount: SupportedLaneCount, { #[inline] - #[must_use = "method returns a new bool and does not mutate the original value"] fn eq(&self, other: &Self) -> bool { self.0 == other.0 } @@ -467,7 +423,6 @@ where LaneCount: SupportedLaneCount, { #[inline] - #[must_use = "method returns a new Ordering and does not mutate the original value"] fn partial_cmp(&self, other: &Self) -> Option { self.0.partial_cmp(&other.0) } @@ -493,7 +448,6 @@ where { type Output = Self; #[inline] - #[must_use = "method returns a new mask and does not mutate the original value"] fn bitand(self, rhs: Self) -> Self { Self(self.0 & rhs.0) } @@ -506,7 +460,6 @@ where { type Output = Self; #[inline] - #[must_use = "method returns a new mask and does not mutate the original value"] fn bitand(self, rhs: bool) -> Self { self & Self::splat(rhs) } @@ -519,7 +472,6 @@ where { type Output = Mask; #[inline] - #[must_use = "method returns a new mask and does not mutate the original value"] fn bitand(self, rhs: Mask) -> Mask { Mask::splat(self) & rhs } @@ -532,7 +484,6 @@ where { type Output = Self; #[inline] - #[must_use = "method returns a new mask and does not mutate the original value"] fn bitor(self, rhs: Self) -> Self { Self(self.0 | rhs.0) } @@ -545,7 +496,6 @@ where { type Output = Self; #[inline] - #[must_use = "method returns a new mask and does not mutate the original value"] fn bitor(self, rhs: bool) -> Self { self | Self::splat(rhs) } @@ -558,7 +508,6 @@ where { type Output = Mask; #[inline] - #[must_use = "method returns a new mask and does not mutate the original value"] fn bitor(self, rhs: Mask) -> Mask { Mask::splat(self) | rhs } @@ -571,7 +520,6 @@ where { type Output = Self; #[inline] - #[must_use = "method returns a new mask and does not mutate the original value"] fn bitxor(self, rhs: Self) -> Self::Output { Self(self.0 ^ rhs.0) } @@ -584,7 +532,6 @@ where { type Output = Self; #[inline] - #[must_use = "method returns a new mask and does not mutate the original value"] fn bitxor(self, rhs: bool) -> Self::Output { self ^ Self::splat(rhs) } @@ -597,7 +544,6 @@ where { type Output = Mask; #[inline] - #[must_use = "method returns a new mask and does not mutate the original value"] fn bitxor(self, rhs: Mask) -> Self::Output { Mask::splat(self) ^ rhs } @@ -610,7 +556,6 @@ where { type Output = Mask; #[inline] - #[must_use = "method returns a new mask and does not mutate the original value"] fn not(self) -> Self::Output { Self(!self.0) } diff --git a/portable-simd/crates/core_simd/src/masks/bitmask.rs b/portable-simd/crates/core_simd/src/masks/bitmask.rs index 96c553426ee74..db4312d5bf88a 100644 --- a/portable-simd/crates/core_simd/src/masks/bitmask.rs +++ b/portable-simd/crates/core_simd/src/masks/bitmask.rs @@ -122,23 +122,6 @@ where unsafe { Self(core::intrinsics::simd::simd_bitmask(value), PhantomData) } } - #[inline] - #[must_use = "method returns a new vector and does not mutate the original value"] - pub fn to_bitmask_vector(self) -> Simd { - let mut bitmask = Simd::splat(0); - bitmask.as_mut_array()[..self.0.as_ref().len()].copy_from_slice(self.0.as_ref()); - bitmask - } - - #[inline] - #[must_use = "method returns a new mask and does not mutate the original value"] - pub fn from_bitmask_vector(bitmask: Simd) -> Self { - let mut bytes = as SupportedLaneCount>::BitMask::default(); - let len = bytes.as_ref().len(); - bytes.as_mut().copy_from_slice(&bitmask.as_array()[..len]); - Self(bytes, PhantomData) - } - #[inline] pub fn to_bitmask_integer(self) -> u64 { let mut bitmask = [0u8; 8]; diff --git a/portable-simd/crates/core_simd/src/masks/full_masks.rs b/portable-simd/crates/core_simd/src/masks/full_masks.rs index 87f031a9f367a..387b508c4b4ef 100644 --- a/portable-simd/crates/core_simd/src/masks/full_masks.rs +++ b/portable-simd/crates/core_simd/src/masks/full_masks.rs @@ -21,7 +21,6 @@ where LaneCount: SupportedLaneCount, { #[inline] - #[must_use = "method returns a new mask and does not mutate the original value"] fn clone(&self) -> Self { *self } @@ -140,62 +139,6 @@ where unsafe { Mask(core::intrinsics::simd::simd_cast(self.0)) } } - #[inline] - #[must_use = "method returns a new vector and does not mutate the original value"] - pub fn to_bitmask_vector(self) -> Simd { - let mut bitmask = Simd::splat(0); - - // Safety: Bytes is the right size array - unsafe { - // Compute the bitmask - let mut bytes: as SupportedLaneCount>::BitMask = - core::intrinsics::simd::simd_bitmask(self.0); - - // LLVM assumes bit order should match endianness - if cfg!(target_endian = "big") { - for x in bytes.as_mut() { - *x = x.reverse_bits() - } - if N % 8 > 0 { - bytes.as_mut()[N / 8] >>= 8 - N % 8; - } - } - - bitmask.as_mut_array()[..bytes.as_ref().len()].copy_from_slice(bytes.as_ref()); - } - - bitmask - } - - #[inline] - #[must_use = "method returns a new mask and does not mutate the original value"] - pub fn from_bitmask_vector(bitmask: Simd) -> Self { - let mut bytes = as SupportedLaneCount>::BitMask::default(); - - // Safety: Bytes is the right size array - unsafe { - let len = bytes.as_ref().len(); - bytes.as_mut().copy_from_slice(&bitmask.as_array()[..len]); - - // LLVM assumes bit order should match endianness - if cfg!(target_endian = "big") { - for x in bytes.as_mut() { - *x = x.reverse_bits(); - } - if N % 8 > 0 { - bytes.as_mut()[N / 8] >>= 8 - N % 8; - } - } - - // Compute the regular mask - Self::from_int_unchecked(core::intrinsics::simd::simd_select_bitmask( - bytes, - Self::splat(true).to_int(), - Self::splat(false).to_int(), - )) - } - } - #[inline] unsafe fn to_bitmask_impl(self) -> U where @@ -283,7 +226,7 @@ where } #[inline] - #[must_use = "method returns a new vector and does not mutate the original value"] + #[must_use = "method returns a new bool and does not mutate the original value"] pub fn all(self) -> bool { // Safety: use `self` as an integer vector unsafe { core::intrinsics::simd::simd_reduce_all(self.to_int()) } @@ -308,7 +251,6 @@ where { type Output = Self; #[inline] - #[must_use = "method returns a new mask and does not mutate the original value"] fn bitand(self, rhs: Self) -> Self { // Safety: `self` is an integer vector unsafe { Self(core::intrinsics::simd::simd_and(self.0, rhs.0)) } @@ -322,7 +264,6 @@ where { type Output = Self; #[inline] - #[must_use = "method returns a new mask and does not mutate the original value"] fn bitor(self, rhs: Self) -> Self { // Safety: `self` is an integer vector unsafe { Self(core::intrinsics::simd::simd_or(self.0, rhs.0)) } @@ -336,7 +277,6 @@ where { type Output = Self; #[inline] - #[must_use = "method returns a new mask and does not mutate the original value"] fn bitxor(self, rhs: Self) -> Self { // Safety: `self` is an integer vector unsafe { Self(core::intrinsics::simd::simd_xor(self.0, rhs.0)) } @@ -350,7 +290,6 @@ where { type Output = Self; #[inline] - #[must_use = "method returns a new mask and does not mutate the original value"] fn not(self) -> Self::Output { Self::splat(true) ^ self } diff --git a/portable-simd/crates/core_simd/src/ops.rs b/portable-simd/crates/core_simd/src/ops.rs index dd7303a97b197..4ac64a253a3bd 100644 --- a/portable-simd/crates/core_simd/src/ops.rs +++ b/portable-simd/crates/core_simd/src/ops.rs @@ -77,7 +77,7 @@ macro_rules! int_divrem_guard { ( $lhs:ident, $rhs:ident, { const PANIC_ZERO: &'static str = $zero:literal; - $simd_call:ident + $simd_call:ident, $op:tt }, $int:ident ) => { if $rhs.simd_eq(Simd::splat(0 as _)).any() { @@ -96,8 +96,23 @@ macro_rules! int_divrem_guard { // Nice base case to make it easy to const-fold away the other branch. $rhs }; - // Safety: $lhs and rhs are vectors - unsafe { core::intrinsics::simd::$simd_call($lhs, rhs) } + + // aarch64 div fails for arbitrary `v % 0`, mod fails when rhs is MIN, for non-powers-of-two + // these operations aren't vectorized on aarch64 anyway + #[cfg(target_arch = "aarch64")] + { + let mut out = Simd::splat(0 as _); + for i in 0..Self::LEN { + out[i] = $lhs[i] $op rhs[i]; + } + out + } + + #[cfg(not(target_arch = "aarch64"))] + { + // Safety: $lhs and rhs are vectors + unsafe { core::intrinsics::simd::$simd_call($lhs, rhs) } + } } }; } @@ -120,7 +135,6 @@ macro_rules! for_base_types { type Output = $out; #[inline] - #[must_use = "operator returns a new vector without mutating the inputs"] // TODO: only useful for int Div::div, but we hope that this // will essentially always get inlined anyway. #[track_caller] @@ -205,14 +219,14 @@ for_base_ops! { impl Div::div { int_divrem_guard { const PANIC_ZERO: &'static str = "attempt to divide by zero"; - simd_div + simd_div, / } } impl Rem::rem { int_divrem_guard { const PANIC_ZERO: &'static str = "attempt to calculate the remainder with a divisor of zero"; - simd_rem + simd_rem, % } } diff --git a/portable-simd/crates/core_simd/src/ops/deref.rs b/portable-simd/crates/core_simd/src/ops/deref.rs index 0ff76cfba39bb..913cbbe977c46 100644 --- a/portable-simd/crates/core_simd/src/ops/deref.rs +++ b/portable-simd/crates/core_simd/src/ops/deref.rs @@ -18,7 +18,6 @@ macro_rules! deref_lhs { type Output = Simd; #[inline] - #[must_use = "operator returns a new vector without mutating the inputs"] fn $call(self, rhs: $simd) -> Self::Output { (*self).$call(rhs) } @@ -39,7 +38,6 @@ macro_rules! deref_rhs { type Output = Simd; #[inline] - #[must_use = "operator returns a new vector without mutating the inputs"] fn $call(self, rhs: &$simd) -> Self::Output { self.$call(*rhs) } @@ -71,7 +69,6 @@ macro_rules! deref_ops { type Output = $simd; #[inline] - #[must_use = "operator returns a new vector without mutating the inputs"] fn $call(self, rhs: &'rhs $simd) -> Self::Output { (*self).$call(*rhs) } diff --git a/portable-simd/crates/core_simd/src/ops/unary.rs b/portable-simd/crates/core_simd/src/ops/unary.rs index bdae96332a3ae..412a5b801171b 100644 --- a/portable-simd/crates/core_simd/src/ops/unary.rs +++ b/portable-simd/crates/core_simd/src/ops/unary.rs @@ -11,7 +11,6 @@ macro_rules! neg { type Output = Self; #[inline] - #[must_use = "operator returns a new vector without mutating the input"] fn neg(self) -> Self::Output { // Safety: `self` is a signed vector unsafe { core::intrinsics::simd::simd_neg(self) } @@ -46,7 +45,6 @@ macro_rules! not { type Output = Self; #[inline] - #[must_use = "operator returns a new vector without mutating the input"] fn not(self) -> Self::Output { self ^ (Simd::splat(!(0 as $scalar))) } diff --git a/portable-simd/crates/core_simd/src/simd/cmp/eq.rs b/portable-simd/crates/core_simd/src/simd/cmp/eq.rs index 5b4615ce51d79..93989ce91b89d 100644 --- a/portable-simd/crates/core_simd/src/simd/cmp/eq.rs +++ b/portable-simd/crates/core_simd/src/simd/cmp/eq.rs @@ -12,7 +12,7 @@ pub trait SimdPartialEq { #[must_use = "method returns a new mask and does not mutate the original value"] fn simd_eq(self, other: Self) -> Self::Mask; - /// Test if each element is equal to the corresponding element in `other`. + /// Test if each element is not equal to the corresponding element in `other`. #[must_use = "method returns a new mask and does not mutate the original value"] fn simd_ne(self, other: Self) -> Self::Mask; } diff --git a/portable-simd/crates/core_simd/src/simd/num/float.rs b/portable-simd/crates/core_simd/src/simd/num/float.rs index 59e43851ea8da..db705dfe20221 100644 --- a/portable-simd/crates/core_simd/src/simd/num/float.rs +++ b/portable-simd/crates/core_simd/src/simd/num/float.rs @@ -255,6 +255,7 @@ macro_rules! impl_trait { type Bits = Simd<$bits_ty, N>; type Cast = Simd; + #[cfg(not(target_arch = "aarch64"))] #[inline] fn cast(self) -> Self::Cast { @@ -262,6 +263,33 @@ macro_rules! impl_trait { unsafe { core::intrinsics::simd::simd_as(self) } } + // https://github.com/llvm/llvm-project/issues/94694 + #[cfg(target_arch = "aarch64")] + #[inline] + fn cast(self) -> Self::Cast + { + const { assert!(N <= 64) }; + if N <= 2 || N == 4 || N == 8 || N == 16 || N == 32 || N == 64 { + // Safety: supported types are guaranteed by SimdCast + unsafe { core::intrinsics::simd::simd_as(self) } + } else if N < 4 { + let x = self.resize::<4>(Default::default()).cast(); + x.resize::(x[0]) + } else if N < 8 { + let x = self.resize::<8>(Default::default()).cast(); + x.resize::(x[0]) + } else if N < 16 { + let x = self.resize::<16>(Default::default()).cast(); + x.resize::(x[0]) + } else if N < 32 { + let x = self.resize::<32>(Default::default()).cast(); + x.resize::(x[0]) + } else { + let x = self.resize::<64>(Default::default()).cast(); + x.resize::(x[0]) + } + } + #[inline] #[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces unsafe fn to_int_unchecked(self) -> Self::Cast @@ -343,7 +371,6 @@ macro_rules! impl_trait { } #[inline] - #[must_use = "method returns a new mask and does not mutate the original value"] fn is_normal(self) -> Self::Mask { !(self.abs().simd_eq(Self::splat(0.0)) | self.is_nan() | self.is_subnormal() | self.is_infinite()) } @@ -391,7 +418,7 @@ macro_rules! impl_trait { self.as_array().iter().sum() } else { // Safety: `self` is a float vector - unsafe { core::intrinsics::simd::simd_reduce_add_ordered(self, 0.) } + unsafe { core::intrinsics::simd::simd_reduce_add_ordered(self, -0.) } } } diff --git a/portable-simd/crates/core_simd/src/simd/num/int.rs b/portable-simd/crates/core_simd/src/simd/num/int.rs index d7598d9ceaf92..3a51235ff954e 100644 --- a/portable-simd/crates/core_simd/src/simd/num/int.rs +++ b/portable-simd/crates/core_simd/src/simd/num/int.rs @@ -1,6 +1,6 @@ use super::sealed::Sealed; use crate::simd::{ - cmp::SimdPartialOrd, num::SimdUint, LaneCount, Mask, Simd, SimdCast, SimdElement, + cmp::SimdOrd, cmp::SimdPartialOrd, num::SimdUint, LaneCount, Mask, Simd, SimdCast, SimdElement, SupportedLaneCount, }; @@ -70,11 +70,27 @@ pub trait SimdInt: Copy + Sealed { /// # #[cfg(not(feature = "as_crate"))] use core::simd; /// # use simd::prelude::*; /// use core::i32::{MIN, MAX}; - /// let xs = Simd::from_array([MIN, MIN +1, -5, 0]); + /// let xs = Simd::from_array([MIN, MIN + 1, -5, 0]); /// assert_eq!(xs.abs(), Simd::from_array([MIN, MAX, 5, 0])); /// ``` fn abs(self) -> Self; + /// Lanewise absolute difference. + /// Every element becomes the absolute difference of `self` and `second`. + /// + /// # Examples + /// ``` + /// # #![feature(portable_simd)] + /// # #[cfg(feature = "as_crate")] use core_simd::simd; + /// # #[cfg(not(feature = "as_crate"))] use core::simd; + /// # use simd::prelude::*; + /// use core::i32::{MIN, MAX}; + /// let a = Simd::from_array([MIN, MAX, 100, -100]); + /// let b = Simd::from_array([MAX, MIN, -80, -120]); + /// assert_eq!(a.abs_diff(b), Simd::from_array([u32::MAX, u32::MAX, 180, 20])); + /// ``` + fn abs_diff(self, second: Self) -> Self::Unsigned; + /// Lanewise saturating absolute value, implemented in Rust. /// As abs(), except the MIN value becomes MAX instead of itself. /// @@ -203,6 +219,12 @@ pub trait SimdInt: Copy + Sealed { /// The least significant bit becomes the most significant bit, second least-significant bit becomes second most-significant bit, etc. fn reverse_bits(self) -> Self; + /// Returns the number of ones in the binary representation of each element. + fn count_ones(self) -> Self::Unsigned; + + /// Returns the number of zeros in the binary representation of each element. + fn count_zeros(self) -> Self::Unsigned; + /// Returns the number of leading zeros in the binary representation of each element. fn leading_zeros(self) -> Self::Unsigned; @@ -259,6 +281,13 @@ macro_rules! impl_trait { (self^m) - m } + #[inline] + fn abs_diff(self, second: Self) -> Self::Unsigned { + let max = self.simd_max(second); + let min = self.simd_min(second); + (max - min).cast() + } + #[inline] fn saturating_abs(self) -> Self { // arith shift for -1 or 0 mask based on sign bit, giving 2s complement @@ -344,6 +373,16 @@ macro_rules! impl_trait { unsafe { core::intrinsics::simd::simd_bitreverse(self) } } + #[inline] + fn count_ones(self) -> Self::Unsigned { + self.cast::<$unsigned>().count_ones() + } + + #[inline] + fn count_zeros(self) -> Self::Unsigned { + self.cast::<$unsigned>().count_zeros() + } + #[inline] fn leading_zeros(self) -> Self::Unsigned { self.cast::<$unsigned>().leading_zeros() diff --git a/portable-simd/crates/core_simd/src/simd/num/uint.rs b/portable-simd/crates/core_simd/src/simd/num/uint.rs index 53dd97f501c63..1ab2d8c7b7316 100644 --- a/portable-simd/crates/core_simd/src/simd/num/uint.rs +++ b/portable-simd/crates/core_simd/src/simd/num/uint.rs @@ -1,5 +1,5 @@ use super::sealed::Sealed; -use crate::simd::{LaneCount, Simd, SimdCast, SimdElement, SupportedLaneCount}; +use crate::simd::{cmp::SimdOrd, LaneCount, Simd, SimdCast, SimdElement, SupportedLaneCount}; /// Operations on SIMD vectors of unsigned integers. pub trait SimdUint: Copy + Sealed { @@ -57,6 +57,22 @@ pub trait SimdUint: Copy + Sealed { /// assert_eq!(sat, Simd::splat(0)); fn saturating_sub(self, second: Self) -> Self; + /// Lanewise absolute difference. + /// Every element becomes the absolute difference of `self` and `second`. + /// + /// # Examples + /// ``` + /// # #![feature(portable_simd)] + /// # #[cfg(feature = "as_crate")] use core_simd::simd; + /// # #[cfg(not(feature = "as_crate"))] use core::simd; + /// # use simd::prelude::*; + /// use core::u32::MAX; + /// let a = Simd::from_array([0, MAX, 100, 20]); + /// let b = Simd::from_array([MAX, 0, 80, 200]); + /// assert_eq!(a.abs_diff(b), Simd::from_array([MAX, MAX, 20, 180])); + /// ``` + fn abs_diff(self, second: Self) -> Self; + /// Returns the sum of the elements of the vector, with wrapping addition. fn reduce_sum(self) -> Self::Scalar; @@ -85,6 +101,12 @@ pub trait SimdUint: Copy + Sealed { /// The least significant bit becomes the most significant bit, second least-significant bit becomes second most-significant bit, etc. fn reverse_bits(self) -> Self; + /// Returns the number of ones in the binary representation of each element. + fn count_ones(self) -> Self; + + /// Returns the number of zeros in the binary representation of each element. + fn count_zeros(self) -> Self; + /// Returns the number of leading zeros in the binary representation of each element. fn leading_zeros(self) -> Self; @@ -138,6 +160,13 @@ macro_rules! impl_trait { unsafe { core::intrinsics::simd::simd_saturating_sub(self, second) } } + #[inline] + fn abs_diff(self, second: Self) -> Self { + let max = self.simd_max(second); + let min = self.simd_min(second); + max - min + } + #[inline] fn reduce_sum(self) -> Self::Scalar { // Safety: `self` is an integer vector @@ -192,6 +221,17 @@ macro_rules! impl_trait { unsafe { core::intrinsics::simd::simd_bitreverse(self) } } + #[inline] + fn count_ones(self) -> Self { + // Safety: `self` is an integer vector + unsafe { core::intrinsics::simd::simd_ctpop(self) } + } + + #[inline] + fn count_zeros(self) -> Self { + (!self).count_ones() + } + #[inline] fn leading_zeros(self) -> Self { // Safety: `self` is an integer vector diff --git a/portable-simd/crates/core_simd/src/simd/ptr/const_ptr.rs b/portable-simd/crates/core_simd/src/simd/ptr/const_ptr.rs index be635ea640b86..47383809ffbae 100644 --- a/portable-simd/crates/core_simd/src/simd/ptr/const_ptr.rs +++ b/portable-simd/crates/core_simd/src/simd/ptr/const_ptr.rs @@ -42,6 +42,19 @@ pub trait SimdConstPtr: Copy + Sealed { /// Equivalent to calling [`pointer::addr`] on each element. fn addr(self) -> Self::Usize; + /// Converts an address to a pointer without giving it any provenance. + /// + /// Without provenance, this pointer is not associated with any actual allocation. Such a + /// no-provenance pointer may be used for zero-sized memory accesses (if suitably aligned), but + /// non-zero-sized memory accesses with a no-provenance pointer are UB. No-provenance pointers + /// are little more than a usize address in disguise. + /// + /// This is different from [`Self::with_exposed_provenance`], which creates a pointer that picks up a + /// previously exposed provenance. + /// + /// Equivalent to calling [`core::ptr::without_provenance`] on each element. + fn without_provenance(addr: Self::Usize) -> Self; + /// Creates a new pointer with the given address. /// /// This performs the same operation as a cast, but copies the *address-space* and @@ -118,6 +131,14 @@ where unsafe { core::mem::transmute_copy(&self) } } + #[inline] + fn without_provenance(addr: Self::Usize) -> Self { + // FIXME(strict_provenance_magic): I am magic and should be a compiler intrinsic. + // SAFETY: Integer-to-pointer transmutes are valid (if you are okay with not getting any + // provenance). + unsafe { core::mem::transmute_copy(&addr) } + } + #[inline] fn with_addr(self, addr: Self::Usize) -> Self { // FIXME(strict_provenance_magic): I am magic and should be a compiler intrinsic. diff --git a/portable-simd/crates/core_simd/src/simd/ptr/mut_ptr.rs b/portable-simd/crates/core_simd/src/simd/ptr/mut_ptr.rs index f6823a949e32a..3f20eef21a312 100644 --- a/portable-simd/crates/core_simd/src/simd/ptr/mut_ptr.rs +++ b/portable-simd/crates/core_simd/src/simd/ptr/mut_ptr.rs @@ -39,6 +39,19 @@ pub trait SimdMutPtr: Copy + Sealed { /// Equivalent to calling [`pointer::addr`] on each element. fn addr(self) -> Self::Usize; + /// Converts an address to a pointer without giving it any provenance. + /// + /// Without provenance, this pointer is not associated with any actual allocation. Such a + /// no-provenance pointer may be used for zero-sized memory accesses (if suitably aligned), but + /// non-zero-sized memory accesses with a no-provenance pointer are UB. No-provenance pointers + /// are little more than a usize address in disguise. + /// + /// This is different from [`Self::with_exposed_provenance`], which creates a pointer that picks up a + /// previously exposed provenance. + /// + /// Equivalent to calling [`core::ptr::without_provenance`] on each element. + fn without_provenance(addr: Self::Usize) -> Self; + /// Creates a new pointer with the given address. /// /// This performs the same operation as a cast, but copies the *address-space* and @@ -115,6 +128,14 @@ where unsafe { core::mem::transmute_copy(&self) } } + #[inline] + fn without_provenance(addr: Self::Usize) -> Self { + // FIXME(strict_provenance_magic): I am magic and should be a compiler intrinsic. + // SAFETY: Integer-to-pointer transmutes are valid (if you are okay with not getting any + // provenance). + unsafe { core::mem::transmute_copy(&addr) } + } + #[inline] fn with_addr(self, addr: Self::Usize) -> Self { // FIXME(strict_provenance_magic): I am magic and should be a compiler intrinsic. diff --git a/portable-simd/crates/core_simd/src/swizzle.rs b/portable-simd/crates/core_simd/src/swizzle.rs index d62642fb9061b..42425ef37e50b 100644 --- a/portable-simd/crates/core_simd/src/swizzle.rs +++ b/portable-simd/crates/core_simd/src/swizzle.rs @@ -155,8 +155,7 @@ pub trait Swizzle { /// Creates a new mask from the elements of `mask`. /// - /// Element `i` of the output is `concat[Self::INDEX[i]]`, where `concat` is the concatenation of - /// `first` and `second`. + /// Element `i` of the output is `mask[Self::INDEX[i]]`. #[inline] #[must_use = "method returns a new mask and does not mutate the original inputs"] fn swizzle_mask(mask: Mask) -> Mask @@ -260,6 +259,50 @@ where Rotate::::swizzle(self) } + /// Shifts the vector elements to the left by `OFFSET`, filling in with + /// `padding` from the right. + #[inline] + #[must_use = "method returns a new vector and does not mutate the original inputs"] + pub fn shift_elements_left(self, padding: T) -> Self { + struct Shift; + + impl Swizzle for Shift { + const INDEX: [usize; N] = const { + let mut index = [N; N]; + let mut i = 0; + while i + OFFSET < N { + index[i] = i + OFFSET; + i += 1; + } + index + }; + } + + Shift::::concat_swizzle(self, Simd::splat(padding)) + } + + /// Shifts the vector elements to the right by `OFFSET`, filling in with + /// `padding` from the left. + #[inline] + #[must_use = "method returns a new vector and does not mutate the original inputs"] + pub fn shift_elements_right(self, padding: T) -> Self { + struct Shift; + + impl Swizzle for Shift { + const INDEX: [usize; N] = const { + let mut index = [N; N]; + let mut i = OFFSET; + while i < N { + index[i] = i - OFFSET; + i += 1; + } + index + }; + } + + Shift::::concat_swizzle(self, Simd::splat(padding)) + } + /// Interleave two vectors. /// /// The resulting vectors contain elements taken alternatively from `self` and `other`, first @@ -320,7 +363,9 @@ where /// /// ``` /// # #![feature(portable_simd)] - /// # use core::simd::Simd; + /// # #[cfg(feature = "as_crate")] use core_simd::simd; + /// # #[cfg(not(feature = "as_crate"))] use core::simd; + /// # use simd::Simd; /// let a = Simd::from_array([0, 4, 1, 5]); /// let b = Simd::from_array([2, 6, 3, 7]); /// let (x, y) = a.deinterleave(b); @@ -391,4 +436,210 @@ where } Resize::::concat_swizzle(self, Simd::splat(value)) } + + /// Extract a vector from another vector. + /// + /// ``` + /// # #![feature(portable_simd)] + /// # #[cfg(feature = "as_crate")] use core_simd::simd; + /// # #[cfg(not(feature = "as_crate"))] use core::simd; + /// # use simd::u32x4; + /// let x = u32x4::from_array([0, 1, 2, 3]); + /// assert_eq!(x.extract::<1, 2>().to_array(), [1, 2]); + /// ``` + #[inline] + #[must_use = "method returns a new vector and does not mutate the original inputs"] + pub fn extract(self) -> Simd + where + LaneCount: SupportedLaneCount, + { + struct Extract; + impl Swizzle for Extract { + const INDEX: [usize; LEN] = const { + assert!(START + LEN <= N, "index out of bounds"); + let mut index = [0; LEN]; + let mut i = 0; + while i < LEN { + index[i] = START + i; + i += 1; + } + index + }; + } + Extract::::swizzle(self) + } +} + +impl Mask +where + T: MaskElement, + LaneCount: SupportedLaneCount, +{ + /// Reverse the order of the elements in the mask. + #[inline] + #[must_use = "method returns a new vector and does not mutate the original inputs"] + pub fn reverse(self) -> Self { + // Safety: swizzles are safe for masks + unsafe { Self::from_int_unchecked(self.to_int().reverse()) } + } + + /// Rotates the mask such that the first `OFFSET` elements of the slice move to the end + /// while the last `self.len() - OFFSET` elements move to the front. After calling `rotate_elements_left`, + /// the element previously at index `OFFSET` will become the first element in the slice. + #[inline] + #[must_use = "method returns a new vector and does not mutate the original inputs"] + pub fn rotate_elements_left(self) -> Self { + // Safety: swizzles are safe for masks + unsafe { Self::from_int_unchecked(self.to_int().rotate_elements_left::()) } + } + + /// Rotates the mask such that the first `self.len() - OFFSET` elements of the mask move to + /// the end while the last `OFFSET` elements move to the front. After calling `rotate_elements_right`, + /// the element previously at index `self.len() - OFFSET` will become the first element in the slice. + #[inline] + #[must_use = "method returns a new vector and does not mutate the original inputs"] + pub fn rotate_elements_right(self) -> Self { + // Safety: swizzles are safe for masks + unsafe { Self::from_int_unchecked(self.to_int().rotate_elements_right::()) } + } + + /// Shifts the mask elements to the left by `OFFSET`, filling in with + /// `padding` from the right. + #[inline] + #[must_use = "method returns a new mask and does not mutate the original inputs"] + pub fn shift_elements_left(self, padding: bool) -> Self { + // Safety: swizzles are safe for masks + unsafe { + Self::from_int_unchecked(self.to_int().shift_elements_left::(if padding { + T::TRUE + } else { + T::FALSE + })) + } + } + + /// Shifts the mask elements to the right by `OFFSET`, filling in with + /// `padding` from the left. + #[inline] + #[must_use = "method returns a new mask and does not mutate the original inputs"] + pub fn shift_elements_right(self, padding: bool) -> Self { + // Safety: swizzles are safe for masks + unsafe { + Self::from_int_unchecked(self.to_int().shift_elements_right::(if padding { + T::TRUE + } else { + T::FALSE + })) + } + } + + /// Interleave two masks. + /// + /// The resulting masks contain elements taken alternatively from `self` and `other`, first + /// filling the first result, and then the second. + /// + /// The reverse of this operation is [`Mask::deinterleave`]. + /// + /// ``` + /// # #![feature(portable_simd)] + /// # #[cfg(feature = "as_crate")] use core_simd::simd; + /// # #[cfg(not(feature = "as_crate"))] use core::simd; + /// # use simd::mask32x4; + /// let a = mask32x4::from_array([false, true, false, true]); + /// let b = mask32x4::from_array([false, false, true, true]); + /// let (x, y) = a.interleave(b); + /// assert_eq!(x.to_array(), [false, false, true, false]); + /// assert_eq!(y.to_array(), [false, true, true, true]); + /// ``` + #[inline] + #[must_use = "method returns a new vector and does not mutate the original inputs"] + pub fn interleave(self, other: Self) -> (Self, Self) { + let (lo, hi) = self.to_int().interleave(other.to_int()); + // Safety: swizzles are safe for masks + unsafe { (Self::from_int_unchecked(lo), Self::from_int_unchecked(hi)) } + } + + /// Deinterleave two masks. + /// + /// The first result takes every other element of `self` and then `other`, starting with + /// the first element. + /// + /// The second result takes every other element of `self` and then `other`, starting with + /// the second element. + /// + /// The reverse of this operation is [`Mask::interleave`]. + /// + /// ``` + /// # #![feature(portable_simd)] + /// # #[cfg(feature = "as_crate")] use core_simd::simd; + /// # #[cfg(not(feature = "as_crate"))] use core::simd; + /// # use simd::mask32x4; + /// let a = mask32x4::from_array([false, true, false, true]); + /// let b = mask32x4::from_array([false, false, true, true]); + /// let (x, y) = a.deinterleave(b); + /// assert_eq!(x.to_array(), [false, false, false, true]); + /// assert_eq!(y.to_array(), [true, true, false, true]); + /// ``` + #[inline] + #[must_use = "method returns a new vector and does not mutate the original inputs"] + pub fn deinterleave(self, other: Self) -> (Self, Self) { + let (even, odd) = self.to_int().deinterleave(other.to_int()); + // Safety: swizzles are safe for masks + unsafe { + ( + Self::from_int_unchecked(even), + Self::from_int_unchecked(odd), + ) + } + } + + /// Resize a mask. + /// + /// If `M` > `N`, extends the length of a mask, setting the new elements to `value`. + /// If `M` < `N`, truncates the mask to the first `M` elements. + /// + /// ``` + /// # #![feature(portable_simd)] + /// # #[cfg(feature = "as_crate")] use core_simd::simd; + /// # #[cfg(not(feature = "as_crate"))] use core::simd; + /// # use simd::mask32x4; + /// let x = mask32x4::from_array([false, true, true, false]); + /// assert_eq!(x.resize::<8>(true).to_array(), [false, true, true, false, true, true, true, true]); + /// assert_eq!(x.resize::<2>(true).to_array(), [false, true]); + /// ``` + #[inline] + #[must_use = "method returns a new vector and does not mutate the original inputs"] + pub fn resize(self, value: bool) -> Mask + where + LaneCount: SupportedLaneCount, + { + // Safety: swizzles are safe for masks + unsafe { + Mask::::from_int_unchecked(self.to_int().resize::(if value { + T::TRUE + } else { + T::FALSE + })) + } + } + + /// Extract a vector from another vector. + /// + /// ``` + /// # #![feature(portable_simd)] + /// # #[cfg(feature = "as_crate")] use core_simd::simd; + /// # #[cfg(not(feature = "as_crate"))] use core::simd; + /// # use simd::mask32x4; + /// let x = mask32x4::from_array([false, true, true, false]); + /// assert_eq!(x.extract::<1, 2>().to_array(), [true, true]); + /// ``` + #[inline] + #[must_use = "method returns a new vector and does not mutate the original inputs"] + pub fn extract(self) -> Mask + where + LaneCount: SupportedLaneCount, + { + // Safety: swizzles are safe for masks + unsafe { Mask::::from_int_unchecked(self.to_int().extract::()) } + } } diff --git a/portable-simd/crates/core_simd/src/swizzle_dyn.rs b/portable-simd/crates/core_simd/src/swizzle_dyn.rs index 3b6388d0f2759..773bd028bae09 100644 --- a/portable-simd/crates/core_simd/src/swizzle_dyn.rs +++ b/portable-simd/crates/core_simd/src/swizzle_dyn.rs @@ -59,15 +59,40 @@ where target_endian = "little" ))] 16 => transize(vqtbl1q_u8, self, idxs), + #[cfg(all( + target_arch = "arm", + target_feature = "v7", + target_feature = "neon", + target_endian = "little" + ))] + 16 => transize(armv7_neon_swizzle_u8x16, self, idxs), #[cfg(all(target_feature = "avx2", not(target_feature = "avx512vbmi")))] 32 => transize(avx2_pshufb, self, idxs), #[cfg(all(target_feature = "avx512vl", target_feature = "avx512vbmi"))] - 32 => transize(x86::_mm256_permutexvar_epi8, zeroing_idxs(idxs), self), - // Notable absence: avx512bw shuffle - // If avx512bw is available, odds of avx512vbmi are good - // FIXME: initial AVX512VBMI variant didn't actually pass muster - // #[cfg(target_feature = "avx512vbmi")] - // 64 => transize(x86::_mm512_permutexvar_epi8, self, idxs), + 32 => { + // Unlike vpshufb, vpermb doesn't zero out values in the result based on the index high bit + let swizzler = |bytes, idxs| { + let mask = x86::_mm256_cmp_epu8_mask::<{ x86::_MM_CMPINT_LT }>( + idxs, + Simd::::splat(N as u8).into(), + ); + x86::_mm256_maskz_permutexvar_epi8(mask, idxs, bytes) + }; + transize(swizzler, self, idxs) + } + // Notable absence: avx512bw pshufb shuffle + #[cfg(all(target_feature = "avx512vl", target_feature = "avx512vbmi"))] + 64 => { + // Unlike vpshufb, vpermb doesn't zero out values in the result based on the index high bit + let swizzler = |bytes, idxs| { + let mask = x86::_mm512_cmp_epu8_mask::<{ x86::_MM_CMPINT_LT }>( + idxs, + Simd::::splat(N as u8).into(), + ); + x86::_mm512_maskz_permutexvar_epi8(mask, idxs, bytes) + }; + transize(swizzler, self, idxs) + } _ => { let mut array = [0; N]; for (i, k) in idxs.to_array().into_iter().enumerate() { @@ -82,6 +107,28 @@ where } } +/// armv7 neon supports swizzling `u8x16` by swizzling two u8x8 blocks +/// with a u8x8x2 lookup table. +/// +/// # Safety +/// This requires armv7 neon to work +#[cfg(all( + target_arch = "arm", + target_feature = "v7", + target_feature = "neon", + target_endian = "little" +))] +unsafe fn armv7_neon_swizzle_u8x16(bytes: Simd, idxs: Simd) -> Simd { + use core::arch::arm::{uint8x8x2_t, vcombine_u8, vget_high_u8, vget_low_u8, vtbl2_u8}; + // SAFETY: Caller promised arm neon support + unsafe { + let bytes = uint8x8x2_t(vget_low_u8(bytes.into()), vget_high_u8(bytes.into())); + let lo = vtbl2_u8(bytes, vget_low_u8(idxs.into())); + let hi = vtbl2_u8(bytes, vget_high_u8(idxs.into())); + vcombine_u8(lo, hi).into() + } +} + /// "vpshufb like it was meant to be" on AVX2 /// /// # Safety diff --git a/portable-simd/crates/core_simd/src/vector.rs b/portable-simd/crates/core_simd/src/vector.rs index 3e23916914963..9c4dd36c24fe8 100644 --- a/portable-simd/crates/core_simd/src/vector.rs +++ b/portable-simd/crates/core_simd/src/vector.rs @@ -99,7 +99,7 @@ use crate::simd::{ // directly constructing an instance of the type (i.e. `let vector = Simd(array)`) should be // avoided, as it will likely become illegal on `#[repr(simd)]` structs in the future. It also // causes rustc to emit illegal LLVM IR in some cases. -#[repr(simd)] +#[repr(simd, packed)] pub struct Simd([T; N]) where LaneCount: SupportedLaneCount, @@ -144,14 +144,32 @@ where /// assert_eq!(v.as_array(), &[8, 8, 8, 8]); /// ``` #[inline] - pub fn splat(value: T) -> Self { - // This is preferred over `[value; N]`, since it's explicitly a splat: - // https://github.com/rust-lang/rust/issues/97804 - struct Splat; - impl Swizzle for Splat { - const INDEX: [usize; N] = [0; N]; + #[rustc_const_unstable(feature = "portable_simd", issue = "86656")] + pub const fn splat(value: T) -> Self { + const fn splat_const(value: T) -> Simd + where + T: SimdElement, + LaneCount: SupportedLaneCount, + { + Simd::from_array([value; N]) } - Splat::swizzle::(Simd::::from([value])) + + fn splat_rt(value: T) -> Simd + where + T: SimdElement, + LaneCount: SupportedLaneCount, + { + // This is preferred over `[value; N]`, since it's explicitly a splat: + // https://github.com/rust-lang/rust/issues/97804 + struct Splat; + impl Swizzle for Splat { + const INDEX: [usize; N] = [0; N]; + } + + Splat::swizzle::(Simd::::from([value])) + } + + core::intrinsics::const_eval_select((value,), splat_const, splat_rt) } /// Returns an array reference containing the entire SIMD vector. @@ -425,6 +443,9 @@ where /// /// When the element is disabled, that memory location is not accessed and the corresponding /// value from `or` is passed through. + /// + /// # Safety + /// Enabled loads must not exceed the length of `slice`. #[must_use] #[inline] pub unsafe fn load_select_unchecked( @@ -442,6 +463,9 @@ where /// /// When the element is disabled, that memory location is not accessed and the corresponding /// value from `or` is passed through. + /// + /// # Safety + /// Enabled `ptr` elements must be safe to read as if by `std::ptr::read`. #[must_use] #[inline] pub unsafe fn load_select_ptr( @@ -924,6 +948,7 @@ where } } +/// Lexicographic order. For the SIMD elementwise minimum and maximum, use simd_min and simd_max instead. impl PartialOrd for Simd where LaneCount: SupportedLaneCount, @@ -943,6 +968,7 @@ where { } +/// Lexicographic order. For the SIMD elementwise minimum and maximum, use simd_min and simd_max instead. impl Ord for Simd where LaneCount: SupportedLaneCount, @@ -1195,6 +1221,7 @@ fn lane_indices() -> Simd where LaneCount: SupportedLaneCount, { + #![allow(clippy::needless_range_loop)] let mut index = [0; N]; for i in 0..N { index[i] = i; diff --git a/portable-simd/crates/core_simd/src/vendor.rs b/portable-simd/crates/core_simd/src/vendor.rs index 1a34a3a8de5c4..57536e4fc77dc 100644 --- a/portable-simd/crates/core_simd/src/vendor.rs +++ b/portable-simd/crates/core_simd/src/vendor.rs @@ -29,3 +29,6 @@ mod arm; #[cfg(any(target_arch = "powerpc", target_arch = "powerpc64"))] mod powerpc; + +#[cfg(target_arch = "loongarch64")] +mod loongarch64; diff --git a/portable-simd/crates/core_simd/src/vendor/loongarch64.rs b/portable-simd/crates/core_simd/src/vendor/loongarch64.rs new file mode 100644 index 0000000000000..1290bc166b2b8 --- /dev/null +++ b/portable-simd/crates/core_simd/src/vendor/loongarch64.rs @@ -0,0 +1,31 @@ +use crate::simd::*; +use core::arch::loongarch64::*; + +from_transmute! { unsafe u8x16 => v16u8 } +from_transmute! { unsafe u8x32 => v32u8 } +from_transmute! { unsafe i8x16 => v16i8 } +from_transmute! { unsafe i8x32 => v32i8 } + +from_transmute! { unsafe u16x8 => v8u16 } +from_transmute! { unsafe u16x16 => v16u16 } +from_transmute! { unsafe i16x8 => v8i16 } +from_transmute! { unsafe i16x16 => v16i16 } + +from_transmute! { unsafe u32x4 => v4u32 } +from_transmute! { unsafe u32x8 => v8u32 } +from_transmute! { unsafe i32x4 => v4i32 } +from_transmute! { unsafe i32x8 => v8i32 } +from_transmute! { unsafe f32x4 => v4f32 } +from_transmute! { unsafe f32x8 => v8f32 } + +from_transmute! { unsafe u64x2 => v2u64 } +from_transmute! { unsafe u64x4 => v4u64 } +from_transmute! { unsafe i64x2 => v2i64 } +from_transmute! { unsafe i64x4 => v4i64 } +from_transmute! { unsafe f64x2 => v2f64 } +from_transmute! { unsafe f64x4 => v4f64 } + +from_transmute! { unsafe usizex2 => v2u64 } +from_transmute! { unsafe usizex4 => v4u64 } +from_transmute! { unsafe isizex2 => v2i64 } +from_transmute! { unsafe isizex4 => v4i64 } diff --git a/portable-simd/crates/core_simd/tests/layout.rs b/portable-simd/crates/core_simd/tests/layout.rs new file mode 100644 index 0000000000000..24114c2d261e7 --- /dev/null +++ b/portable-simd/crates/core_simd/tests/layout.rs @@ -0,0 +1,35 @@ +#![feature(portable_simd)] + +macro_rules! layout_tests { + { $($mod:ident, $ty:ty,)* } => { + $( + mod $mod { + test_helpers::test_lanes! { + fn no_padding() { + assert_eq!( + core::mem::size_of::>(), + core::mem::size_of::<[$ty; LANES]>(), + ); + } + } + } + )* + } +} + +layout_tests! { + i8, i8, + i16, i16, + i32, i32, + i64, i64, + isize, isize, + u8, u8, + u16, u16, + u32, u32, + u64, u64, + usize, usize, + f32, f32, + f64, f64, + mut_ptr, *mut (), + const_ptr, *const (), +} diff --git a/portable-simd/crates/core_simd/tests/masks.rs b/portable-simd/crates/core_simd/tests/masks.rs index fc6a3476b7c60..48786d02440b3 100644 --- a/portable-simd/crates/core_simd/tests/masks.rs +++ b/portable-simd/crates/core_simd/tests/masks.rs @@ -99,7 +99,6 @@ macro_rules! test_mask_api { assert_eq!(Mask::<$type, 2>::from_bitmask(bitmask), mask); } - #[cfg(feature = "all_lane_counts")] #[test] fn roundtrip_bitmask_conversion_odd() { let values = [ @@ -134,48 +133,6 @@ macro_rules! test_mask_api { cast_impl::(); cast_impl::(); } - - #[test] - fn roundtrip_bitmask_vector_conversion() { - use core_simd::simd::ToBytes; - let values = [ - true, false, false, true, false, false, true, false, - true, true, false, false, false, false, false, true, - ]; - let mask = Mask::<$type, 16>::from_array(values); - let bitmask = mask.to_bitmask_vector(); - assert_eq!(bitmask.resize::<2>(0).to_ne_bytes()[..2], [0b01001001, 0b10000011]); - assert_eq!(Mask::<$type, 16>::from_bitmask_vector(bitmask), mask); - } - - // rust-lang/portable-simd#379 - #[test] - fn roundtrip_bitmask_vector_conversion_small() { - use core_simd::simd::ToBytes; - let values = [ - true, false, true, true - ]; - let mask = Mask::<$type, 4>::from_array(values); - let bitmask = mask.to_bitmask_vector(); - assert_eq!(bitmask.resize::<1>(0).to_ne_bytes()[0], 0b00001101); - assert_eq!(Mask::<$type, 4>::from_bitmask_vector(bitmask), mask); - } - - /* FIXME doesn't work with non-powers-of-two, yet - // rust-lang/portable-simd#379 - #[cfg(feature = "all_lane_counts")] - #[test] - fn roundtrip_bitmask_vector_conversion_odd() { - use core_simd::simd::ToBytes; - let values = [ - true, false, true, false, true, true, false, false, false, true, true, - ]; - let mask = Mask::<$type, 11>::from_array(values); - let bitmask = mask.to_bitmask_vector(); - assert_eq!(bitmask.resize::<2>(0).to_ne_bytes()[..2], [0b00110101, 0b00000110]); - assert_eq!(Mask::<$type, 11>::from_bitmask_vector(bitmask), mask); - } - */ } } } diff --git a/portable-simd/crates/core_simd/tests/ops_macros.rs b/portable-simd/crates/core_simd/tests/ops_macros.rs index aa565a137527e..6de78f51e59df 100644 --- a/portable-simd/crates/core_simd/tests/ops_macros.rs +++ b/portable-simd/crates/core_simd/tests/ops_macros.rs @@ -216,6 +216,22 @@ macro_rules! impl_common_integer_tests { ) } + fn count_ones() { + test_helpers::test_unary_elementwise( + &$vector::::count_ones, + &|x| x.count_ones() as _, + &|_| true, + ) + } + + fn count_zeros() { + test_helpers::test_unary_elementwise( + &$vector::::count_zeros, + &|x| x.count_zeros() as _, + &|_| true, + ) + } + fn leading_zeros() { test_helpers::test_unary_elementwise( &$vector::::leading_zeros, @@ -307,6 +323,14 @@ macro_rules! impl_signed_tests { assert_eq!(a % b, Vector::::splat(0)); } + fn abs_diff() { + test_helpers::test_binary_elementwise( + &Vector::::abs_diff, + &Scalar::abs_diff, + &|_, _| true, + ) + } + fn simd_min() { use core_simd::simd::cmp::SimdOrd; let a = Vector::::splat(Scalar::MIN); @@ -419,6 +443,14 @@ macro_rules! impl_unsigned_tests { &|_| true, ); } + + fn abs_diff() { + test_helpers::test_binary_elementwise( + &Vector::::abs_diff, + &Scalar::abs_diff, + &|_, _| true, + ) + } } impl_binary_op_test!(Scalar, Add::add, AddAssign::add_assign, Scalar::wrapping_add); @@ -495,6 +527,9 @@ macro_rules! impl_float_tests { } fn is_normal() { + // Arm v7 Neon violates float opsem re: subnormals, see + // https://github.com/rust-lang/portable-simd/issues/439 + #[cfg(not(target_arch = "arm"))] test_helpers::test_unary_mask_elementwise( &Vector::::is_normal, &Scalar::is_normal, @@ -503,6 +538,9 @@ macro_rules! impl_float_tests { } fn is_subnormal() { + // Arm v7 Neon violates float opsem re: subnormals, see + // https://github.com/rust-lang/portable-simd/issues/439 + #[cfg(not(target_arch = "arm"))] test_helpers::test_unary_mask_elementwise( &Vector::::is_subnormal, &Scalar::is_subnormal, diff --git a/portable-simd/crates/core_simd/tests/swizzle.rs b/portable-simd/crates/core_simd/tests/swizzle.rs index 522d71439b77d..7001e5f6bf87b 100644 --- a/portable-simd/crates/core_simd/tests/swizzle.rs +++ b/portable-simd/crates/core_simd/tests/swizzle.rs @@ -48,6 +48,24 @@ fn rotate() { assert_eq!(a.rotate_elements_right::<5>().to_array(), [4, 1, 2, 3]); } +#[test] +#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)] +fn shift() { + let a = Simd::from_array([1, 2, 3, 4]); + assert_eq!(a.shift_elements_left::<0>(0).to_array(), [1, 2, 3, 4]); + assert_eq!(a.shift_elements_left::<1>(0).to_array(), [2, 3, 4, 0]); + assert_eq!(a.shift_elements_left::<2>(9).to_array(), [3, 4, 9, 9]); + assert_eq!(a.shift_elements_left::<3>(8).to_array(), [4, 8, 8, 8]); + assert_eq!(a.shift_elements_left::<4>(7).to_array(), [7, 7, 7, 7]); + assert_eq!(a.shift_elements_left::<5>(6).to_array(), [6, 6, 6, 6]); + assert_eq!(a.shift_elements_right::<0>(0).to_array(), [1, 2, 3, 4]); + assert_eq!(a.shift_elements_right::<1>(0).to_array(), [0, 1, 2, 3]); + assert_eq!(a.shift_elements_right::<2>(-1).to_array(), [-1, -1, 1, 2]); + assert_eq!(a.shift_elements_right::<3>(-2).to_array(), [-2, -2, -2, 1]); + assert_eq!(a.shift_elements_right::<4>(-3).to_array(), [-3, -3, -3, -3]); + assert_eq!(a.shift_elements_right::<5>(-4).to_array(), [-4, -4, -4, -4]); +} + #[test] #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)] fn interleave() { diff --git a/portable-simd/crates/test_helpers/Cargo.toml b/portable-simd/crates/test_helpers/Cargo.toml index 23dae7c93381e..a5359b9abc84d 100644 --- a/portable-simd/crates/test_helpers/Cargo.toml +++ b/portable-simd/crates/test_helpers/Cargo.toml @@ -6,6 +6,3 @@ publish = false [dependencies] proptest = { version = "0.10", default-features = false, features = ["alloc"] } - -[features] -all_lane_counts = [] diff --git a/portable-simd/crates/test_helpers/src/lib.rs b/portable-simd/crates/test_helpers/src/lib.rs index 51b860a863560..197c920e11eac 100644 --- a/portable-simd/crates/test_helpers/src/lib.rs +++ b/portable-simd/crates/test_helpers/src/lib.rs @@ -539,32 +539,22 @@ macro_rules! test_lanes { #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]; lanes_1 1; lanes_2 2; - lanes_4 4; - ); - - #[cfg(not(miri))] // Miri intrinsic implementations are uniform and larger tests are sloooow - $crate::test_lanes_helper!( - #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]; - lanes_8 8; - lanes_16 16; - lanes_32 32; - lanes_64 64; - ); - - #[cfg(feature = "all_lane_counts")] - $crate::test_lanes_helper!( - // test some odd and even non-power-of-2 lengths on miri - #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]; + // Cover an odd and an even non-power-of-2 length in Miri. + // (Even non-power-of-2 vectors have alignment between element + // and vector size, so we want to cover that case as well.) lanes_3 3; - lanes_5 5; + lanes_6 6; ); - #[cfg(feature = "all_lane_counts")] #[cfg(not(miri))] // Miri intrinsic implementations are uniform and larger tests are sloooow $crate::test_lanes_helper!( #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]; + lanes_4 4; + lanes_5 5; + lanes_7 7; + lanes_8 8; lanes_9 9; lanes_10 10; lanes_11 11; @@ -572,52 +562,55 @@ macro_rules! test_lanes { lanes_13 13; lanes_14 14; lanes_15 15; + lanes_16 16; lanes_17 17; - lanes_18 18; - lanes_19 19; - lanes_20 20; - lanes_21 21; - lanes_22 22; - lanes_23 23; + //lanes_18 18; + //lanes_19 19; + //lanes_20 20; + //lanes_21 21; + //lanes_22 22; + //lanes_23 23; lanes_24 24; - lanes_25 25; - lanes_26 26; - lanes_27 27; - lanes_28 28; - lanes_29 29; - lanes_30 30; - lanes_31 31; - lanes_33 33; - lanes_34 34; - lanes_35 35; - lanes_36 36; - lanes_37 37; - lanes_38 38; - lanes_39 39; - lanes_40 40; - lanes_41 41; - lanes_42 42; - lanes_43 43; - lanes_44 44; - lanes_45 45; - lanes_46 46; + //lanes_25 25; + //lanes_26 26; + //lanes_27 27; + //lanes_28 28; + //lanes_29 29; + //lanes_30 30; + //lanes_31 31; + lanes_32 32; + //lanes_33 33; + //lanes_34 34; + //lanes_35 35; + //lanes_36 36; + //lanes_37 37; + //lanes_38 38; + //lanes_39 39; + //lanes_40 40; + //lanes_41 41; + //lanes_42 42; + //lanes_43 43; + //lanes_44 44; + //lanes_45 45; + //lanes_46 46; lanes_47 47; - lanes_48 48; - lanes_49 49; - lanes_50 50; - lanes_51 51; - lanes_52 52; - lanes_53 53; - lanes_54 54; - lanes_55 55; + //lanes_48 48; + //lanes_49 49; + //lanes_50 50; + //lanes_51 51; + //lanes_52 52; + //lanes_53 53; + //lanes_54 54; + //lanes_55 55; lanes_56 56; lanes_57 57; - lanes_58 58; - lanes_59 59; - lanes_60 60; - lanes_61 61; - lanes_62 62; + //lanes_58 58; + //lanes_59 59; + //lanes_60 60; + //lanes_61 61; + //lanes_62 62; lanes_63 63; + lanes_64 64; ); } )* @@ -639,36 +632,24 @@ macro_rules! test_lanes_panic { core_simd::simd::LaneCount<$lanes>: core_simd::simd::SupportedLaneCount, $body + // test some odd and even non-power-of-2 lengths on miri $crate::test_lanes_helper!( #[should_panic]; lanes_1 1; lanes_2 2; - lanes_4 4; - ); - - #[cfg(not(miri))] // Miri intrinsic implementations are uniform and larger tests are sloooow - $crate::test_lanes_helper!( - #[should_panic]; - lanes_8 8; - lanes_16 16; - lanes_32 32; - lanes_64 64; - ); - - #[cfg(feature = "all_lane_counts")] - $crate::test_lanes_helper!( - // test some odd and even non-power-of-2 lengths on miri - #[should_panic]; lanes_3 3; - lanes_5 5; + lanes_6 6; ); - #[cfg(feature = "all_lane_counts")] #[cfg(not(miri))] // Miri intrinsic implementations are uniform and larger tests are sloooow $crate::test_lanes_helper!( #[should_panic]; + lanes_4 4; + lanes_5 5; + lanes_7 7; + lanes_8 8; lanes_9 9; lanes_10 10; lanes_11 11; @@ -676,52 +657,55 @@ macro_rules! test_lanes_panic { lanes_13 13; lanes_14 14; lanes_15 15; + lanes_16 16; lanes_17 17; - lanes_18 18; - lanes_19 19; - lanes_20 20; - lanes_21 21; - lanes_22 22; - lanes_23 23; + //lanes_18 18; + //lanes_19 19; + //lanes_20 20; + //lanes_21 21; + //lanes_22 22; + //lanes_23 23; lanes_24 24; - lanes_25 25; - lanes_26 26; - lanes_27 27; - lanes_28 28; - lanes_29 29; - lanes_30 30; - lanes_31 31; - lanes_33 33; - lanes_34 34; - lanes_35 35; - lanes_36 36; - lanes_37 37; - lanes_38 38; - lanes_39 39; - lanes_40 40; - lanes_41 41; - lanes_42 42; - lanes_43 43; - lanes_44 44; - lanes_45 45; - lanes_46 46; + //lanes_25 25; + //lanes_26 26; + //lanes_27 27; + //lanes_28 28; + //lanes_29 29; + //lanes_30 30; + //lanes_31 31; + lanes_32 32; + //lanes_33 33; + //lanes_34 34; + //lanes_35 35; + //lanes_36 36; + //lanes_37 37; + //lanes_38 38; + //lanes_39 39; + //lanes_40 40; + //lanes_41 41; + //lanes_42 42; + //lanes_43 43; + //lanes_44 44; + //lanes_45 45; + //lanes_46 46; lanes_47 47; - lanes_48 48; - lanes_49 49; - lanes_50 50; - lanes_51 51; - lanes_52 52; - lanes_53 53; - lanes_54 54; - lanes_55 55; + //lanes_48 48; + //lanes_49 49; + //lanes_50 50; + //lanes_51 51; + //lanes_52 52; + //lanes_53 53; + //lanes_54 54; + //lanes_55 55; lanes_56 56; lanes_57 57; - lanes_58 58; - lanes_59 59; - lanes_60 60; - lanes_61 61; - lanes_62 62; + //lanes_58 58; + //lanes_59 59; + //lanes_60 60; + //lanes_61 61; + //lanes_62 62; lanes_63 63; + lanes_64 64; ); } )* diff --git a/portable-simd/rust-toolchain.toml b/portable-simd/rust-toolchain.toml new file mode 100644 index 0000000000000..d17c6d2e88946 --- /dev/null +++ b/portable-simd/rust-toolchain.toml @@ -0,0 +1,3 @@ +[toolchain] +channel = "nightly-2025-01-16" +components = ["rustfmt", "clippy", "miri", "rust-src"] diff --git a/portable-simd/subtree-sync.sh b/portable-simd/subtree-sync.sh new file mode 100755 index 0000000000000..18360077623b1 --- /dev/null +++ b/portable-simd/subtree-sync.sh @@ -0,0 +1,52 @@ +#!/bin/bash + +set -eou pipefail + +git fetch origin +pushd $2 +git fetch origin +popd + +if [ "$(git rev-parse --show-prefix)" != "" ]; then + echo "Run this script from the git root" >&2 + exit 1 +fi + +if [ "$(git rev-parse HEAD)" != "$(git rev-parse origin/master)" ]; then + echo "$(pwd) is not at origin/master" >&2 + exit 1 +fi + +if [ ! -f library/portable-simd/git-subtree.sh ]; then + curl -sS https://raw.githubusercontent.com/bjorn3/git/tqc-subtree-portable/contrib/subtree/git-subtree.sh -o library/portable-simd/git-subtree.sh + chmod +x library/portable-simd/git-subtree.sh +fi + +today=$(date +%Y-%m-%d) + +case $1 in + "push") + upstream=rust-upstream-$today + merge=sync-from-rust-$today + + pushd $2 + git checkout master + git pull + popd + + library/portable-simd/git-subtree.sh push -P library/portable-simd $2 $upstream + + pushd $2 + git checkout -B $merge origin/master + git merge $upstream + popd + echo "Branch \`$merge\` created in \`$2\`. You may need to resolve merge conflicts." + ;; + "pull") + branch=sync-from-portable-simd-$today + + git checkout -B $branch + echo "Creating branch \`$branch\`... You may need to resolve merge conflicts." + library/portable-simd/git-subtree.sh pull -P library/portable-simd $2 origin/master + ;; +esac diff --git a/proc_macro/src/bridge/closure.rs b/proc_macro/src/bridge/closure.rs index 524fdf53d6b7e..e0e688434dce5 100644 --- a/proc_macro/src/bridge/closure.rs +++ b/proc_macro/src/bridge/closure.rs @@ -19,7 +19,7 @@ struct Env; impl<'a, A, R, F: FnMut(A) -> R> From<&'a mut F> for Closure<'a, A, R> { fn from(f: &'a mut F) -> Self { unsafe extern "C" fn call R>(env: *mut Env, arg: A) -> R { - (*(env as *mut _ as *mut F))(arg) + unsafe { (*(env as *mut _ as *mut F))(arg) } } Closure { call: call::, env: f as *mut _ as *mut Env, _marker: PhantomData } } diff --git a/proc_macro/src/lib.rs b/proc_macro/src/lib.rs index 6611ce30a1b01..d9141eab5919f 100644 --- a/proc_macro/src/lib.rs +++ b/proc_macro/src/lib.rs @@ -33,6 +33,7 @@ #![deny(ffi_unwind_calls)] #![warn(rustdoc::unescaped_backticks)] #![warn(unreachable_pub)] +#![deny(unsafe_op_in_unsafe_fn)] #[unstable(feature = "proc_macro_internals", issue = "27812")] #[doc(hidden)] diff --git a/rtstartup/rsbegin.rs b/rtstartup/rsbegin.rs index d3ff5c14aa4a8..67b09599d9d2b 100644 --- a/rtstartup/rsbegin.rs +++ b/rtstartup/rsbegin.rs @@ -52,7 +52,7 @@ pub unsafe fn drop_in_place(to_drop: *mut T) { #[cfg(all(target_os = "windows", target_arch = "x86", target_env = "gnu"))] pub mod eh_frames { #[no_mangle] - #[link_section = ".eh_frame"] + #[unsafe(link_section = ".eh_frame")] // Marks beginning of the stack frame unwind info section pub static __EH_FRAME_BEGIN__: [u8; 0] = []; @@ -76,7 +76,7 @@ pub mod eh_frames { } // Unwind info registration/deregistration routines. - extern "C" { + unsafe extern "C" { fn __register_frame_info(eh_frame_begin: *const u8, object: *mut u8); fn __deregister_frame_info(eh_frame_begin: *const u8, object: *mut u8); } @@ -101,10 +101,10 @@ pub mod eh_frames { // end of the list. Since constructors are run in reverse order, this ensures that our // callbacks are the first and last ones executed. - #[link_section = ".ctors.65535"] // .ctors.* : C initialization callbacks + #[unsafe(link_section = ".ctors.65535")] // .ctors.* : C initialization callbacks pub static P_INIT: unsafe extern "C" fn() = super::init; - #[link_section = ".dtors.65535"] // .dtors.* : C termination callbacks + #[unsafe(link_section = ".dtors.65535")] // .dtors.* : C termination callbacks pub static P_UNINIT: unsafe extern "C" fn() = super::uninit; } } diff --git a/rtstartup/rsend.rs b/rtstartup/rsend.rs index 81acfbed4477d..a6f7d103356bf 100644 --- a/rtstartup/rsend.rs +++ b/rtstartup/rsend.rs @@ -32,6 +32,6 @@ pub mod eh_frames { // Terminate the frame unwind info section with a 0 as a sentinel; // this would be the 'length' field in a real FDE. #[no_mangle] - #[link_section = ".eh_frame"] + #[unsafe(link_section = ".eh_frame")] pub static __EH_FRAME_END__: u32 = 0; } diff --git a/std/Cargo.toml b/std/Cargo.toml index aa391a4b317ac..f4d4894c1bbdf 100644 --- a/std/Cargo.toml +++ b/std/Cargo.toml @@ -18,7 +18,7 @@ cfg-if = { version = "1.0", features = ['rustc-dep-of-std'] } panic_unwind = { path = "../panic_unwind", optional = true } panic_abort = { path = "../panic_abort" } core = { path = "../core", public = true } -compiler_builtins = { version = "=0.1.145" } +compiler_builtins = { version = "=0.1.148" } unwind = { path = "../unwind" } hashbrown = { version = "0.15", default-features = false, features = [ 'rustc-dep-of-std', @@ -61,8 +61,8 @@ object = { version = "0.36.0", default-features = false, optional = true, featur path = "../windows_targets" [dev-dependencies] -rand = { version = "0.8.5", default-features = false, features = ["alloc"] } -rand_xorshift = "0.3.0" +rand = { version = "0.9.0", default-features = false, features = ["alloc"] } +rand_xorshift = "0.4.0" [target.'cfg(any(all(target_family = "wasm", target_os = "unknown"), target_os = "xous", all(target_vendor = "fortanix", target_env = "sgx")))'.dependencies] dlmalloc = { version = "0.2.4", features = ['rustc-dep-of-std'] } @@ -110,6 +110,13 @@ panic_immediate_abort = [ # Choose algorithms that are optimized for binary size instead of runtime performance optimize_for_size = ["core/optimize_for_size", "alloc/optimize_for_size"] +# Make `RefCell` store additional debugging information, which is printed out when +# a borrow error occurs +debug_refcell = ["core/debug_refcell"] +# Make `TypeId` store a reference to the name of the type, so that it can print that name. +debug_typeid = ["core/debug_typeid"] + + # Enable std_detect default features for stdarch/crates/std_detect: # https://github.com/rust-lang/stdarch/blob/master/crates/std_detect/Cargo.toml std_detect_file_io = ["std_detect/std_detect_file_io"] @@ -152,8 +159,6 @@ test = true level = "warn" check-cfg = [ 'cfg(bootstrap)', - 'cfg(target_arch, values("xtensa", "aarch64-unknown-nto-qnx710_iosock", "x86_64-pc-nto-qnx710_iosock", "x86_64-pc-nto-qnx800","aarch64-unknown-nto-qnx800"))', - 'cfg(target_env, values("nto71_iosock", "nto80"))', # std use #[path] imports to portable-simd `std_float` crate # and to the `backtrace` crate which messes-up with Cargo list # of declared features, we therefor expect any feature cfg diff --git a/std/benches/time.rs b/std/benches/time.rs index 552481cad928a..dfd886738f984 100644 --- a/std/benches/time.rs +++ b/std/benches/time.rs @@ -1,5 +1,3 @@ -use std::time::Instant; - #[cfg(not(target_arch = "wasm32"))] use test::{Bencher, black_box}; @@ -10,6 +8,7 @@ macro_rules! bench_instant_threaded { fn $bench_name(b: &mut Bencher) -> std::thread::Result<()> { use std::sync::Arc; use std::sync::atomic::{AtomicBool, Ordering}; + use std::time::Instant; let running = Arc::new(AtomicBool::new(true)); diff --git a/std/build.rs b/std/build.rs index 8dc326a3dde6a..723d1eb02e07e 100644 --- a/std/build.rs +++ b/std/build.rs @@ -107,7 +107,6 @@ fn main() { ("csky", _) => false, ("hexagon", _) => false, ("loongarch64", _) => false, - ("mips" | "mips64" | "mips32r6" | "mips64r6", _) => false, ("powerpc" | "powerpc64", _) => false, ("sparc" | "sparc64", _) => false, ("wasm32" | "wasm64", _) => false, diff --git a/std/src/alloc.rs b/std/src/alloc.rs index 5d51d6a0c78a8..99d105a2454a5 100644 --- a/std/src/alloc.rs +++ b/std/src/alloc.rs @@ -20,11 +20,11 @@ //! //! unsafe impl GlobalAlloc for MyAllocator { //! unsafe fn alloc(&self, layout: Layout) -> *mut u8 { -//! System.alloc(layout) +//! unsafe { System.alloc(layout) } //! } //! //! unsafe fn dealloc(&self, ptr: *mut u8, layout: Layout) { -//! System.dealloc(ptr, layout) +//! unsafe { System.dealloc(ptr, layout) } //! } //! } //! @@ -102,7 +102,7 @@ pub use alloc_crate::alloc::*; /// /// unsafe impl GlobalAlloc for Counter { /// unsafe fn alloc(&self, layout: Layout) -> *mut u8 { -/// let ret = System.alloc(layout); +/// let ret = unsafe { System.alloc(layout) }; /// if !ret.is_null() { /// ALLOCATED.fetch_add(layout.size(), Relaxed); /// } @@ -110,7 +110,7 @@ pub use alloc_crate::alloc::*; /// } /// /// unsafe fn dealloc(&self, ptr: *mut u8, layout: Layout) { -/// System.dealloc(ptr, layout); +/// unsafe { System.dealloc(ptr, layout); } /// ALLOCATED.fetch_sub(layout.size(), Relaxed); /// } /// } @@ -345,7 +345,7 @@ pub fn take_alloc_error_hook() -> fn(Layout) { } fn default_alloc_error_hook(layout: Layout) { - extern "Rust" { + unsafe extern "Rust" { // This symbol is emitted by rustc next to __rust_alloc_error_handler. // Its value depends on the -Zoom={panic,abort} compiler option. static __rust_alloc_error_handler_should_panic: u8; diff --git a/std/src/collections/hash/map.rs b/std/src/collections/hash/map.rs index 6a0ff3a29e08f..ff4a4b35ce450 100644 --- a/std/src/collections/hash/map.rs +++ b/std/src/collections/hash/map.rs @@ -656,7 +656,6 @@ impl HashMap { /// Splitting a map into even and odd keys, reusing the original map: /// /// ``` - /// #![feature(hash_extract_if)] /// use std::collections::HashMap; /// /// let mut map: HashMap = (0..8).map(|x| (x, x)).collect(); @@ -672,7 +671,7 @@ impl HashMap { /// ``` #[inline] #[rustc_lint_query_instability] - #[unstable(feature = "hash_extract_if", issue = "59618")] + #[stable(feature = "hash_extract_if", since = "CURRENT_RUSTC_VERSION")] pub fn extract_if(&mut self, pred: F) -> ExtractIf<'_, K, V, F> where F: FnMut(&K, &mut V) -> bool, @@ -1024,7 +1023,7 @@ where /// ``` #[inline] #[doc(alias = "get_many_mut")] - #[stable(feature = "map_many_mut", since = "CURRENT_RUSTC_VERSION")] + #[stable(feature = "map_many_mut", since = "1.86.0")] pub fn get_disjoint_mut( &mut self, ks: [&Q; N], @@ -1091,7 +1090,7 @@ where /// ``` #[inline] #[doc(alias = "get_many_unchecked_mut")] - #[stable(feature = "map_many_mut", since = "CURRENT_RUSTC_VERSION")] + #[stable(feature = "map_many_mut", since = "1.86.0")] pub unsafe fn get_disjoint_unchecked_mut( &mut self, ks: [&Q; N], @@ -1722,8 +1721,6 @@ impl<'a, K, V> Drain<'a, K, V> { /// # Example /// /// ``` -/// #![feature(hash_extract_if)] -/// /// use std::collections::HashMap; /// /// let mut map = HashMap::from([ @@ -1731,7 +1728,7 @@ impl<'a, K, V> Drain<'a, K, V> { /// ]); /// let iter = map.extract_if(|_k, v| *v % 2 == 0); /// ``` -#[unstable(feature = "hash_extract_if", issue = "59618")] +#[stable(feature = "hash_extract_if", since = "CURRENT_RUSTC_VERSION")] #[must_use = "iterators are lazy and do nothing unless consumed"] pub struct ExtractIf<'a, K, V, F> where @@ -2746,7 +2743,7 @@ where } } -#[unstable(feature = "hash_extract_if", issue = "59618")] +#[stable(feature = "hash_extract_if", since = "CURRENT_RUSTC_VERSION")] impl Iterator for ExtractIf<'_, K, V, F> where F: FnMut(&K, &mut V) -> bool, @@ -2763,10 +2760,10 @@ where } } -#[unstable(feature = "hash_extract_if", issue = "59618")] +#[stable(feature = "hash_extract_if", since = "CURRENT_RUSTC_VERSION")] impl FusedIterator for ExtractIf<'_, K, V, F> where F: FnMut(&K, &mut V) -> bool {} -#[unstable(feature = "hash_extract_if", issue = "59618")] +#[stable(feature = "hash_extract_if", since = "CURRENT_RUSTC_VERSION")] impl<'a, K, V, F> fmt::Debug for ExtractIf<'a, K, V, F> where F: FnMut(&K, &mut V) -> bool, diff --git a/std/src/collections/hash/set.rs b/std/src/collections/hash/set.rs index c265d42d06a9f..a547a9943c1a0 100644 --- a/std/src/collections/hash/set.rs +++ b/std/src/collections/hash/set.rs @@ -293,7 +293,6 @@ impl HashSet { /// Splitting a set into even and odd values, reusing the original set: /// /// ``` - /// #![feature(hash_extract_if)] /// use std::collections::HashSet; /// /// let mut set: HashSet = (0..8).collect(); @@ -309,7 +308,7 @@ impl HashSet { /// ``` #[inline] #[rustc_lint_query_instability] - #[unstable(feature = "hash_extract_if", issue = "59618")] + #[stable(feature = "hash_extract_if", since = "CURRENT_RUSTC_VERSION")] pub fn extract_if(&mut self, pred: F) -> ExtractIf<'_, T, F> where F: FnMut(&T) -> bool, @@ -1385,15 +1384,13 @@ pub struct Drain<'a, K: 'a> { /// # Examples /// /// ``` -/// #![feature(hash_extract_if)] -/// /// use std::collections::HashSet; /// /// let mut a = HashSet::from([1, 2, 3]); /// /// let mut extract_ifed = a.extract_if(|v| v % 2 == 0); /// ``` -#[unstable(feature = "hash_extract_if", issue = "59618")] +#[stable(feature = "hash_extract_if", since = "CURRENT_RUSTC_VERSION")] pub struct ExtractIf<'a, K, F> where F: FnMut(&K) -> bool, @@ -1676,7 +1673,7 @@ impl fmt::Debug for Drain<'_, K> { } } -#[unstable(feature = "hash_extract_if", issue = "59618")] +#[stable(feature = "hash_extract_if", since = "CURRENT_RUSTC_VERSION")] impl Iterator for ExtractIf<'_, K, F> where F: FnMut(&K) -> bool, @@ -1693,10 +1690,10 @@ where } } -#[unstable(feature = "hash_extract_if", issue = "59618")] +#[stable(feature = "hash_extract_if", since = "CURRENT_RUSTC_VERSION")] impl FusedIterator for ExtractIf<'_, K, F> where F: FnMut(&K) -> bool {} -#[unstable(feature = "hash_extract_if", issue = "59618")] +#[stable(feature = "hash_extract_if", since = "CURRENT_RUSTC_VERSION")] impl<'a, K, F> fmt::Debug for ExtractIf<'a, K, F> where F: FnMut(&K) -> bool, diff --git a/std/src/env.rs b/std/src/env.rs index c665dfd36247f..4a071b4e1faec 100644 --- a/std/src/env.rs +++ b/std/src/env.rs @@ -568,7 +568,7 @@ pub struct JoinPathsError { /// let mut paths = env::split_paths(&path).collect::>(); /// paths.push(PathBuf::from("/home/xyz/bin")); /// let new_path = env::join_paths(paths)?; -/// env::set_var("PATH", &new_path); +/// unsafe { env::set_var("PATH", &new_path); } /// } /// /// Ok(()) @@ -668,7 +668,9 @@ pub fn home_dir() -> Option { /// On Unix, returns the value of the `TMPDIR` environment variable if it is /// set, otherwise the value is OS-specific: /// - On Android, there is no global temporary folder (it is usually allocated -/// per-app), it returns `/data/local/tmp`. +/// per-app), it will return the application's cache dir if the program runs +/// in application's namespace and system version is Android 13 (or above), or +/// `/data/local/tmp` otherwise. /// - On Darwin-based OSes (macOS, iOS, etc) it returns the directory provided /// by `confstr(_CS_DARWIN_USER_TEMP_DIR, ...)`, as recommended by [Apple's /// security guidelines][appledoc]. diff --git a/std/src/f128.rs b/std/src/f128.rs index 89612fa747551..974514c9c4556 100644 --- a/std/src/f128.rs +++ b/std/src/f128.rs @@ -1,4 +1,4 @@ -//! Constants for the `f128` double-precision floating point type. +//! Constants for the `f128` quadruple-precision floating point type. //! //! *[See also the `f128` primitive type](primitive@f128).* //! @@ -126,7 +126,7 @@ impl f128 { #[unstable(feature = "f128", issue = "116909")] #[must_use = "method returns a new number and does not mutate the original value"] pub fn round_ties_even(self) -> f128 { - unsafe { intrinsics::rintf128(self) } + intrinsics::round_ties_even_f128(self) } /// Returns the integer part of `self`. @@ -1226,6 +1226,7 @@ impl f128 { #[inline] #[rustc_allow_incoherent_impl] #[unstable(feature = "f128", issue = "116909")] + // #[unstable(feature = "float_gamma", issue = "99842")] #[must_use = "method returns a new number and does not mutate the original value"] pub fn gamma(self) -> f128 { unsafe { cmath::tgammaf128(self) } @@ -1260,10 +1261,83 @@ impl f128 { #[inline] #[rustc_allow_incoherent_impl] #[unstable(feature = "f128", issue = "116909")] + // #[unstable(feature = "float_gamma", issue = "99842")] #[must_use = "method returns a new number and does not mutate the original value"] pub fn ln_gamma(self) -> (f128, i32) { let mut signgamp: i32 = 0; let x = unsafe { cmath::lgammaf128_r(self, &mut signgamp) }; (x, signgamp) } + + /// Error function. + /// + /// # Unspecified precision + /// + /// The precision of this function is non-deterministic. This means it varies by platform, + /// Rust version, and can even differ within the same execution from one invocation to the next. + /// + /// This function currently corresponds to the `erff128` from libc on Unix + /// and Windows. Note that this might change in the future. + /// + /// # Examples + /// + /// ``` + /// #![feature(f128)] + /// #![feature(float_erf)] + /// # #[cfg(reliable_f128_math)] { + /// /// The error function relates what percent of a normal distribution lies + /// /// within `x` standard deviations (scaled by `1/sqrt(2)`). + /// fn within_standard_deviations(x: f128) -> f128 { + /// (x * std::f128::consts::FRAC_1_SQRT_2).erf() * 100.0 + /// } + /// + /// // 68% of a normal distribution is within one standard deviation + /// assert!((within_standard_deviations(1.0) - 68.269).abs() < 0.01); + /// // 95% of a normal distribution is within two standard deviations + /// assert!((within_standard_deviations(2.0) - 95.450).abs() < 0.01); + /// // 99.7% of a normal distribution is within three standard deviations + /// assert!((within_standard_deviations(3.0) - 99.730).abs() < 0.01); + /// # } + /// ``` + #[rustc_allow_incoherent_impl] + #[must_use = "method returns a new number and does not mutate the original value"] + #[unstable(feature = "f128", issue = "116909")] + // #[unstable(feature = "float_erf", issue = "136321")] + #[inline] + pub fn erf(self) -> f128 { + unsafe { cmath::erff128(self) } + } + + /// Complementary error function. + /// + /// # Unspecified precision + /// + /// The precision of this function is non-deterministic. This means it varies by platform, + /// Rust version, and can even differ within the same execution from one invocation to the next. + /// + /// This function currently corresponds to the `erfcf128` from libc on Unix + /// and Windows. Note that this might change in the future. + /// + /// # Examples + /// + /// ``` + /// #![feature(f128)] + /// #![feature(float_erf)] + /// # #[cfg(reliable_f128_math)] { + /// let x: f128 = 0.123; + /// + /// let one = x.erf() + x.erfc(); + /// let abs_difference = (one - 1.0).abs(); + /// + /// assert!(abs_difference <= f128::EPSILON); + /// # } + /// ``` + #[rustc_allow_incoherent_impl] + #[must_use = "method returns a new number and does not mutate the original value"] + #[unstable(feature = "f128", issue = "116909")] + // #[unstable(feature = "float_erf", issue = "136321")] + #[inline] + pub fn erfc(self) -> f128 { + unsafe { cmath::erfcf128(self) } + } } diff --git a/std/src/f16.rs b/std/src/f16.rs index cc523c93b4de7..c3b51bf31de70 100644 --- a/std/src/f16.rs +++ b/std/src/f16.rs @@ -1,4 +1,4 @@ -//! Constants for the `f16` double-precision floating point type. +//! Constants for the `f16` half-precision floating point type. //! //! *[See also the `f16` primitive type](primitive@f16).* //! @@ -126,7 +126,7 @@ impl f16 { #[unstable(feature = "f16", issue = "116909")] #[must_use = "method returns a new number and does not mutate the original value"] pub fn round_ties_even(self) -> f16 { - unsafe { intrinsics::rintf16(self) } + intrinsics::round_ties_even_f16(self) } /// Returns the integer part of `self`. @@ -1224,6 +1224,7 @@ impl f16 { #[inline] #[rustc_allow_incoherent_impl] #[unstable(feature = "f16", issue = "116909")] + // #[unstable(feature = "float_gamma", issue = "99842")] #[must_use = "method returns a new number and does not mutate the original value"] pub fn gamma(self) -> f16 { (unsafe { cmath::tgammaf(self as f32) }) as f16 @@ -1258,10 +1259,83 @@ impl f16 { #[inline] #[rustc_allow_incoherent_impl] #[unstable(feature = "f16", issue = "116909")] + // #[unstable(feature = "float_gamma", issue = "99842")] #[must_use = "method returns a new number and does not mutate the original value"] pub fn ln_gamma(self) -> (f16, i32) { let mut signgamp: i32 = 0; let x = (unsafe { cmath::lgammaf_r(self as f32, &mut signgamp) }) as f16; (x, signgamp) } + + /// Error function. + /// + /// # Unspecified precision + /// + /// The precision of this function is non-deterministic. This means it varies by platform, + /// Rust version, and can even differ within the same execution from one invocation to the next. + /// + /// This function currently corresponds to the `erff` from libc on Unix + /// and Windows. Note that this might change in the future. + /// + /// # Examples + /// + /// ``` + /// #![feature(f16)] + /// #![feature(float_erf)] + /// # #[cfg(reliable_f16_math)] { + /// /// The error function relates what percent of a normal distribution lies + /// /// within `x` standard deviations (scaled by `1/sqrt(2)`). + /// fn within_standard_deviations(x: f16) -> f16 { + /// (x * std::f16::consts::FRAC_1_SQRT_2).erf() * 100.0 + /// } + /// + /// // 68% of a normal distribution is within one standard deviation + /// assert!((within_standard_deviations(1.0) - 68.269).abs() < 0.1); + /// // 95% of a normal distribution is within two standard deviations + /// assert!((within_standard_deviations(2.0) - 95.450).abs() < 0.1); + /// // 99.7% of a normal distribution is within three standard deviations + /// assert!((within_standard_deviations(3.0) - 99.730).abs() < 0.1); + /// # } + /// ``` + #[rustc_allow_incoherent_impl] + #[must_use = "method returns a new number and does not mutate the original value"] + #[unstable(feature = "f16", issue = "116909")] + // #[unstable(feature = "float_erf", issue = "136321")] + #[inline] + pub fn erf(self) -> f16 { + (unsafe { cmath::erff(self as f32) }) as f16 + } + + /// Complementary error function. + /// + /// # Unspecified precision + /// + /// The precision of this function is non-deterministic. This means it varies by platform, + /// Rust version, and can even differ within the same execution from one invocation to the next. + /// + /// This function currently corresponds to the `erfcf` from libc on Unix + /// and Windows. Note that this might change in the future. + /// + /// # Examples + /// + /// ``` + /// #![feature(f16)] + /// #![feature(float_erf)] + /// # #[cfg(reliable_f16_math)] { + /// let x: f16 = 0.123; + /// + /// let one = x.erf() + x.erfc(); + /// let abs_difference = (one - 1.0).abs(); + /// + /// assert!(abs_difference <= f16::EPSILON); + /// # } + /// ``` + #[rustc_allow_incoherent_impl] + #[must_use = "method returns a new number and does not mutate the original value"] + #[unstable(feature = "f16", issue = "116909")] + // #[unstable(feature = "float_erf", issue = "136321")] + #[inline] + pub fn erfc(self) -> f16 { + (unsafe { cmath::erfcf(self as f32) }) as f16 + } } diff --git a/std/src/f32.rs b/std/src/f32.rs index 260c499b7f4b9..19fb24c8ee26c 100644 --- a/std/src/f32.rs +++ b/std/src/f32.rs @@ -122,7 +122,7 @@ impl f32 { #[stable(feature = "round_ties_even", since = "1.77.0")] #[inline] pub fn round_ties_even(self) -> f32 { - unsafe { intrinsics::rintf32(self) } + intrinsics::round_ties_even_f32(self) } /// Returns the integer part of `self`. @@ -1151,4 +1151,68 @@ impl f32 { let x = unsafe { cmath::lgammaf_r(self, &mut signgamp) }; (x, signgamp) } + + /// Error function. + /// + /// # Unspecified precision + /// + /// The precision of this function is non-deterministic. This means it varies by platform, + /// Rust version, and can even differ within the same execution from one invocation to the next. + /// + /// This function currently corresponds to the `erff` from libc on Unix + /// and Windows. Note that this might change in the future. + /// + /// # Examples + /// + /// ``` + /// #![feature(float_erf)] + /// /// The error function relates what percent of a normal distribution lies + /// /// within `x` standard deviations (scaled by `1/sqrt(2)`). + /// fn within_standard_deviations(x: f32) -> f32 { + /// (x * std::f32::consts::FRAC_1_SQRT_2).erf() * 100.0 + /// } + /// + /// // 68% of a normal distribution is within one standard deviation + /// assert!((within_standard_deviations(1.0) - 68.269).abs() < 0.01); + /// // 95% of a normal distribution is within two standard deviations + /// assert!((within_standard_deviations(2.0) - 95.450).abs() < 0.01); + /// // 99.7% of a normal distribution is within three standard deviations + /// assert!((within_standard_deviations(3.0) - 99.730).abs() < 0.01); + /// ``` + #[rustc_allow_incoherent_impl] + #[must_use = "method returns a new number and does not mutate the original value"] + #[unstable(feature = "float_erf", issue = "136321")] + #[inline] + pub fn erf(self) -> f32 { + unsafe { cmath::erff(self) } + } + + /// Complementary error function. + /// + /// # Unspecified precision + /// + /// The precision of this function is non-deterministic. This means it varies by platform, + /// Rust version, and can even differ within the same execution from one invocation to the next. + /// + /// This function currently corresponds to the `erfcf` from libc on Unix + /// and Windows. Note that this might change in the future. + /// + /// # Examples + /// + /// ``` + /// #![feature(float_erf)] + /// let x: f32 = 0.123; + /// + /// let one = x.erf() + x.erfc(); + /// let abs_difference = (one - 1.0).abs(); + /// + /// assert!(abs_difference <= f32::EPSILON); + /// ``` + #[rustc_allow_incoherent_impl] + #[must_use = "method returns a new number and does not mutate the original value"] + #[unstable(feature = "float_erf", issue = "136321")] + #[inline] + pub fn erfc(self) -> f32 { + unsafe { cmath::erfcf(self) } + } } diff --git a/std/src/f64.rs b/std/src/f64.rs index 7af646f8cfd60..f1c3cb561271a 100644 --- a/std/src/f64.rs +++ b/std/src/f64.rs @@ -122,7 +122,7 @@ impl f64 { #[stable(feature = "round_ties_even", since = "1.77.0")] #[inline] pub fn round_ties_even(self) -> f64 { - unsafe { intrinsics::rintf64(self) } + intrinsics::round_ties_even_f64(self) } /// Returns the integer part of `self`. @@ -1151,4 +1151,68 @@ impl f64 { let x = unsafe { cmath::lgamma_r(self, &mut signgamp) }; (x, signgamp) } + + /// Error function. + /// + /// # Unspecified precision + /// + /// The precision of this function is non-deterministic. This means it varies by platform, + /// Rust version, and can even differ within the same execution from one invocation to the next. + /// + /// This function currently corresponds to the `erf` from libc on Unix + /// and Windows. Note that this might change in the future. + /// + /// # Examples + /// + /// ``` + /// #![feature(float_erf)] + /// /// The error function relates what percent of a normal distribution lies + /// /// within `x` standard deviations (scaled by `1/sqrt(2)`). + /// fn within_standard_deviations(x: f64) -> f64 { + /// (x * std::f64::consts::FRAC_1_SQRT_2).erf() * 100.0 + /// } + /// + /// // 68% of a normal distribution is within one standard deviation + /// assert!((within_standard_deviations(1.0) - 68.269).abs() < 0.01); + /// // 95% of a normal distribution is within two standard deviations + /// assert!((within_standard_deviations(2.0) - 95.450).abs() < 0.01); + /// // 99.7% of a normal distribution is within three standard deviations + /// assert!((within_standard_deviations(3.0) - 99.730).abs() < 0.01); + /// ``` + #[rustc_allow_incoherent_impl] + #[must_use = "method returns a new number and does not mutate the original value"] + #[unstable(feature = "float_erf", issue = "136321")] + #[inline] + pub fn erf(self) -> f64 { + unsafe { cmath::erf(self) } + } + + /// Complementary error function. + /// + /// # Unspecified precision + /// + /// The precision of this function is non-deterministic. This means it varies by platform, + /// Rust version, and can even differ within the same execution from one invocation to the next. + /// + /// This function currently corresponds to the `erfc` from libc on Unix + /// and Windows. Note that this might change in the future. + /// + /// # Examples + /// + /// ``` + /// #![feature(float_erf)] + /// let x: f64 = 0.123; + /// + /// let one = x.erf() + x.erfc(); + /// let abs_difference = (one - 1.0).abs(); + /// + /// assert!(abs_difference <= f64::EPSILON); + /// ``` + #[rustc_allow_incoherent_impl] + #[must_use = "method returns a new number and does not mutate the original value"] + #[unstable(feature = "float_erf", issue = "136321")] + #[inline] + pub fn erfc(self) -> f64 { + unsafe { cmath::erfc(self) } + } } diff --git a/std/src/ffi/mod.rs b/std/src/ffi/mod.rs index 7d7cce09a3f09..860ec3a6be16e 100644 --- a/std/src/ffi/mod.rs +++ b/std/src/ffi/mod.rs @@ -201,5 +201,5 @@ pub use self::c_str::{CStr, CString}; #[doc(inline)] pub use self::os_str::{OsStr, OsString}; -#[unstable(feature = "os_str_display", issue = "120048")] +#[stable(feature = "os_str_display", since = "CURRENT_RUSTC_VERSION")] pub mod os_str; diff --git a/std/src/ffi/os_str.rs b/std/src/ffi/os_str.rs index c4c8dbccd7a44..f4a02802336d5 100644 --- a/std/src/ffi/os_str.rs +++ b/std/src/ffi/os_str.rs @@ -1204,13 +1204,12 @@ impl OsStr { /// # Examples /// /// ``` - /// #![feature(os_str_display)] /// use std::ffi::OsStr; /// /// let s = OsStr::new("Hello, world!"); /// println!("{}", s.display()); /// ``` - #[unstable(feature = "os_str_display", issue = "120048")] + #[stable(feature = "os_str_display", since = "CURRENT_RUSTC_VERSION")] #[must_use = "this does not display the `OsStr`; \ it returns an object that can be displayed"] #[inline] @@ -1559,7 +1558,6 @@ impl fmt::Debug for OsStr { /// # Examples /// /// ``` -/// #![feature(os_str_display)] /// use std::ffi::OsStr; /// /// let s = OsStr::new("Hello, world!"); @@ -1568,19 +1566,19 @@ impl fmt::Debug for OsStr { /// /// [`Display`]: fmt::Display /// [`format!`]: crate::format -#[unstable(feature = "os_str_display", issue = "120048")] +#[stable(feature = "os_str_display", since = "CURRENT_RUSTC_VERSION")] pub struct Display<'a> { os_str: &'a OsStr, } -#[unstable(feature = "os_str_display", issue = "120048")] +#[stable(feature = "os_str_display", since = "CURRENT_RUSTC_VERSION")] impl fmt::Debug for Display<'_> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fmt::Debug::fmt(&self.os_str, f) } } -#[unstable(feature = "os_str_display", issue = "120048")] +#[stable(feature = "os_str_display", since = "CURRENT_RUSTC_VERSION")] impl fmt::Display for Display<'_> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fmt::Display::fmt(&self.os_str.inner, f) diff --git a/std/src/fs.rs b/std/src/fs.rs index 0871a9e22d386..57e235c3efe1d 100644 --- a/std/src/fs.rs +++ b/std/src/fs.rs @@ -624,20 +624,20 @@ impl File { self.inner.datasync() } - /// Acquire an exclusive advisory lock on the file. Blocks until the lock can be acquired. + /// Acquire an exclusive lock on the file. Blocks until the lock can be acquired. /// - /// This acquires an exclusive advisory lock; no other file handle to this file may acquire - /// another lock. + /// This acquires an exclusive lock; no other file handle to this file may acquire another lock. /// - /// If this file handle/descriptor, or a clone of it, already holds an advisory lock the exact - /// behavior is unspecified and platform dependent, including the possibility that it will - /// deadlock. However, if this method returns, then an exclusive lock is held. + /// This lock may be advisory or mandatory. This lock is meant to interact with [`lock`], + /// [`try_lock`], [`lock_shared`], [`try_lock_shared`], and [`unlock`]. Its interactions with + /// other methods, such as [`read`] and [`write`] are platform specific, and it may or may not + /// cause non-lockholders to block. /// - /// If the file not open for writing, it is unspecified whether this function returns an error. + /// If this file handle/descriptor, or a clone of it, already holds an lock the exact behavior + /// is unspecified and platform dependent, including the possibility that it will deadlock. + /// However, if this method returns, then an exclusive lock is held. /// - /// Note, this is an advisory lock meant to interact with [`lock_shared`], [`try_lock`], - /// [`try_lock_shared`], and [`unlock`]. Its interactions with other methods, such as [`read`] - /// and [`write`] are platform specific, and it may or may not cause non-lockholders to block. + /// If the file not open for writing, it is unspecified whether this function returns an error. /// /// The lock will be released when this file (along with any other file descriptors/handles /// duplicated or inherited from it) is closed, or if the [`unlock`] method is called. @@ -648,8 +648,12 @@ impl File { /// and the `LockFileEx` function on Windows with the `LOCKFILE_EXCLUSIVE_LOCK` flag. Note that, /// this [may change in the future][changes]. /// + /// On Windows, locking a file will fail if the file is opened only for append. To lock a file, + /// open it with one of `.read(true)`, `.read(true).append(true)`, or `.write(true)`. + /// /// [changes]: io#platform-specific-behavior /// + /// [`lock`]: File::lock /// [`lock_shared`]: File::lock_shared /// [`try_lock`]: File::try_lock /// [`try_lock_shared`]: File::try_lock_shared @@ -660,32 +664,32 @@ impl File { /// # Examples /// /// ```no_run - /// #![feature(file_lock)] /// use std::fs::File; /// /// fn main() -> std::io::Result<()> { - /// let f = File::open("foo.txt")?; + /// let f = File::create("foo.txt")?; /// f.lock()?; /// Ok(()) /// } /// ``` - #[unstable(feature = "file_lock", issue = "130994")] + #[stable(feature = "file_lock", since = "CURRENT_RUSTC_VERSION")] pub fn lock(&self) -> io::Result<()> { self.inner.lock() } - /// Acquire a shared (non-exclusive) advisory lock on the file. Blocks until the lock can be acquired. + /// Acquire a shared (non-exclusive) lock on the file. Blocks until the lock can be acquired. /// - /// This acquires a shared advisory lock; more than one file handle may hold a shared lock, but - /// none may hold an exclusive lock at the same time. + /// This acquires a shared lock; more than one file handle may hold a shared lock, but none may + /// hold an exclusive lock at the same time. /// - /// If this file handle/descriptor, or a clone of it, already holds an advisory lock, the exact - /// behavior is unspecified and platform dependent, including the possibility that it will - /// deadlock. However, if this method returns, then a shared lock is held. + /// This lock may be advisory or mandatory. This lock is meant to interact with [`lock`], + /// [`try_lock`], [`lock_shared`], [`try_lock_shared`], and [`unlock`]. Its interactions with + /// other methods, such as [`read`] and [`write`] are platform specific, and it may or may not + /// cause non-lockholders to block. /// - /// Note, this is an advisory lock meant to interact with [`lock`], [`try_lock`], - /// [`try_lock_shared`], and [`unlock`]. Its interactions with other methods, such as [`read`] - /// and [`write`] are platform specific, and it may or may not cause non-lockholders to block. + /// If this file handle/descriptor, or a clone of it, already holds an lock, the exact behavior + /// is unspecified and platform dependent, including the possibility that it will deadlock. + /// However, if this method returns, then a shared lock is held. /// /// The lock will be released when this file (along with any other file descriptors/handles /// duplicated or inherited from it) is closed, or if the [`unlock`] method is called. @@ -696,9 +700,13 @@ impl File { /// and the `LockFileEx` function on Windows. Note that, this /// [may change in the future][changes]. /// + /// On Windows, locking a file will fail if the file is opened only for append. To lock a file, + /// open it with one of `.read(true)`, `.read(true).append(true)`, or `.write(true)`. + /// /// [changes]: io#platform-specific-behavior /// /// [`lock`]: File::lock + /// [`lock_shared`]: File::lock_shared /// [`try_lock`]: File::try_lock /// [`try_lock_shared`]: File::try_lock_shared /// [`unlock`]: File::unlock @@ -708,7 +716,6 @@ impl File { /// # Examples /// /// ```no_run - /// #![feature(file_lock)] /// use std::fs::File; /// /// fn main() -> std::io::Result<()> { @@ -717,29 +724,28 @@ impl File { /// Ok(()) /// } /// ``` - #[unstable(feature = "file_lock", issue = "130994")] + #[stable(feature = "file_lock", since = "CURRENT_RUSTC_VERSION")] pub fn lock_shared(&self) -> io::Result<()> { self.inner.lock_shared() } - /// Try to acquire an exclusive advisory lock on the file. + /// Try to acquire an exclusive lock on the file. /// /// Returns `Ok(false)` if a different lock is already held on this file (via another /// handle/descriptor). /// - /// This acquires an exclusive advisory lock; no other file handle to this file may acquire - /// another lock. + /// This acquires an exclusive lock; no other file handle to this file may acquire another lock. /// - /// If this file handle/descriptor, or a clone of it, already holds an advisory lock, the exact - /// behavior is unspecified and platform dependent, including the possibility that it will - /// deadlock. However, if this method returns `Ok(true)`, then it has acquired an exclusive - /// lock. + /// This lock may be advisory or mandatory. This lock is meant to interact with [`lock`], + /// [`try_lock`], [`lock_shared`], [`try_lock_shared`], and [`unlock`]. Its interactions with + /// other methods, such as [`read`] and [`write`] are platform specific, and it may or may not + /// cause non-lockholders to block. /// - /// If the file not open for writing, it is unspecified whether this function returns an error. + /// If this file handle/descriptor, or a clone of it, already holds an lock, the exact behavior + /// is unspecified and platform dependent, including the possibility that it will deadlock. + /// However, if this method returns `Ok(true)`, then it has acquired an exclusive lock. /// - /// Note, this is an advisory lock meant to interact with [`lock`], [`lock_shared`], - /// [`try_lock_shared`], and [`unlock`]. Its interactions with other methods, such as [`read`] - /// and [`write`] are platform specific, and it may or may not cause non-lockholders to block. + /// If the file not open for writing, it is unspecified whether this function returns an error. /// /// The lock will be released when this file (along with any other file descriptors/handles /// duplicated or inherited from it) is closed, or if the [`unlock`] method is called. @@ -751,10 +757,14 @@ impl File { /// and `LOCKFILE_FAIL_IMMEDIATELY` flags. Note that, this /// [may change in the future][changes]. /// + /// On Windows, locking a file will fail if the file is opened only for append. To lock a file, + /// open it with one of `.read(true)`, `.read(true).append(true)`, or `.write(true)`. + /// /// [changes]: io#platform-specific-behavior /// /// [`lock`]: File::lock /// [`lock_shared`]: File::lock_shared + /// [`try_lock`]: File::try_lock /// [`try_lock_shared`]: File::try_lock_shared /// [`unlock`]: File::unlock /// [`read`]: Read::read @@ -763,36 +773,36 @@ impl File { /// # Examples /// /// ```no_run - /// #![feature(file_lock)] /// use std::fs::File; /// /// fn main() -> std::io::Result<()> { - /// let f = File::open("foo.txt")?; + /// let f = File::create("foo.txt")?; /// f.try_lock()?; /// Ok(()) /// } /// ``` - #[unstable(feature = "file_lock", issue = "130994")] + #[stable(feature = "file_lock", since = "CURRENT_RUSTC_VERSION")] pub fn try_lock(&self) -> io::Result { self.inner.try_lock() } - /// Try to acquire a shared (non-exclusive) advisory lock on the file. + /// Try to acquire a shared (non-exclusive) lock on the file. /// /// Returns `Ok(false)` if an exclusive lock is already held on this file (via another /// handle/descriptor). /// - /// This acquires a shared advisory lock; more than one file handle may hold a shared lock, but - /// none may hold an exclusive lock at the same time. + /// This acquires a shared lock; more than one file handle may hold a shared lock, but none may + /// hold an exclusive lock at the same time. /// - /// If this file handle, or a clone of it, already holds an advisory lock, the exact behavior is + /// This lock may be advisory or mandatory. This lock is meant to interact with [`lock`], + /// [`try_lock`], [`lock_shared`], [`try_lock_shared`], and [`unlock`]. Its interactions with + /// other methods, such as [`read`] and [`write`] are platform specific, and it may or may not + /// cause non-lockholders to block. + /// + /// If this file handle, or a clone of it, already holds an lock, the exact behavior is /// unspecified and platform dependent, including the possibility that it will deadlock. /// However, if this method returns `Ok(true)`, then it has acquired a shared lock. /// - /// Note, this is an advisory lock meant to interact with [`lock`], [`try_lock`], - /// [`try_lock`], and [`unlock`]. Its interactions with other methods, such as [`read`] - /// and [`write`] are platform specific, and it may or may not cause non-lockholders to block. - /// /// The lock will be released when this file (along with any other file descriptors/handles /// duplicated or inherited from it) is closed, or if the [`unlock`] method is called. /// @@ -803,11 +813,15 @@ impl File { /// `LOCKFILE_FAIL_IMMEDIATELY` flag. Note that, this /// [may change in the future][changes]. /// + /// On Windows, locking a file will fail if the file is opened only for append. To lock a file, + /// open it with one of `.read(true)`, `.read(true).append(true)`, or `.write(true)`. + /// /// [changes]: io#platform-specific-behavior /// /// [`lock`]: File::lock /// [`lock_shared`]: File::lock_shared /// [`try_lock`]: File::try_lock + /// [`try_lock_shared`]: File::try_lock_shared /// [`unlock`]: File::unlock /// [`read`]: Read::read /// [`write`]: Write::write @@ -815,7 +829,6 @@ impl File { /// # Examples /// /// ```no_run - /// #![feature(file_lock)] /// use std::fs::File; /// /// fn main() -> std::io::Result<()> { @@ -824,7 +837,7 @@ impl File { /// Ok(()) /// } /// ``` - #[unstable(feature = "file_lock", issue = "130994")] + #[stable(feature = "file_lock", since = "CURRENT_RUSTC_VERSION")] pub fn try_lock_shared(&self) -> io::Result { self.inner.try_lock_shared() } @@ -844,12 +857,14 @@ impl File { /// and the `UnlockFile` function on Windows. Note that, this /// [may change in the future][changes]. /// + /// On Windows, locking a file will fail if the file is opened only for append. To lock a file, + /// open it with one of `.read(true)`, `.read(true).append(true)`, or `.write(true)`. + /// /// [changes]: io#platform-specific-behavior /// /// # Examples /// /// ```no_run - /// #![feature(file_lock)] /// use std::fs::File; /// /// fn main() -> std::io::Result<()> { @@ -859,7 +874,7 @@ impl File { /// Ok(()) /// } /// ``` - #[unstable(feature = "file_lock", issue = "130994")] + #[stable(feature = "file_lock", since = "CURRENT_RUSTC_VERSION")] pub fn unlock(&self) -> io::Result<()> { self.inner.unlock() } @@ -1229,6 +1244,9 @@ impl Seek for &File { fn seek(&mut self, pos: SeekFrom) -> io::Result { self.inner.seek(pos) } + fn stream_position(&mut self) -> io::Result { + self.inner.tell() + } } #[stable(feature = "rust1", since = "1.0.0")] @@ -1275,6 +1293,9 @@ impl Seek for File { fn seek(&mut self, pos: SeekFrom) -> io::Result { (&*self).seek(pos) } + fn stream_position(&mut self) -> io::Result { + (&*self).stream_position() + } } #[stable(feature = "io_traits_arc", since = "1.73.0")] @@ -2505,6 +2526,7 @@ pub fn rename, Q: AsRef>(from: P, to: Q) -> io::Result<()> /// * `from` does not exist. /// * The current process does not have the permission rights to read /// `from` or write `to`. +/// * The parent directory of `to` doesn't exist. /// /// # Examples /// diff --git a/std/src/fs/tests.rs b/std/src/fs/tests.rs index 8e307f57cf9d2..38dcd816d267d 100644 --- a/std/src/fs/tests.rs +++ b/std/src/fs/tests.rs @@ -1,5 +1,6 @@ use rand::RngCore; +use crate::char::MAX_LEN_UTF8; use crate::fs::{self, File, FileTimes, OpenOptions}; use crate::io::prelude::*; use crate::io::{BorrowedBuf, ErrorKind, SeekFrom}; @@ -155,7 +156,7 @@ fn file_test_io_non_positional_read() { #[test] fn file_test_io_seek_and_tell_smoke_test() { let message = "ten-four"; - let mut read_mem = [0; 4]; + let mut read_mem = [0; MAX_LEN_UTF8]; let set_cursor = 4 as u64; let tell_pos_pre_read; let tell_pos_post_read; @@ -356,7 +357,7 @@ fn file_test_io_seek_shakedown() { let chunk_one: &str = "qwer"; let chunk_two: &str = "asdf"; let chunk_three: &str = "zxcv"; - let mut read_mem = [0; 4]; + let mut read_mem = [0; MAX_LEN_UTF8]; let tmpdir = tmpdir(); let filename = &tmpdir.join("file_rt_io_file_test_seek_shakedown.txt"); { @@ -621,7 +622,7 @@ fn file_test_directoryinfo_readdir() { check!(w.write(msg)); } let files = check!(fs::read_dir(dir)); - let mut mem = [0; 4]; + let mut mem = [0; MAX_LEN_UTF8]; for f in files { let f = f.unwrap().path(); { @@ -1913,8 +1914,11 @@ fn test_hidden_file_truncation() { assert_eq!(metadata.len(), 0); } +// See https://github.com/rust-lang/rust/pull/131072 for more details about why +// these two tests are disabled under Windows 7 here. #[cfg(windows)] #[test] +#[cfg_attr(target_vendor = "win7", ignore = "Unsupported under Windows 7.")] fn test_rename_file_over_open_file() { // Make sure that std::fs::rename works if the target file is already opened with FILE_SHARE_DELETE. See #123985. let tmpdir = tmpdir(); @@ -1939,6 +1943,7 @@ fn test_rename_file_over_open_file() { #[test] #[cfg(windows)] +#[cfg_attr(target_vendor = "win7", ignore = "Unsupported under Windows 7.")] fn test_rename_directory_to_non_empty_directory() { // Renaming a directory over a non-empty existing directory should fail on Windows. let tmpdir: TempDir = tmpdir(); @@ -1957,6 +1962,10 @@ fn test_rename_directory_to_non_empty_directory() { #[test] fn test_rename_symlink() { let tmpdir = tmpdir(); + if !got_symlink_permission(&tmpdir) { + return; + }; + let original = tmpdir.join("original"); let dest = tmpdir.join("dest"); let not_exist = Path::new("does not exist"); diff --git a/std/src/io/cursor.rs b/std/src/io/cursor.rs index 606099c8bc67a..08832bbc1e3d1 100644 --- a/std/src/io/cursor.rs +++ b/std/src/io/cursor.rs @@ -153,7 +153,7 @@ impl Cursor { /// let reference = buff.get_mut(); /// ``` #[stable(feature = "rust1", since = "1.0.0")] - #[rustc_const_stable(feature = "const_mut_cursor", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "const_mut_cursor", since = "1.86.0")] pub const fn get_mut(&mut self) -> &mut T { &mut self.inner } @@ -201,7 +201,7 @@ impl Cursor { /// assert_eq!(buff.position(), 4); /// ``` #[stable(feature = "rust1", since = "1.0.0")] - #[rustc_const_stable(feature = "const_mut_cursor", since = "CURRENT_RUSTC_VERSION")] + #[rustc_const_stable(feature = "const_mut_cursor", since = "1.86.0")] pub const fn set_position(&mut self, pos: u64) { self.pos = pos; } diff --git a/std/src/io/error.rs b/std/src/io/error.rs index 38b723366175f..30bc0e3b08833 100644 --- a/std/src/io/error.rs +++ b/std/src/io/error.rs @@ -83,7 +83,7 @@ impl Error { pub(crate) const UNKNOWN_THREAD_COUNT: Self = const_error!( ErrorKind::NotFound, - "The number of hardware threads is not known for the target platform" + "The number of hardware threads is not known for the target platform", ); pub(crate) const UNSUPPORTED_PLATFORM: Self = diff --git a/std/src/io/impls.rs b/std/src/io/impls.rs index b952c85addf65..8239b29884e8e 100644 --- a/std/src/io/impls.rs +++ b/std/src/io/impls.rs @@ -45,6 +45,7 @@ impl Read for &mut R { fn read_exact(&mut self, buf: &mut [u8]) -> io::Result<()> { (**self).read_exact(buf) } + #[inline] fn read_buf_exact(&mut self, cursor: BorrowedCursor<'_>) -> io::Result<()> { (**self).read_buf_exact(cursor) @@ -77,6 +78,11 @@ impl Write for &mut W { (**self).write_all(buf) } + #[inline] + fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> io::Result<()> { + (**self).write_all_vectored(bufs) + } + #[inline] fn write_fmt(&mut self, fmt: fmt::Arguments<'_>) -> io::Result<()> { (**self).write_fmt(fmt) @@ -89,10 +95,25 @@ impl Seek for &mut S { (**self).seek(pos) } + #[inline] + fn rewind(&mut self) -> io::Result<()> { + (**self).rewind() + } + + #[inline] + fn stream_len(&mut self) -> io::Result { + (**self).stream_len() + } + #[inline] fn stream_position(&mut self) -> io::Result { (**self).stream_position() } + + #[inline] + fn seek_relative(&mut self, offset: i64) -> io::Result<()> { + (**self).seek_relative(offset) + } } #[stable(feature = "rust1", since = "1.0.0")] impl BufRead for &mut B { @@ -106,11 +127,21 @@ impl BufRead for &mut B { (**self).consume(amt) } + #[inline] + fn has_data_left(&mut self) -> io::Result { + (**self).has_data_left() + } + #[inline] fn read_until(&mut self, byte: u8, buf: &mut Vec) -> io::Result { (**self).read_until(byte, buf) } + #[inline] + fn skip_until(&mut self, byte: u8) -> io::Result { + (**self).skip_until(byte) + } + #[inline] fn read_line(&mut self, buf: &mut String) -> io::Result { (**self).read_line(buf) @@ -153,6 +184,7 @@ impl Read for Box { fn read_exact(&mut self, buf: &mut [u8]) -> io::Result<()> { (**self).read_exact(buf) } + #[inline] fn read_buf_exact(&mut self, cursor: BorrowedCursor<'_>) -> io::Result<()> { (**self).read_buf_exact(cursor) @@ -185,6 +217,11 @@ impl Write for Box { (**self).write_all(buf) } + #[inline] + fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> io::Result<()> { + (**self).write_all_vectored(bufs) + } + #[inline] fn write_fmt(&mut self, fmt: fmt::Arguments<'_>) -> io::Result<()> { (**self).write_fmt(fmt) @@ -197,10 +234,25 @@ impl Seek for Box { (**self).seek(pos) } + #[inline] + fn rewind(&mut self) -> io::Result<()> { + (**self).rewind() + } + + #[inline] + fn stream_len(&mut self) -> io::Result { + (**self).stream_len() + } + #[inline] fn stream_position(&mut self) -> io::Result { (**self).stream_position() } + + #[inline] + fn seek_relative(&mut self, offset: i64) -> io::Result<()> { + (**self).seek_relative(offset) + } } #[stable(feature = "rust1", since = "1.0.0")] impl BufRead for Box { @@ -214,11 +266,21 @@ impl BufRead for Box { (**self).consume(amt) } + #[inline] + fn has_data_left(&mut self) -> io::Result { + (**self).has_data_left() + } + #[inline] fn read_until(&mut self, byte: u8, buf: &mut Vec) -> io::Result { (**self).read_until(byte, buf) } + #[inline] + fn skip_until(&mut self, byte: u8) -> io::Result { + (**self).skip_until(byte) + } + #[inline] fn read_line(&mut self, buf: &mut String) -> io::Result { (**self).read_line(buf) diff --git a/std/src/io/mod.rs b/std/src/io/mod.rs index 0ffad2c27a4d5..980ea1478e084 100644 --- a/std/src/io/mod.rs +++ b/std/src/io/mod.rs @@ -2249,6 +2249,7 @@ fn skip_until(r: &mut R, delim: u8) -> Result { /// } /// ``` #[stable(feature = "rust1", since = "1.0.0")] +#[cfg_attr(not(test), rustc_diagnostic_item = "IoBufRead")] pub trait BufRead: Read { /// Returns the contents of the internal buffer, filling it with more data /// from the inner reader if it is empty. diff --git a/std/src/io/stdio.rs b/std/src/io/stdio.rs index 318c350822168..017862c7f3aac 100644 --- a/std/src/io/stdio.rs +++ b/std/src/io/stdio.rs @@ -20,7 +20,7 @@ type LocalStream = Arc>>; thread_local! { /// Used by the test crate to capture the output of the print macros and panics. - static OUTPUT_CAPTURE: Cell> = { + static OUTPUT_CAPTURE: Cell> = const { Cell::new(None) } } @@ -239,6 +239,7 @@ fn handle_ebadf_lazy(r: io::Result, default: impl FnOnce() -> T) -> io::Re /// } /// ``` #[stable(feature = "rust1", since = "1.0.0")] +#[cfg_attr(not(test), rustc_diagnostic_item = "Stdin")] pub struct Stdin { inner: &'static Mutex>, } diff --git a/std/src/io/util.rs b/std/src/io/util.rs index b4c4dffc371c1..cb3f864fd4e1e 100644 --- a/std/src/io/util.rs +++ b/std/src/io/util.rs @@ -7,6 +7,7 @@ use crate::fmt; use crate::io::{ self, BorrowedCursor, BufRead, IoSlice, IoSliceMut, Read, Seek, SeekFrom, SizeHint, Write, }; +use crate::mem::MaybeUninit; /// `Empty` ignores any data written via [`Write`], and will always be empty /// (returning zero bytes) when read via [`Read`]. @@ -182,28 +183,30 @@ pub const fn repeat(byte: u8) -> Repeat { impl Read for Repeat { #[inline] fn read(&mut self, buf: &mut [u8]) -> io::Result { - for slot in &mut *buf { - *slot = self.byte; - } + buf.fill(self.byte); Ok(buf.len()) } - fn read_buf(&mut self, mut buf: BorrowedCursor<'_>) -> io::Result<()> { - // SAFETY: No uninit bytes are being written - for slot in unsafe { buf.as_mut() } { - slot.write(self.byte); - } - - let remaining = buf.capacity(); - - // SAFETY: the entire unfilled portion of buf has been initialized - unsafe { - buf.advance_unchecked(remaining); - } + #[inline] + fn read_exact(&mut self, buf: &mut [u8]) -> io::Result<()> { + buf.fill(self.byte); + Ok(()) + } + #[inline] + fn read_buf(&mut self, mut buf: BorrowedCursor<'_>) -> io::Result<()> { + // SAFETY: No uninit bytes are being written. + MaybeUninit::fill(unsafe { buf.as_mut() }, self.byte); + // SAFETY: the entire unfilled portion of buf has been initialized. + unsafe { buf.advance_unchecked(buf.capacity()) }; Ok(()) } + #[inline] + fn read_buf_exact(&mut self, buf: BorrowedCursor<'_>) -> io::Result<()> { + self.read_buf(buf) + } + /// This function is not supported by `io::Repeat`, because there's no end of its data fn read_to_end(&mut self, _: &mut Vec) -> io::Result { Err(io::Error::from(io::ErrorKind::OutOfMemory)) diff --git a/std/src/keyword_docs.rs b/std/src/keyword_docs.rs index 1d26bf37f4d28..bdd330611de3d 100644 --- a/std/src/keyword_docs.rs +++ b/std/src/keyword_docs.rs @@ -398,7 +398,7 @@ mod enum_keyword {} /// The mirror use case of FFI is also done via the `extern` keyword: /// /// ```rust -/// #[no_mangle] +/// #[unsafe(no_mangle)] /// pub extern "C" fn callable_from_c(x: i32) -> bool { /// x % 3 == 0 /// } @@ -651,16 +651,24 @@ mod if_keyword {} #[doc(keyword = "impl")] // -/// Implement some functionality for a type. +/// Implementations of functionality for a type, or a type implementing some functionality. +/// +/// There are two uses of the keyword `impl`: +/// * An `impl` block is an item that is used to implement some functionality for a type. +/// * An `impl Trait` in a type-position can be used to designate a type that implements a trait called `Trait`. +/// +/// # Implementing Functionality for a Type /// /// The `impl` keyword is primarily used to define implementations on types. Inherent /// implementations are standalone, while trait implementations are used to implement traits for /// types, or other traits. /// -/// Functions and consts can both be defined in an implementation. A function defined in an -/// `impl` block can be standalone, meaning it would be called like `Foo::bar()`. If the function +/// An implementation consists of definitions of functions and consts. A function defined in an +/// `impl` block can be standalone, meaning it would be called like `Vec::new()`. If the function /// takes `self`, `&self`, or `&mut self` as its first argument, it can also be called using -/// method-call syntax, a familiar feature to any object oriented programmer, like `foo.bar()`. +/// method-call syntax, a familiar feature to any object-oriented programmer, like `vec.len()`. +/// +/// ## Inherent Implementations /// /// ```rust /// struct Example { @@ -680,6 +688,17 @@ mod if_keyword {} /// self.number /// } /// } +/// ``` +/// +/// It matters little where an inherent implementation is defined; +/// its functionality is in scope wherever its implementing type is. +/// +/// ## Trait Implementations +/// +/// ```rust +/// struct Example { +/// number: i32, +/// } /// /// trait Thingy { /// fn do_thingy(&self); @@ -692,11 +711,19 @@ mod if_keyword {} /// } /// ``` /// +/// It matters little where a trait implementation is defined; +/// its functionality can be brought into scope by importing the trait it implements. +/// /// For more information on implementations, see the [Rust book][book1] or the [Reference]. /// -/// The other use of the `impl` keyword is in `impl Trait` syntax, which can be seen as a shorthand -/// for "a concrete type that implements this trait". Its primary use is working with closures, -/// which have type definitions generated at compile time that can't be simply typed out. +/// # Designating a Type that Implements Some Functionality +/// +/// The other use of the `impl` keyword is in `impl Trait` syntax, which can be understood to mean +/// "any (or some) concrete type that implements Trait". +/// It can be used as the type of a variable declaration, +/// in [argument position](https://rust-lang.github.io/rfcs/1951-expand-impl-trait.html) +/// or in [return position](https://rust-lang.github.io/rfcs/3425-return-position-impl-trait-in-traits.html). +/// One pertinent use case is in working with closures, which have unnameable types. /// /// ```rust /// fn thing_returning_closure() -> impl Fn(i32) -> bool { @@ -1401,7 +1428,7 @@ mod self_upper_keyword {} /// /// ```rust,no_run /// # #![allow(dead_code)] -/// extern "C" { +/// unsafe extern "C" { /// static mut ERROR_MESSAGE: *mut std::os::raw::c_char; /// } /// ``` @@ -1898,7 +1925,7 @@ mod type_keyword {} /// /// unsafe fn unsafe_fn() {} /// -/// extern "C" { +/// unsafe extern "C" { /// fn unsafe_extern_fn(); /// static BAR: *mut u32; /// } diff --git a/std/src/lib.rs b/std/src/lib.rs index 954a4182fbd6c..938b8c6e4f41b 100644 --- a/std/src/lib.rs +++ b/std/src/lib.rs @@ -272,6 +272,8 @@ // // Language features: // tidy-alphabetical-start + +// stabilization was reverted after it hit beta #![feature(alloc_error_handler)] #![feature(allocator_internals)] #![feature(allow_internal_unsafe)] @@ -281,6 +283,7 @@ #![feature(cfg_sanitizer_cfi)] #![feature(cfg_target_thread_local)] #![feature(cfi_encoding)] +#![feature(char_max_len)] #![feature(concat_idents)] #![feature(decl_macro)] #![feature(deprecated_suggestion)] @@ -289,6 +292,7 @@ #![feature(doc_masked)] #![feature(doc_notable_trait)] #![feature(dropck_eyepatch)] +#![feature(extended_varargs_abi_support)] #![feature(f128)] #![feature(f16)] #![feature(formatting_options)] @@ -299,6 +303,7 @@ #![feature(link_cfg)] #![feature(linkage)] #![feature(macro_metavar_expr_concat)] +#![feature(maybe_uninit_fill)] #![feature(min_specialization)] #![feature(must_not_suspend)] #![feature(needs_panic_runtime)] @@ -401,7 +406,6 @@ #![feature(custom_test_frameworks)] #![feature(edition_panic)] #![feature(format_args_nl)] -#![feature(get_many_mut)] #![feature(log_syntax)] #![feature(test)] #![feature(trace_macros)] diff --git a/std/src/net/ip_addr.rs b/std/src/net/ip_addr.rs index 4d673a1d66db6..7262899b3bbbe 100644 --- a/std/src/net/ip_addr.rs +++ b/std/src/net/ip_addr.rs @@ -8,32 +8,3 @@ pub use core::net::IpAddr; pub use core::net::Ipv6MulticastScope; #[stable(feature = "rust1", since = "1.0.0")] pub use core::net::{Ipv4Addr, Ipv6Addr}; - -use crate::sys::net::netc as c; -use crate::sys_common::{FromInner, IntoInner}; - -impl IntoInner for Ipv4Addr { - #[inline] - fn into_inner(self) -> c::in_addr { - // `s_addr` is stored as BE on all machines and the array is in BE order. - // So the native endian conversion method is used so that it's never swapped. - c::in_addr { s_addr: u32::from_ne_bytes(self.octets()) } - } -} -impl FromInner for Ipv4Addr { - fn from_inner(addr: c::in_addr) -> Ipv4Addr { - Ipv4Addr::from(addr.s_addr.to_ne_bytes()) - } -} - -impl IntoInner for Ipv6Addr { - fn into_inner(self) -> c::in6_addr { - c::in6_addr { s6_addr: self.octets() } - } -} -impl FromInner for Ipv6Addr { - #[inline] - fn from_inner(addr: c::in6_addr) -> Ipv6Addr { - Ipv6Addr::from(addr.s6_addr) - } -} diff --git a/std/src/net/socket_addr.rs b/std/src/net/socket_addr.rs index e8355cc31d7a5..4c8905c0d4609 100644 --- a/std/src/net/socket_addr.rs +++ b/std/src/net/socket_addr.rs @@ -6,50 +6,8 @@ mod tests; pub use core::net::{SocketAddr, SocketAddrV4, SocketAddrV6}; use crate::net::{IpAddr, Ipv4Addr, Ipv6Addr}; -use crate::sys::net::{LookupHost, netc as c}; -use crate::sys_common::{FromInner, IntoInner}; -use crate::{io, iter, mem, option, slice, vec}; - -impl FromInner for SocketAddrV4 { - fn from_inner(addr: c::sockaddr_in) -> SocketAddrV4 { - SocketAddrV4::new(Ipv4Addr::from_inner(addr.sin_addr), u16::from_be(addr.sin_port)) - } -} - -impl FromInner for SocketAddrV6 { - fn from_inner(addr: c::sockaddr_in6) -> SocketAddrV6 { - SocketAddrV6::new( - Ipv6Addr::from_inner(addr.sin6_addr), - u16::from_be(addr.sin6_port), - addr.sin6_flowinfo, - addr.sin6_scope_id, - ) - } -} - -impl IntoInner for SocketAddrV4 { - fn into_inner(self) -> c::sockaddr_in { - c::sockaddr_in { - sin_family: c::AF_INET as c::sa_family_t, - sin_port: self.port().to_be(), - sin_addr: self.ip().into_inner(), - ..unsafe { mem::zeroed() } - } - } -} - -impl IntoInner for SocketAddrV6 { - fn into_inner(self) -> c::sockaddr_in6 { - c::sockaddr_in6 { - sin6_family: c::AF_INET6 as c::sa_family_t, - sin6_port: self.port().to_be(), - sin6_addr: self.ip().into_inner(), - sin6_flowinfo: self.flowinfo(), - sin6_scope_id: self.scope_id(), - ..unsafe { mem::zeroed() } - } - } -} +use crate::sys::net::LookupHost; +use crate::{io, iter, option, slice, vec}; /// A trait for objects which can be converted or resolved to one or more /// [`SocketAddr`] values. diff --git a/std/src/os/fd/owned.rs b/std/src/os/fd/owned.rs index 1e814eca3c1a5..5cec11ecccf1c 100644 --- a/std/src/os/fd/owned.rs +++ b/std/src/os/fd/owned.rs @@ -67,13 +67,11 @@ impl BorrowedFd<'_> { /// The resource pointed to by `fd` must remain open for the duration of /// the returned `BorrowedFd`, and it must not have the value `-1`. #[inline] + #[track_caller] #[rustc_const_stable(feature = "io_safety", since = "1.63.0")] #[stable(feature = "io_safety", since = "1.63.0")] pub const unsafe fn borrow_raw(fd: RawFd) -> Self { - assert!(fd != u32::MAX as RawFd); - // SAFETY: we just asserted that the value is in the valid range and isn't `-1` (the only value bigger than `0xFF_FF_FF_FE` unsigned) - let fd = unsafe { ValidRawFd::new_unchecked(fd) }; - Self { fd, _phantom: PhantomData } + Self { fd: ValidRawFd::new(fd).expect("fd != -1"), _phantom: PhantomData } } } @@ -154,11 +152,9 @@ impl FromRawFd for OwnedFd { /// /// [io-safety]: io#io-safety #[inline] + #[track_caller] unsafe fn from_raw_fd(fd: RawFd) -> Self { - assert_ne!(fd, u32::MAX as RawFd); - // SAFETY: we just asserted that the value is in the valid range and isn't `-1` (the only value bigger than `0xFF_FF_FF_FE` unsigned) - let fd = unsafe { ValidRawFd::new_unchecked(fd) }; - Self { fd } + Self { fd: ValidRawFd::new(fd).expect("fd != -1") } } } diff --git a/std/src/os/solid/io.rs b/std/src/os/solid/io.rs index b8c3440542d00..c23d842b238b8 100644 --- a/std/src/os/solid/io.rs +++ b/std/src/os/solid/io.rs @@ -101,12 +101,9 @@ impl BorrowedFd<'_> { /// the returned `BorrowedFd`, and it must not have the value /// `SOLID_NET_INVALID_FD`. #[inline] + #[track_caller] pub const unsafe fn borrow_raw(fd: RawFd) -> Self { - assert!(fd != -1 as RawFd); - // SAFETY: we just asserted that the value is in the valid range and - // isn't `-1` (the only value bigger than `0xFF_FF_FF_FE` unsigned) - let fd = unsafe { ValidRawFd::new_unchecked(fd) }; - Self { fd, _phantom: PhantomData } + Self { fd: ValidRawFd::new(fd).expect("fd != -1"), _phantom: PhantomData } } } @@ -122,7 +119,7 @@ impl BorrowedFd<'_> { /// Creates a new `OwnedFd` instance that shares the same underlying file /// description as the existing `BorrowedFd` instance. pub fn try_clone_to_owned(&self) -> crate::io::Result { - let fd = sys::net::cvt(unsafe { sys::net::netc::dup(self.as_raw_fd()) })?; + let fd = sys::net::cvt(unsafe { crate::sys::abi::sockets::dup(self.as_raw_fd()) })?; Ok(unsafe { OwnedFd::from_raw_fd(fd) }) } } @@ -156,19 +153,16 @@ impl FromRawFd for OwnedFd { /// The resource pointed to by `fd` must be open and suitable for assuming /// ownership. The resource must not require any cleanup other than `close`. #[inline] + #[track_caller] unsafe fn from_raw_fd(fd: RawFd) -> Self { - assert_ne!(fd, -1 as RawFd); - // SAFETY: we just asserted that the value is in the valid range and - // isn't `-1` (the only value bigger than `0xFF_FF_FF_FE` unsigned) - let fd = unsafe { ValidRawFd::new_unchecked(fd) }; - Self { fd } + Self { fd: ValidRawFd::new(fd).expect("fd != -1") } } } impl Drop for OwnedFd { #[inline] fn drop(&mut self) { - unsafe { sys::net::netc::close(self.fd.as_inner()) }; + unsafe { crate::sys::abi::sockets::close(self.fd.as_inner()) }; } } diff --git a/std/src/os/wasi/fs.rs b/std/src/os/wasi/fs.rs index 42aada131dadc..34f0e89f2f1ee 100644 --- a/std/src/os/wasi/fs.rs +++ b/std/src/os/wasi/fs.rs @@ -162,13 +162,6 @@ pub trait FileExt { Ok(()) } - /// Returns the current position within the file. - /// - /// This corresponds to the `fd_tell` syscall and is similar to - /// `seek` where you offset 0 bytes from the current position. - #[doc(alias = "fd_tell")] - fn tell(&self) -> io::Result; - /// Adjusts the flags associated with this file. /// /// This corresponds to the `fd_fdstat_set_flags` syscall. @@ -240,10 +233,6 @@ impl FileExt for fs::File { self.as_inner().as_inner().pwrite(bufs, offset) } - fn tell(&self) -> io::Result { - self.as_inner().as_inner().tell() - } - fn fdstat_set_flags(&self, flags: u16) -> io::Result<()> { self.as_inner().as_inner().set_flags(flags) } diff --git a/std/src/os/windows/io/socket.rs b/std/src/os/windows/io/socket.rs index 6e13a8b502a73..2bc6ce222ae5c 100644 --- a/std/src/os/windows/io/socket.rs +++ b/std/src/os/windows/io/socket.rs @@ -58,12 +58,11 @@ impl BorrowedSocket<'_> { /// the returned `BorrowedSocket`, and it must not have the value /// `INVALID_SOCKET`. #[inline] + #[track_caller] #[rustc_const_stable(feature = "io_safety", since = "1.63.0")] #[stable(feature = "io_safety", since = "1.63.0")] pub const unsafe fn borrow_raw(socket: RawSocket) -> Self { - assert!(socket != sys::c::INVALID_SOCKET as RawSocket); - let socket = unsafe { ValidRawSocket::new_unchecked(socket) }; - Self { socket, _phantom: PhantomData } + Self { socket: ValidRawSocket::new(socket).expect("socket != -1"), _phantom: PhantomData } } } @@ -185,10 +184,9 @@ impl IntoRawSocket for OwnedSocket { #[stable(feature = "io_safety", since = "1.63.0")] impl FromRawSocket for OwnedSocket { #[inline] + #[track_caller] unsafe fn from_raw_socket(socket: RawSocket) -> Self { - debug_assert_ne!(socket, sys::c::INVALID_SOCKET as RawSocket); - let socket = unsafe { ValidRawSocket::new_unchecked(socket) }; - Self { socket } + Self { socket: ValidRawSocket::new(socket).expect("socket != -1") } } } diff --git a/std/src/panic.rs b/std/src/panic.rs index 153189b8b0315..22776ae2bc4a7 100644 --- a/std/src/panic.rs +++ b/std/src/panic.rs @@ -255,6 +255,7 @@ pub use crate::panicking::{set_hook, take_hook}; #[stable(feature = "panic_any", since = "1.51.0")] #[inline] #[track_caller] +#[cfg_attr(not(test), rustc_diagnostic_item = "panic_any")] pub fn panic_any(msg: M) -> ! { crate::panicking::begin_panic(msg); } @@ -376,7 +377,9 @@ pub fn catch_unwind R + UnwindSafe, R>(f: F) -> Result { /// use std::panic; /// /// let result = panic::catch_unwind(|| { -/// panic!("oh no!"); +/// if 1 != 2 { +/// panic!("oh no!"); +/// } /// }); /// /// if let Err(err) = result { diff --git a/std/src/panicking.rs b/std/src/panicking.rs index 8e50bf11dd082..b47b41d4bc5b7 100644 --- a/std/src/panicking.rs +++ b/std/src/panicking.rs @@ -54,11 +54,11 @@ pub static EMPTY_PANIC: fn(&'static str) -> ! = // One day this may look a little less ad-hoc with the compiler helping out to // hook up these functions, but it is not this day! #[allow(improper_ctypes)] -extern "C" { +unsafe extern "C" { fn __rust_panic_cleanup(payload: *mut u8) -> *mut (dyn Any + Send + 'static); } -extern "Rust" { +unsafe extern "Rust" { /// `PanicPayload` lazily performs allocation only when needed (this avoids /// allocations when using the "abort" panic runtime). fn __rust_start_panic(payload: &mut dyn PanicPayload) -> u32; diff --git a/std/src/path.rs b/std/src/path.rs index 97e17acadeac7..f9f3b488f0d03 100644 --- a/std/src/path.rs +++ b/std/src/path.rs @@ -3575,7 +3575,7 @@ impl Error for StripPrefixError { pub fn absolute>(path: P) -> io::Result { let path = path.as_ref(); if path.as_os_str().is_empty() { - Err(io::const_error!(io::ErrorKind::InvalidInput, "cannot make an empty path absolute",)) + Err(io::const_error!(io::ErrorKind::InvalidInput, "cannot make an empty path absolute")) } else { sys::path::absolute(path) } diff --git a/std/src/prelude/mod.rs b/std/src/prelude/mod.rs index 14e6c2715df0b..992a9207a7206 100644 --- a/std/src/prelude/mod.rs +++ b/std/src/prelude/mod.rs @@ -111,16 +111,7 @@ #![stable(feature = "rust1", since = "1.0.0")] -mod common; - -/// The first version of the prelude of The Rust Standard Library. -/// -/// See the [module-level documentation](self) for more. -#[stable(feature = "rust1", since = "1.0.0")] -pub mod v1 { - #[stable(feature = "rust1", since = "1.0.0")] - pub use super::common::*; -} +pub mod v1; /// The 2015 version of the prelude of The Rust Standard Library. /// @@ -162,7 +153,8 @@ pub mod rust_2021 { #[stable(feature = "prelude_2024", since = "1.85.0")] pub mod rust_2024 { #[stable(feature = "rust1", since = "1.0.0")] - pub use super::common::*; + #[doc(no_inline)] + pub use super::v1::*; #[stable(feature = "prelude_2024", since = "1.85.0")] #[doc(no_inline)] diff --git a/std/src/prelude/common.rs b/std/src/prelude/v1.rs similarity index 97% rename from std/src/prelude/common.rs rename to std/src/prelude/v1.rs index 0f2d8334fca79..5b324b2e91671 100644 --- a/std/src/prelude/common.rs +++ b/std/src/prelude/v1.rs @@ -1,7 +1,9 @@ -//! Items common to the prelude of all editions. +//! The first version of the prelude of The Rust Standard Library. //! //! See the [module-level documentation](super) for more. +#![stable(feature = "rust1", since = "1.0.0")] + // No formatting: this file is nothing but re-exports, and their order is worth preserving. #![cfg_attr(rustfmt, rustfmt::skip)] diff --git a/std/src/process.rs b/std/src/process.rs index fd0fd1cb755e0..bdd4844b6511a 100644 --- a/std/src/process.rs +++ b/std/src/process.rs @@ -217,6 +217,7 @@ use crate::{fmt, fs, str}; /// /// [`wait`]: Child::wait #[stable(feature = "process", since = "1.0.0")] +#[cfg_attr(not(test), rustc_diagnostic_item = "Child")] pub struct Child { pub(crate) handle: imp::Process, @@ -2115,6 +2116,7 @@ impl Child { /// [`ErrorKind`]: io::ErrorKind /// [`InvalidInput`]: io::ErrorKind::InvalidInput #[stable(feature = "process", since = "1.0.0")] + #[cfg_attr(not(test), rustc_diagnostic_item = "child_kill")] pub fn kill(&mut self) -> io::Result<()> { self.handle.kill() } @@ -2135,6 +2137,7 @@ impl Child { /// ``` #[must_use] #[stable(feature = "process_id", since = "1.3.0")] + #[cfg_attr(not(test), rustc_diagnostic_item = "child_id")] pub fn id(&self) -> u32 { self.handle.id() } @@ -2375,6 +2378,7 @@ pub fn exit(code: i32) -> ! { /// [panic hook]: crate::panic::set_hook #[stable(feature = "process_abort", since = "1.17.0")] #[cold] +#[cfg_attr(not(test), rustc_diagnostic_item = "process_abort")] pub fn abort() -> ! { crate::sys::abort_internal(); } diff --git a/std/src/process/tests.rs b/std/src/process/tests.rs index 69273d863ebbd..5879914ca206a 100644 --- a/std/src/process/tests.rs +++ b/std/src/process/tests.rs @@ -323,9 +323,13 @@ fn test_capture_env_at_spawn() { // This variable will not be present if the environment has already // been captured above. - env::set_var("RUN_TEST_NEW_ENV2", "456"); + unsafe { + env::set_var("RUN_TEST_NEW_ENV2", "456"); + } let result = cmd.output().unwrap(); - env::remove_var("RUN_TEST_NEW_ENV2"); + unsafe { + env::remove_var("RUN_TEST_NEW_ENV2"); + } let output = String::from_utf8_lossy(&result.stdout).to_string(); diff --git a/std/src/sync/mpmc/mod.rs b/std/src/sync/mpmc/mod.rs index 00966ee3ecffd..8712332dd2767 100644 --- a/std/src/sync/mpmc/mod.rs +++ b/std/src/sync/mpmc/mod.rs @@ -616,9 +616,9 @@ impl Sender { #[unstable(feature = "mpmc_channel", issue = "126840")] pub fn same_channel(&self, other: &Sender) -> bool { match (&self.flavor, &other.flavor) { - (SenderFlavor::Array(ref a), SenderFlavor::Array(ref b)) => a == b, - (SenderFlavor::List(ref a), SenderFlavor::List(ref b)) => a == b, - (SenderFlavor::Zero(ref a), SenderFlavor::Zero(ref b)) => a == b, + (SenderFlavor::Array(a), SenderFlavor::Array(b)) => a == b, + (SenderFlavor::List(a), SenderFlavor::List(b)) => a == b, + (SenderFlavor::Zero(a), SenderFlavor::Zero(b)) => a == b, _ => false, } } @@ -1382,3 +1382,6 @@ impl fmt::Debug for Receiver { f.pad("Receiver { .. }") } } + +#[cfg(test)] +mod tests; diff --git a/std/src/sync/mpmc/tests.rs b/std/src/sync/mpmc/tests.rs new file mode 100644 index 0000000000000..6deb4dc2fe0cc --- /dev/null +++ b/std/src/sync/mpmc/tests.rs @@ -0,0 +1,14 @@ +// Ensure that thread_local init with `const { 0 }` still has unique address at run-time +#[test] +fn waker_current_thread_id() { + let first = super::waker::current_thread_id(); + let t = crate::thread::spawn(move || { + let second = super::waker::current_thread_id(); + assert_ne!(first, second); + assert_eq!(second, super::waker::current_thread_id()); + }); + + assert_eq!(first, super::waker::current_thread_id()); + t.join().unwrap(); + assert_eq!(first, super::waker::current_thread_id()); +} diff --git a/std/src/sync/mpmc/waker.rs b/std/src/sync/mpmc/waker.rs index 1895466f95d45..f5e764e69bd6e 100644 --- a/std/src/sync/mpmc/waker.rs +++ b/std/src/sync/mpmc/waker.rs @@ -204,6 +204,6 @@ impl Drop for SyncWaker { pub fn current_thread_id() -> usize { // `u8` is not drop so this variable will be available during thread destruction, // whereas `thread::current()` would not be - thread_local! { static DUMMY: u8 = 0 } + thread_local! { static DUMMY: u8 = const { 0 } } DUMMY.with(|x| (x as *const u8).addr()) } diff --git a/std/src/sync/once_lock.rs b/std/src/sync/once_lock.rs index 21e6b65a744f8..ffb90b1469584 100644 --- a/std/src/sync/once_lock.rs +++ b/std/src/sync/once_lock.rs @@ -191,7 +191,7 @@ impl OnceLock { /// }) /// ``` #[inline] - #[stable(feature = "once_wait", since = "CURRENT_RUSTC_VERSION")] + #[stable(feature = "once_wait", since = "1.86.0")] pub fn wait(&self) -> &T { self.once.wait_force(); diff --git a/std/src/sync/poison/once.rs b/std/src/sync/poison/once.rs index d2938b7a0c12e..103e519540795 100644 --- a/std/src/sync/poison/once.rs +++ b/std/src/sync/poison/once.rs @@ -284,7 +284,7 @@ impl Once { /// If this [`Once`] has been poisoned because an initialization closure has /// panicked, this method will also panic. Use [`wait_force`](Self::wait_force) /// if this behavior is not desired. - #[stable(feature = "once_wait", since = "CURRENT_RUSTC_VERSION")] + #[stable(feature = "once_wait", since = "1.86.0")] pub fn wait(&self) { if !self.inner.is_completed() { self.inner.wait(false); @@ -293,7 +293,7 @@ impl Once { /// Blocks the current thread until initialization has completed, ignoring /// poisoning. - #[stable(feature = "once_wait", since = "CURRENT_RUSTC_VERSION")] + #[stable(feature = "once_wait", since = "1.86.0")] pub fn wait_force(&self) { if !self.inner.is_completed() { self.inner.wait(true); diff --git a/std/src/sys/alloc/sgx.rs b/std/src/sys/alloc/sgx.rs index fca9d087e5bfc..f5c27688fbc8f 100644 --- a/std/src/sys/alloc/sgx.rs +++ b/std/src/sys/alloc/sgx.rs @@ -11,7 +11,7 @@ use crate::sys::pal::waitqueue::SpinMutex; // in the rust-lang/rust repository as a submodule. The crate is a port of // dlmalloc.c from C to Rust. #[cfg_attr(test, linkage = "available_externally")] -#[export_name = "_ZN16__rust_internals3std3sys3sgx5alloc8DLMALLOCE"] +#[unsafe(export_name = "_ZN16__rust_internals3std3sys3sgx5alloc8DLMALLOCE")] static DLMALLOC: SpinMutex> = SpinMutex::new(dlmalloc::Dlmalloc::new_with_allocator(Sgx {})); @@ -85,13 +85,13 @@ unsafe impl GlobalAlloc for System { // The following functions are needed by libunwind. These symbols are named // in pre-link args for the target specification, so keep that in sync. #[cfg(not(test))] -#[no_mangle] +#[unsafe(no_mangle)] pub unsafe extern "C" fn __rust_c_alloc(size: usize, align: usize) -> *mut u8 { unsafe { crate::alloc::alloc(Layout::from_size_align_unchecked(size, align)) } } #[cfg(not(test))] -#[no_mangle] +#[unsafe(no_mangle)] pub unsafe extern "C" fn __rust_c_dealloc(ptr: *mut u8, size: usize, align: usize) { unsafe { crate::alloc::dealloc(ptr, Layout::from_size_align_unchecked(size, align)) } } diff --git a/std/src/sys/alloc/xous.rs b/std/src/sys/alloc/xous.rs index 321d30e0b11b2..ccaa972c22de3 100644 --- a/std/src/sys/alloc/xous.rs +++ b/std/src/sys/alloc/xous.rs @@ -4,11 +4,11 @@ use crate::alloc::{GlobalAlloc, Layout, System}; #[cfg(not(test))] -#[export_name = "_ZN16__rust_internals3std3sys4xous5alloc8DLMALLOCE"] +#[unsafe(export_name = "_ZN16__rust_internals3std3sys4xous5alloc8DLMALLOCE")] static mut DLMALLOC: dlmalloc::Dlmalloc = dlmalloc::Dlmalloc::new(); #[cfg(test)] -extern "Rust" { +unsafe extern "Rust" { #[link_name = "_ZN16__rust_internals3std3sys4xous5alloc8DLMALLOCE"] static mut DLMALLOC: dlmalloc::Dlmalloc; } diff --git a/std/src/sys/cmath.rs b/std/src/sys/cmath.rs index ee36127cfdf1e..c9969b4e376ea 100644 --- a/std/src/sys/cmath.rs +++ b/std/src/sys/cmath.rs @@ -2,7 +2,7 @@ // These symbols are all defined by `libm`, // or by `compiler-builtins` on unsupported platforms. -extern "C" { +unsafe extern "C" { pub fn acos(n: f64) -> f64; pub fn asin(n: f64) -> f64; pub fn atan(n: f64) -> f64; @@ -28,6 +28,10 @@ extern "C" { pub fn lgamma_r(n: f64, s: &mut i32) -> f64; #[cfg(not(target_os = "aix"))] pub fn lgammaf_r(n: f32, s: &mut i32) -> f32; + pub fn erf(n: f64) -> f64; + pub fn erff(n: f32) -> f32; + pub fn erfc(n: f64) -> f64; + pub fn erfcf(n: f32) -> f32; pub fn acosf128(n: f128) -> f128; pub fn asinf128(n: f128) -> f128; @@ -43,6 +47,8 @@ extern "C" { pub fn tanhf128(n: f128) -> f128; pub fn tgammaf128(n: f128) -> f128; pub fn lgammaf128_r(n: f128, s: &mut i32) -> f128; + pub fn erff128(n: f128) -> f128; + pub fn erfcf128(n: f128) -> f128; cfg_if::cfg_if! { if #[cfg(not(all(target_os = "windows", target_env = "msvc", target_arch = "x86")))] { diff --git a/std/src/sys/net/connection/sgx.rs b/std/src/sys/net/connection/sgx.rs index b390a5eac5f74..242df10bc3270 100644 --- a/std/src/sys/net/connection/sgx.rs +++ b/std/src/sys/net/connection/sgx.rs @@ -499,38 +499,3 @@ impl<'a> TryFrom<(&'a str, u16)> for LookupHost { LookupHost::new(format!("{host}:{port}")) } } - -#[allow(bad_style)] -pub mod netc { - pub const AF_INET: u8 = 0; - pub const AF_INET6: u8 = 1; - pub type sa_family_t = u8; - - #[derive(Copy, Clone)] - pub struct in_addr { - pub s_addr: u32, - } - - #[derive(Copy, Clone)] - pub struct sockaddr_in { - #[allow(dead_code)] - pub sin_family: sa_family_t, - pub sin_port: u16, - pub sin_addr: in_addr, - } - - #[derive(Copy, Clone)] - pub struct in6_addr { - pub s6_addr: [u8; 16], - } - - #[derive(Copy, Clone)] - pub struct sockaddr_in6 { - #[allow(dead_code)] - pub sin6_family: sa_family_t, - pub sin6_port: u16, - pub sin6_addr: in6_addr, - pub sin6_flowinfo: u32, - pub sin6_scope_id: u32, - } -} diff --git a/std/src/sys/net/connection/socket.rs b/std/src/sys/net/connection/socket.rs index 6fe3430b53f79..ddd74b426158d 100644 --- a/std/src/sys/net/connection/socket.rs +++ b/std/src/sys/net/connection/socket.rs @@ -3,9 +3,9 @@ mod tests; use crate::ffi::{c_int, c_void}; use crate::io::{self, BorrowedCursor, ErrorKind, IoSlice, IoSliceMut}; -use crate::net::{Ipv4Addr, Ipv6Addr, Shutdown, SocketAddr}; +use crate::net::{Ipv4Addr, Ipv6Addr, Shutdown, SocketAddr, SocketAddrV4, SocketAddrV6}; use crate::sys::common::small_c_string::run_with_cstr; -use crate::sys_common::{AsInner, FromInner, IntoInner}; +use crate::sys_common::{AsInner, FromInner}; use crate::time::Duration; use crate::{cmp, fmt, mem, ptr}; @@ -79,6 +79,111 @@ cfg_if::cfg_if! { } } +//////////////////////////////////////////////////////////////////////////////// +// address conversions +//////////////////////////////////////////////////////////////////////////////// + +fn ip_v4_addr_to_c(addr: &Ipv4Addr) -> c::in_addr { + // `s_addr` is stored as BE on all machines and the array is in BE order. + // So the native endian conversion method is used so that it's never swapped. + c::in_addr { s_addr: u32::from_ne_bytes(addr.octets()) } +} + +fn ip_v6_addr_to_c(addr: &Ipv6Addr) -> c::in6_addr { + c::in6_addr { s6_addr: addr.octets() } +} + +fn ip_v4_addr_from_c(addr: c::in_addr) -> Ipv4Addr { + Ipv4Addr::from(addr.s_addr.to_ne_bytes()) +} + +fn ip_v6_addr_from_c(addr: c::in6_addr) -> Ipv6Addr { + Ipv6Addr::from(addr.s6_addr) +} + +fn socket_addr_v4_to_c(addr: &SocketAddrV4) -> c::sockaddr_in { + c::sockaddr_in { + sin_family: c::AF_INET as c::sa_family_t, + sin_port: addr.port().to_be(), + sin_addr: ip_v4_addr_to_c(addr.ip()), + ..unsafe { mem::zeroed() } + } +} + +fn socket_addr_v6_to_c(addr: &SocketAddrV6) -> c::sockaddr_in6 { + c::sockaddr_in6 { + sin6_family: c::AF_INET6 as c::sa_family_t, + sin6_port: addr.port().to_be(), + sin6_addr: ip_v6_addr_to_c(addr.ip()), + sin6_flowinfo: addr.flowinfo(), + sin6_scope_id: addr.scope_id(), + ..unsafe { mem::zeroed() } + } +} + +fn socket_addr_v4_from_c(addr: c::sockaddr_in) -> SocketAddrV4 { + SocketAddrV4::new(ip_v4_addr_from_c(addr.sin_addr), u16::from_be(addr.sin_port)) +} + +fn socket_addr_v6_from_c(addr: c::sockaddr_in6) -> SocketAddrV6 { + SocketAddrV6::new( + ip_v6_addr_from_c(addr.sin6_addr), + u16::from_be(addr.sin6_port), + addr.sin6_flowinfo, + addr.sin6_scope_id, + ) +} + +/// A type with the same memory layout as `c::sockaddr`. Used in converting Rust level +/// SocketAddr* types into their system representation. The benefit of this specific +/// type over using `c::sockaddr_storage` is that this type is exactly as large as it +/// needs to be and not a lot larger. And it can be initialized more cleanly from Rust. +#[repr(C)] +union SocketAddrCRepr { + v4: c::sockaddr_in, + v6: c::sockaddr_in6, +} + +impl SocketAddrCRepr { + fn as_ptr(&self) -> *const c::sockaddr { + self as *const _ as *const c::sockaddr + } +} + +fn socket_addr_to_c(addr: &SocketAddr) -> (SocketAddrCRepr, c::socklen_t) { + match addr { + SocketAddr::V4(a) => { + let sockaddr = SocketAddrCRepr { v4: socket_addr_v4_to_c(a) }; + (sockaddr, mem::size_of::() as c::socklen_t) + } + SocketAddr::V6(a) => { + let sockaddr = SocketAddrCRepr { v6: socket_addr_v6_to_c(a) }; + (sockaddr, mem::size_of::() as c::socklen_t) + } + } +} + +unsafe fn socket_addr_from_c( + storage: *const c::sockaddr_storage, + len: usize, +) -> io::Result { + match (*storage).ss_family as c_int { + c::AF_INET => { + assert!(len >= mem::size_of::()); + Ok(SocketAddr::V4(socket_addr_v4_from_c(unsafe { + *(storage as *const _ as *const c::sockaddr_in) + }))) + } + c::AF_INET6 => { + assert!(len >= mem::size_of::()); + Ok(SocketAddr::V6(socket_addr_v6_from_c(unsafe { + *(storage as *const _ as *const c::sockaddr_in6) + }))) + } + _ => Err(io::const_error!(ErrorKind::InvalidInput, "invalid argument")), + } +} + //////////////////////////////////////////////////////////////////////////////// // sockaddr and misc bindings //////////////////////////////////////////////////////////////////////////////// @@ -124,25 +229,7 @@ where let mut storage: c::sockaddr_storage = mem::zeroed(); let mut len = mem::size_of_val(&storage) as c::socklen_t; cvt(f((&raw mut storage) as *mut _, &mut len))?; - sockaddr_to_addr(&storage, len as usize) - } -} - -pub fn sockaddr_to_addr(storage: &c::sockaddr_storage, len: usize) -> io::Result { - match storage.ss_family as c_int { - c::AF_INET => { - assert!(len >= mem::size_of::()); - Ok(SocketAddr::V4(FromInner::from_inner(unsafe { - *(storage as *const _ as *const c::sockaddr_in) - }))) - } - c::AF_INET6 => { - assert!(len >= mem::size_of::()); - Ok(SocketAddr::V6(FromInner::from_inner(unsafe { - *(storage as *const _ as *const c::sockaddr_in6) - }))) - } - _ => Err(io::const_error!(ErrorKind::InvalidInput, "invalid argument")), + socket_addr_from_c(&storage, len as usize) } } @@ -179,7 +266,7 @@ impl Iterator for LookupHost { unsafe { let cur = self.cur.as_ref()?; self.cur = cur.ai_next; - match sockaddr_to_addr(mem::transmute(cur.ai_addr), cur.ai_addrlen as usize) { + match socket_addr_from_c(cur.ai_addr.cast(), cur.ai_addrlen as usize) { Ok(addr) => return Some(addr), Err(_) => continue, } @@ -432,7 +519,7 @@ impl TcpListener { setsockopt(&sock, c::SOL_SOCKET, c::SO_REUSEADDR, 1 as c_int)?; // Bind our new socket - let (addr, len) = addr.into_inner(); + let (addr, len) = socket_addr_to_c(addr); cvt(unsafe { c::bind(sock.as_raw(), addr.as_ptr(), len as _) })?; cfg_if::cfg_if! { @@ -470,10 +557,13 @@ impl TcpListener { } pub fn accept(&self) -> io::Result<(TcpStream, SocketAddr)> { - let mut storage: c::sockaddr_storage = unsafe { mem::zeroed() }; + // The `accept` function will fill in the storage with the address, + // so we don't need to zero it here. + // reference: https://linux.die.net/man/2/accept4 + let mut storage: mem::MaybeUninit = mem::MaybeUninit::uninit(); let mut len = mem::size_of_val(&storage) as c::socklen_t; - let sock = self.inner.accept((&raw mut storage) as *mut _, &mut len)?; - let addr = sockaddr_to_addr(&storage, len as usize)?; + let sock = self.inner.accept(storage.as_mut_ptr() as *mut _, &mut len)?; + let addr = unsafe { socket_addr_from_c(storage.as_ptr(), len as usize)? }; Ok((TcpStream { inner: sock }, addr)) } @@ -542,7 +632,7 @@ impl UdpSocket { init(); let sock = Socket::new(addr, c::SOCK_DGRAM)?; - let (addr, len) = addr.into_inner(); + let (addr, len) = socket_addr_to_c(addr); cvt(unsafe { c::bind(sock.as_raw(), addr.as_ptr(), len as _) })?; Ok(UdpSocket { inner: sock }) } @@ -574,7 +664,7 @@ impl UdpSocket { pub fn send_to(&self, buf: &[u8], dst: &SocketAddr) -> io::Result { let len = cmp::min(buf.len(), ::MAX as usize) as wrlen_t; - let (dst, dstlen) = dst.into_inner(); + let (dst, dstlen) = socket_addr_to_c(dst); let ret = cvt(unsafe { c::sendto( self.inner.as_raw(), @@ -656,15 +746,15 @@ impl UdpSocket { pub fn join_multicast_v4(&self, multiaddr: &Ipv4Addr, interface: &Ipv4Addr) -> io::Result<()> { let mreq = c::ip_mreq { - imr_multiaddr: multiaddr.into_inner(), - imr_interface: interface.into_inner(), + imr_multiaddr: ip_v4_addr_to_c(multiaddr), + imr_interface: ip_v4_addr_to_c(interface), }; setsockopt(&self.inner, c::IPPROTO_IP, c::IP_ADD_MEMBERSHIP, mreq) } pub fn join_multicast_v6(&self, multiaddr: &Ipv6Addr, interface: u32) -> io::Result<()> { let mreq = c::ipv6_mreq { - ipv6mr_multiaddr: multiaddr.into_inner(), + ipv6mr_multiaddr: ip_v6_addr_to_c(multiaddr), ipv6mr_interface: to_ipv6mr_interface(interface), }; setsockopt(&self.inner, c::IPPROTO_IPV6, IPV6_ADD_MEMBERSHIP, mreq) @@ -672,15 +762,15 @@ impl UdpSocket { pub fn leave_multicast_v4(&self, multiaddr: &Ipv4Addr, interface: &Ipv4Addr) -> io::Result<()> { let mreq = c::ip_mreq { - imr_multiaddr: multiaddr.into_inner(), - imr_interface: interface.into_inner(), + imr_multiaddr: ip_v4_addr_to_c(multiaddr), + imr_interface: ip_v4_addr_to_c(interface), }; setsockopt(&self.inner, c::IPPROTO_IP, c::IP_DROP_MEMBERSHIP, mreq) } pub fn leave_multicast_v6(&self, multiaddr: &Ipv6Addr, interface: u32) -> io::Result<()> { let mreq = c::ipv6_mreq { - ipv6mr_multiaddr: multiaddr.into_inner(), + ipv6mr_multiaddr: ip_v6_addr_to_c(multiaddr), ipv6mr_interface: to_ipv6mr_interface(interface), }; setsockopt(&self.inner, c::IPPROTO_IPV6, IPV6_DROP_MEMBERSHIP, mreq) @@ -720,7 +810,7 @@ impl UdpSocket { } pub fn connect(&self, addr: io::Result<&SocketAddr>) -> io::Result<()> { - let (addr, len) = addr?.into_inner(); + let (addr, len) = socket_addr_to_c(addr?); cvt_r(|| unsafe { c::connect(self.inner.as_raw(), addr.as_ptr(), len) }).map(drop) } } @@ -743,38 +833,3 @@ impl fmt::Debug for UdpSocket { res.field(name, &self.inner.as_raw()).finish() } } - -//////////////////////////////////////////////////////////////////////////////// -// Converting SocketAddr to libc representation -//////////////////////////////////////////////////////////////////////////////// - -/// A type with the same memory layout as `c::sockaddr`. Used in converting Rust level -/// SocketAddr* types into their system representation. The benefit of this specific -/// type over using `c::sockaddr_storage` is that this type is exactly as large as it -/// needs to be and not a lot larger. And it can be initialized more cleanly from Rust. -#[repr(C)] -pub(crate) union SocketAddrCRepr { - v4: c::sockaddr_in, - v6: c::sockaddr_in6, -} - -impl SocketAddrCRepr { - pub fn as_ptr(&self) -> *const c::sockaddr { - self as *const _ as *const c::sockaddr - } -} - -impl<'a> IntoInner<(SocketAddrCRepr, c::socklen_t)> for &'a SocketAddr { - fn into_inner(self) -> (SocketAddrCRepr, c::socklen_t) { - match *self { - SocketAddr::V4(ref a) => { - let sockaddr = SocketAddrCRepr { v4: a.into_inner() }; - (sockaddr, mem::size_of::() as c::socklen_t) - } - SocketAddr::V6(ref a) => { - let sockaddr = SocketAddrCRepr { v6: a.into_inner() }; - (sockaddr, mem::size_of::() as c::socklen_t) - } - } - } -} diff --git a/std/src/sys/net/connection/socket/hermit.rs b/std/src/sys/net/connection/socket/hermit.rs index 42179dcc9156d..e393342ced9da 100644 --- a/std/src/sys/net/connection/socket/hermit.rs +++ b/std/src/sys/net/connection/socket/hermit.rs @@ -2,13 +2,13 @@ use core::ffi::c_int; -pub(crate) use hermit_abi as netc; +pub(super) use hermit_abi as netc; +use super::{getsockopt, setsockopt, socket_addr_from_c, socket_addr_to_c}; use crate::io::{self, BorrowedBuf, BorrowedCursor, IoSlice, IoSliceMut}; use crate::net::{Shutdown, SocketAddr}; use crate::os::hermit::io::{AsFd, AsRawFd, BorrowedFd, FromRawFd, RawFd}; use crate::sys::fd::FileDesc; -use crate::sys::net::{getsockopt, setsockopt, sockaddr_to_addr}; use crate::sys::time::Instant; pub use crate::sys::{cvt, cvt_r}; use crate::sys_common::{AsInner, FromInner, IntoInner}; @@ -55,7 +55,7 @@ impl Socket { } pub fn connect(&self, addr: &SocketAddr) -> io::Result<()> { - let (addr, len) = addr.into_inner(); + let (addr, len) = socket_addr_to_c(addr); cvt_r(|| unsafe { netc::connect(self.as_raw_fd(), addr.as_ptr(), len) })?; Ok(()) } @@ -63,7 +63,7 @@ impl Socket { pub fn connect_timeout(&self, addr: &SocketAddr, timeout: Duration) -> io::Result<()> { self.set_nonblocking(true)?; let r = unsafe { - let (addr, len) = addr.into_inner(); + let (addr, len) = socket_addr_to_c(addr); cvt(netc::connect(self.as_raw_fd(), addr.as_ptr(), len)) }; self.set_nonblocking(false)?; @@ -195,7 +195,7 @@ impl Socket { &mut addrlen, ) })?; - Ok((n as usize, sockaddr_to_addr(&storage, addrlen as usize)?)) + Ok((n as usize, unsafe { socket_addr_from_c(&storage, addrlen as usize)? })) } pub fn recv_from(&self, buf: &mut [u8]) -> io::Result<(usize, SocketAddr)> { diff --git a/std/src/sys/net/connection/socket/solid.rs b/std/src/sys/net/connection/socket/solid.rs index f85ecbb883ee7..906bef267b6f0 100644 --- a/std/src/sys/net/connection/socket/solid.rs +++ b/std/src/sys/net/connection/socket/solid.rs @@ -1,17 +1,17 @@ use libc::{c_int, c_void, size_t}; use self::netc::{MSG_PEEK, sockaddr, socklen_t}; +use super::{getsockopt, setsockopt, socket_addr_from_c, socket_addr_to_c}; use crate::ffi::CStr; use crate::io::{self, BorrowedBuf, BorrowedCursor, ErrorKind, IoSlice, IoSliceMut}; use crate::net::{Shutdown, SocketAddr}; use crate::os::solid::io::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, OwnedFd}; use crate::sys::abi; -use crate::sys::net::{getsockopt, setsockopt, sockaddr_to_addr}; use crate::sys_common::{FromInner, IntoInner}; use crate::time::Duration; use crate::{cmp, mem, ptr, str}; -pub mod netc { +pub(super) mod netc { pub use crate::sys::abi::sockets::*; } @@ -131,7 +131,7 @@ impl Socket { } pub fn connect(&self, addr: &SocketAddr) -> io::Result<()> { - let (addr, len) = addr.into_inner(); + let (addr, len) = socket_addr_to_c(addr); cvt(unsafe { netc::connect(self.as_raw_fd(), addr.as_ptr(), len) })?; Ok(()) } @@ -256,7 +256,7 @@ impl Socket { &mut addrlen, ) })?; - Ok((n as usize, sockaddr_to_addr(&storage, addrlen as usize)?)) + Ok((n as usize, unsafe { socket_addr_from_c(&storage, addrlen as usize)? })) } pub fn recv_from(&self, buf: &mut [u8]) -> io::Result<(usize, SocketAddr)> { diff --git a/std/src/sys/net/connection/socket/unix.rs b/std/src/sys/net/connection/socket/unix.rs index da6316055273f..29fb47ddca3b9 100644 --- a/std/src/sys/net/connection/socket/unix.rs +++ b/std/src/sys/net/connection/socket/unix.rs @@ -5,7 +5,7 @@ use crate::io::{self, BorrowedBuf, BorrowedCursor, IoSlice, IoSliceMut}; use crate::net::{Shutdown, SocketAddr}; use crate::os::unix::io::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, RawFd}; use crate::sys::fd::FileDesc; -use crate::sys::net::{getsockopt, setsockopt, sockaddr_to_addr}; +use crate::sys::net::{getsockopt, setsockopt}; use crate::sys::pal::IsMinusOne; use crate::sys_common::{AsInner, FromInner, IntoInner}; use crate::time::{Duration, Instant}; @@ -19,8 +19,9 @@ cfg_if::cfg_if! { } } -pub(crate) use libc as netc; +pub(super) use libc as netc; +use super::{socket_addr_from_c, socket_addr_to_c}; pub use crate::sys::{cvt, cvt_r}; #[expect(non_camel_case_types)] @@ -150,7 +151,7 @@ impl Socket { } pub fn connect(&self, addr: &SocketAddr) -> io::Result<()> { - let (addr, len) = addr.into_inner(); + let (addr, len) = socket_addr_to_c(addr); loop { let result = unsafe { libc::connect(self.as_raw_fd(), addr.as_ptr(), len) }; if result.is_minus_one() { @@ -168,7 +169,7 @@ impl Socket { pub fn connect_timeout(&self, addr: &SocketAddr, timeout: Duration) -> io::Result<()> { self.set_nonblocking(true)?; let r = unsafe { - let (addr, len) = addr.into_inner(); + let (addr, len) = socket_addr_to_c(addr); cvt(libc::connect(self.as_raw_fd(), addr.as_ptr(), len)) }; self.set_nonblocking(false)?; @@ -321,7 +322,10 @@ impl Socket { buf: &mut [u8], flags: c_int, ) -> io::Result<(usize, SocketAddr)> { - let mut storage: libc::sockaddr_storage = unsafe { mem::zeroed() }; + // The `recvfrom` function will fill in the storage with the address, + // so we don't need to zero it here. + // reference: https://linux.die.net/man/2/recvfrom + let mut storage: mem::MaybeUninit = mem::MaybeUninit::uninit(); let mut addrlen = mem::size_of_val(&storage) as libc::socklen_t; let n = cvt(unsafe { @@ -334,7 +338,7 @@ impl Socket { &mut addrlen, ) })?; - Ok((n as usize, sockaddr_to_addr(&storage, addrlen as usize)?)) + Ok((n as usize, unsafe { socket_addr_from_c(storage.as_ptr(), addrlen as usize)? })) } pub fn recv_from(&self, buf: &mut [u8]) -> io::Result<(usize, SocketAddr)> { diff --git a/std/src/sys/net/connection/socket/wasip2.rs b/std/src/sys/net/connection/socket/wasip2.rs index 9d1c05a473e4d..c5034e73dd704 100644 --- a/std/src/sys/net/connection/socket/wasip2.rs +++ b/std/src/sys/net/connection/socket/wasip2.rs @@ -1,19 +1,18 @@ #![deny(unsafe_op_in_unsafe_fn)] +pub(super) use libc as netc; use libc::{c_int, c_void, size_t}; +use super::{getsockopt, setsockopt, socket_addr_from_c, socket_addr_to_c}; use crate::ffi::CStr; use crate::io::{self, BorrowedBuf, BorrowedCursor, IoSlice, IoSliceMut}; use crate::net::{Shutdown, SocketAddr}; use crate::os::wasi::io::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, OwnedFd, RawFd}; -use crate::sys::net::{getsockopt, setsockopt, sockaddr_to_addr}; use crate::sys::unsupported; use crate::sys_common::{AsInner, FromInner, IntoInner}; use crate::time::{Duration, Instant}; use crate::{cmp, mem, str}; -pub extern crate libc as netc; - #[allow(non_camel_case_types)] pub type wrlen_t = size_t; @@ -89,7 +88,7 @@ impl Socket { } pub fn connect(&self, addr: &SocketAddr) -> io::Result<()> { - let (addr, len) = addr.into_inner(); + let (addr, len) = socket_addr_to_c(addr); cvt_r(|| unsafe { netc::connect(self.as_raw_fd(), addr.as_ptr(), len) })?; Ok(()) } @@ -224,7 +223,7 @@ impl Socket { &mut addrlen, ) })?; - Ok((n as usize, sockaddr_to_addr(&storage, addrlen as usize)?)) + Ok((n as usize, unsafe { socket_addr_from_c(&storage, addrlen as usize)? })) } pub fn recv_from(&self, buf: &mut [u8]) -> io::Result<(usize, SocketAddr)> { diff --git a/std/src/sys/net/connection/socket/windows.rs b/std/src/sys/net/connection/socket/windows.rs index 80cf37eaf0580..428f142dabe20 100644 --- a/std/src/sys/net/connection/socket/windows.rs +++ b/std/src/sys/net/connection/socket/windows.rs @@ -2,6 +2,7 @@ use core::ffi::{c_int, c_long, c_ulong, c_ushort}; +use super::{getsockopt, setsockopt, socket_addr_from_c, socket_addr_to_c}; use crate::io::{self, BorrowedBuf, BorrowedCursor, IoSlice, IoSliceMut, Read}; use crate::net::{Shutdown, SocketAddr}; use crate::os::windows::io::{ @@ -16,7 +17,7 @@ use crate::{cmp, mem, ptr, sys}; #[allow(non_camel_case_types)] pub type wrlen_t = i32; -pub mod netc { +pub(super) mod netc { //! BSD socket compatibility shim //! //! Some Windows API types are not quite what's expected by our cross-platform @@ -225,7 +226,7 @@ impl Socket { } pub fn connect(&self, addr: &SocketAddr) -> io::Result<()> { - let (addr, len) = addr.into_inner(); + let (addr, len) = socket_addr_to_c(addr); let result = unsafe { c::connect(self.as_raw(), addr.as_ptr(), len) }; cvt(result).map(drop) } @@ -401,12 +402,12 @@ impl Socket { let error = unsafe { c::WSAGetLastError() }; if error == c::WSAESHUTDOWN { - Ok((0, super::sockaddr_to_addr(&storage, addrlen as usize)?)) + Ok((0, unsafe { socket_addr_from_c(&storage, addrlen as usize)? })) } else { Err(io::Error::from_raw_os_error(error)) } } - _ => Ok((result as usize, super::sockaddr_to_addr(&storage, addrlen as usize)?)), + _ => Ok((result as usize, unsafe { socket_addr_from_c(&storage, addrlen as usize)? })), } } @@ -451,11 +452,11 @@ impl Socket { } None => 0, }; - super::setsockopt(self, c::SOL_SOCKET, kind, timeout) + setsockopt(self, c::SOL_SOCKET, kind, timeout) } pub fn timeout(&self, kind: c_int) -> io::Result> { - let raw: u32 = super::getsockopt(self, c::SOL_SOCKET, kind)?; + let raw: u32 = getsockopt(self, c::SOL_SOCKET, kind)?; if raw == 0 { Ok(None) } else { @@ -488,26 +489,26 @@ impl Socket { l_linger: linger.unwrap_or_default().as_secs() as c_ushort, }; - super::setsockopt(self, c::SOL_SOCKET, c::SO_LINGER, linger) + setsockopt(self, c::SOL_SOCKET, c::SO_LINGER, linger) } pub fn linger(&self) -> io::Result> { - let val: c::LINGER = super::getsockopt(self, c::SOL_SOCKET, c::SO_LINGER)?; + let val: c::LINGER = getsockopt(self, c::SOL_SOCKET, c::SO_LINGER)?; Ok((val.l_onoff != 0).then(|| Duration::from_secs(val.l_linger as u64))) } pub fn set_nodelay(&self, nodelay: bool) -> io::Result<()> { - super::setsockopt(self, c::IPPROTO_TCP, c::TCP_NODELAY, nodelay as c::BOOL) + setsockopt(self, c::IPPROTO_TCP, c::TCP_NODELAY, nodelay as c::BOOL) } pub fn nodelay(&self) -> io::Result { - let raw: c::BOOL = super::getsockopt(self, c::IPPROTO_TCP, c::TCP_NODELAY)?; + let raw: c::BOOL = getsockopt(self, c::IPPROTO_TCP, c::TCP_NODELAY)?; Ok(raw != 0) } pub fn take_error(&self) -> io::Result> { - let raw: c_int = super::getsockopt(self, c::SOL_SOCKET, c::SO_ERROR)?; + let raw: c_int = getsockopt(self, c::SOL_SOCKET, c::SO_ERROR)?; if raw == 0 { Ok(None) } else { Ok(Some(io::Error::from_raw_os_error(raw as i32))) } } diff --git a/std/src/sys/net/connection/uefi/mod.rs b/std/src/sys/net/connection/uefi/mod.rs index 87e6106468fdb..da2174396266f 100644 --- a/std/src/sys/net/connection/uefi/mod.rs +++ b/std/src/sys/net/connection/uefi/mod.rs @@ -332,38 +332,3 @@ impl<'a> TryFrom<(&'a str, u16)> for LookupHost { unsupported() } } - -#[allow(nonstandard_style)] -pub mod netc { - pub const AF_INET: u8 = 0; - pub const AF_INET6: u8 = 1; - pub type sa_family_t = u8; - - #[derive(Copy, Clone)] - pub struct in_addr { - pub s_addr: u32, - } - - #[derive(Copy, Clone)] - pub struct sockaddr_in { - #[allow(dead_code)] - pub sin_family: sa_family_t, - pub sin_port: u16, - pub sin_addr: in_addr, - } - - #[derive(Copy, Clone)] - pub struct in6_addr { - pub s6_addr: [u8; 16], - } - - #[derive(Copy, Clone)] - pub struct sockaddr_in6 { - #[allow(dead_code)] - pub sin6_family: sa_family_t, - pub sin6_port: u16, - pub sin6_addr: in6_addr, - pub sin6_flowinfo: u32, - pub sin6_scope_id: u32, - } -} diff --git a/std/src/sys/net/connection/unsupported.rs b/std/src/sys/net/connection/unsupported.rs index 87e6106468fdb..da2174396266f 100644 --- a/std/src/sys/net/connection/unsupported.rs +++ b/std/src/sys/net/connection/unsupported.rs @@ -332,38 +332,3 @@ impl<'a> TryFrom<(&'a str, u16)> for LookupHost { unsupported() } } - -#[allow(nonstandard_style)] -pub mod netc { - pub const AF_INET: u8 = 0; - pub const AF_INET6: u8 = 1; - pub type sa_family_t = u8; - - #[derive(Copy, Clone)] - pub struct in_addr { - pub s_addr: u32, - } - - #[derive(Copy, Clone)] - pub struct sockaddr_in { - #[allow(dead_code)] - pub sin_family: sa_family_t, - pub sin_port: u16, - pub sin_addr: in_addr, - } - - #[derive(Copy, Clone)] - pub struct in6_addr { - pub s6_addr: [u8; 16], - } - - #[derive(Copy, Clone)] - pub struct sockaddr_in6 { - #[allow(dead_code)] - pub sin6_family: sa_family_t, - pub sin6_port: u16, - pub sin6_addr: in6_addr, - pub sin6_flowinfo: u32, - pub sin6_scope_id: u32, - } -} diff --git a/std/src/sys/net/connection/wasip1.rs b/std/src/sys/net/connection/wasip1.rs index 27e3a528af497..951dc65e5b47d 100644 --- a/std/src/sys/net/connection/wasip1.rs +++ b/std/src/sys/net/connection/wasip1.rs @@ -505,38 +505,3 @@ impl<'a> TryFrom<(&'a str, u16)> for LookupHost { unsupported() } } - -#[allow(nonstandard_style)] -pub mod netc { - pub const AF_INET: u8 = 0; - pub const AF_INET6: u8 = 1; - pub type sa_family_t = u8; - - #[derive(Copy, Clone)] - pub struct in_addr { - pub s_addr: u32, - } - - #[derive(Copy, Clone)] - pub struct sockaddr_in { - #[allow(dead_code)] - pub sin_family: sa_family_t, - pub sin_port: u16, - pub sin_addr: in_addr, - } - - #[derive(Copy, Clone)] - pub struct in6_addr { - pub s6_addr: [u8; 16], - } - - #[derive(Copy, Clone)] - pub struct sockaddr_in6 { - #[allow(dead_code)] - pub sin6_family: sa_family_t, - pub sin6_port: u16, - pub sin6_addr: in6_addr, - pub sin6_flowinfo: u32, - pub sin6_scope_id: u32, - } -} diff --git a/std/src/sys/net/connection/xous/dns.rs b/std/src/sys/net/connection/xous/dns.rs index ff6e49ed2d430..bb29d211fad56 100644 --- a/std/src/sys/net/connection/xous/dns.rs +++ b/std/src/sys/net/connection/xous/dns.rs @@ -123,6 +123,6 @@ impl TryFrom<(&str, u16)> for LookupHost { type Error = io::Error; fn try_from(v: (&str, u16)) -> io::Result { - lookup(v.0, v.1).map_err(|_e| io::const_error!(io::ErrorKind::InvalidInput, &"DNS failure")) + lookup(v.0, v.1).map_err(|_e| io::const_error!(io::ErrorKind::InvalidInput, "DNS failure")) } } diff --git a/std/src/sys/net/connection/xous/mod.rs b/std/src/sys/net/connection/xous/mod.rs index 3e18ed24208d3..e44a375b9e3c5 100644 --- a/std/src/sys/net/connection/xous/mod.rs +++ b/std/src/sys/net/connection/xous/mod.rs @@ -46,38 +46,3 @@ pub struct GetAddress { } pub use dns::LookupHost; - -#[allow(nonstandard_style)] -pub mod netc { - pub const AF_INET: u8 = 0; - pub const AF_INET6: u8 = 1; - pub type sa_family_t = u8; - - #[derive(Copy, Clone)] - pub struct in_addr { - pub s_addr: u32, - } - - #[derive(Copy, Clone)] - pub struct sockaddr_in { - #[allow(dead_code)] - pub sin_family: sa_family_t, - pub sin_port: u16, - pub sin_addr: in_addr, - } - - #[derive(Copy, Clone)] - pub struct in6_addr { - pub s6_addr: [u8; 16], - } - - #[derive(Copy, Clone)] - pub struct sockaddr_in6 { - #[allow(dead_code)] - pub sin6_family: sa_family_t, - pub sin6_port: u16, - pub sin6_addr: in6_addr, - pub sin6_flowinfo: u32, - pub sin6_scope_id: u32, - } -} diff --git a/std/src/sys/net/connection/xous/tcplistener.rs b/std/src/sys/net/connection/xous/tcplistener.rs index 640a02a64f525..851d2eb8178d4 100644 --- a/std/src/sys/net/connection/xous/tcplistener.rs +++ b/std/src/sys/net/connection/xous/tcplistener.rs @@ -11,7 +11,7 @@ macro_rules! unimpl { () => { return Err(io::const_error!( io::ErrorKind::Unsupported, - &"This function is not yet implemented", + "This function is not yet implemented", )); }; } @@ -71,7 +71,7 @@ impl TcpListener { 0, 4096, ) else { - return Err(io::const_error!(io::ErrorKind::InvalidInput, &"Invalid response")); + return Err(io::const_error!(io::ErrorKind::InvalidInput, "Invalid response")); }; // The first four bytes should be zero upon success, and will be nonzero @@ -80,15 +80,15 @@ impl TcpListener { if response[0] != 0 || valid == 0 { let errcode = response[1]; if errcode == NetError::SocketInUse as u8 { - return Err(io::const_error!(io::ErrorKind::ResourceBusy, &"Socket in use")); + return Err(io::const_error!(io::ErrorKind::ResourceBusy, "Socket in use")); } else if errcode == NetError::Invalid as u8 { - return Err(io::const_error!(io::ErrorKind::AddrNotAvailable, &"Invalid address")); + return Err(io::const_error!(io::ErrorKind::AddrNotAvailable, "Invalid address")); } else if errcode == NetError::LibraryError as u8 { - return Err(io::const_error!(io::ErrorKind::Other, &"Library error")); + return Err(io::const_error!(io::ErrorKind::Other, "Library error")); } else { return Err(io::const_error!( io::ErrorKind::Other, - &"Unable to connect or internal error" + "Unable to connect or internal error", )); } } @@ -127,15 +127,13 @@ impl TcpListener { if receive_request.raw[0] != 0 { // error case if receive_request.raw[1] == NetError::TimedOut as u8 { - return Err(io::const_error!(io::ErrorKind::TimedOut, &"accept timed out",)); + return Err(io::const_error!(io::ErrorKind::TimedOut, "accept timed out")); } else if receive_request.raw[1] == NetError::WouldBlock as u8 { - return Err( - io::const_error!(io::ErrorKind::WouldBlock, &"accept would block",), - ); + return Err(io::const_error!(io::ErrorKind::WouldBlock, "accept would block")); } else if receive_request.raw[1] == NetError::LibraryError as u8 { - return Err(io::const_error!(io::ErrorKind::Other, &"Library error")); + return Err(io::const_error!(io::ErrorKind::Other, "Library error")); } else { - return Err(io::const_error!(io::ErrorKind::Other, &"library error",)); + return Err(io::const_error!(io::ErrorKind::Other, "library error")); } } else { // accept successful @@ -159,7 +157,7 @@ impl TcpListener { port, ) } else { - return Err(io::const_error!(io::ErrorKind::Other, &"library error",)); + return Err(io::const_error!(io::ErrorKind::Other, "library error")); }; // replenish the listener @@ -171,7 +169,7 @@ impl TcpListener { Ok((TcpStream::from_listener(stream_fd, self.local.port(), port, addr), addr)) } } else { - Err(io::const_error!(io::ErrorKind::InvalidInput, &"Unable to accept")) + Err(io::const_error!(io::ErrorKind::InvalidInput, "Unable to accept")) } } @@ -182,13 +180,13 @@ impl TcpListener { pub fn set_ttl(&self, ttl: u32) -> io::Result<()> { if ttl > 255 { - return Err(io::Error::new(io::ErrorKind::InvalidInput, "TTL must be less than 256")); + return Err(io::const_error!(io::ErrorKind::InvalidInput, "TTL must be less than 256")); } crate::os::xous::ffi::blocking_scalar( services::net_server(), services::NetBlockingScalar::StdSetTtlTcp(self.fd.load(Ordering::Relaxed), ttl).into(), ) - .or(Err(io::const_error!(io::ErrorKind::InvalidInput, &"Unexpected return value"))) + .or(Err(io::const_error!(io::ErrorKind::InvalidInput, "Unexpected return value"))) .map(|_| ()) } @@ -197,7 +195,7 @@ impl TcpListener { services::net_server(), services::NetBlockingScalar::StdGetTtlTcp(self.fd.load(Ordering::Relaxed)).into(), ) - .or(Err(io::const_error!(io::ErrorKind::InvalidInput, &"Unexpected return value"))) + .or(Err(io::const_error!(io::ErrorKind::InvalidInput, "Unexpected return value"))) .map(|res| res[0] as _)?) } diff --git a/std/src/sys/net/connection/xous/tcpstream.rs b/std/src/sys/net/connection/xous/tcpstream.rs index 572dd6b3b6398..7f7bbfb7fed34 100644 --- a/std/src/sys/net/connection/xous/tcpstream.rs +++ b/std/src/sys/net/connection/xous/tcpstream.rs @@ -12,7 +12,7 @@ macro_rules! unimpl { () => { return Err(io::const_error!( io::ErrorKind::Unsupported, - &"This function is not yet implemented", + "This function is not yet implemented", )); }; } @@ -96,7 +96,7 @@ impl TcpStream { 0, 4096, ) else { - return Err(io::const_error!(io::ErrorKind::InvalidInput, &"Invalid response")); + return Err(io::const_error!(io::ErrorKind::InvalidInput, "Invalid response")); }; // The first four bytes should be zero upon success, and will be nonzero @@ -106,13 +106,13 @@ impl TcpStream { // errcode is a u8 but stuck in a u16 where the upper byte is invalid. Mask & decode accordingly. let errcode = response[0]; if errcode == NetError::SocketInUse as u8 { - return Err(io::const_error!(io::ErrorKind::ResourceBusy, &"Socket in use",)); + return Err(io::const_error!(io::ErrorKind::ResourceBusy, "Socket in use")); } else if errcode == NetError::Unaddressable as u8 { - return Err(io::const_error!(io::ErrorKind::AddrNotAvailable, &"Invalid address",)); + return Err(io::const_error!(io::ErrorKind::AddrNotAvailable, "Invalid address")); } else { return Err(io::const_error!( io::ErrorKind::InvalidInput, - &"Unable to connect or internal error", + "Unable to connect or internal error", )); } } @@ -198,7 +198,7 @@ impl TcpStream { ) else { return Err(io::const_error!( io::ErrorKind::InvalidInput, - &"Library failure: wrong message type or messaging error" + "Library failure: wrong message type or messaging error", )); }; @@ -212,14 +212,14 @@ impl TcpStream { if result[0] != 0 { if result[1] == 8 { // timed out - return Err(io::const_error!(io::ErrorKind::TimedOut, &"Timeout",)); + return Err(io::const_error!(io::ErrorKind::TimedOut, "Timeout")); } if result[1] == 9 { // would block - return Err(io::const_error!(io::ErrorKind::WouldBlock, &"Would block",)); + return Err(io::const_error!(io::ErrorKind::WouldBlock, "Would block")); } } - Err(io::const_error!(io::ErrorKind::Other, &"recv_slice failure")) + Err(io::const_error!(io::ErrorKind::Other, "recv_slice failure")) } } @@ -258,20 +258,20 @@ impl TcpStream { self.write_timeout.load(Ordering::Relaxed) as usize, buf_len, ) - .or(Err(io::const_error!(io::ErrorKind::InvalidInput, &"Internal error")))?; + .or(Err(io::const_error!(io::ErrorKind::InvalidInput, "Internal error")))?; if send_request.raw[0] != 0 { if send_request.raw[4] == 8 { // timed out return Err(io::const_error!( io::ErrorKind::BrokenPipe, - &"Timeout or connection closed", + "Timeout or connection closed", )); } else if send_request.raw[4] == 9 { // would block - return Err(io::const_error!(io::ErrorKind::WouldBlock, &"Would block",)); + return Err(io::const_error!(io::ErrorKind::WouldBlock, "Would block")); } else { - return Err(io::const_error!(io::ErrorKind::InvalidInput, &"Error when sending",)); + return Err(io::const_error!(io::ErrorKind::InvalidInput, "Error when sending")); } } Ok(u32::from_le_bytes([ @@ -304,7 +304,7 @@ impl TcpStream { 0, 0, ) else { - return Err(io::const_error!(io::ErrorKind::InvalidInput, &"Internal error")); + return Err(io::const_error!(io::ErrorKind::InvalidInput, "Internal error")); }; let mut i = get_addr.raw.iter(); match *i.next().unwrap() { @@ -324,7 +324,7 @@ impl TcpStream { } Ok(SocketAddr::V6(SocketAddrV6::new(new_addr.into(), self.local_port, 0, 0))) } - _ => Err(io::const_error!(io::ErrorKind::InvalidInput, &"Internal error")), + _ => Err(io::const_error!(io::ErrorKind::InvalidInput, "Internal error")), } } @@ -333,7 +333,7 @@ impl TcpStream { services::net_server(), services::NetBlockingScalar::StdTcpStreamShutdown(self.fd, how).into(), ) - .or(Err(io::const_error!(io::ErrorKind::InvalidInput, &"Unexpected return value"))) + .or(Err(io::const_error!(io::ErrorKind::InvalidInput, "Unexpected return value"))) .map(|_| ()) } @@ -355,7 +355,7 @@ impl TcpStream { services::net_server(), services::NetBlockingScalar::StdSetNodelay(self.fd, enabled).into(), ) - .or(Err(io::const_error!(io::ErrorKind::InvalidInput, &"Unexpected return value"))) + .or(Err(io::const_error!(io::ErrorKind::InvalidInput, "Unexpected return value"))) .map(|_| ()) } @@ -364,19 +364,19 @@ impl TcpStream { services::net_server(), services::NetBlockingScalar::StdGetNodelay(self.fd).into(), ) - .or(Err(io::const_error!(io::ErrorKind::InvalidInput, &"Unexpected return value"))) + .or(Err(io::const_error!(io::ErrorKind::InvalidInput, "Unexpected return value"))) .map(|res| res[0] != 0)?) } pub fn set_ttl(&self, ttl: u32) -> io::Result<()> { if ttl > 255 { - return Err(io::Error::new(io::ErrorKind::InvalidInput, "TTL must be less than 256")); + return Err(io::const_error!(io::ErrorKind::InvalidInput, "TTL must be less than 256")); } crate::os::xous::ffi::blocking_scalar( services::net_server(), services::NetBlockingScalar::StdSetTtlTcp(self.fd, ttl).into(), ) - .or(Err(io::const_error!(io::ErrorKind::InvalidInput, &"Unexpected return value"))) + .or(Err(io::const_error!(io::ErrorKind::InvalidInput, "Unexpected return value"))) .map(|_| ()) } @@ -385,7 +385,7 @@ impl TcpStream { services::net_server(), services::NetBlockingScalar::StdGetTtlTcp(self.fd).into(), ) - .or(Err(io::const_error!(io::ErrorKind::InvalidInput, &"Unexpected return value"))) + .or(Err(io::const_error!(io::ErrorKind::InvalidInput, "Unexpected return value"))) .map(|res| res[0] as _)?) } diff --git a/std/src/sys/net/connection/xous/udp.rs b/std/src/sys/net/connection/xous/udp.rs index 1b7ecac6d3a7e..ab5bd357b6123 100644 --- a/std/src/sys/net/connection/xous/udp.rs +++ b/std/src/sys/net/connection/xous/udp.rs @@ -13,7 +13,7 @@ macro_rules! unimpl { () => { return Err(io::const_error!( io::ErrorKind::Unsupported, - &"This function is not yet implemented", + "This function is not yet implemented", )); }; } @@ -72,18 +72,18 @@ impl UdpSocket { if response[0] != 0 || valid == 0 { let errcode = response[1]; if errcode == NetError::SocketInUse as u8 { - return Err(io::const_error!(io::ErrorKind::ResourceBusy, &"Socket in use")); + return Err(io::const_error!(io::ErrorKind::ResourceBusy, "Socket in use")); } else if errcode == NetError::Invalid as u8 { return Err(io::const_error!( io::ErrorKind::InvalidInput, - &"Port can't be 0 or invalid address" + "Port can't be 0 or invalid address", )); } else if errcode == NetError::LibraryError as u8 { - return Err(io::const_error!(io::ErrorKind::Other, &"Library error")); + return Err(io::const_error!(io::ErrorKind::Other, "Library error")); } else { return Err(io::const_error!( io::ErrorKind::Other, - &"Unable to connect or internal error" + "Unable to connect or internal error", )); } } @@ -98,13 +98,13 @@ impl UdpSocket { nonblocking: Cell::new(false), }); } - Err(io::const_error!(io::ErrorKind::InvalidInput, &"Invalid response")) + Err(io::const_error!(io::ErrorKind::InvalidInput, "Invalid response")) } pub fn peer_addr(&self) -> io::Result { match self.remote.get() { Some(dest) => Ok(dest), - None => Err(io::const_error!(io::ErrorKind::NotConnected, &"No peer specified")), + None => Err(io::const_error!(io::ErrorKind::NotConnected, "No peer specified")), } } @@ -141,13 +141,13 @@ impl UdpSocket { if receive_request.raw[0] != 0 { // error case if receive_request.raw[1] == NetError::TimedOut as u8 { - return Err(io::const_error!(io::ErrorKind::TimedOut, &"recv timed out",)); + return Err(io::const_error!(io::ErrorKind::TimedOut, "recv timed out")); } else if receive_request.raw[1] == NetError::WouldBlock as u8 { - return Err(io::const_error!(io::ErrorKind::WouldBlock, &"recv would block",)); + return Err(io::const_error!(io::ErrorKind::WouldBlock, "recv would block")); } else if receive_request.raw[1] == NetError::LibraryError as u8 { - return Err(io::const_error!(io::ErrorKind::Other, &"Library error")); + return Err(io::const_error!(io::ErrorKind::Other, "Library error")); } else { - return Err(io::const_error!(io::ErrorKind::Other, &"library error",)); + return Err(io::const_error!(io::ErrorKind::Other, "library error")); } } else { let rr = &receive_request.raw; @@ -170,7 +170,7 @@ impl UdpSocket { port, ) } else { - return Err(io::const_error!(io::ErrorKind::Other, &"library error",)); + return Err(io::const_error!(io::ErrorKind::Other, "library error")); }; for (&s, d) in rr[22..22 + rxlen as usize].iter().zip(buf.iter_mut()) { *d = s; @@ -178,7 +178,7 @@ impl UdpSocket { Ok((rxlen as usize, addr)) } } else { - Err(io::const_error!(io::ErrorKind::InvalidInput, &"Unable to recv")) + Err(io::const_error!(io::ErrorKind::InvalidInput, "Unable to recv")) } } @@ -208,7 +208,7 @@ impl UdpSocket { if let Some(addr) = self.remote.get() { self.send_to(buf, &addr) } else { - Err(io::const_error!(io::ErrorKind::NotConnected, &"No remote specified")) + Err(io::const_error!(io::ErrorKind::NotConnected, "No remote specified")) } } @@ -281,19 +281,19 @@ impl UdpSocket { if errcode == NetError::SocketInUse as u8 { return Err(io::const_error!( io::ErrorKind::ResourceBusy, - &"Socket in use" + "Socket in use", )); } else if errcode == NetError::Invalid as u8 { return Err(io::const_error!( io::ErrorKind::InvalidInput, - &"Socket not valid" + "Socket not valid", )); } else if errcode == NetError::LibraryError as u8 { - return Err(io::const_error!(io::ErrorKind::Other, &"Library error")); + return Err(io::const_error!(io::ErrorKind::Other, "Library error")); } else { return Err(io::const_error!( io::ErrorKind::Other, - &"Unable to connect" + "Unable to connect", )); } } else { @@ -303,16 +303,13 @@ impl UdpSocket { } Err(crate::os::xous::ffi::Error::ServerQueueFull) => { if now.elapsed() >= write_timeout { - return Err(io::const_error!( - io::ErrorKind::WouldBlock, - &"Write timed out" - )); + return Err(io::const_error!(io::ErrorKind::WouldBlock, "Write timed out")); } else { // question: do we want to do something a bit more gentle than immediately retrying? crate::thread::yield_now(); } } - _ => return Err(io::const_error!(io::ErrorKind::Other, &"Library error")), + _ => return Err(io::const_error!(io::ErrorKind::Other, "Library error")), } } } @@ -360,13 +357,13 @@ impl UdpSocket { pub fn set_ttl(&self, ttl: u32) -> io::Result<()> { if ttl > 255 { - return Err(io::Error::new(io::ErrorKind::InvalidInput, "TTL must be less than 256")); + return Err(io::const_error!(io::ErrorKind::InvalidInput, "TTL must be less than 256")); } crate::os::xous::ffi::blocking_scalar( services::net_server(), services::NetBlockingScalar::StdSetTtlUdp(self.fd, ttl).into(), ) - .or(Err(io::const_error!(io::ErrorKind::InvalidInput, &"Unexpected return value"))) + .or(Err(io::const_error!(io::ErrorKind::InvalidInput, "Unexpected return value"))) .map(|_| ()) } @@ -375,7 +372,7 @@ impl UdpSocket { services::net_server(), services::NetBlockingScalar::StdGetTtlUdp(self.fd).into(), ) - .or(Err(io::const_error!(io::ErrorKind::InvalidInput, &"Unexpected return value"))) + .or(Err(io::const_error!(io::ErrorKind::InvalidInput, "Unexpected return value"))) .map(|res| res[0] as _)?) } @@ -441,7 +438,7 @@ impl UdpSocket { impl fmt::Debug for UdpSocket { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!(f, "UDP listening on {:?} to {:?}", self.local, self.remote.get(),) + write!(f, "UDP listening on {:?} to {:?}", self.local, self.remote.get()) } } diff --git a/std/src/sys/os_str/bytes.rs b/std/src/sys/os_str/bytes.rs index 5b65d862be102..1d337694944bc 100644 --- a/std/src/sys/os_str/bytes.rs +++ b/std/src/sys/os_str/bytes.rs @@ -8,7 +8,7 @@ use crate::collections::TryReserveError; use crate::fmt::Write; use crate::rc::Rc; use crate::sync::Arc; -use crate::sys_common::{AsInner, IntoInner}; +use crate::sys_common::{AsInner, FromInner, IntoInner}; use crate::{fmt, mem, str}; #[cfg(test)] @@ -25,6 +25,37 @@ pub struct Slice { pub inner: [u8], } +impl IntoInner> for Buf { + fn into_inner(self) -> Vec { + self.inner + } +} + +impl FromInner> for Buf { + fn from_inner(inner: Vec) -> Self { + Buf { inner } + } +} + +impl AsInner<[u8]> for Buf { + #[inline] + fn as_inner(&self) -> &[u8] { + &self.inner + } +} + +impl fmt::Debug for Buf { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + fmt::Debug::fmt(self.as_slice(), f) + } +} + +impl fmt::Display for Buf { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + fmt::Display::fmt(self.as_slice(), f) + } +} + impl fmt::Debug for Slice { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fmt::Debug::fmt(&self.inner.utf8_chunks().debug(), f) @@ -55,18 +86,6 @@ impl fmt::Display for Slice { } } -impl fmt::Debug for Buf { - fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { - fmt::Debug::fmt(self.as_slice(), formatter) - } -} - -impl fmt::Display for Buf { - fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { - fmt::Display::fmt(self.as_slice(), formatter) - } -} - impl Clone for Buf { #[inline] fn clone(&self) -> Self { @@ -79,19 +98,6 @@ impl Clone for Buf { } } -impl IntoInner> for Buf { - fn into_inner(self) -> Vec { - self.inner - } -} - -impl AsInner<[u8]> for Buf { - #[inline] - fn as_inner(&self) -> &[u8] { - &self.inner - } -} - impl Buf { #[inline] pub fn into_encoded_bytes(self) -> Vec { @@ -103,6 +109,12 @@ impl Buf { Self { inner: s } } + #[inline] + pub fn into_string(self) -> Result { + String::from_utf8(self.inner).map_err(|p| Buf { inner: p.into_bytes() }) + } + + #[inline] pub fn from_string(s: String) -> Buf { Buf { inner: s.into_bytes() } } @@ -122,6 +134,11 @@ impl Buf { self.inner.capacity() } + #[inline] + pub fn push_slice(&mut self, s: &Slice) { + self.inner.extend_from_slice(&s.inner) + } + #[inline] pub fn reserve(&mut self, additional: usize) { self.inner.reserve(additional) @@ -157,7 +174,7 @@ impl Buf { // SAFETY: Slice just wraps [u8], // and &*self.inner is &[u8], therefore // transmuting &[u8] to &Slice is safe. - unsafe { mem::transmute(&*self.inner) } + unsafe { mem::transmute(self.inner.as_slice()) } } #[inline] @@ -165,15 +182,7 @@ impl Buf { // SAFETY: Slice just wraps [u8], // and &mut *self.inner is &mut [u8], therefore // transmuting &mut [u8] to &mut Slice is safe. - unsafe { mem::transmute(&mut *self.inner) } - } - - pub fn into_string(self) -> Result { - String::from_utf8(self.inner).map_err(|p| Buf { inner: p.into_bytes() }) - } - - pub fn push_slice(&mut self, s: &Slice) { - self.inner.extend_from_slice(&s.inner) + unsafe { mem::transmute(self.inner.as_mut_slice()) } } #[inline] @@ -278,18 +287,22 @@ impl Slice { unsafe { Slice::from_encoded_bytes_unchecked(s.as_bytes()) } } + #[inline] pub fn to_str(&self) -> Result<&str, crate::str::Utf8Error> { str::from_utf8(&self.inner) } + #[inline] pub fn to_string_lossy(&self) -> Cow<'_, str> { String::from_utf8_lossy(&self.inner) } + #[inline] pub fn to_owned(&self) -> Buf { Buf { inner: self.inner.to_vec() } } + #[inline] pub fn clone_into(&self, buf: &mut Buf) { self.inner.clone_into(&mut buf.inner) } @@ -300,6 +313,7 @@ impl Slice { unsafe { mem::transmute(boxed) } } + #[inline] pub fn empty_box() -> Box { let boxed: Box<[u8]> = Default::default(); unsafe { mem::transmute(boxed) } diff --git a/std/src/sys/os_str/wtf8.rs b/std/src/sys/os_str/wtf8.rs index a4ad5966afe57..8acec6f949fc5 100644 --- a/std/src/sys/os_str/wtf8.rs +++ b/std/src/sys/os_str/wtf8.rs @@ -10,11 +10,16 @@ use crate::sys_common::wtf8::{Wtf8, Wtf8Buf, check_utf8_boundary}; use crate::sys_common::{AsInner, FromInner, IntoInner}; use crate::{fmt, mem}; -#[derive(Clone, Hash)] +#[derive(Hash)] pub struct Buf { pub inner: Wtf8Buf, } +#[repr(transparent)] +pub struct Slice { + pub inner: Wtf8, +} + impl IntoInner for Buf { fn into_inner(self) -> Wtf8Buf { self.inner @@ -35,31 +40,38 @@ impl AsInner for Buf { } impl fmt::Debug for Buf { - fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { - fmt::Debug::fmt(self.as_slice(), formatter) + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + fmt::Debug::fmt(&self.inner, f) } } impl fmt::Display for Buf { - fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { - fmt::Display::fmt(self.as_slice(), formatter) + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + fmt::Display::fmt(&self.inner, f) } } -#[repr(transparent)] -pub struct Slice { - pub inner: Wtf8, -} - impl fmt::Debug for Slice { - fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { - fmt::Debug::fmt(&self.inner, formatter) + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + fmt::Debug::fmt(&self.inner, f) } } impl fmt::Display for Slice { - fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { - fmt::Display::fmt(&self.inner, formatter) + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + fmt::Display::fmt(&self.inner, f) + } +} + +impl Clone for Buf { + #[inline] + fn clone(&self) -> Self { + Buf { inner: self.inner.clone() } + } + + #[inline] + fn clone_from(&mut self, source: &Self) { + self.inner.clone_from(&source.inner) } } @@ -74,62 +86,57 @@ impl Buf { unsafe { Self { inner: Wtf8Buf::from_bytes_unchecked(s) } } } - pub fn with_capacity(capacity: usize) -> Buf { - Buf { inner: Wtf8Buf::with_capacity(capacity) } - } - - pub fn clear(&mut self) { - self.inner.clear() - } - - pub fn capacity(&self) -> usize { - self.inner.capacity() + #[inline] + pub fn into_string(self) -> Result { + self.inner.into_string().map_err(|buf| Buf { inner: buf }) } + #[inline] pub fn from_string(s: String) -> Buf { Buf { inner: Wtf8Buf::from_string(s) } } - pub fn as_slice(&self) -> &Slice { - // SAFETY: Slice is just a wrapper for Wtf8, - // and self.inner.as_slice() returns &Wtf8. - // Therefore, transmuting &Wtf8 to &Slice is safe. - unsafe { mem::transmute(self.inner.as_slice()) } + #[inline] + pub fn with_capacity(capacity: usize) -> Buf { + Buf { inner: Wtf8Buf::with_capacity(capacity) } } - pub fn as_mut_slice(&mut self) -> &mut Slice { - // SAFETY: Slice is just a wrapper for Wtf8, - // and self.inner.as_mut_slice() returns &mut Wtf8. - // Therefore, transmuting &mut Wtf8 to &mut Slice is safe. - // Additionally, care should be taken to ensure the slice - // is always valid Wtf8. - unsafe { mem::transmute(self.inner.as_mut_slice()) } + #[inline] + pub fn clear(&mut self) { + self.inner.clear() } - pub fn into_string(self) -> Result { - self.inner.into_string().map_err(|buf| Buf { inner: buf }) + #[inline] + pub fn capacity(&self) -> usize { + self.inner.capacity() } + #[inline] pub fn push_slice(&mut self, s: &Slice) { self.inner.push_wtf8(&s.inner) } + #[inline] pub fn reserve(&mut self, additional: usize) { self.inner.reserve(additional) } + #[inline] pub fn try_reserve(&mut self, additional: usize) -> Result<(), TryReserveError> { self.inner.try_reserve(additional) } + #[inline] pub fn reserve_exact(&mut self, additional: usize) { self.inner.reserve_exact(additional) } + #[inline] pub fn try_reserve_exact(&mut self, additional: usize) -> Result<(), TryReserveError> { self.inner.try_reserve_exact(additional) } + #[inline] pub fn shrink_to_fit(&mut self) { self.inner.shrink_to_fit() } @@ -139,6 +146,24 @@ impl Buf { self.inner.shrink_to(min_capacity) } + #[inline] + pub fn as_slice(&self) -> &Slice { + // SAFETY: Slice is just a wrapper for Wtf8, + // and self.inner.as_slice() returns &Wtf8. + // Therefore, transmuting &Wtf8 to &Slice is safe. + unsafe { mem::transmute(self.inner.as_slice()) } + } + + #[inline] + pub fn as_mut_slice(&mut self) -> &mut Slice { + // SAFETY: Slice is just a wrapper for Wtf8, + // and self.inner.as_mut_slice() returns &mut Wtf8. + // Therefore, transmuting &mut Wtf8 to &mut Slice is safe. + // Additionally, care should be taken to ensure the slice + // is always valid Wtf8. + unsafe { mem::transmute(self.inner.as_mut_slice()) } + } + #[inline] pub fn leak<'a>(self) -> &'a mut Slice { unsafe { mem::transmute(self.inner.leak()) } @@ -194,6 +219,7 @@ impl Slice { } #[track_caller] + #[inline] pub fn check_public_boundary(&self, index: usize) { check_utf8_boundary(&self.inner, index); } @@ -203,18 +229,22 @@ impl Slice { unsafe { mem::transmute(Wtf8::from_str(s)) } } + #[inline] pub fn to_str(&self) -> Result<&str, crate::str::Utf8Error> { self.inner.as_str() } + #[inline] pub fn to_string_lossy(&self) -> Cow<'_, str> { self.inner.to_string_lossy() } + #[inline] pub fn to_owned(&self) -> Buf { Buf { inner: self.inner.to_owned() } } + #[inline] pub fn clone_into(&self, buf: &mut Buf) { self.inner.clone_into(&mut buf.inner) } @@ -224,6 +254,7 @@ impl Slice { unsafe { mem::transmute(self.inner.into_box()) } } + #[inline] pub fn empty_box() -> Box { unsafe { mem::transmute(Wtf8::empty_box()) } } diff --git a/std/src/sys/pal/hermit/fs.rs b/std/src/sys/pal/hermit/fs.rs index 783623552bb17..d4bf84dc1854c 100644 --- a/std/src/sys/pal/hermit/fs.rs +++ b/std/src/sys/pal/hermit/fs.rs @@ -304,16 +304,12 @@ impl OpenOptions { (true, false) => {} (false, false) => { if self.truncate || self.create || self.create_new { - return Err( - io::const_error!(ErrorKind::InvalidInput, "invalid creation mode",), - ); + return Err(io::const_error!(ErrorKind::InvalidInput, "invalid creation mode")); } } (_, true) => { if self.truncate && !self.create_new { - return Err( - io::const_error!(ErrorKind::InvalidInput, "invalid creation mode",), - ); + return Err(io::const_error!(ErrorKind::InvalidInput, "invalid creation mode")); } } } @@ -425,6 +421,10 @@ impl File { Err(Error::from_raw_os_error(22)) } + pub fn tell(&self) -> io::Result { + self.seek(SeekFrom::Current(0)) + } + pub fn duplicate(&self) -> io::Result { Err(Error::from_raw_os_error(22)) } diff --git a/std/src/sys/pal/hermit/mod.rs b/std/src/sys/pal/hermit/mod.rs index 3d555ad5050c2..21cbac643bbec 100644 --- a/std/src/sys/pal/hermit/mod.rs +++ b/std/src/sys/pal/hermit/mod.rs @@ -53,7 +53,7 @@ pub fn abort_internal() -> ! { // This function is needed by the panic runtime. The symbol is named in // pre-link args for the target specification, so keep that in sync. #[cfg(not(test))] -#[no_mangle] +#[unsafe(no_mangle)] // NB. used by both libunwind and libpanic_abort pub extern "C" fn __rust_abort() { abort_internal(); @@ -72,13 +72,13 @@ pub unsafe fn init(argc: isize, argv: *const *const u8, _sigpipe: u8) { pub unsafe fn cleanup() {} #[cfg(not(test))] -#[no_mangle] +#[unsafe(no_mangle)] pub unsafe extern "C" fn runtime_entry( argc: i32, argv: *const *const c_char, env: *const *const c_char, ) -> ! { - extern "C" { + unsafe extern "C" { fn main(argc: isize, argv: *const *const c_char) -> i32; } diff --git a/std/src/sys/pal/itron/abi.rs b/std/src/sys/pal/itron/abi.rs index 5eb14bb7e534b..49b5251fc0eb6 100644 --- a/std/src/sys/pal/itron/abi.rs +++ b/std/src/sys/pal/itron/abi.rs @@ -132,7 +132,7 @@ pub struct T_CTSK { pub stk: *mut u8, } -extern "C" { +unsafe extern "C" { #[link_name = "__asp3_acre_tsk"] pub fn acre_tsk(pk_ctsk: *const T_CTSK) -> ER_ID; #[link_name = "__asp3_get_tid"] diff --git a/std/src/sys/pal/sgx/abi/mem.rs b/std/src/sys/pal/sgx/abi/mem.rs index 18e6d5b3fa24d..e6ce15bed3cfd 100644 --- a/std/src/sys/pal/sgx/abi/mem.rs +++ b/std/src/sys/pal/sgx/abi/mem.rs @@ -12,7 +12,7 @@ pub(crate) unsafe fn rel_ptr_mut(offset: u64) -> *mut T { (image_base() + offset) as *mut T } -extern "C" { +unsafe extern "C" { static ENCLAVE_SIZE: usize; static HEAP_BASE: u64; static HEAP_SIZE: usize; diff --git a/std/src/sys/pal/sgx/abi/mod.rs b/std/src/sys/pal/sgx/abi/mod.rs index d8836452e7555..90981bd6a6a04 100644 --- a/std/src/sys/pal/sgx/abi/mod.rs +++ b/std/src/sys/pal/sgx/abi/mod.rs @@ -23,7 +23,7 @@ global_asm!(include_str!("entry.S"), options(att_syntax)); struct EntryReturn(u64, u64); #[cfg(not(test))] -#[no_mangle] +#[unsafe(no_mangle)] unsafe extern "C" fn tcs_init(secondary: bool) { // Be very careful when changing this code: it runs before the binary has been // relocated. Any indirect accesses to symbols will likely fail. @@ -60,7 +60,7 @@ unsafe extern "C" fn tcs_init(secondary: bool) { // (main function exists). If this is a library, the crate author should be // able to specify this #[cfg(not(test))] -#[no_mangle] +#[unsafe(no_mangle)] extern "C" fn entry(p1: u64, p2: u64, p3: u64, secondary: bool, p4: u64, p5: u64) -> EntryReturn { // FIXME: how to support TLS in library mode? let tls = Box::new(tls::Tls::new()); @@ -73,7 +73,7 @@ extern "C" fn entry(p1: u64, p2: u64, p3: u64, secondary: bool, p4: u64, p5: u64 EntryReturn(0, 0) } else { - extern "C" { + unsafe extern "C" { fn main(argc: isize, argv: *const *const u8) -> isize; } @@ -103,7 +103,7 @@ pub(super) fn exit_with_code(code: isize) -> ! { } #[cfg(not(test))] -#[no_mangle] +#[unsafe(no_mangle)] extern "C" fn abort_reentry() -> ! { usercalls::exit(false) } diff --git a/std/src/sys/pal/sgx/abi/panic.rs b/std/src/sys/pal/sgx/abi/panic.rs index c06b97ee3674a..67af062b0fffe 100644 --- a/std/src/sys/pal/sgx/abi/panic.rs +++ b/std/src/sys/pal/sgx/abi/panic.rs @@ -2,7 +2,7 @@ use super::usercalls::alloc::UserRef; use crate::io::{self, Write}; use crate::{cmp, mem}; -extern "C" { +unsafe extern "C" { fn take_debug_panic_buf_ptr() -> *mut u8; static DEBUG: u8; } diff --git a/std/src/sys/pal/sgx/abi/reloc.rs b/std/src/sys/pal/sgx/abi/reloc.rs index 02dff0ad29fc3..a4f5e4a0936f4 100644 --- a/std/src/sys/pal/sgx/abi/reloc.rs +++ b/std/src/sys/pal/sgx/abi/reloc.rs @@ -11,7 +11,7 @@ struct Rela { } pub fn relocate_elf_rela() { - extern "C" { + unsafe extern "C" { static RELA: u64; static RELACOUNT: usize; } diff --git a/std/src/sys/pal/sgx/abi/thread.rs b/std/src/sys/pal/sgx/abi/thread.rs index 2b23e368cc31a..9b37e2baf3642 100644 --- a/std/src/sys/pal/sgx/abi/thread.rs +++ b/std/src/sys/pal/sgx/abi/thread.rs @@ -6,7 +6,7 @@ use fortanix_sgx_abi::Tcs; /// is a one-to-one correspondence of the ID to the address of the TCS. #[unstable(feature = "sgx_platform", issue = "56975")] pub fn current() -> Tcs { - extern "C" { + unsafe extern "C" { fn get_tcs_addr() -> *mut u8; } let addr = unsafe { get_tcs_addr() }; diff --git a/std/src/sys/pal/sgx/abi/tls/mod.rs b/std/src/sys/pal/sgx/abi/tls/mod.rs index 34fc2f20d2214..8e2b271f1c970 100644 --- a/std/src/sys/pal/sgx/abi/tls/mod.rs +++ b/std/src/sys/pal/sgx/abi/tls/mod.rs @@ -12,17 +12,17 @@ const TLS_KEYS: usize = 128; // Same as POSIX minimum const TLS_KEYS_BITSET_SIZE: usize = (TLS_KEYS + (USIZE_BITS - 1)) / USIZE_BITS; #[cfg_attr(test, linkage = "available_externally")] -#[export_name = "_ZN16__rust_internals3std3sys3sgx3abi3tls14TLS_KEY_IN_USEE"] +#[unsafe(export_name = "_ZN16__rust_internals3std3sys3sgx3abi3tls14TLS_KEY_IN_USEE")] static TLS_KEY_IN_USE: SyncBitset = SYNC_BITSET_INIT; macro_rules! dup { ((* $($exp:tt)*) $($val:tt)*) => (dup!( ($($exp)*) $($val)* $($val)* )); (() $($val:tt)*) => ([$($val),*]) } #[cfg_attr(test, linkage = "available_externally")] -#[export_name = "_ZN16__rust_internals3std3sys3sgx3abi3tls14TLS_DESTRUCTORE"] +#[unsafe(export_name = "_ZN16__rust_internals3std3sys3sgx3abi3tls14TLS_DESTRUCTORE")] static TLS_DESTRUCTOR: [AtomicUsize; TLS_KEYS] = dup!((* * * * * * *) (AtomicUsize::new(0))); -extern "C" { +unsafe extern "C" { fn get_tls_ptr() -> *const u8; fn set_tls_ptr(tls: *const u8); } diff --git a/std/src/sys/pal/sgx/abi/usercalls/raw.rs b/std/src/sys/pal/sgx/abi/usercalls/raw.rs index 943b771498f8f..28fbbc3c51816 100644 --- a/std/src/sys/pal/sgx/abi/usercalls/raw.rs +++ b/std/src/sys/pal/sgx/abi/usercalls/raw.rs @@ -9,7 +9,7 @@ use crate::ptr::NonNull; #[repr(C)] struct UsercallReturn(u64, u64); -extern "C" { +unsafe extern "C" { fn usercall(nr: NonZero, p1: u64, p2: u64, abort: u64, p3: u64, p4: u64) -> UsercallReturn; } diff --git a/std/src/sys/pal/sgx/args.rs b/std/src/sys/pal/sgx/args.rs index a72a041da6cc9..e62bf383954eb 100644 --- a/std/src/sys/pal/sgx/args.rs +++ b/std/src/sys/pal/sgx/args.rs @@ -7,7 +7,7 @@ use crate::sys_common::FromInner; use crate::{fmt, slice}; #[cfg_attr(test, linkage = "available_externally")] -#[export_name = "_ZN16__rust_internals3std3sys3sgx4args4ARGSE"] +#[unsafe(export_name = "_ZN16__rust_internals3std3sys3sgx4args4ARGSE")] static ARGS: AtomicUsize = AtomicUsize::new(0); type ArgsStore = Vec; diff --git a/std/src/sys/pal/sgx/libunwind_integration.rs b/std/src/sys/pal/sgx/libunwind_integration.rs index debfd324c864e..6d0d78d1eb9b5 100644 --- a/std/src/sys/pal/sgx/libunwind_integration.rs +++ b/std/src/sys/pal/sgx/libunwind_integration.rs @@ -15,7 +15,7 @@ const _: () = unsafe { const EINVAL: i32 = 22; -#[no_mangle] +#[unsafe(no_mangle)] pub unsafe extern "C" fn __rust_rwlock_rdlock(p: *mut RwLock) -> i32 { if p.is_null() { return EINVAL; @@ -27,7 +27,7 @@ pub unsafe extern "C" fn __rust_rwlock_rdlock(p: *mut RwLock) -> i32 { return 0; } -#[no_mangle] +#[unsafe(no_mangle)] pub unsafe extern "C" fn __rust_rwlock_wrlock(p: *mut RwLock) -> i32 { if p.is_null() { return EINVAL; @@ -36,7 +36,7 @@ pub unsafe extern "C" fn __rust_rwlock_wrlock(p: *mut RwLock) -> i32 { return 0; } -#[no_mangle] +#[unsafe(no_mangle)] pub unsafe extern "C" fn __rust_rwlock_unlock(p: *mut RwLock) -> i32 { if p.is_null() { return EINVAL; diff --git a/std/src/sys/pal/sgx/mod.rs b/std/src/sys/pal/sgx/mod.rs index 9a04fa4b97e19..37ca6b08c950b 100644 --- a/std/src/sys/pal/sgx/mod.rs +++ b/std/src/sys/pal/sgx/mod.rs @@ -123,7 +123,7 @@ pub fn abort_internal() -> ! { // This function is needed by the panic runtime. The symbol is named in // pre-link args for the target specification, so keep that in sync. #[cfg(not(test))] -#[no_mangle] +#[unsafe(no_mangle)] // NB. used by both libunwind and libpanic_abort pub extern "C" fn __rust_abort() { abort_internal(); diff --git a/std/src/sys/pal/sgx/os.rs b/std/src/sys/pal/sgx/os.rs index 46af710aa396c..b1ec2afd764e6 100644 --- a/std/src/sys/pal/sgx/os.rs +++ b/std/src/sys/pal/sgx/os.rs @@ -74,10 +74,10 @@ pub fn current_exe() -> io::Result { } #[cfg_attr(test, linkage = "available_externally")] -#[export_name = "_ZN16__rust_internals3std3sys3sgx2os3ENVE"] +#[unsafe(export_name = "_ZN16__rust_internals3std3sys3sgx2os3ENVE")] static ENV: AtomicUsize = AtomicUsize::new(0); #[cfg_attr(test, linkage = "available_externally")] -#[export_name = "_ZN16__rust_internals3std3sys3sgx2os8ENV_INITE"] +#[unsafe(export_name = "_ZN16__rust_internals3std3sys3sgx2os8ENV_INITE")] static ENV_INIT: Once = Once::new(); type EnvStore = Mutex>; diff --git a/std/src/sys/pal/sgx/stdio.rs b/std/src/sys/pal/sgx/stdio.rs index e79a3d971c6be..726a93acae44b 100644 --- a/std/src/sys/pal/sgx/stdio.rs +++ b/std/src/sys/pal/sgx/stdio.rs @@ -76,7 +76,7 @@ pub fn panic_output() -> Option { // This function is needed by libunwind. The symbol is named in pre-link args // for the target specification, so keep that in sync. #[cfg(not(test))] -#[no_mangle] +#[unsafe(no_mangle)] pub unsafe extern "C" fn __rust_print_err(m: *mut u8, s: i32) { if s < 0 { return; diff --git a/std/src/sys/pal/sgx/thread.rs b/std/src/sys/pal/sgx/thread.rs index cecd53c352c5a..b6932df431f42 100644 --- a/std/src/sys/pal/sgx/thread.rs +++ b/std/src/sys/pal/sgx/thread.rs @@ -46,7 +46,7 @@ mod task_queue { } #[cfg_attr(test, linkage = "available_externally")] - #[export_name = "_ZN16__rust_internals3std3sys3sgx6thread10TASK_QUEUEE"] + #[unsafe(export_name = "_ZN16__rust_internals3std3sys3sgx6thread10TASK_QUEUEE")] static TASK_QUEUE: Mutex> = Mutex::new(Vec::new()); pub(super) fn lock() -> MutexGuard<'static, Vec> { diff --git a/std/src/sys/pal/solid/abi/fs.rs b/std/src/sys/pal/solid/abi/fs.rs index 6864a3e7745b9..7f2b1f83e8561 100644 --- a/std/src/sys/pal/solid/abi/fs.rs +++ b/std/src/sys/pal/solid/abi/fs.rs @@ -31,7 +31,7 @@ pub const DT_WHT: c_uchar = 14; pub type S_DIR = c_int; -extern "C" { +unsafe extern "C" { pub fn SOLID_FS_Open(fd: *mut c_int, path: *const c_char, mode: c_int) -> c_int; pub fn SOLID_FS_Close(fd: c_int) -> c_int; pub fn SOLID_FS_Read(fd: c_int, buf: *mut u8, size: usize, result: *mut usize) -> c_int; diff --git a/std/src/sys/pal/solid/abi/mod.rs b/std/src/sys/pal/solid/abi/mod.rs index 4d09705721748..819f93f407423 100644 --- a/std/src/sys/pal/solid/abi/mod.rs +++ b/std/src/sys/pal/solid/abi/mod.rs @@ -33,27 +33,27 @@ pub struct SOLID_RTC_TIME { pub tm_wday: c_int, } -extern "C" { +unsafe extern "C" { pub fn SOLID_RTC_ReadTime(time: *mut SOLID_RTC_TIME) -> c_int; } // `solid_log.h` -extern "C" { +unsafe extern "C" { pub fn SOLID_LOG_write(s: *const u8, l: usize); } // `solid_mem.h` -extern "C" { +unsafe extern "C" { pub fn SOLID_TLS_AddDestructor(id: i32, dtor: unsafe extern "C" fn(*mut u8)); } // `solid_rng.h` -extern "C" { +unsafe extern "C" { pub fn SOLID_RNG_SampleRandomBytes(buffer: *mut u8, length: usize) -> c_int; } // `rwlock.h` -extern "C" { +unsafe extern "C" { pub fn rwl_loc_rdl(id: ID) -> ER; pub fn rwl_loc_wrl(id: ID) -> ER; pub fn rwl_ploc_rdl(id: ID) -> ER; diff --git a/std/src/sys/pal/solid/abi/sockets.rs b/std/src/sys/pal/solid/abi/sockets.rs index 3c9e3f9ffb95d..80802dd42e248 100644 --- a/std/src/sys/pal/solid/abi/sockets.rs +++ b/std/src/sys/pal/solid/abi/sockets.rs @@ -158,7 +158,7 @@ pub struct fd_set { pub fds: [c_int; SOLID_NET_FD_SETSIZE], } -extern "C" { +unsafe extern "C" { #[link_name = "SOLID_NET_StrError"] pub fn strerror(errnum: c_int) -> *const c_char; diff --git a/std/src/sys/pal/solid/fs.rs b/std/src/sys/pal/solid/fs.rs index fa2e470d6b601..4e741943283d0 100644 --- a/std/src/sys/pal/solid/fs.rs +++ b/std/src/sys/pal/solid/fs.rs @@ -22,12 +22,9 @@ struct FileDesc { impl FileDesc { #[inline] + #[track_caller] fn new(fd: c_int) -> FileDesc { - assert_ne!(fd, -1i32); - // Safety: we just asserted that the value is in the valid range and - // isn't `-1` (the only value bigger than `0xFF_FF_FF_FE` unsigned) - let fd = unsafe { CIntNotMinusOne::new_unchecked(fd) }; - FileDesc { fd } + FileDesc { fd: CIntNotMinusOne::new(fd).expect("fd != -1") } } #[inline] @@ -312,7 +309,7 @@ fn cstr(path: &Path) -> io::Result { let wrapped_path = [SAFE_PREFIX, &path, &[0]].concat(); CString::from_vec_with_nul(wrapped_path).map_err(|_| { - crate::io::const_error!(io::ErrorKind::InvalidInput, "path provided contains a nul byte",) + crate::io::const_error!(io::ErrorKind::InvalidInput, "path provided contains a nul byte") }) } @@ -455,8 +452,11 @@ impl File { abi::SOLID_FS_Lseek(self.fd.raw(), pos, whence) }) .map_err(|e| e.as_io_error())?; - // Get the new offset + self.tell() + } + + pub fn tell(&self) -> io::Result { unsafe { let mut out_offset = MaybeUninit::uninit(); error::SolidError::err_if_negative(abi::SOLID_FS_Ftell( diff --git a/std/src/sys/pal/solid/os.rs b/std/src/sys/pal/solid/os.rs index 57c28aed3b293..e3b2e0aa50f4a 100644 --- a/std/src/sys/pal/solid/os.rs +++ b/std/src/sys/pal/solid/os.rs @@ -129,7 +129,7 @@ impl Iterator for Env { /// Returns a vector of (variable, value) byte-vector pairs for all the /// environment variables of the current process. pub fn env() -> Env { - extern "C" { + unsafe extern "C" { static mut environ: *const *const c_char; } diff --git a/std/src/sys/pal/teeos/mod.rs b/std/src/sys/pal/teeos/mod.rs index f850fefc8f22f..3632524157db9 100644 --- a/std/src/sys/pal/teeos/mod.rs +++ b/std/src/sys/pal/teeos/mod.rs @@ -148,5 +148,5 @@ pub fn unsupported() -> std_io::Result { } pub fn unsupported_err() -> std_io::Error { - std_io::Error::new(std_io::ErrorKind::Unsupported, "operation not supported on this platform") + std_io::Error::UNSUPPORTED_PLATFORM } diff --git a/std/src/sys/pal/teeos/os.rs b/std/src/sys/pal/teeos/os.rs index 82cade771b513..bf6945811ab0e 100644 --- a/std/src/sys/pal/teeos/os.rs +++ b/std/src/sys/pal/teeos/os.rs @@ -107,11 +107,11 @@ pub fn getenv(_: &OsStr) -> Option { } pub unsafe fn setenv(_: &OsStr, _: &OsStr) -> io::Result<()> { - Err(io::Error::new(io::ErrorKind::Unsupported, "cannot set env vars on this platform")) + Err(io::const_error!(io::ErrorKind::Unsupported, "cannot set env vars on this platform")) } pub unsafe fn unsetenv(_: &OsStr) -> io::Result<()> { - Err(io::Error::new(io::ErrorKind::Unsupported, "cannot unset env vars on this platform")) + Err(io::const_error!(io::ErrorKind::Unsupported, "cannot unset env vars on this platform")) } pub fn temp_dir() -> PathBuf { diff --git a/std/src/sys/pal/teeos/thread.rs b/std/src/sys/pal/teeos/thread.rs index 15c65240ddd2a..e3b4908f85863 100644 --- a/std/src/sys/pal/teeos/thread.rs +++ b/std/src/sys/pal/teeos/thread.rs @@ -16,7 +16,7 @@ pub struct Thread { unsafe impl Send for Thread {} unsafe impl Sync for Thread {} -extern "C" { +unsafe extern "C" { pub fn TEE_Wait(timeout: u32) -> u32; } @@ -56,7 +56,7 @@ impl Thread { } }; - let ret = libc::pthread_create(&mut native, &attr, thread_start, p as *mut _); + let ret = unsafe { libc::pthread_create(&mut native, &attr, thread_start, p as *mut _) }; // Note: if the thread creation fails and this assert fails, then p will // be leaked. However, an alternative design could cause double-free // which is clearly worse. diff --git a/std/src/sys/pal/uefi/fs.rs b/std/src/sys/pal/uefi/fs.rs index 9585ec24f687d..45e93deffa3a4 100644 --- a/std/src/sys/pal/uefi/fs.rs +++ b/std/src/sys/pal/uefi/fs.rs @@ -258,6 +258,10 @@ impl File { self.0 } + pub fn tell(&self) -> io::Result { + self.0 + } + pub fn duplicate(&self) -> io::Result { self.0 } diff --git a/std/src/sys/pal/uefi/helpers.rs b/std/src/sys/pal/uefi/helpers.rs index dccc137d6f561..ec2da4e4ee7a4 100644 --- a/std/src/sys/pal/uefi/helpers.rs +++ b/std/src/sys/pal/uefi/helpers.rs @@ -273,7 +273,7 @@ impl OwnedDevicePath { io::Result::Err(const_error!( io::ErrorKind::NotFound, - "DevicePathFromText Protocol not found" + "DevicePathFromText Protocol not found", )) } diff --git a/std/src/sys/pal/uefi/mod.rs b/std/src/sys/pal/uefi/mod.rs index 4766e2ef0a95f..6a03e240c6bd4 100644 --- a/std/src/sys/pal/uefi/mod.rs +++ b/std/src/sys/pal/uefi/mod.rs @@ -90,7 +90,7 @@ pub const fn unsupported() -> std_io::Result { #[inline] pub const fn unsupported_err() -> std_io::Error { - std_io::const_error!(std_io::ErrorKind::Unsupported, "operation not supported on UEFI",) + std_io::const_error!(std_io::ErrorKind::Unsupported, "operation not supported on UEFI") } pub fn decode_error_kind(code: RawOsError) -> crate::io::ErrorKind { @@ -169,7 +169,7 @@ pub fn abort_internal() -> ! { // This function is needed by the panic runtime. The symbol is named in // pre-link args for the target specification, so keep that in sync. #[cfg(not(test))] -#[no_mangle] +#[unsafe(no_mangle)] pub extern "C" fn __rust_abort() { abort_internal(); } diff --git a/std/src/sys/pal/uefi/os.rs b/std/src/sys/pal/uefi/os.rs index 6d23c72ef2209..e305b8610c9f8 100644 --- a/std/src/sys/pal/uefi/os.rs +++ b/std/src/sys/pal/uefi/os.rs @@ -17,111 +17,50 @@ pub fn errno() -> RawOsError { pub fn error_string(errno: RawOsError) -> String { // Keep the List in Alphabetical Order // The Messages are taken from UEFI Specification Appendix D - Status Codes - match r_efi::efi::Status::from_usize(errno) { - Status::ABORTED => "The operation was aborted.".to_owned(), - Status::ACCESS_DENIED => "Access was denied.".to_owned(), - Status::ALREADY_STARTED => "The protocol has already been started.".to_owned(), - Status::BAD_BUFFER_SIZE => "The buffer was not the proper size for the request.".to_owned(), - Status::BUFFER_TOO_SMALL => { - "The buffer is not large enough to hold the requested data. The required buffer size is returned in the appropriate parameter when this error occurs.".to_owned() - } - Status::COMPROMISED_DATA => { - "The security status of the data is unknown or compromised and the data must be updated or replaced to restore a valid security status.".to_owned() - } - Status::CONNECTION_FIN => { - "The receiving operation fails because the communication peer has closed the connection and there is no more data in the receive buffer of the instance.".to_owned() - } - Status::CONNECTION_REFUSED => { - "The receiving or transmission operation fails because this connection is refused.".to_owned() - } - Status::CONNECTION_RESET => { - "The connect fails because the connection is reset either by instance itself or the communication peer.".to_owned() - } - Status::CRC_ERROR => "A CRC error was detected.".to_owned(), - Status::DEVICE_ERROR => "The physical device reported an error while attempting the operation.".to_owned() - , - Status::END_OF_FILE => { - "The end of the file was reached.".to_owned() - } - Status::END_OF_MEDIA => { - "Beginning or end of media was reached".to_owned() - } - Status::HOST_UNREACHABLE => { - "The remote host is not reachable.".to_owned() - } - Status::HTTP_ERROR => { - "A HTTP error occurred during the network operation.".to_owned() - } - Status::ICMP_ERROR => { - "An ICMP error occurred during the network operation.".to_owned() - } - Status::INCOMPATIBLE_VERSION => { - "The function encountered an internal version that was incompatible with a version requested by the caller.".to_owned() - } - Status::INVALID_LANGUAGE => { - "The language specified was invalid.".to_owned() - } - Status::INVALID_PARAMETER => { - "A parameter was incorrect.".to_owned() - } - Status::IP_ADDRESS_CONFLICT => { - "There is an address conflict address allocation".to_owned() - } - Status::LOAD_ERROR => { - "The image failed to load.".to_owned() - } - Status::MEDIA_CHANGED => { - "The medium in the device has changed since the last access.".to_owned() - } - Status::NETWORK_UNREACHABLE => { - "The network containing the remote host is not reachable.".to_owned() - } - Status::NO_MAPPING => { - "A mapping to a device does not exist.".to_owned() - } - Status::NO_MEDIA => { - "The device does not contain any medium to perform the operation.".to_owned() - } - Status::NO_RESPONSE => { - "The server was not found or did not respond to the request.".to_owned() - } - Status::NOT_FOUND => "The item was not found.".to_owned(), - Status::NOT_READY => { - "There is no data pending upon return.".to_owned() - } - Status::NOT_STARTED => { - "The protocol has not been started.".to_owned() - } - Status::OUT_OF_RESOURCES => { - "A resource has run out.".to_owned() - } - Status::PROTOCOL_ERROR => { - "A protocol error occurred during the network operation.".to_owned() - } - Status::PROTOCOL_UNREACHABLE => { - "An ICMP protocol unreachable error is received.".to_owned() - } - Status::SECURITY_VIOLATION => { - "The function was not performed due to a security violation.".to_owned() - } - Status::TFTP_ERROR => { - "A TFTP error occurred during the network operation.".to_owned() - } - Status::TIMEOUT => "The timeout time expired.".to_owned(), - Status::UNSUPPORTED => { - "The operation is not supported.".to_owned() - } - Status::VOLUME_FULL => { - "There is no more space on the file system.".to_owned() - } - Status::VOLUME_CORRUPTED => { - "An inconstancy was detected on the file system causing the operating to fail.".to_owned() - } - Status::WRITE_PROTECTED => { - "The device cannot be written to.".to_owned() - } - _ => format!("Status: {}", errno), - } + #[rustfmt::skip] + let msg = match r_efi::efi::Status::from_usize(errno) { + Status::ABORTED => "The operation was aborted.", + Status::ACCESS_DENIED => "Access was denied.", + Status::ALREADY_STARTED => "The protocol has already been started.", + Status::BAD_BUFFER_SIZE => "The buffer was not the proper size for the request.", + Status::BUFFER_TOO_SMALL => "The buffer is not large enough to hold the requested data. The required buffer size is returned in the appropriate parameter when this error occurs.", + Status::COMPROMISED_DATA => "The security status of the data is unknown or compromised and the data must be updated or replaced to restore a valid security status.", + Status::CONNECTION_FIN => "The receiving operation fails because the communication peer has closed the connection and there is no more data in the receive buffer of the instance.", + Status::CONNECTION_REFUSED => "The receiving or transmission operation fails because this connection is refused.", + Status::CONNECTION_RESET => "The connect fails because the connection is reset either by instance itself or the communication peer.", + Status::CRC_ERROR => "A CRC error was detected.", + Status::DEVICE_ERROR => "The physical device reported an error while attempting the operation.", + Status::END_OF_FILE => "The end of the file was reached.", + Status::END_OF_MEDIA => "Beginning or end of media was reached", + Status::HOST_UNREACHABLE => "The remote host is not reachable.", + Status::HTTP_ERROR => "A HTTP error occurred during the network operation.", + Status::ICMP_ERROR => "An ICMP error occurred during the network operation.", + Status::INCOMPATIBLE_VERSION => "The function encountered an internal version that was incompatible with a version requested by the caller.", + Status::INVALID_LANGUAGE => "The language specified was invalid.", + Status::INVALID_PARAMETER => "A parameter was incorrect.", + Status::IP_ADDRESS_CONFLICT => "There is an address conflict address allocation", + Status::LOAD_ERROR => "The image failed to load.", + Status::MEDIA_CHANGED => "The medium in the device has changed since the last access.", + Status::NETWORK_UNREACHABLE => "The network containing the remote host is not reachable.", + Status::NO_MAPPING => "A mapping to a device does not exist.", + Status::NO_MEDIA => "The device does not contain any medium to perform the operation.", + Status::NO_RESPONSE => "The server was not found or did not respond to the request.", + Status::NOT_FOUND => "The item was not found.", + Status::NOT_READY => "There is no data pending upon return.", + Status::NOT_STARTED => "The protocol has not been started.", + Status::OUT_OF_RESOURCES => "A resource has run out.", + Status::PROTOCOL_ERROR => "A protocol error occurred during the network operation.", + Status::PROTOCOL_UNREACHABLE => "An ICMP protocol unreachable error is received.", + Status::SECURITY_VIOLATION => "The function was not performed due to a security violation.", + Status::TFTP_ERROR => "A TFTP error occurred during the network operation.", + Status::TIMEOUT => "The timeout time expired.", + Status::UNSUPPORTED => "The operation is not supported.", + Status::VOLUME_FULL => "There is no more space on the file system.", + Status::VOLUME_CORRUPTED => "An inconstancy was detected on the file system causing the operating to fail.", + Status::WRITE_PROTECTED => "The device cannot be written to.", + _ => return format!("Status: {errno}"), + }; + msg.to_owned() } pub fn getcwd() -> io::Result { @@ -314,7 +253,7 @@ mod uefi_env { let mut start = 0; - // UEFI Shell returns all keys seperated by NULL. + // UEFI Shell returns all keys separated by NULL. // End of string is denoted by two NULLs for i in 0.. { if unsafe { *val.add(i) } == 0 { diff --git a/std/src/sys/pal/uefi/process.rs b/std/src/sys/pal/uefi/process.rs index 0757f1cb490d4..c73a6350357a4 100644 --- a/std/src/sys/pal/uefi/process.rs +++ b/std/src/sys/pal/uefi/process.rs @@ -154,8 +154,8 @@ impl Command { if let Some(e) = &env { for (k, (_, v)) in e { match v { - Some(v) => crate::env::set_var(k, v), - None => crate::env::remove_var(k), + Some(v) => unsafe { crate::env::set_var(k, v) }, + None => unsafe { crate::env::remove_var(k) }, } } } @@ -166,8 +166,8 @@ impl Command { if let Some(e) = env { for (k, (v, _)) in e { match v { - Some(v) => crate::env::set_var(k, v), - None => crate::env::remove_var(k), + Some(v) => unsafe { crate::env::set_var(k, v) }, + None => unsafe { crate::env::remove_var(k) }, } } } @@ -388,7 +388,7 @@ mod uefi_command_internal { } } - pub fn start_image(&mut self) -> io::Result { + pub(crate) fn start_image(&mut self) -> io::Result { self.update_st_crc32()?; // Use our system table instead of the default one diff --git a/std/src/sys/pal/uefi/stdio.rs b/std/src/sys/pal/uefi/stdio.rs index 703e8ba8e5710..d049d19bc83ee 100644 --- a/std/src/sys/pal/uefi/stdio.rs +++ b/std/src/sys/pal/uefi/stdio.rs @@ -71,7 +71,7 @@ impl io::Read for Stdin { }; if ch.len() > 1 { - return Err(io::Error::new(io::ErrorKind::InvalidData, "invalid utf-16 sequence")); + return Err(io::const_error!(io::ErrorKind::InvalidData, "invalid utf-16 sequence")); } match ch.pop().unwrap() { diff --git a/std/src/sys/pal/uefi/time.rs b/std/src/sys/pal/uefi/time.rs index 495ff2dc930ed..c4ff3015ac60d 100644 --- a/std/src/sys/pal/uefi/time.rs +++ b/std/src/sys/pal/uefi/time.rs @@ -84,7 +84,7 @@ pub(crate) mod system_time_internal { // This algorithm is based on the one described in the post // https://blog.reverberate.org/2020/05/12/optimizing-date-algorithms.html - pub const fn uefi_time_to_duration(t: r_efi::system::Time) -> Duration { + pub(crate) const fn uefi_time_to_duration(t: r_efi::system::Time) -> Duration { assert!(t.month <= 12); assert!(t.month != 0); diff --git a/std/src/sys/pal/unix/args.rs b/std/src/sys/pal/unix/args.rs index 8438a61e90feb..1c87a79803c0d 100644 --- a/std/src/sys/pal/unix/args.rs +++ b/std/src/sys/pal/unix/args.rs @@ -147,7 +147,7 @@ mod imp { /// This allows `std::env::args` to work even in a `cdylib`, as it does on macOS and Windows. #[cfg(all(target_os = "linux", target_env = "gnu"))] #[used] - #[link_section = ".init_array.00099"] + #[unsafe(link_section = ".init_array.00099")] static ARGV_INIT_ARRAY: extern "C" fn( crate::os::raw::c_int, *const *const u8, @@ -204,7 +204,7 @@ mod imp { } pub fn argc_argv() -> (isize, *const *const c_char) { - extern "C" { + unsafe extern "C" { // These functions are in crt_externs.h. fn _NSGetArgc() -> *mut c_int; fn _NSGetArgv() -> *mut *mut *mut c_char; diff --git a/std/src/sys/pal/unix/fs.rs b/std/src/sys/pal/unix/fs.rs index 00cfa7a7fcfda..3df460e38b72e 100644 --- a/std/src/sys/pal/unix/fs.rs +++ b/std/src/sys/pal/unix/fs.rs @@ -568,8 +568,7 @@ impl FileAttr { Err(io::const_error!( io::ErrorKind::Unsupported, - "creation time is not available on this platform \ - currently", + "creation time is not available on this platform currently", )) } @@ -1438,6 +1437,10 @@ impl File { Ok(n as u64) } + pub fn tell(&self) -> io::Result { + self.seek(SeekFrom::Current(0)) + } + pub fn duplicate(&self) -> io::Result { self.0.duplicate().map(File) } @@ -1459,11 +1462,11 @@ impl File { Some(time) if let Some(ts) = time.t.to_timespec() => Ok(ts), Some(time) if time > crate::sys::time::UNIX_EPOCH => Err(io::const_error!( io::ErrorKind::InvalidInput, - "timestamp is too large to set as a file time" + "timestamp is too large to set as a file time", )), Some(_) => Err(io::const_error!( io::ErrorKind::InvalidInput, - "timestamp is too small to set as a file time" + "timestamp is too small to set as a file time", )), None => Ok(libc::timespec { tv_sec: 0, tv_nsec: libc::UTIME_OMIT as _ }), }; diff --git a/std/src/sys/pal/unix/futex.rs b/std/src/sys/pal/unix/futex.rs index 0fc765dc87a5d..d4551dd6a38bb 100644 --- a/std/src/sys/pal/unix/futex.rs +++ b/std/src/sys/pal/unix/futex.rs @@ -219,7 +219,7 @@ pub fn futex_wake_all(futex: &AtomicU32) { } #[cfg(target_os = "emscripten")] -extern "C" { +unsafe extern "C" { fn emscripten_futex_wake(addr: *const AtomicU32, count: libc::c_int) -> libc::c_int; fn emscripten_futex_wait( addr: *const AtomicU32, @@ -267,7 +267,7 @@ pub mod zircon { pub const ZX_ERR_BAD_STATE: zx_status_t = -20; pub const ZX_ERR_TIMED_OUT: zx_status_t = -21; - extern "C" { + unsafe extern "C" { pub fn zx_clock_get_monotonic() -> zx_time_t; pub fn zx_futex_wait( value_ptr: *const zx_futex_t, diff --git a/std/src/sys/pal/unix/linux/pidfd/tests.rs b/std/src/sys/pal/unix/linux/pidfd/tests.rs index fb928c76fbd04..17b06bea91278 100644 --- a/std/src/sys/pal/unix/linux/pidfd/tests.rs +++ b/std/src/sys/pal/unix/linux/pidfd/tests.rs @@ -45,8 +45,8 @@ fn test_command_pidfd() { .expect_err("pidfd should not have been created"); // exercise the fork/exec path since the earlier attempts may have used pidfd_spawnp() - let mut child = - unsafe { Command::new("false").pre_exec(|| Ok(())) }.create_pidfd(true).spawn().unwrap(); + let mut cmd = Command::new("false"); + let mut child = unsafe { cmd.pre_exec(|| Ok(())) }.create_pidfd(true).spawn().unwrap(); assert!(child.id() > 0 && child.id() < -1i32 as u32); diff --git a/std/src/sys/pal/unix/mod.rs b/std/src/sys/pal/unix/mod.rs index 027df6c5691c6..c0b56d8d2b28a 100644 --- a/std/src/sys/pal/unix/mod.rs +++ b/std/src/sys/pal/unix/mod.rs @@ -373,24 +373,24 @@ cfg_if::cfg_if! { cfg(target_feature = "crt-static"))] #[link(name = "dl", cfg(not(target_feature = "crt-static")))] #[link(name = "log", cfg(not(target_feature = "crt-static")))] - extern "C" {} + unsafe extern "C" {} } else if #[cfg(target_os = "freebsd")] { #[link(name = "execinfo")] #[link(name = "pthread")] - extern "C" {} + unsafe extern "C" {} } else if #[cfg(target_os = "netbsd")] { #[link(name = "pthread")] #[link(name = "rt")] - extern "C" {} + unsafe extern "C" {} } else if #[cfg(any(target_os = "dragonfly", target_os = "openbsd"))] { #[link(name = "pthread")] - extern "C" {} + unsafe extern "C" {} } else if #[cfg(target_os = "solaris")] { #[link(name = "socket")] #[link(name = "posix4")] #[link(name = "pthread")] #[link(name = "resolv")] - extern "C" {} + unsafe extern "C" {} } else if #[cfg(target_os = "illumos")] { #[link(name = "socket")] #[link(name = "posix4")] @@ -399,24 +399,24 @@ cfg_if::cfg_if! { #[link(name = "nsl")] // Use libumem for the (malloc-compatible) allocator #[link(name = "umem")] - extern "C" {} + unsafe extern "C" {} } else if #[cfg(target_vendor = "apple")] { // Link to `libSystem.dylib`. // // Don't get confused by the presence of `System.framework`, // it is a deprecated wrapper over the dynamic library. #[link(name = "System")] - extern "C" {} + unsafe extern "C" {} } else if #[cfg(target_os = "fuchsia")] { #[link(name = "zircon")] #[link(name = "fdio")] - extern "C" {} + unsafe extern "C" {} } else if #[cfg(all(target_os = "linux", target_env = "uclibc"))] { #[link(name = "dl")] - extern "C" {} + unsafe extern "C" {} } else if #[cfg(target_os = "vita")] { #[link(name = "pthread", kind = "static", modifiers = "-bundle")] - extern "C" {} + unsafe extern "C" {} } } diff --git a/std/src/sys/pal/unix/os.rs b/std/src/sys/pal/unix/os.rs index b83772e34c173..78404b4afa790 100644 --- a/std/src/sys/pal/unix/os.rs +++ b/std/src/sys/pal/unix/os.rs @@ -30,7 +30,7 @@ cfg_if::cfg_if! { } } -extern "C" { +unsafe extern "C" { #[cfg(not(any(target_os = "dragonfly", target_os = "vxworks", target_os = "rtems")))] #[cfg_attr( any( @@ -82,7 +82,7 @@ pub fn errno() -> i32 { #[cfg(target_os = "rtems")] pub fn errno() -> i32 { - extern "C" { + unsafe extern "C" { #[thread_local] static _tls_errno: c_int; } @@ -92,7 +92,7 @@ pub fn errno() -> i32 { #[cfg(target_os = "dragonfly")] pub fn errno() -> i32 { - extern "C" { + unsafe extern "C" { #[thread_local] static errno: c_int; } @@ -103,7 +103,7 @@ pub fn errno() -> i32 { #[cfg(target_os = "dragonfly")] #[allow(dead_code)] pub fn set_errno(e: i32) { - extern "C" { + unsafe extern "C" { #[thread_local] static mut errno: c_int; } @@ -115,7 +115,7 @@ pub fn set_errno(e: i32) { /// Gets a detailed string description for the given error number. pub fn error_string(errno: i32) -> String { - extern "C" { + unsafe extern "C" { #[cfg_attr( all( any(target_os = "linux", target_os = "hurd", target_env = "newlib"), @@ -260,7 +260,7 @@ pub fn current_exe() -> io::Result { let exe_path = env::args().next().ok_or(io::const_error!( ErrorKind::NotFound, - "an executable path was not found because no arguments were provided through argv" + "an executable path was not found because no arguments were provided through argv", ))?; let path = PathBuf::from(exe_path); if path.is_absolute() { @@ -382,9 +382,7 @@ pub fn current_exe() -> io::Result { cvt(libc::sysctl(mib, 4, argv.as_mut_ptr() as *mut _, &mut argv_len, ptr::null_mut(), 0))?; argv.set_len(argv_len as usize); if argv[0].is_null() { - return Err( - io::const_error!(io::ErrorKind::Uncategorized, "no current exe available",), - ); + return Err(io::const_error!(io::ErrorKind::Uncategorized, "no current exe available")); } let argv0 = CStr::from_ptr(argv[0]).to_bytes(); if argv0[0] == b'.' || argv0.iter().any(|b| *b == b'/') { @@ -526,7 +524,7 @@ pub fn current_exe() -> io::Result { let exe_path = env::args().next().ok_or(io::const_error!( ErrorKind::Uncategorized, - "an executable path was not found because no arguments were provided through argv" + "an executable path was not found because no arguments were provided through argv", ))?; let path = PathBuf::from(exe_path); @@ -610,7 +608,7 @@ pub unsafe fn environ() -> *mut *const *const c_char { // Use the `environ` static which is part of POSIX. #[cfg(not(target_vendor = "apple"))] pub unsafe fn environ() -> *mut *const *const c_char { - extern "C" { + unsafe extern "C" { static mut environ: *const *const c_char; } &raw mut environ @@ -847,7 +845,7 @@ pub fn getppid() -> u32 { #[cfg(all(target_os = "linux", target_env = "gnu"))] pub fn glibc_version() -> Option<(usize, usize)> { - extern "C" { + unsafe extern "C" { fn gnu_get_libc_version() -> *const libc::c_char; } let version_cstr = unsafe { CStr::from_ptr(gnu_get_libc_version()) }; diff --git a/std/src/sys/pal/unix/process/process_unix.rs b/std/src/sys/pal/unix/process/process_unix.rs index 2bff192a5bd83..aa7406dd54874 100644 --- a/std/src/sys/pal/unix/process/process_unix.rs +++ b/std/src/sys/pal/unix/process/process_unix.rs @@ -228,7 +228,7 @@ impl Command { let envp = self.capture_env(); if self.saw_nul() { - return io::const_error!(ErrorKind::InvalidInput, "nul byte found in provided data",); + return io::const_error!(ErrorKind::InvalidInput, "nul byte found in provided data"); } match self.setup_io(default, true) { @@ -1228,7 +1228,7 @@ mod linux_child_ext { .as_ref() // SAFETY: The os type is a transparent wrapper, therefore we can transmute references .map(|fd| unsafe { mem::transmute::<&imp::PidFd, &os::PidFd>(fd) }) - .ok_or_else(|| io::Error::new(ErrorKind::Uncategorized, "No pidfd was created.")) + .ok_or_else(|| io::const_error!(ErrorKind::Uncategorized, "No pidfd was created.")) } fn into_pidfd(mut self) -> Result { diff --git a/std/src/sys/pal/unix/process/zircon.rs b/std/src/sys/pal/unix/process/zircon.rs index 4035e2370a3c6..7932bd26d76c3 100644 --- a/std/src/sys/pal/unix/process/zircon.rs +++ b/std/src/sys/pal/unix/process/zircon.rs @@ -75,7 +75,7 @@ pub struct zx_info_process_t { pub reserved1: u32, } -extern "C" { +unsafe extern "C" { pub fn zx_job_default() -> zx_handle_t; pub fn zx_task_kill(handle: zx_handle_t) -> zx_status_t; @@ -115,7 +115,7 @@ pub struct fdio_spawn_action_t { pub reserved1: u64, } -extern "C" { +unsafe extern "C" { pub fn fdio_spawn_etc( job: zx_handle_t, flags: u32, diff --git a/std/src/sys/pal/unix/stack_overflow.rs b/std/src/sys/pal/unix/stack_overflow.rs index db5c6bd3a1c32..43ece63457fe6 100644 --- a/std/src/sys/pal/unix/stack_overflow.rs +++ b/std/src/sys/pal/unix/stack_overflow.rs @@ -319,21 +319,27 @@ mod imp { ))] unsafe fn get_stack_start() -> Option<*mut libc::c_void> { let mut ret = None; - let mut attr: libc::pthread_attr_t = crate::mem::zeroed(); + let mut attr: mem::MaybeUninit = mem::MaybeUninit::uninit(); + if !cfg!(target_os = "freebsd") { + attr = mem::MaybeUninit::zeroed(); + } #[cfg(target_os = "freebsd")] - assert_eq!(libc::pthread_attr_init(&mut attr), 0); + assert_eq!(libc::pthread_attr_init(attr.as_mut_ptr()), 0); #[cfg(target_os = "freebsd")] - let e = libc::pthread_attr_get_np(libc::pthread_self(), &mut attr); + let e = libc::pthread_attr_get_np(libc::pthread_self(), attr.as_mut_ptr()); #[cfg(not(target_os = "freebsd"))] - let e = libc::pthread_getattr_np(libc::pthread_self(), &mut attr); + let e = libc::pthread_getattr_np(libc::pthread_self(), attr.as_mut_ptr()); if e == 0 { let mut stackaddr = crate::ptr::null_mut(); let mut stacksize = 0; - assert_eq!(libc::pthread_attr_getstack(&attr, &mut stackaddr, &mut stacksize), 0); + assert_eq!( + libc::pthread_attr_getstack(attr.as_ptr(), &mut stackaddr, &mut stacksize), + 0 + ); ret = Some(stackaddr); } if e == 0 || cfg!(target_os = "freebsd") { - assert_eq!(libc::pthread_attr_destroy(&mut attr), 0); + assert_eq!(libc::pthread_attr_destroy(attr.as_mut_ptr()), 0); } ret } @@ -509,16 +515,20 @@ mod imp { // FIXME: I am probably not unsafe. unsafe fn current_guard() -> Option> { let mut ret = None; - let mut attr: libc::pthread_attr_t = crate::mem::zeroed(); + + let mut attr: mem::MaybeUninit = mem::MaybeUninit::uninit(); + if !cfg!(target_os = "freebsd") { + attr = mem::MaybeUninit::zeroed(); + } #[cfg(target_os = "freebsd")] - assert_eq!(libc::pthread_attr_init(&mut attr), 0); + assert_eq!(libc::pthread_attr_init(attr.as_mut_ptr()), 0); #[cfg(target_os = "freebsd")] - let e = libc::pthread_attr_get_np(libc::pthread_self(), &mut attr); + let e = libc::pthread_attr_get_np(libc::pthread_self(), attr.as_mut_ptr()); #[cfg(not(target_os = "freebsd"))] - let e = libc::pthread_getattr_np(libc::pthread_self(), &mut attr); + let e = libc::pthread_getattr_np(libc::pthread_self(), attr.as_mut_ptr()); if e == 0 { let mut guardsize = 0; - assert_eq!(libc::pthread_attr_getguardsize(&attr, &mut guardsize), 0); + assert_eq!(libc::pthread_attr_getguardsize(attr.as_ptr(), &mut guardsize), 0); if guardsize == 0 { if cfg!(all(target_os = "linux", target_env = "musl")) { // musl versions before 1.1.19 always reported guard @@ -531,7 +541,7 @@ mod imp { } let mut stackptr = crate::ptr::null_mut::(); let mut size = 0; - assert_eq!(libc::pthread_attr_getstack(&attr, &mut stackptr, &mut size), 0); + assert_eq!(libc::pthread_attr_getstack(attr.as_ptr(), &mut stackptr, &mut size), 0); let stackaddr = stackptr.addr(); ret = if cfg!(any(target_os = "freebsd", target_os = "netbsd", target_os = "hurd")) { @@ -552,7 +562,7 @@ mod imp { }; } if e == 0 || cfg!(target_os = "freebsd") { - assert_eq!(libc::pthread_attr_destroy(&mut attr), 0); + assert_eq!(libc::pthread_attr_destroy(attr.as_mut_ptr()), 0); } ret } diff --git a/std/src/sys/pal/unix/sync/mutex.rs b/std/src/sys/pal/unix/sync/mutex.rs index 8ff6c3d3d15da..557e70af94ba7 100644 --- a/std/src/sys/pal/unix/sync/mutex.rs +++ b/std/src/sys/pal/unix/sync/mutex.rs @@ -111,9 +111,9 @@ impl Drop for Mutex { // `PTHREAD_MUTEX_INITIALIZER`, which is valid at all locations. Thus, // this call always destroys a valid mutex. let r = unsafe { libc::pthread_mutex_destroy(self.raw()) }; - if cfg!(target_os = "dragonfly") { - // On DragonFly pthread_mutex_destroy() returns EINVAL if called on a - // mutex that was just initialized with libc::PTHREAD_MUTEX_INITIALIZER. + if cfg!(any(target_os = "aix", target_os = "dragonfly")) { + // On AIX and DragonFly pthread_mutex_destroy() returns EINVAL if called + // on a mutex that was just initialized with libc::PTHREAD_MUTEX_INITIALIZER. // Once it is used (locked/unlocked) or pthread_mutex_init() is called, // this behaviour no longer occurs. debug_assert!(r == 0 || r == libc::EINVAL); diff --git a/std/src/sys/pal/unix/thread.rs b/std/src/sys/pal/unix/thread.rs index 356669980c7d9..4c5757b890ada 100644 --- a/std/src/sys/pal/unix/thread.rs +++ b/std/src/sys/pal/unix/thread.rs @@ -23,7 +23,7 @@ mod zircon { type zx_status_t = i32; pub const ZX_PROP_NAME: u32 = 3; - extern "C" { + unsafe extern "C" { pub fn zx_object_set_property( handle: zx_handle_t, property: u32, @@ -49,24 +49,27 @@ impl Thread { pub unsafe fn new(stack: usize, p: Box) -> io::Result { let p = Box::into_raw(Box::new(p)); let mut native: libc::pthread_t = mem::zeroed(); - let mut attr: libc::pthread_attr_t = mem::zeroed(); - assert_eq!(libc::pthread_attr_init(&mut attr), 0); + let mut attr: mem::MaybeUninit = mem::MaybeUninit::uninit(); + assert_eq!(libc::pthread_attr_init(attr.as_mut_ptr()), 0); #[cfg(target_os = "espidf")] if stack > 0 { // Only set the stack if a non-zero value is passed // 0 is used as an indication that the default stack size configured in the ESP-IDF menuconfig system should be used assert_eq!( - libc::pthread_attr_setstacksize(&mut attr, cmp::max(stack, min_stack_size(&attr))), + libc::pthread_attr_setstacksize( + attr.as_mut_ptr(), + cmp::max(stack, min_stack_size(attr.as_ptr())) + ), 0 ); } #[cfg(not(target_os = "espidf"))] { - let stack_size = cmp::max(stack, min_stack_size(&attr)); + let stack_size = cmp::max(stack, min_stack_size(attr.as_ptr())); - match libc::pthread_attr_setstacksize(&mut attr, stack_size) { + match libc::pthread_attr_setstacksize(attr.as_mut_ptr(), stack_size) { 0 => {} n => { assert_eq!(n, libc::EINVAL); @@ -77,16 +80,16 @@ impl Thread { let page_size = os::page_size(); let stack_size = (stack_size + page_size - 1) & (-(page_size as isize - 1) as usize - 1); - assert_eq!(libc::pthread_attr_setstacksize(&mut attr, stack_size), 0); + assert_eq!(libc::pthread_attr_setstacksize(attr.as_mut_ptr(), stack_size), 0); } }; } - let ret = libc::pthread_create(&mut native, &attr, thread_start, p as *mut _); + let ret = libc::pthread_create(&mut native, attr.as_ptr(), thread_start, p as *mut _); // Note: if the thread creation fails and this assert fails, then p will // be leaked. However, an alternative design could cause double-free // which is clearly worse. - assert_eq!(libc::pthread_attr_destroy(&mut attr), 0); + assert_eq!(libc::pthread_attr_destroy(attr.as_mut_ptr()), 0); return if ret != 0 { // The thread failed to start and as a result p was not consumed. Therefore, it is @@ -144,7 +147,7 @@ impl Thread { const TASK_COMM_LEN: usize = 16; let name = truncate_cstr::<{ TASK_COMM_LEN }>(name); } else { - // FreeBSD, DragonFly, FreeBSD and NuttX do not enforce length limits. + // FreeBSD, DragonFly BSD and NuttX do not enforce length limits. } }; // Available since glibc 2.12, musl 1.1.16, and uClibc 1.0.20 for Linux, @@ -230,7 +233,7 @@ impl Thread { #[cfg(target_os = "vxworks")] pub fn set_name(name: &CStr) { // FIXME(libc): adding real STATUS, ERROR type eventually. - extern "C" { + unsafe extern "C" { fn taskNameSet(task_id: libc::TASK_ID, task_name: *mut libc::c_char) -> libc::c_int; } @@ -506,7 +509,7 @@ pub fn available_parallelism() -> io::Result> { } else if #[cfg(target_os = "vxworks")] { // Note: there is also `vxCpuConfiguredGet`, closer to _SC_NPROCESSORS_CONF // expectations than the actual cores availability. - extern "C" { + unsafe extern "C" { fn vxCpuEnabledGet() -> libc::cpuset_t; } diff --git a/std/src/sys/pal/unix/thread_parking.rs b/std/src/sys/pal/unix/thread_parking.rs index 72dd2031479ee..bef8b4fb36391 100644 --- a/std/src/sys/pal/unix/thread_parking.rs +++ b/std/src/sys/pal/unix/thread_parking.rs @@ -8,7 +8,7 @@ use crate::ffi::{c_int, c_void}; use crate::ptr; use crate::time::Duration; -extern "C" { +unsafe extern "C" { fn ___lwp_park60( clock_id: clockid_t, flags: c_int, diff --git a/std/src/sys/pal/unix/weak.rs b/std/src/sys/pal/unix/weak.rs index 35762f5a53b5b..5a37598f43827 100644 --- a/std/src/sys/pal/unix/weak.rs +++ b/std/src/sys/pal/unix/weak.rs @@ -31,7 +31,7 @@ use crate::{mem, ptr}; pub(crate) macro weak { (fn $name:ident($($t:ty),*) -> $ret:ty) => ( let ref $name: ExternWeak $ret> = { - extern "C" { + unsafe extern "C" { #[linkage = "extern_weak"] static $name: Option $ret>; } diff --git a/std/src/sys/pal/unsupported/fs.rs b/std/src/sys/pal/unsupported/fs.rs index 9585ec24f687d..45e93deffa3a4 100644 --- a/std/src/sys/pal/unsupported/fs.rs +++ b/std/src/sys/pal/unsupported/fs.rs @@ -258,6 +258,10 @@ impl File { self.0 } + pub fn tell(&self) -> io::Result { + self.0 + } + pub fn duplicate(&self) -> io::Result { self.0 } diff --git a/std/src/sys/pal/wasi/fs.rs b/std/src/sys/pal/wasi/fs.rs index 7779d2b97d7f9..39978346d7382 100644 --- a/std/src/sys/pal/wasi/fs.rs +++ b/std/src/sys/pal/wasi/fs.rs @@ -183,7 +183,7 @@ impl Iterator for ReadDir { fn next(&mut self) -> Option> { match &mut self.state { - ReadDirState::FillBuffer { next_read_offset, ref mut buf } => { + ReadDirState::FillBuffer { next_read_offset, buf } => { let result = self.inner.dir.fd.readdir(buf, *next_read_offset); match result { Ok(read_bytes) => { @@ -207,7 +207,7 @@ impl Iterator for ReadDir { } } } - ReadDirState::ProcessEntry { ref mut buf, next_read_offset, offset } => { + ReadDirState::ProcessEntry { buf, next_read_offset, offset } => { let contents = &buf[*offset..]; const DIRENT_SIZE: usize = crate::mem::size_of::(); if contents.len() >= DIRENT_SIZE { @@ -517,6 +517,10 @@ impl File { self.fd.seek(pos) } + pub fn tell(&self) -> io::Result { + self.fd.tell() + } + pub fn duplicate(&self) -> io::Result { // https://github.com/CraneStation/wasmtime/blob/master/docs/WASI-rationale.md#why-no-dup unsupported() @@ -533,7 +537,7 @@ impl File { Some(time) if let Some(ts) = time.to_wasi_timestamp() => Ok(ts), Some(_) => Err(io::const_error!( io::ErrorKind::InvalidInput, - "timestamp is too large to set as a file time" + "timestamp is too large to set as a file time", )), None => Ok(0), }; @@ -773,8 +777,7 @@ fn open_parent(p: &Path) -> io::Result<(ManuallyDrop, PathBuf)> { } let msg = format!( "failed to find a pre-opened file descriptor \ - through which {:?} could be opened", - p + through which {p:?} could be opened", ); return Err(io::Error::new(io::ErrorKind::Uncategorized, msg)); } @@ -787,7 +790,7 @@ fn open_parent(p: &Path) -> io::Result<(ManuallyDrop, PathBuf)> { } } - extern "C" { + unsafe extern "C" { pub fn __wasilibc_find_relpath( path: *const libc::c_char, abs_prefix: *mut *const libc::c_char, diff --git a/std/src/sys/pal/wasi/os.rs b/std/src/sys/pal/wasi/os.rs index f7701360f5a9c..ba2b65a1f40dc 100644 --- a/std/src/sys/pal/wasi/os.rs +++ b/std/src/sys/pal/wasi/os.rs @@ -16,7 +16,7 @@ use crate::{fmt, io, str, vec}; mod libc { pub use libc::*; - extern "C" { + unsafe extern "C" { pub fn getcwd(buf: *mut c_char, size: size_t) -> *mut c_char; pub fn chdir(dir: *const c_char) -> c_int; pub fn __wasilibc_get_environ() -> *mut *mut c_char; @@ -46,7 +46,7 @@ cfg_if::cfg_if! { } pub fn errno() -> i32 { - extern "C" { + unsafe extern "C" { #[thread_local] static errno: libc::c_int; } diff --git a/std/src/sys/pal/wasi/stdio.rs b/std/src/sys/pal/wasi/stdio.rs index d08b772e5fc7d..fb21cb4d393d0 100644 --- a/std/src/sys/pal/wasi/stdio.rs +++ b/std/src/sys/pal/wasi/stdio.rs @@ -1,7 +1,7 @@ #![forbid(unsafe_op_in_unsafe_fn)] use super::fd::WasiFd; -use crate::io::{self, IoSlice, IoSliceMut}; +use crate::io::{self, BorrowedCursor, IoSlice, IoSliceMut}; use crate::mem::ManuallyDrop; use crate::os::raw; use crate::os::wasi::io::{AsRawFd, FromRawFd}; @@ -28,6 +28,10 @@ impl io::Read for Stdin { self.read_vectored(&mut [IoSliceMut::new(data)]) } + fn read_buf(&mut self, buf: BorrowedCursor<'_>) -> io::Result<()> { + ManuallyDrop::new(unsafe { WasiFd::from_raw_fd(self.as_raw_fd()) }).read_buf(buf) + } + fn read_vectored(&mut self, data: &mut [IoSliceMut<'_>]) -> io::Result { ManuallyDrop::new(unsafe { WasiFd::from_raw_fd(self.as_raw_fd()) }).read(data) } @@ -64,6 +68,7 @@ impl io::Write for Stdout { fn is_write_vectored(&self) -> bool { true } + fn flush(&mut self) -> io::Result<()> { Ok(()) } diff --git a/std/src/sys/pal/wasi/thread.rs b/std/src/sys/pal/wasi/thread.rs index f5e19f26bfe17..0ae0236941061 100644 --- a/std/src/sys/pal/wasi/thread.rs +++ b/std/src/sys/pal/wasi/thread.rs @@ -35,7 +35,7 @@ cfg_if::cfg_if! { pub const _SC_NPROCESSORS_ONLN: ffi::c_int = 84; - extern "C" { + unsafe extern "C" { pub fn pthread_create( native: *mut pthread_t, attr: *const pthread_attr_t, diff --git a/std/src/sys/pal/wasip2/cabi_realloc.rs b/std/src/sys/pal/wasip2/cabi_realloc.rs index 820063173d657..78adf9002fd7e 100644 --- a/std/src/sys/pal/wasip2/cabi_realloc.rs +++ b/std/src/sys/pal/wasip2/cabi_realloc.rs @@ -32,7 +32,7 @@ static FORCE_CODEGEN_OF_CABI_REALLOC: unsafe extern "C" fn( ) -> *mut u8 = cabi_realloc; #[linkage = "weak"] -#[no_mangle] +#[unsafe(no_mangle)] pub unsafe extern "C" fn cabi_realloc( old_ptr: *mut u8, old_len: usize, diff --git a/std/src/sys/pal/windows/c.rs b/std/src/sys/pal/windows/c.rs index 9ce3e912caf1b..4fbdc839939c9 100644 --- a/std/src/sys/pal/windows/c.rs +++ b/std/src/sys/pal/windows/c.rs @@ -115,7 +115,7 @@ if #[cfg(not(target_vendor = "uwp"))] { link(name = "bcryptprimitives", kind = "raw-dylib", import_name_type = "undecorated") )] #[cfg_attr(not(target_arch = "x86"), link(name = "bcryptprimitives", kind = "raw-dylib"))] -extern "system" { +unsafe extern "system" { pub fn ProcessPrng(pbdata: *mut u8, cbdata: usize) -> BOOL; } @@ -164,7 +164,7 @@ compat_fn_with_fallback! { not(target_arch = "x86"), link(name = "api-ms-win-core-synch-l1-2-0", kind = "raw-dylib") )] -extern "system" { +unsafe extern "system" { pub fn WaitOnAddress( address: *const c_void, compareaddress: *const c_void, @@ -204,7 +204,7 @@ compat_fn_with_fallback! { pub fn NtReleaseKeyedEvent( EventHandle: HANDLE, Key: *const c_void, - Alertable: BOOLEAN, + Alertable: bool, Timeout: *mut i64 ) -> NTSTATUS { panic!("keyed events not available") @@ -213,7 +213,7 @@ compat_fn_with_fallback! { pub fn NtWaitForKeyedEvent( EventHandle: HANDLE, Key: *const c_void, - Alertable: BOOLEAN, + Alertable: bool, Timeout: *mut i64 ) -> NTSTATUS { panic!("keyed events not available") diff --git a/std/src/sys/pal/windows/c/bindings.txt b/std/src/sys/pal/windows/c/bindings.txt index c06f274685c24..e2c2163327968 100644 --- a/std/src/sys/pal/windows/c/bindings.txt +++ b/std/src/sys/pal/windows/c/bindings.txt @@ -1,2611 +1,2612 @@ --out windows_sys.rs ---config flatten sys +--flat +--sys +--no-core --filter -!Windows.Win32.Foundation.INVALID_HANDLE_VALUE -Windows.Wdk.Storage.FileSystem.FILE_COMPLETE_IF_OPLOCKED -Windows.Wdk.Storage.FileSystem.FILE_CONTAINS_EXTENDED_CREATE_INFORMATION -Windows.Wdk.Storage.FileSystem.FILE_CREATE -Windows.Wdk.Storage.FileSystem.FILE_CREATE_TREE_CONNECTION -Windows.Wdk.Storage.FileSystem.FILE_DELETE_ON_CLOSE -Windows.Wdk.Storage.FileSystem.FILE_DIRECTORY_FILE -Windows.Wdk.Storage.FileSystem.FILE_DISALLOW_EXCLUSIVE +!INVALID_HANDLE_VALUE +ABOVE_NORMAL_PRIORITY_CLASS +accept +AcquireSRWLockExclusive +AcquireSRWLockShared +ADDRESS_FAMILY +ADDRINFOA +AddVectoredExceptionHandler +AF_INET +AF_INET6 +AF_UNIX +AF_UNSPEC +ALL_PROCESSOR_GROUPS +ARM64_NT_NEON128 +BELOW_NORMAL_PRIORITY_CLASS +bind +BOOL +BY_HANDLE_FILE_INFORMATION +CALLBACK_CHUNK_FINISHED +CALLBACK_STREAM_SWITCH +CancelIo +CloseHandle +closesocket +COMPARESTRING_RESULT +CompareStringOrdinal +connect +CONSOLE_MODE +CONSOLE_READCONSOLE_CONTROL +CONTEXT +CopyFileExW +CP_UTF8 +CREATE_ALWAYS +CREATE_BREAKAWAY_FROM_JOB +CREATE_DEFAULT_ERROR_MODE +CREATE_FORCEDOS +CREATE_IGNORE_SYSTEM_DEFAULT +CREATE_NEW +CREATE_NEW_CONSOLE +CREATE_NEW_PROCESS_GROUP +CREATE_NO_WINDOW +CREATE_PRESERVE_CODE_AUTHZ_LEVEL +CREATE_PROTECTED_PROCESS +CREATE_SECURE_PROCESS +CREATE_SEPARATE_WOW_VDM +CREATE_SHARED_WOW_VDM +CREATE_SUSPENDED +CREATE_UNICODE_ENVIRONMENT +CREATE_WAITABLE_TIMER_HIGH_RESOLUTION +CREATE_WAITABLE_TIMER_MANUAL_RESET +CreateDirectoryW +CreateEventW +CreateFileW +CreateHardLinkW +CreateNamedPipeW +CreatePipe +CreateProcessW +CreateSymbolicLinkW +CreateThread +CreateWaitableTimerExW +CSTR_EQUAL +CSTR_GREATER_THAN +CSTR_LESS_THAN +DEBUG_ONLY_THIS_PROCESS +DEBUG_PROCESS +DELETE +DeleteFileW +DeleteProcThreadAttributeList +DETACHED_PROCESS +DeviceIoControl +DISABLE_NEWLINE_AUTO_RETURN +DLL_PROCESS_DETACH +DLL_THREAD_DETACH +DNS_ERROR_ADDRESS_REQUIRED +DNS_ERROR_ALIAS_LOOP +DNS_ERROR_AUTOZONE_ALREADY_EXISTS +DNS_ERROR_AXFR +DNS_ERROR_BACKGROUND_LOADING +DNS_ERROR_BAD_KEYMASTER +DNS_ERROR_BAD_PACKET +DNS_ERROR_CANNOT_FIND_ROOT_HINTS +DNS_ERROR_CLIENT_SUBNET_ALREADY_EXISTS +DNS_ERROR_CLIENT_SUBNET_DOES_NOT_EXIST +DNS_ERROR_CLIENT_SUBNET_IS_ACCESSED +DNS_ERROR_CNAME_COLLISION +DNS_ERROR_CNAME_LOOP +DNS_ERROR_DATAFILE_OPEN_FAILURE +DNS_ERROR_DATAFILE_PARSING +DNS_ERROR_DEFAULT_SCOPE +DNS_ERROR_DEFAULT_VIRTUALIZATION_INSTANCE +DNS_ERROR_DEFAULT_ZONESCOPE +DNS_ERROR_DELEGATION_REQUIRED +DNS_ERROR_DNAME_COLLISION +DNS_ERROR_DNSSEC_IS_DISABLED +DNS_ERROR_DP_ALREADY_ENLISTED +DNS_ERROR_DP_ALREADY_EXISTS +DNS_ERROR_DP_DOES_NOT_EXIST +DNS_ERROR_DP_FSMO_ERROR +DNS_ERROR_DP_NOT_AVAILABLE +DNS_ERROR_DP_NOT_ENLISTED +DNS_ERROR_DS_UNAVAILABLE +DNS_ERROR_DS_ZONE_ALREADY_EXISTS +DNS_ERROR_DWORD_VALUE_TOO_LARGE +DNS_ERROR_DWORD_VALUE_TOO_SMALL +DNS_ERROR_FILE_WRITEBACK_FAILED +DNS_ERROR_FORWARDER_ALREADY_EXISTS +DNS_ERROR_INCONSISTENT_ROOT_HINTS +DNS_ERROR_INVAILD_VIRTUALIZATION_INSTANCE_NAME +DNS_ERROR_INVALID_CLIENT_SUBNET_NAME +DNS_ERROR_INVALID_DATA +DNS_ERROR_INVALID_DATAFILE_NAME +DNS_ERROR_INVALID_INITIAL_ROLLOVER_OFFSET +DNS_ERROR_INVALID_IP_ADDRESS +DNS_ERROR_INVALID_KEY_SIZE +DNS_ERROR_INVALID_NAME +DNS_ERROR_INVALID_NAME_CHAR +DNS_ERROR_INVALID_NSEC3_ITERATION_COUNT +DNS_ERROR_INVALID_POLICY_TABLE +DNS_ERROR_INVALID_PROPERTY +DNS_ERROR_INVALID_ROLLOVER_PERIOD +DNS_ERROR_INVALID_SCOPE_NAME +DNS_ERROR_INVALID_SCOPE_OPERATION +DNS_ERROR_INVALID_SIGNATURE_VALIDITY_PERIOD +DNS_ERROR_INVALID_TYPE +DNS_ERROR_INVALID_XML +DNS_ERROR_INVALID_ZONE_OPERATION +DNS_ERROR_INVALID_ZONE_TYPE +DNS_ERROR_INVALID_ZONESCOPE_NAME +DNS_ERROR_KEYMASTER_REQUIRED +DNS_ERROR_KSP_DOES_NOT_SUPPORT_PROTECTION +DNS_ERROR_KSP_NOT_ACCESSIBLE +DNS_ERROR_LOAD_ZONESCOPE_FAILED +DNS_ERROR_NAME_DOES_NOT_EXIST +DNS_ERROR_NAME_NOT_IN_ZONE +DNS_ERROR_NBSTAT_INIT_FAILED +DNS_ERROR_NEED_SECONDARY_ADDRESSES +DNS_ERROR_NEED_WINS_SERVERS +DNS_ERROR_NO_BOOTFILE_IF_DS_ZONE +DNS_ERROR_NO_CREATE_CACHE_DATA +DNS_ERROR_NO_DNS_SERVERS +DNS_ERROR_NO_MEMORY +DNS_ERROR_NO_PACKET +DNS_ERROR_NO_TCPIP +DNS_ERROR_NO_VALID_TRUST_ANCHORS +DNS_ERROR_NO_ZONE_INFO +DNS_ERROR_NODE_CREATION_FAILED +DNS_ERROR_NODE_IS_CNAME +DNS_ERROR_NODE_IS_DNAME +DNS_ERROR_NON_RFC_NAME +DNS_ERROR_NOT_ALLOWED_ON_ACTIVE_SKD +DNS_ERROR_NOT_ALLOWED_ON_RODC +DNS_ERROR_NOT_ALLOWED_ON_ROOT_SERVER +DNS_ERROR_NOT_ALLOWED_ON_SIGNED_ZONE +DNS_ERROR_NOT_ALLOWED_ON_UNSIGNED_ZONE +DNS_ERROR_NOT_ALLOWED_ON_ZSK +DNS_ERROR_NOT_ALLOWED_UNDER_DELEGATION +DNS_ERROR_NOT_ALLOWED_UNDER_DNAME +DNS_ERROR_NOT_ALLOWED_WITH_ZONESCOPES +DNS_ERROR_NOT_ENOUGH_SIGNING_KEY_DESCRIPTORS +DNS_ERROR_NOT_UNIQUE +DNS_ERROR_NSEC3_INCOMPATIBLE_WITH_RSA_SHA1 +DNS_ERROR_NSEC3_NAME_COLLISION +DNS_ERROR_NSEC_INCOMPATIBLE_WITH_NSEC3_RSA_SHA1 +DNS_ERROR_NUMERIC_NAME +DNS_ERROR_POLICY_ALREADY_EXISTS +DNS_ERROR_POLICY_DOES_NOT_EXIST +DNS_ERROR_POLICY_INVALID_CRITERIA +DNS_ERROR_POLICY_INVALID_CRITERIA_CLIENT_SUBNET +DNS_ERROR_POLICY_INVALID_CRITERIA_FQDN +DNS_ERROR_POLICY_INVALID_CRITERIA_INTERFACE +DNS_ERROR_POLICY_INVALID_CRITERIA_NETWORK_PROTOCOL +DNS_ERROR_POLICY_INVALID_CRITERIA_QUERY_TYPE +DNS_ERROR_POLICY_INVALID_CRITERIA_TIME_OF_DAY +DNS_ERROR_POLICY_INVALID_CRITERIA_TRANSPORT_PROTOCOL +DNS_ERROR_POLICY_INVALID_NAME +DNS_ERROR_POLICY_INVALID_SETTINGS +DNS_ERROR_POLICY_INVALID_WEIGHT +DNS_ERROR_POLICY_LOCKED +DNS_ERROR_POLICY_MISSING_CRITERIA +DNS_ERROR_POLICY_PROCESSING_ORDER_INVALID +DNS_ERROR_POLICY_SCOPE_MISSING +DNS_ERROR_POLICY_SCOPE_NOT_ALLOWED +DNS_ERROR_PRIMARY_REQUIRES_DATAFILE +DNS_ERROR_RCODE +DNS_ERROR_RCODE_BADKEY +DNS_ERROR_RCODE_BADSIG +DNS_ERROR_RCODE_BADTIME +DNS_ERROR_RCODE_FORMAT_ERROR +DNS_ERROR_RCODE_NAME_ERROR +DNS_ERROR_RCODE_NOT_IMPLEMENTED +DNS_ERROR_RCODE_NOTAUTH +DNS_ERROR_RCODE_NOTZONE +DNS_ERROR_RCODE_NXRRSET +DNS_ERROR_RCODE_REFUSED +DNS_ERROR_RCODE_SERVER_FAILURE +DNS_ERROR_RCODE_YXDOMAIN +DNS_ERROR_RCODE_YXRRSET +DNS_ERROR_RECORD_ALREADY_EXISTS +DNS_ERROR_RECORD_DOES_NOT_EXIST +DNS_ERROR_RECORD_FORMAT +DNS_ERROR_RECORD_ONLY_AT_ZONE_ROOT +DNS_ERROR_RECORD_TIMED_OUT +DNS_ERROR_ROLLOVER_ALREADY_QUEUED +DNS_ERROR_ROLLOVER_IN_PROGRESS +DNS_ERROR_ROLLOVER_NOT_POKEABLE +DNS_ERROR_RRL_INVALID_IPV4_PREFIX +DNS_ERROR_RRL_INVALID_IPV6_PREFIX +DNS_ERROR_RRL_INVALID_LEAK_RATE +DNS_ERROR_RRL_INVALID_TC_RATE +DNS_ERROR_RRL_INVALID_WINDOW_SIZE +DNS_ERROR_RRL_LEAK_RATE_LESSTHAN_TC_RATE +DNS_ERROR_RRL_NOT_ENABLED +DNS_ERROR_SCOPE_ALREADY_EXISTS +DNS_ERROR_SCOPE_DOES_NOT_EXIST +DNS_ERROR_SCOPE_LOCKED +DNS_ERROR_SECONDARY_DATA +DNS_ERROR_SECONDARY_REQUIRES_MASTER_IP +DNS_ERROR_SERVERSCOPE_IS_REFERENCED +DNS_ERROR_SIGNING_KEY_NOT_ACCESSIBLE +DNS_ERROR_SOA_DELETE_INVALID +DNS_ERROR_STANDBY_KEY_NOT_PRESENT +DNS_ERROR_SUBNET_ALREADY_EXISTS +DNS_ERROR_SUBNET_DOES_NOT_EXIST +DNS_ERROR_TOO_MANY_SKDS +DNS_ERROR_TRY_AGAIN_LATER +DNS_ERROR_UNEXPECTED_CNG_ERROR +DNS_ERROR_UNEXPECTED_DATA_PROTECTION_ERROR +DNS_ERROR_UNKNOWN_RECORD_TYPE +DNS_ERROR_UNKNOWN_SIGNING_PARAMETER_VERSION +DNS_ERROR_UNSECURE_PACKET +DNS_ERROR_UNSUPPORTED_ALGORITHM +DNS_ERROR_VIRTUALIZATION_INSTANCE_ALREADY_EXISTS +DNS_ERROR_VIRTUALIZATION_INSTANCE_DOES_NOT_EXIST +DNS_ERROR_VIRTUALIZATION_TREE_LOCKED +DNS_ERROR_WINS_INIT_FAILED +DNS_ERROR_ZONE_ALREADY_EXISTS +DNS_ERROR_ZONE_CONFIGURATION_ERROR +DNS_ERROR_ZONE_CREATION_FAILED +DNS_ERROR_ZONE_DOES_NOT_EXIST +DNS_ERROR_ZONE_HAS_NO_NS_RECORDS +DNS_ERROR_ZONE_HAS_NO_SOA_RECORD +DNS_ERROR_ZONE_IS_SHUTDOWN +DNS_ERROR_ZONE_LOCKED +DNS_ERROR_ZONE_LOCKED_FOR_SIGNING +DNS_ERROR_ZONE_NOT_SECONDARY +DNS_ERROR_ZONE_REQUIRES_MASTER_IP +DNS_ERROR_ZONESCOPE_ALREADY_EXISTS +DNS_ERROR_ZONESCOPE_DOES_NOT_EXIST +DNS_ERROR_ZONESCOPE_FILE_WRITEBACK_FAILED +DNS_ERROR_ZONESCOPE_IS_REFERENCED +DUPLICATE_CLOSE_SOURCE +DUPLICATE_HANDLE_OPTIONS +DUPLICATE_SAME_ACCESS +DuplicateHandle +E_NOTIMPL +ENABLE_AUTO_POSITION +ENABLE_ECHO_INPUT +ENABLE_EXTENDED_FLAGS +ENABLE_INSERT_MODE +ENABLE_LINE_INPUT +ENABLE_LVB_GRID_WORLDWIDE +ENABLE_MOUSE_INPUT +ENABLE_PROCESSED_INPUT +ENABLE_PROCESSED_OUTPUT +ENABLE_QUICK_EDIT_MODE +ENABLE_VIRTUAL_TERMINAL_INPUT +ENABLE_VIRTUAL_TERMINAL_PROCESSING +ENABLE_WINDOW_INPUT +ENABLE_WRAP_AT_EOL_OUTPUT +ERROR_ABANDON_HIBERFILE +ERROR_ABANDONED_WAIT_0 +ERROR_ABANDONED_WAIT_63 +ERROR_ABIOS_ERROR +ERROR_ACCESS_AUDIT_BY_POLICY +ERROR_ACCESS_DENIED +ERROR_ACCESS_DENIED_APPDATA +ERROR_ACCESS_DISABLED_BY_POLICY +ERROR_ACCESS_DISABLED_NO_SAFER_UI_BY_POLICY +ERROR_ACCESS_DISABLED_WEBBLADE +ERROR_ACCESS_DISABLED_WEBBLADE_TAMPER +ERROR_ACCOUNT_DISABLED +ERROR_ACCOUNT_EXPIRED +ERROR_ACCOUNT_LOCKED_OUT +ERROR_ACCOUNT_RESTRICTION +ERROR_ACPI_ERROR +ERROR_ACTIVE_CONNECTIONS +ERROR_ADAP_HDW_ERR +ERROR_ADDRESS_ALREADY_ASSOCIATED +ERROR_ADDRESS_NOT_ASSOCIATED +ERROR_ALERTED +ERROR_ALIAS_EXISTS +ERROR_ALL_USER_TRUST_QUOTA_EXCEEDED +ERROR_ALLOCATE_BUCKET +ERROR_ALLOTTED_SPACE_EXCEEDED +ERROR_ALREADY_ASSIGNED +ERROR_ALREADY_EXISTS +ERROR_ALREADY_FIBER +ERROR_ALREADY_HAS_STREAM_ID +ERROR_ALREADY_INITIALIZED +ERROR_ALREADY_REGISTERED +ERROR_ALREADY_RUNNING_LKG +ERROR_ALREADY_THREAD +ERROR_ALREADY_WAITING +ERROR_ALREADY_WIN32 +ERROR_API_UNAVAILABLE +ERROR_APP_HANG +ERROR_APP_INIT_FAILURE +ERROR_APP_WRONG_OS +ERROR_APPCONTAINER_REQUIRED +ERROR_APPEXEC_APP_COMPAT_BLOCK +ERROR_APPEXEC_CALLER_WAIT_TIMEOUT +ERROR_APPEXEC_CALLER_WAIT_TIMEOUT_LICENSING +ERROR_APPEXEC_CALLER_WAIT_TIMEOUT_RESOURCES +ERROR_APPEXEC_CALLER_WAIT_TIMEOUT_TERMINATION +ERROR_APPEXEC_CONDITION_NOT_SATISFIED +ERROR_APPEXEC_HANDLE_INVALIDATED +ERROR_APPEXEC_HOST_ID_MISMATCH +ERROR_APPEXEC_INVALID_HOST_GENERATION +ERROR_APPEXEC_INVALID_HOST_STATE +ERROR_APPEXEC_NO_DONOR +ERROR_APPEXEC_UNEXPECTED_PROCESS_REGISTRATION +ERROR_APPEXEC_UNKNOWN_USER +ERROR_APPHELP_BLOCK +ERROR_APPX_FILE_NOT_ENCRYPTED +ERROR_ARBITRATION_UNHANDLED +ERROR_ARENA_TRASHED +ERROR_ARITHMETIC_OVERFLOW +ERROR_ASSERTION_FAILURE +ERROR_ATOMIC_LOCKS_NOT_SUPPORTED +ERROR_AUDIT_FAILED +ERROR_AUTHENTICATION_FIREWALL_FAILED +ERROR_AUTHIP_FAILURE +ERROR_AUTODATASEG_EXCEEDS_64k +ERROR_BACKUP_CONTROLLER +ERROR_BAD_ACCESSOR_FLAGS +ERROR_BAD_ARGUMENTS +ERROR_BAD_COMMAND +ERROR_BAD_COMPRESSION_BUFFER +ERROR_BAD_CONFIGURATION +ERROR_BAD_CURRENT_DIRECTORY +ERROR_BAD_DESCRIPTOR_FORMAT +ERROR_BAD_DEV_TYPE +ERROR_BAD_DEVICE +ERROR_BAD_DEVICE_PATH +ERROR_BAD_DLL_ENTRYPOINT +ERROR_BAD_DRIVER_LEVEL +ERROR_BAD_ENVIRONMENT +ERROR_BAD_EXE_FORMAT +ERROR_BAD_FILE_TYPE +ERROR_BAD_FORMAT +ERROR_BAD_FUNCTION_TABLE +ERROR_BAD_IMPERSONATION_LEVEL +ERROR_BAD_INHERITANCE_ACL +ERROR_BAD_LENGTH +ERROR_BAD_LOGON_SESSION_STATE +ERROR_BAD_MCFG_TABLE +ERROR_BAD_NET_NAME +ERROR_BAD_NET_RESP +ERROR_BAD_NETPATH +ERROR_BAD_PATHNAME +ERROR_BAD_PIPE +ERROR_BAD_PROFILE +ERROR_BAD_PROVIDER +ERROR_BAD_QUERY_SYNTAX +ERROR_BAD_RECOVERY_POLICY +ERROR_BAD_REM_ADAP +ERROR_BAD_SERVICE_ENTRYPOINT +ERROR_BAD_STACK +ERROR_BAD_THREADID_ADDR +ERROR_BAD_TOKEN_TYPE +ERROR_BAD_UNIT +ERROR_BAD_USER_PROFILE +ERROR_BAD_USERNAME +ERROR_BAD_VALIDATION_CLASS +ERROR_BADDB +ERROR_BADKEY +ERROR_BADSTARTPOSITION +ERROR_BEGINNING_OF_MEDIA +ERROR_BEYOND_VDL +ERROR_BIOS_FAILED_TO_CONNECT_INTERRUPT +ERROR_BLOCK_SHARED +ERROR_BLOCK_SOURCE_WEAK_REFERENCE_INVALID +ERROR_BLOCK_TARGET_WEAK_REFERENCE_INVALID +ERROR_BLOCK_TOO_MANY_REFERENCES +ERROR_BLOCK_WEAK_REFERENCE_INVALID +ERROR_BLOCKED_BY_PARENTAL_CONTROLS +ERROR_BOOT_ALREADY_ACCEPTED +ERROR_BROKEN_PIPE +ERROR_BUFFER_ALL_ZEROS +ERROR_BUFFER_OVERFLOW +ERROR_BUS_RESET +ERROR_BUSY +ERROR_BUSY_DRIVE +ERROR_BYPASSIO_FLT_NOT_SUPPORTED +ERROR_CACHE_PAGE_LOCKED +ERROR_CALL_NOT_IMPLEMENTED +ERROR_CALLBACK_INVOKE_INLINE +ERROR_CALLBACK_POP_STACK +ERROR_CALLBACK_SUPPLIED_INVALID_DATA +ERROR_CAN_NOT_COMPLETE +ERROR_CANCEL_VIOLATION +ERROR_CANCELLED +ERROR_CANNOT_BREAK_OPLOCK +ERROR_CANNOT_COPY +ERROR_CANNOT_DETECT_DRIVER_FAILURE +ERROR_CANNOT_DETECT_PROCESS_ABORT +ERROR_CANNOT_FIND_WND_CLASS +ERROR_CANNOT_GRANT_REQUESTED_OPLOCK +ERROR_CANNOT_IMPERSONATE +ERROR_CANNOT_LOAD_REGISTRY_FILE +ERROR_CANNOT_MAKE +ERROR_CANNOT_OPEN_PROFILE +ERROR_CANT_ACCESS_DOMAIN_INFO +ERROR_CANT_ACCESS_FILE +ERROR_CANT_CLEAR_ENCRYPTION_FLAG +ERROR_CANT_DISABLE_MANDATORY +ERROR_CANT_ENABLE_DENY_ONLY +ERROR_CANT_OPEN_ANONYMOUS +ERROR_CANT_RESOLVE_FILENAME +ERROR_CANT_TERMINATE_SELF +ERROR_CANT_WAIT +ERROR_CANTFETCHBACKWARDS +ERROR_CANTOPEN +ERROR_CANTREAD +ERROR_CANTSCROLLBACKWARDS +ERROR_CANTWRITE +ERROR_CAPAUTHZ_CHANGE_TYPE +ERROR_CAPAUTHZ_DB_CORRUPTED +ERROR_CAPAUTHZ_NO_POLICY +ERROR_CAPAUTHZ_NOT_AUTHORIZED +ERROR_CAPAUTHZ_NOT_DEVUNLOCKED +ERROR_CAPAUTHZ_NOT_PROVISIONED +ERROR_CAPAUTHZ_SCCD_DEV_MODE_REQUIRED +ERROR_CAPAUTHZ_SCCD_INVALID_CATALOG +ERROR_CAPAUTHZ_SCCD_NO_AUTH_ENTITY +ERROR_CAPAUTHZ_SCCD_NO_CAPABILITY_MATCH +ERROR_CAPAUTHZ_SCCD_PARSE_ERROR +ERROR_CARDBUS_NOT_SUPPORTED +ERROR_CASE_DIFFERING_NAMES_IN_DIR +ERROR_CASE_SENSITIVE_PATH +ERROR_CERTIFICATE_VALIDATION_PREFERENCE_CONFLICT +ERROR_CHECKING_FILE_SYSTEM +ERROR_CHECKOUT_REQUIRED +ERROR_CHILD_MUST_BE_VOLATILE +ERROR_CHILD_NOT_COMPLETE +ERROR_CHILD_PROCESS_BLOCKED +ERROR_CHILD_WINDOW_MENU +ERROR_CIMFS_IMAGE_CORRUPT +ERROR_CIMFS_IMAGE_VERSION_NOT_SUPPORTED +ERROR_CIRCULAR_DEPENDENCY +ERROR_CLASS_ALREADY_EXISTS +ERROR_CLASS_DOES_NOT_EXIST +ERROR_CLASS_HAS_WINDOWS +ERROR_CLIENT_SERVER_PARAMETERS_INVALID +ERROR_CLIPBOARD_NOT_OPEN +ERROR_CLOUD_FILE_ACCESS_DENIED +ERROR_CLOUD_FILE_ALREADY_CONNECTED +ERROR_CLOUD_FILE_AUTHENTICATION_FAILED +ERROR_CLOUD_FILE_CONNECTED_PROVIDER_ONLY +ERROR_CLOUD_FILE_DEHYDRATION_DISALLOWED +ERROR_CLOUD_FILE_IN_USE +ERROR_CLOUD_FILE_INCOMPATIBLE_HARDLINKS +ERROR_CLOUD_FILE_INSUFFICIENT_RESOURCES +ERROR_CLOUD_FILE_INVALID_REQUEST +ERROR_CLOUD_FILE_METADATA_CORRUPT +ERROR_CLOUD_FILE_METADATA_TOO_LARGE +ERROR_CLOUD_FILE_NETWORK_UNAVAILABLE +ERROR_CLOUD_FILE_NOT_IN_SYNC +ERROR_CLOUD_FILE_NOT_SUPPORTED +ERROR_CLOUD_FILE_NOT_UNDER_SYNC_ROOT +ERROR_CLOUD_FILE_PINNED +ERROR_CLOUD_FILE_PROPERTY_BLOB_CHECKSUM_MISMATCH +ERROR_CLOUD_FILE_PROPERTY_BLOB_TOO_LARGE +ERROR_CLOUD_FILE_PROPERTY_CORRUPT +ERROR_CLOUD_FILE_PROPERTY_LOCK_CONFLICT +ERROR_CLOUD_FILE_PROPERTY_VERSION_NOT_SUPPORTED +ERROR_CLOUD_FILE_PROVIDER_NOT_RUNNING +ERROR_CLOUD_FILE_PROVIDER_TERMINATED +ERROR_CLOUD_FILE_READ_ONLY_VOLUME +ERROR_CLOUD_FILE_REQUEST_ABORTED +ERROR_CLOUD_FILE_REQUEST_CANCELED +ERROR_CLOUD_FILE_REQUEST_TIMEOUT +ERROR_CLOUD_FILE_SYNC_ROOT_METADATA_CORRUPT +ERROR_CLOUD_FILE_TOO_MANY_PROPERTY_BLOBS +ERROR_CLOUD_FILE_UNSUCCESSFUL +ERROR_CLOUD_FILE_US_MESSAGE_TIMEOUT +ERROR_CLOUD_FILE_VALIDATION_FAILED +ERROR_COMMITMENT_LIMIT +ERROR_COMMITMENT_MINIMUM +ERROR_COMPRESSED_FILE_NOT_SUPPORTED +ERROR_COMPRESSION_DISABLED +ERROR_COMPRESSION_NOT_BENEFICIAL +ERROR_CONNECTED_OTHER_PASSWORD +ERROR_CONNECTED_OTHER_PASSWORD_DEFAULT +ERROR_CONNECTION_ABORTED +ERROR_CONNECTION_ACTIVE +ERROR_CONNECTION_COUNT_LIMIT +ERROR_CONNECTION_INVALID +ERROR_CONNECTION_REFUSED +ERROR_CONNECTION_UNAVAIL +ERROR_CONTAINER_ASSIGNED +ERROR_CONTENT_BLOCKED +ERROR_CONTEXT_EXPIRED +ERROR_CONTINUE +ERROR_CONTROL_C_EXIT +ERROR_CONTROL_ID_NOT_FOUND +ERROR_CONVERT_TO_LARGE +ERROR_CORRUPT_LOG_CLEARED +ERROR_CORRUPT_LOG_CORRUPTED +ERROR_CORRUPT_LOG_DELETED_FULL +ERROR_CORRUPT_LOG_OVERFULL +ERROR_CORRUPT_LOG_UNAVAILABLE +ERROR_CORRUPT_SYSTEM_FILE +ERROR_COULD_NOT_INTERPRET +ERROR_COUNTER_TIMEOUT +ERROR_CPU_SET_INVALID +ERROR_CRASH_DUMP +ERROR_CRC +ERROR_CREATE_FAILED +ERROR_CROSS_PARTITION_VIOLATION +ERROR_CS_ENCRYPTION_EXISTING_ENCRYPTED_FILE +ERROR_CS_ENCRYPTION_FILE_NOT_CSE +ERROR_CS_ENCRYPTION_INVALID_SERVER_RESPONSE +ERROR_CS_ENCRYPTION_NEW_ENCRYPTED_FILE +ERROR_CS_ENCRYPTION_UNSUPPORTED_SERVER +ERROR_CSCSHARE_OFFLINE +ERROR_CTX_CLIENT_QUERY_TIMEOUT +ERROR_CTX_MODEM_RESPONSE_TIMEOUT +ERROR_CURRENT_DIRECTORY +ERROR_CURRENT_DOMAIN_NOT_ALLOWED +ERROR_DATA_CHECKSUM_ERROR +ERROR_DATA_NOT_ACCEPTED +ERROR_DATABASE_DOES_NOT_EXIST +ERROR_DATATYPE_MISMATCH +ERROR_DAX_MAPPING_EXISTS +ERROR_DBG_COMMAND_EXCEPTION +ERROR_DBG_CONTINUE +ERROR_DBG_CONTROL_BREAK +ERROR_DBG_CONTROL_C +ERROR_DBG_EXCEPTION_HANDLED +ERROR_DBG_EXCEPTION_NOT_HANDLED +ERROR_DBG_PRINTEXCEPTION_C +ERROR_DBG_REPLY_LATER +ERROR_DBG_RIPEXCEPTION +ERROR_DBG_TERMINATE_PROCESS +ERROR_DBG_TERMINATE_THREAD +ERROR_DBG_UNABLE_TO_PROVIDE_HANDLE +ERROR_DC_NOT_FOUND +ERROR_DDE_FAIL +ERROR_DEBUG_ATTACH_FAILED +ERROR_DEBUGGER_INACTIVE +ERROR_DECRYPTION_FAILED +ERROR_DELAY_LOAD_FAILED +ERROR_DELETE_PENDING +ERROR_DEPENDENT_SERVICES_RUNNING +ERROR_DESTINATION_ELEMENT_FULL +ERROR_DESTROY_OBJECT_OF_OTHER_THREAD +ERROR_DEV_NOT_EXIST +ERROR_DEVICE_ALREADY_ATTACHED +ERROR_DEVICE_ALREADY_REMEMBERED +ERROR_DEVICE_DOOR_OPEN +ERROR_DEVICE_ENUMERATION_ERROR +ERROR_DEVICE_FEATURE_NOT_SUPPORTED +ERROR_DEVICE_HARDWARE_ERROR +ERROR_DEVICE_HINT_NAME_BUFFER_TOO_SMALL +ERROR_DEVICE_IN_MAINTENANCE +ERROR_DEVICE_IN_USE +ERROR_DEVICE_NO_RESOURCES +ERROR_DEVICE_NOT_CONNECTED +ERROR_DEVICE_NOT_PARTITIONED +ERROR_DEVICE_REINITIALIZATION_NEEDED +ERROR_DEVICE_REMOVED +ERROR_DEVICE_REQUIRES_CLEANING +ERROR_DEVICE_RESET_REQUIRED +ERROR_DEVICE_SUPPORT_IN_PROGRESS +ERROR_DEVICE_UNREACHABLE +ERROR_DHCP_ADDRESS_CONFLICT +ERROR_DIFFERENT_SERVICE_ACCOUNT +ERROR_DIR_EFS_DISALLOWED +ERROR_DIR_NOT_EMPTY +ERROR_DIR_NOT_ROOT +ERROR_DIRECT_ACCESS_HANDLE +ERROR_DIRECTORY +ERROR_DIRECTORY_NOT_SUPPORTED +ERROR_DISCARDED +ERROR_DISK_CHANGE +ERROR_DISK_CORRUPT +ERROR_DISK_FULL +ERROR_DISK_OPERATION_FAILED +ERROR_DISK_QUOTA_EXCEEDED +ERROR_DISK_RECALIBRATE_FAILED +ERROR_DISK_REPAIR_DISABLED +ERROR_DISK_REPAIR_REDIRECTED +ERROR_DISK_REPAIR_UNSUCCESSFUL +ERROR_DISK_RESET_FAILED +ERROR_DISK_RESOURCES_EXHAUSTED +ERROR_DISK_TOO_FRAGMENTED +ERROR_DLL_INIT_FAILED +ERROR_DLL_INIT_FAILED_LOGOFF +ERROR_DLL_MIGHT_BE_INCOMPATIBLE +ERROR_DLL_MIGHT_BE_INSECURE +ERROR_DLL_NOT_FOUND +ERROR_DLP_POLICY_DENIES_OPERATION +ERROR_DLP_POLICY_SILENTLY_FAIL +ERROR_DLP_POLICY_WARNS_AGAINST_OPERATION +ERROR_DOMAIN_CONTROLLER_EXISTS +ERROR_DOMAIN_CONTROLLER_NOT_FOUND +ERROR_DOMAIN_CTRLR_CONFIG_ERROR +ERROR_DOMAIN_EXISTS +ERROR_DOMAIN_LIMIT_EXCEEDED +ERROR_DOMAIN_SID_SAME_AS_LOCAL_WORKSTATION +ERROR_DOMAIN_TRUST_INCONSISTENT +ERROR_DOWNGRADE_DETECTED +ERROR_DPL_NOT_SUPPORTED_FOR_USER +ERROR_DRIVE_LOCKED +ERROR_DRIVER_BLOCKED +ERROR_DRIVER_CANCEL_TIMEOUT +ERROR_DRIVER_DATABASE_ERROR +ERROR_DRIVER_FAILED_PRIOR_UNLOAD +ERROR_DRIVER_FAILED_SLEEP +ERROR_DRIVER_PROCESS_TERMINATED +ERROR_DRIVERS_LEAKING_LOCKED_PAGES +ERROR_DS_ADD_REPLICA_INHIBITED +ERROR_DS_ADMIN_LIMIT_EXCEEDED +ERROR_DS_AFFECTS_MULTIPLE_DSAS +ERROR_DS_AG_CANT_HAVE_UNIVERSAL_MEMBER +ERROR_DS_ALIAS_DEREF_PROBLEM +ERROR_DS_ALIAS_POINTS_TO_ALIAS +ERROR_DS_ALIAS_PROBLEM +ERROR_DS_ALIASED_OBJ_MISSING +ERROR_DS_ATT_ALREADY_EXISTS +ERROR_DS_ATT_IS_NOT_ON_OBJ +ERROR_DS_ATT_NOT_DEF_FOR_CLASS +ERROR_DS_ATT_NOT_DEF_IN_SCHEMA +ERROR_DS_ATT_SCHEMA_REQ_ID +ERROR_DS_ATT_SCHEMA_REQ_SYNTAX +ERROR_DS_ATT_VAL_ALREADY_EXISTS +ERROR_DS_ATTRIBUTE_OR_VALUE_EXISTS +ERROR_DS_ATTRIBUTE_OWNED_BY_SAM +ERROR_DS_ATTRIBUTE_TYPE_UNDEFINED +ERROR_DS_AUDIT_FAILURE +ERROR_DS_AUTH_METHOD_NOT_SUPPORTED +ERROR_DS_AUTH_UNKNOWN +ERROR_DS_AUTHORIZATION_FAILED +ERROR_DS_AUX_CLS_TEST_FAIL +ERROR_DS_BACKLINK_WITHOUT_LINK +ERROR_DS_BAD_ATT_SCHEMA_SYNTAX +ERROR_DS_BAD_HIERARCHY_FILE +ERROR_DS_BAD_INSTANCE_TYPE +ERROR_DS_BAD_NAME_SYNTAX +ERROR_DS_BAD_RDN_ATT_ID_SYNTAX +ERROR_DS_BUILD_HIERARCHY_TABLE_FAILED +ERROR_DS_BUSY +ERROR_DS_CANT_ACCESS_REMOTE_PART_OF_AD +ERROR_DS_CANT_ADD_ATT_VALUES +ERROR_DS_CANT_ADD_SYSTEM_ONLY +ERROR_DS_CANT_ADD_TO_GC +ERROR_DS_CANT_CACHE_ATT +ERROR_DS_CANT_CACHE_CLASS +ERROR_DS_CANT_CREATE_IN_NONDOMAIN_NC +ERROR_DS_CANT_CREATE_UNDER_SCHEMA +ERROR_DS_CANT_DEL_MASTER_CROSSREF +ERROR_DS_CANT_DELETE +ERROR_DS_CANT_DELETE_DSA_OBJ +ERROR_DS_CANT_DEMOTE_WITH_WRITEABLE_NC +ERROR_DS_CANT_DEREF_ALIAS +ERROR_DS_CANT_DERIVE_SPN_FOR_DELETED_DOMAIN +ERROR_DS_CANT_DERIVE_SPN_WITHOUT_SERVER_REF +ERROR_DS_CANT_FIND_DC_FOR_SRC_DOMAIN +ERROR_DS_CANT_FIND_DSA_OBJ +ERROR_DS_CANT_FIND_EXPECTED_NC +ERROR_DS_CANT_FIND_NC_IN_CACHE +ERROR_DS_CANT_MIX_MASTER_AND_REPS +ERROR_DS_CANT_MOD_OBJ_CLASS +ERROR_DS_CANT_MOD_PRIMARYGROUPID +ERROR_DS_CANT_MOD_SYSTEM_ONLY +ERROR_DS_CANT_MOVE_ACCOUNT_GROUP +ERROR_DS_CANT_MOVE_APP_BASIC_GROUP +ERROR_DS_CANT_MOVE_APP_QUERY_GROUP +ERROR_DS_CANT_MOVE_DELETED_OBJECT +ERROR_DS_CANT_MOVE_RESOURCE_GROUP +ERROR_DS_CANT_ON_NON_LEAF +ERROR_DS_CANT_ON_RDN +ERROR_DS_CANT_REM_MISSING_ATT +ERROR_DS_CANT_REM_MISSING_ATT_VAL +ERROR_DS_CANT_REMOVE_ATT_CACHE +ERROR_DS_CANT_REMOVE_CLASS_CACHE +ERROR_DS_CANT_REPLACE_HIDDEN_REC +ERROR_DS_CANT_RETRIEVE_ATTS +ERROR_DS_CANT_RETRIEVE_CHILD +ERROR_DS_CANT_RETRIEVE_DN +ERROR_DS_CANT_RETRIEVE_INSTANCE +ERROR_DS_CANT_RETRIEVE_SD +ERROR_DS_CANT_START +ERROR_DS_CANT_TREE_DELETE_CRITICAL_OBJ +ERROR_DS_CANT_WITH_ACCT_GROUP_MEMBERSHPS +ERROR_DS_CHILDREN_EXIST +ERROR_DS_CLASS_MUST_BE_CONCRETE +ERROR_DS_CLASS_NOT_DSA +ERROR_DS_CLIENT_LOOP +ERROR_DS_CODE_INCONSISTENCY +ERROR_DS_COMPARE_FALSE +ERROR_DS_COMPARE_TRUE +ERROR_DS_CONFIDENTIALITY_REQUIRED +ERROR_DS_CONFIG_PARAM_MISSING +ERROR_DS_CONSTRAINT_VIOLATION +ERROR_DS_CONSTRUCTED_ATT_MOD +ERROR_DS_CONTROL_NOT_FOUND +ERROR_DS_COULDNT_CONTACT_FSMO +ERROR_DS_COULDNT_IDENTIFY_OBJECTS_FOR_TREE_DELETE +ERROR_DS_COULDNT_LOCK_TREE_FOR_DELETE +ERROR_DS_COULDNT_UPDATE_SPNS +ERROR_DS_COUNTING_AB_INDICES_FAILED +ERROR_DS_CR_IMPOSSIBLE_TO_VALIDATE +ERROR_DS_CR_IMPOSSIBLE_TO_VALIDATE_V2 +ERROR_DS_CROSS_DOM_MOVE_ERROR +ERROR_DS_CROSS_DOMAIN_CLEANUP_REQD +ERROR_DS_CROSS_NC_DN_RENAME +ERROR_DS_CROSS_REF_BUSY +ERROR_DS_CROSS_REF_EXISTS +ERROR_DS_DATABASE_ERROR +ERROR_DS_DECODING_ERROR +ERROR_DS_DESTINATION_AUDITING_NOT_ENABLED +ERROR_DS_DESTINATION_DOMAIN_NOT_IN_FOREST +ERROR_DS_DIFFERENT_REPL_EPOCHS +ERROR_DS_DISALLOWED_IN_SYSTEM_CONTAINER +ERROR_DS_DISALLOWED_NC_REDIRECT +ERROR_DS_DNS_LOOKUP_FAILURE +ERROR_DS_DOMAIN_NAME_EXISTS_IN_FOREST +ERROR_DS_DOMAIN_RENAME_IN_PROGRESS +ERROR_DS_DOMAIN_VERSION_TOO_HIGH +ERROR_DS_DOMAIN_VERSION_TOO_LOW +ERROR_DS_DRA_ABANDON_SYNC +ERROR_DS_DRA_ACCESS_DENIED +ERROR_DS_DRA_BAD_DN +ERROR_DS_DRA_BAD_INSTANCE_TYPE +ERROR_DS_DRA_BAD_NC +ERROR_DS_DRA_BUSY +ERROR_DS_DRA_CONNECTION_FAILED +ERROR_DS_DRA_CORRUPT_UTD_VECTOR +ERROR_DS_DRA_DB_ERROR +ERROR_DS_DRA_DN_EXISTS +ERROR_DS_DRA_EARLIER_SCHEMA_CONFLICT +ERROR_DS_DRA_EXTN_CONNECTION_FAILED +ERROR_DS_DRA_GENERIC +ERROR_DS_DRA_INCOMPATIBLE_PARTIAL_SET +ERROR_DS_DRA_INCONSISTENT_DIT +ERROR_DS_DRA_INTERNAL_ERROR +ERROR_DS_DRA_INVALID_PARAMETER +ERROR_DS_DRA_MAIL_PROBLEM +ERROR_DS_DRA_MISSING_KRBTGT_SECRET +ERROR_DS_DRA_MISSING_PARENT +ERROR_DS_DRA_NAME_COLLISION +ERROR_DS_DRA_NO_REPLICA +ERROR_DS_DRA_NOT_SUPPORTED +ERROR_DS_DRA_OBJ_IS_REP_SOURCE +ERROR_DS_DRA_OBJ_NC_MISMATCH +ERROR_DS_DRA_OUT_OF_MEM +ERROR_DS_DRA_OUT_SCHEDULE_WINDOW +ERROR_DS_DRA_PREEMPTED +ERROR_DS_DRA_RECYCLED_TARGET +ERROR_DS_DRA_REF_ALREADY_EXISTS +ERROR_DS_DRA_REF_NOT_FOUND +ERROR_DS_DRA_REPL_PENDING +ERROR_DS_DRA_RPC_CANCELLED +ERROR_DS_DRA_SCHEMA_CONFLICT +ERROR_DS_DRA_SCHEMA_INFO_SHIP +ERROR_DS_DRA_SCHEMA_MISMATCH +ERROR_DS_DRA_SECRETS_DENIED +ERROR_DS_DRA_SHUTDOWN +ERROR_DS_DRA_SINK_DISABLED +ERROR_DS_DRA_SOURCE_DISABLED +ERROR_DS_DRA_SOURCE_IS_PARTIAL_REPLICA +ERROR_DS_DRA_SOURCE_REINSTALLED +ERROR_DS_DRS_EXTENSIONS_CHANGED +ERROR_DS_DS_REQUIRED +ERROR_DS_DSA_MUST_BE_INT_MASTER +ERROR_DS_DST_DOMAIN_NOT_NATIVE +ERROR_DS_DST_NC_MISMATCH +ERROR_DS_DUP_LDAP_DISPLAY_NAME +ERROR_DS_DUP_LINK_ID +ERROR_DS_DUP_MAPI_ID +ERROR_DS_DUP_MSDS_INTID +ERROR_DS_DUP_OID +ERROR_DS_DUP_RDN +ERROR_DS_DUP_SCHEMA_ID_GUID +ERROR_DS_DUPLICATE_ID_FOUND +ERROR_DS_ENCODING_ERROR +ERROR_DS_EPOCH_MISMATCH +ERROR_DS_EXISTING_AD_CHILD_NC +ERROR_DS_EXISTS_IN_AUX_CLS +ERROR_DS_EXISTS_IN_MAY_HAVE +ERROR_DS_EXISTS_IN_MUST_HAVE +ERROR_DS_EXISTS_IN_POSS_SUP +ERROR_DS_EXISTS_IN_RDNATTID +ERROR_DS_EXISTS_IN_SUB_CLS +ERROR_DS_FILTER_UNKNOWN +ERROR_DS_FILTER_USES_CONTRUCTED_ATTRS +ERROR_DS_FLAT_NAME_EXISTS_IN_FOREST +ERROR_DS_FOREST_VERSION_TOO_HIGH +ERROR_DS_FOREST_VERSION_TOO_LOW +ERROR_DS_GC_NOT_AVAILABLE +ERROR_DS_GC_REQUIRED +ERROR_DS_GCVERIFY_ERROR +ERROR_DS_GENERIC_ERROR +ERROR_DS_GLOBAL_CANT_HAVE_CROSSDOMAIN_MEMBER +ERROR_DS_GLOBAL_CANT_HAVE_LOCAL_MEMBER +ERROR_DS_GLOBAL_CANT_HAVE_UNIVERSAL_MEMBER +ERROR_DS_GOVERNSID_MISSING +ERROR_DS_GROUP_CONVERSION_ERROR +ERROR_DS_HAVE_PRIMARY_MEMBERS +ERROR_DS_HIERARCHY_TABLE_MALLOC_FAILED +ERROR_DS_HIERARCHY_TABLE_TOO_DEEP +ERROR_DS_HIGH_ADLDS_FFL +ERROR_DS_HIGH_DSA_VERSION +ERROR_DS_ILLEGAL_BASE_SCHEMA_MOD +ERROR_DS_ILLEGAL_MOD_OPERATION +ERROR_DS_ILLEGAL_SUPERIOR +ERROR_DS_ILLEGAL_XDOM_MOVE_OPERATION +ERROR_DS_INAPPROPRIATE_AUTH +ERROR_DS_INAPPROPRIATE_MATCHING +ERROR_DS_INCOMPATIBLE_CONTROLS_USED +ERROR_DS_INCOMPATIBLE_VERSION +ERROR_DS_INCORRECT_ROLE_OWNER +ERROR_DS_INIT_FAILURE +ERROR_DS_INIT_FAILURE_CONSOLE +ERROR_DS_INSTALL_NO_SCH_VERSION_IN_INIFILE +ERROR_DS_INSTALL_NO_SRC_SCH_VERSION +ERROR_DS_INSTALL_SCHEMA_MISMATCH +ERROR_DS_INSUFF_ACCESS_RIGHTS +ERROR_DS_INSUFFICIENT_ATTR_TO_CREATE_OBJECT +ERROR_DS_INTERNAL_FAILURE +ERROR_DS_INVALID_ATTRIBUTE_SYNTAX +ERROR_DS_INVALID_DMD +ERROR_DS_INVALID_DN_SYNTAX +ERROR_DS_INVALID_GROUP_TYPE +ERROR_DS_INVALID_LDAP_DISPLAY_NAME +ERROR_DS_INVALID_NAME_FOR_SPN +ERROR_DS_INVALID_ROLE_OWNER +ERROR_DS_INVALID_SCRIPT +ERROR_DS_INVALID_SEARCH_FLAG +ERROR_DS_INVALID_SEARCH_FLAG_SUBTREE +ERROR_DS_INVALID_SEARCH_FLAG_TUPLE +ERROR_DS_IS_LEAF +ERROR_DS_KEY_NOT_UNIQUE +ERROR_DS_LDAP_SEND_QUEUE_FULL +ERROR_DS_LINK_ID_NOT_AVAILABLE +ERROR_DS_LOCAL_CANT_HAVE_CROSSDOMAIN_LOCAL_MEMBER +ERROR_DS_LOCAL_ERROR +ERROR_DS_LOCAL_MEMBER_OF_LOCAL_ONLY +ERROR_DS_LOOP_DETECT +ERROR_DS_LOW_ADLDS_FFL +ERROR_DS_LOW_DSA_VERSION +ERROR_DS_MACHINE_ACCOUNT_CREATED_PRENT4 +ERROR_DS_MACHINE_ACCOUNT_QUOTA_EXCEEDED +ERROR_DS_MAPI_ID_NOT_AVAILABLE +ERROR_DS_MASTERDSA_REQUIRED +ERROR_DS_MAX_OBJ_SIZE_EXCEEDED +ERROR_DS_MEMBERSHIP_EVALUATED_LOCALLY +ERROR_DS_MISSING_EXPECTED_ATT +ERROR_DS_MISSING_FOREST_TRUST +ERROR_DS_MISSING_FSMO_SETTINGS +ERROR_DS_MISSING_INFRASTRUCTURE_CONTAINER +ERROR_DS_MISSING_REQUIRED_ATT +ERROR_DS_MISSING_SUPREF +ERROR_DS_MODIFYDN_DISALLOWED_BY_FLAG +ERROR_DS_MODIFYDN_DISALLOWED_BY_INSTANCE_TYPE +ERROR_DS_MODIFYDN_WRONG_GRANDPARENT +ERROR_DS_MUST_BE_RUN_ON_DST_DC +ERROR_DS_NAME_ERROR_DOMAIN_ONLY +ERROR_DS_NAME_ERROR_NO_MAPPING +ERROR_DS_NAME_ERROR_NO_SYNTACTICAL_MAPPING +ERROR_DS_NAME_ERROR_NOT_FOUND +ERROR_DS_NAME_ERROR_NOT_UNIQUE +ERROR_DS_NAME_ERROR_RESOLVING +ERROR_DS_NAME_ERROR_TRUST_REFERRAL +ERROR_DS_NAME_NOT_UNIQUE +ERROR_DS_NAME_REFERENCE_INVALID +ERROR_DS_NAME_TOO_LONG +ERROR_DS_NAME_TOO_MANY_PARTS +ERROR_DS_NAME_TYPE_UNKNOWN +ERROR_DS_NAME_UNPARSEABLE +ERROR_DS_NAME_VALUE_TOO_LONG +ERROR_DS_NAMING_MASTER_GC +ERROR_DS_NAMING_VIOLATION +ERROR_DS_NC_MUST_HAVE_NC_PARENT +ERROR_DS_NC_STILL_HAS_DSAS +ERROR_DS_NCNAME_MISSING_CR_REF +ERROR_DS_NCNAME_MUST_BE_NC +ERROR_DS_NO_ATTRIBUTE_OR_VALUE +ERROR_DS_NO_BEHAVIOR_VERSION_IN_MIXEDDOMAIN +ERROR_DS_NO_CHAINED_EVAL +ERROR_DS_NO_CHAINING +ERROR_DS_NO_CHECKPOINT_WITH_PDC +ERROR_DS_NO_CROSSREF_FOR_NC +ERROR_DS_NO_DELETED_NAME +ERROR_DS_NO_FPO_IN_UNIVERSAL_GROUPS +ERROR_DS_NO_MORE_RIDS +ERROR_DS_NO_MSDS_INTID +ERROR_DS_NO_NEST_GLOBALGROUP_IN_MIXEDDOMAIN +ERROR_DS_NO_NEST_LOCALGROUP_IN_MIXEDDOMAIN +ERROR_DS_NO_NTDSA_OBJECT +ERROR_DS_NO_OBJECT_MOVE_IN_SCHEMA_NC +ERROR_DS_NO_PARENT_OBJECT +ERROR_DS_NO_PKT_PRIVACY_ON_CONNECTION +ERROR_DS_NO_RDN_DEFINED_IN_SCHEMA +ERROR_DS_NO_REF_DOMAIN +ERROR_DS_NO_REQUESTED_ATTS_FOUND +ERROR_DS_NO_RESULTS_RETURNED +ERROR_DS_NO_RIDS_ALLOCATED +ERROR_DS_NO_SERVER_OBJECT +ERROR_DS_NO_SUCH_OBJECT +ERROR_DS_NO_TREE_DELETE_ABOVE_NC +ERROR_DS_NON_ASQ_SEARCH +ERROR_DS_NON_BASE_SEARCH +ERROR_DS_NONEXISTENT_MAY_HAVE +ERROR_DS_NONEXISTENT_MUST_HAVE +ERROR_DS_NONEXISTENT_POSS_SUP +ERROR_DS_NONSAFE_SCHEMA_CHANGE +ERROR_DS_NOT_AN_OBJECT +ERROR_DS_NOT_AUTHORITIVE_FOR_DST_NC +ERROR_DS_NOT_CLOSEST +ERROR_DS_NOT_INSTALLED +ERROR_DS_NOT_ON_BACKLINK +ERROR_DS_NOT_SUPPORTED +ERROR_DS_NOT_SUPPORTED_SORT_ORDER +ERROR_DS_NOTIFY_FILTER_TOO_COMPLEX +ERROR_DS_NTDSCRIPT_PROCESS_ERROR +ERROR_DS_NTDSCRIPT_SYNTAX_ERROR +ERROR_DS_OBJ_CLASS_NOT_DEFINED +ERROR_DS_OBJ_CLASS_NOT_SUBCLASS +ERROR_DS_OBJ_CLASS_VIOLATION +ERROR_DS_OBJ_GUID_EXISTS +ERROR_DS_OBJ_NOT_FOUND +ERROR_DS_OBJ_STRING_NAME_EXISTS +ERROR_DS_OBJ_TOO_LARGE +ERROR_DS_OBJECT_BEING_REMOVED +ERROR_DS_OBJECT_CLASS_REQUIRED +ERROR_DS_OBJECT_RESULTS_TOO_LARGE +ERROR_DS_OFFSET_RANGE_ERROR +ERROR_DS_OID_MAPPED_GROUP_CANT_HAVE_MEMBERS +ERROR_DS_OID_NOT_FOUND +ERROR_DS_OPERATIONS_ERROR +ERROR_DS_OUT_OF_SCOPE +ERROR_DS_OUT_OF_VERSION_STORE +ERROR_DS_PARAM_ERROR +ERROR_DS_PARENT_IS_AN_ALIAS +ERROR_DS_PDC_OPERATION_IN_PROGRESS +ERROR_DS_PER_ATTRIBUTE_AUTHZ_FAILED_DURING_ADD +ERROR_DS_POLICY_NOT_KNOWN +ERROR_DS_PROTOCOL_ERROR +ERROR_DS_RANGE_CONSTRAINT +ERROR_DS_RDN_DOESNT_MATCH_SCHEMA +ERROR_DS_RECALCSCHEMA_FAILED +ERROR_DS_REFERRAL +ERROR_DS_REFERRAL_LIMIT_EXCEEDED +ERROR_DS_REFUSING_FSMO_ROLES +ERROR_DS_REMOTE_CROSSREF_OP_FAILED +ERROR_DS_REPL_LIFETIME_EXCEEDED +ERROR_DS_REPLICA_SET_CHANGE_NOT_ALLOWED_ON_DISABLED_CR +ERROR_DS_REPLICATOR_ONLY +ERROR_DS_RESERVED_LINK_ID +ERROR_DS_RESERVED_MAPI_ID +ERROR_DS_RIDMGR_DISABLED +ERROR_DS_RIDMGR_INIT_ERROR +ERROR_DS_ROLE_NOT_VERIFIED +ERROR_DS_ROOT_CANT_BE_SUBREF +ERROR_DS_ROOT_MUST_BE_NC +ERROR_DS_ROOT_REQUIRES_CLASS_TOP +ERROR_DS_SAM_INIT_FAILURE +ERROR_DS_SAM_INIT_FAILURE_CONSOLE +ERROR_DS_SAM_NEED_BOOTKEY_FLOPPY +ERROR_DS_SAM_NEED_BOOTKEY_PASSWORD +ERROR_DS_SCHEMA_ALLOC_FAILED +ERROR_DS_SCHEMA_NOT_LOADED +ERROR_DS_SCHEMA_UPDATE_DISALLOWED +ERROR_DS_SEC_DESC_INVALID +ERROR_DS_SEC_DESC_TOO_SHORT +ERROR_DS_SECURITY_CHECKING_ERROR +ERROR_DS_SECURITY_ILLEGAL_MODIFY +ERROR_DS_SEMANTIC_ATT_TEST +ERROR_DS_SENSITIVE_GROUP_VIOLATION +ERROR_DS_SERVER_DOWN +ERROR_DS_SHUTTING_DOWN +ERROR_DS_SINGLE_USER_MODE_FAILED +ERROR_DS_SINGLE_VALUE_CONSTRAINT +ERROR_DS_SIZELIMIT_EXCEEDED +ERROR_DS_SORT_CONTROL_MISSING +ERROR_DS_SOURCE_AUDITING_NOT_ENABLED +ERROR_DS_SOURCE_DOMAIN_IN_FOREST +ERROR_DS_SPN_VALUE_NOT_UNIQUE_IN_FOREST +ERROR_DS_SRC_AND_DST_NC_IDENTICAL +ERROR_DS_SRC_AND_DST_OBJECT_CLASS_MISMATCH +ERROR_DS_SRC_DC_MUST_BE_SP4_OR_GREATER +ERROR_DS_SRC_GUID_MISMATCH +ERROR_DS_SRC_NAME_MISMATCH +ERROR_DS_SRC_OBJ_NOT_GROUP_OR_USER +ERROR_DS_SRC_SID_EXISTS_IN_FOREST +ERROR_DS_STRING_SD_CONVERSION_FAILED +ERROR_DS_STRONG_AUTH_REQUIRED +ERROR_DS_SUB_CLS_TEST_FAIL +ERROR_DS_SUBREF_MUST_HAVE_PARENT +ERROR_DS_SUBTREE_NOTIFY_NOT_NC_HEAD +ERROR_DS_SYNTAX_MISMATCH +ERROR_DS_THREAD_LIMIT_EXCEEDED +ERROR_DS_TIMELIMIT_EXCEEDED +ERROR_DS_TREE_DELETE_NOT_FINISHED +ERROR_DS_UNABLE_TO_SURRENDER_ROLES +ERROR_DS_UNAVAILABLE +ERROR_DS_UNAVAILABLE_CRIT_EXTENSION +ERROR_DS_UNDELETE_SAM_VALIDATION_FAILED +ERROR_DS_UNICODEPWD_NOT_IN_QUOTES +ERROR_DS_UNIVERSAL_CANT_HAVE_LOCAL_MEMBER +ERROR_DS_UNKNOWN_ERROR +ERROR_DS_UNKNOWN_OPERATION +ERROR_DS_UNWILLING_TO_PERFORM +ERROR_DS_UPN_VALUE_NOT_UNIQUE_IN_FOREST +ERROR_DS_USER_BUFFER_TO_SMALL +ERROR_DS_VALUE_KEY_NOT_UNIQUE +ERROR_DS_VERSION_CHECK_FAILURE +ERROR_DS_WKO_CONTAINER_CANNOT_BE_SPECIAL +ERROR_DS_WRONG_LINKED_ATT_SYNTAX +ERROR_DS_WRONG_OM_OBJ_CLASS +ERROR_DUP_DOMAINNAME +ERROR_DUP_NAME +ERROR_DUPLICATE_PRIVILEGES +ERROR_DUPLICATE_SERVICE_NAME +ERROR_DYNAMIC_CODE_BLOCKED +ERROR_DYNLINK_FROM_INVALID_RING +ERROR_EA_ACCESS_DENIED +ERROR_EA_FILE_CORRUPT +ERROR_EA_LIST_INCONSISTENT +ERROR_EA_TABLE_FULL +ERROR_EAS_DIDNT_FIT +ERROR_EAS_NOT_SUPPORTED +ERROR_EDP_DPL_POLICY_CANT_BE_SATISFIED +ERROR_EDP_POLICY_DENIES_OPERATION +ERROR_EFS_ALG_BLOB_TOO_BIG +ERROR_EFS_DISABLED +ERROR_EFS_SERVER_NOT_TRUSTED +ERROR_EFS_VERSION_NOT_SUPPORT +ERROR_ELEVATION_REQUIRED +ERROR_ENCLAVE_FAILURE +ERROR_ENCLAVE_NOT_TERMINATED +ERROR_ENCLAVE_VIOLATION +ERROR_ENCRYPTED_FILE_NOT_SUPPORTED +ERROR_ENCRYPTED_IO_NOT_POSSIBLE +ERROR_ENCRYPTING_METADATA_DISALLOWED +ERROR_ENCRYPTION_DISABLED +ERROR_ENCRYPTION_FAILED +ERROR_ENCRYPTION_POLICY_DENIES_OPERATION +ERROR_END_OF_MEDIA +ERROR_ENVVAR_NOT_FOUND +ERROR_EOM_OVERFLOW +ERROR_ERRORS_ENCOUNTERED +ERROR_EVALUATION_EXPIRATION +ERROR_EVENT_DONE +ERROR_EVENT_PENDING +ERROR_EVENTLOG_CANT_START +ERROR_EVENTLOG_FILE_CHANGED +ERROR_EVENTLOG_FILE_CORRUPT +ERROR_EXCEPTION_IN_SERVICE +ERROR_EXCL_SEM_ALREADY_OWNED +ERROR_EXE_CANNOT_MODIFY_SIGNED_BINARY +ERROR_EXE_CANNOT_MODIFY_STRONG_SIGNED_BINARY +ERROR_EXE_MACHINE_TYPE_MISMATCH +ERROR_EXE_MARKED_INVALID +ERROR_EXTENDED_ERROR +ERROR_EXTERNAL_BACKING_PROVIDER_UNKNOWN +ERROR_EXTERNAL_SYSKEY_NOT_SUPPORTED +ERROR_EXTRANEOUS_INFORMATION +ERROR_FAIL_FAST_EXCEPTION +ERROR_FAIL_I24 +ERROR_FAIL_NOACTION_REBOOT +ERROR_FAIL_RESTART +ERROR_FAIL_SHUTDOWN +ERROR_FAILED_DRIVER_ENTRY +ERROR_FAILED_SERVICE_CONTROLLER_CONNECT +ERROR_FATAL_APP_EXIT +ERROR_FILE_CHECKED_OUT +ERROR_FILE_CORRUPT +ERROR_FILE_ENCRYPTED +ERROR_FILE_EXISTS +ERROR_FILE_HANDLE_REVOKED +ERROR_FILE_INVALID +ERROR_FILE_LEVEL_TRIM_NOT_SUPPORTED +ERROR_FILE_METADATA_OPTIMIZATION_IN_PROGRESS +ERROR_FILE_NOT_ENCRYPTED +ERROR_FILE_NOT_FOUND +ERROR_FILE_NOT_SUPPORTED +ERROR_FILE_OFFLINE +ERROR_FILE_PROTECTED_UNDER_DPL +ERROR_FILE_READ_ONLY +ERROR_FILE_SNAP_IN_PROGRESS +ERROR_FILE_SNAP_INVALID_PARAMETER +ERROR_FILE_SNAP_IO_NOT_COORDINATED +ERROR_FILE_SNAP_MODIFY_NOT_SUPPORTED +ERROR_FILE_SNAP_UNEXPECTED_ERROR +ERROR_FILE_SNAP_USER_SECTION_NOT_SUPPORTED +ERROR_FILE_SYSTEM_LIMITATION +ERROR_FILE_SYSTEM_VIRTUALIZATION_BUSY +ERROR_FILE_SYSTEM_VIRTUALIZATION_INVALID_OPERATION +ERROR_FILE_SYSTEM_VIRTUALIZATION_METADATA_CORRUPT +ERROR_FILE_SYSTEM_VIRTUALIZATION_PROVIDER_UNKNOWN +ERROR_FILE_SYSTEM_VIRTUALIZATION_UNAVAILABLE +ERROR_FILE_TOO_LARGE +ERROR_FILEMARK_DETECTED +ERROR_FILENAME_EXCED_RANGE +ERROR_FIRMWARE_UPDATED +ERROR_FLOAT_MULTIPLE_FAULTS +ERROR_FLOAT_MULTIPLE_TRAPS +ERROR_FLOPPY_BAD_REGISTERS +ERROR_FLOPPY_ID_MARK_NOT_FOUND +ERROR_FLOPPY_UNKNOWN_ERROR +ERROR_FLOPPY_VOLUME +ERROR_FLOPPY_WRONG_CYLINDER +ERROR_FORMS_AUTH_REQUIRED +ERROR_FOUND_OUT_OF_SCOPE +ERROR_FS_DRIVER_REQUIRED +ERROR_FS_METADATA_INCONSISTENT +ERROR_FSFILTER_OP_COMPLETED_SUCCESSFULLY +ERROR_FT_DI_SCAN_REQUIRED +ERROR_FT_READ_FAILURE +ERROR_FT_READ_FROM_COPY_FAILURE +ERROR_FT_READ_RECOVERY_FROM_BACKUP +ERROR_FT_WRITE_FAILURE +ERROR_FT_WRITE_RECOVERY +ERROR_FULLSCREEN_MODE +ERROR_FUNCTION_FAILED +ERROR_FUNCTION_NOT_CALLED +ERROR_GDI_HANDLE_LEAK +ERROR_GEN_FAILURE +ERROR_GENERIC_NOT_MAPPED +ERROR_GLOBAL_ONLY_HOOK +ERROR_GRACEFUL_DISCONNECT +ERROR_GROUP_EXISTS +ERROR_GUID_SUBSTITUTION_MADE +ERROR_HANDLE_DISK_FULL +ERROR_HANDLE_EOF +ERROR_HANDLE_REVOKED +ERROR_HANDLES_CLOSED +ERROR_HAS_SYSTEM_CRITICAL_FILES +ERROR_HIBERNATED +ERROR_HIBERNATION_FAILURE +ERROR_HOOK_NEEDS_HMOD +ERROR_HOOK_NOT_INSTALLED +ERROR_HOOK_TYPE_NOT_ALLOWED +ERROR_HOST_DOWN +ERROR_HOST_UNREACHABLE +ERROR_HOTKEY_ALREADY_REGISTERED +ERROR_HOTKEY_NOT_REGISTERED +ERROR_HWNDS_HAVE_DIFF_PARENT +ERROR_ILL_FORMED_PASSWORD +ERROR_ILLEGAL_CHARACTER +ERROR_ILLEGAL_DLL_RELOCATION +ERROR_ILLEGAL_ELEMENT_ADDRESS +ERROR_ILLEGAL_FLOAT_CONTEXT +ERROR_IMAGE_AT_DIFFERENT_BASE +ERROR_IMAGE_MACHINE_TYPE_MISMATCH +ERROR_IMAGE_MACHINE_TYPE_MISMATCH_EXE +ERROR_IMAGE_NOT_AT_BASE +ERROR_IMAGE_SUBSYSTEM_NOT_PRESENT +ERROR_IMPLEMENTATION_LIMIT +ERROR_INCOMPATIBLE_SERVICE_PRIVILEGE +ERROR_INCOMPATIBLE_SERVICE_SID_TYPE +ERROR_INCOMPATIBLE_WITH_GLOBAL_SHORT_NAME_REGISTRY_SETTING +ERROR_INCORRECT_ACCOUNT_TYPE +ERROR_INCORRECT_ADDRESS +ERROR_INCORRECT_SIZE +ERROR_INDEX_ABSENT +ERROR_INDEX_OUT_OF_BOUNDS +ERROR_INFLOOP_IN_RELOC_CHAIN +ERROR_INSTALL_ALREADY_RUNNING +ERROR_INSTALL_FAILURE +ERROR_INSTALL_LANGUAGE_UNSUPPORTED +ERROR_INSTALL_LOG_FAILURE +ERROR_INSTALL_NOTUSED +ERROR_INSTALL_PACKAGE_INVALID +ERROR_INSTALL_PACKAGE_OPEN_FAILED +ERROR_INSTALL_PACKAGE_REJECTED +ERROR_INSTALL_PACKAGE_VERSION +ERROR_INSTALL_PLATFORM_UNSUPPORTED +ERROR_INSTALL_REJECTED +ERROR_INSTALL_REMOTE_DISALLOWED +ERROR_INSTALL_REMOTE_PROHIBITED +ERROR_INSTALL_SERVICE_FAILURE +ERROR_INSTALL_SERVICE_SAFEBOOT +ERROR_INSTALL_SOURCE_ABSENT +ERROR_INSTALL_SUSPEND +ERROR_INSTALL_TEMP_UNWRITABLE +ERROR_INSTALL_TRANSFORM_FAILURE +ERROR_INSTALL_TRANSFORM_REJECTED +ERROR_INSTALL_UI_FAILURE +ERROR_INSTALL_USEREXIT +ERROR_INSTRUCTION_MISALIGNMENT +ERROR_INSUFFICIENT_BUFFER +ERROR_INSUFFICIENT_LOGON_INFO +ERROR_INSUFFICIENT_POWER +ERROR_INSUFFICIENT_RESOURCE_FOR_SPECIFIED_SHARED_SECTION_SIZE +ERROR_INSUFFICIENT_VIRTUAL_ADDR_RESOURCES +ERROR_INTERMIXED_KERNEL_EA_OPERATION +ERROR_INTERNAL_DB_CORRUPTION +ERROR_INTERNAL_DB_ERROR +ERROR_INTERNAL_ERROR +ERROR_INTERRUPT_STILL_CONNECTED +ERROR_INTERRUPT_VECTOR_ALREADY_CONNECTED +ERROR_INVALID_ACCEL_HANDLE +ERROR_INVALID_ACCESS +ERROR_INVALID_ACCOUNT_NAME +ERROR_INVALID_ACE_CONDITION +ERROR_INVALID_ACL +ERROR_INVALID_ADDRESS +ERROR_INVALID_AT_INTERRUPT_TIME +ERROR_INVALID_BLOCK +ERROR_INVALID_BLOCK_LENGTH +ERROR_INVALID_CAP +ERROR_INVALID_CATEGORY +ERROR_INVALID_COMBOBOX_MESSAGE +ERROR_INVALID_COMMAND_LINE +ERROR_INVALID_COMPUTERNAME +ERROR_INVALID_CRUNTIME_PARAMETER +ERROR_INVALID_CURSOR_HANDLE +ERROR_INVALID_DATA +ERROR_INVALID_DATATYPE +ERROR_INVALID_DEVICE_OBJECT_PARAMETER +ERROR_INVALID_DLL +ERROR_INVALID_DOMAIN_ROLE +ERROR_INVALID_DOMAIN_STATE +ERROR_INVALID_DOMAINNAME +ERROR_INVALID_DRIVE +ERROR_INVALID_DWP_HANDLE +ERROR_INVALID_EA_HANDLE +ERROR_INVALID_EA_NAME +ERROR_INVALID_EDIT_HEIGHT +ERROR_INVALID_ENVIRONMENT +ERROR_INVALID_EVENT_COUNT +ERROR_INVALID_EVENTNAME +ERROR_INVALID_EXCEPTION_HANDLER +ERROR_INVALID_EXE_SIGNATURE +ERROR_INVALID_FIELD +ERROR_INVALID_FIELD_IN_PARAMETER_LIST +ERROR_INVALID_FILTER_PROC +ERROR_INVALID_FLAG_NUMBER +ERROR_INVALID_FLAGS +ERROR_INVALID_FORM_NAME +ERROR_INVALID_FORM_SIZE +ERROR_INVALID_FUNCTION +ERROR_INVALID_GROUP_ATTRIBUTES +ERROR_INVALID_GROUPNAME +ERROR_INVALID_GW_COMMAND +ERROR_INVALID_HANDLE +ERROR_INVALID_HANDLE_STATE +ERROR_INVALID_HOOK_FILTER +ERROR_INVALID_HOOK_HANDLE +ERROR_INVALID_HW_PROFILE +ERROR_INVALID_ICON_HANDLE +ERROR_INVALID_ID_AUTHORITY +ERROR_INVALID_IMAGE_HASH +ERROR_INVALID_IMPORT_OF_NON_DLL +ERROR_INVALID_INDEX +ERROR_INVALID_KERNEL_INFO_VERSION +ERROR_INVALID_KEYBOARD_HANDLE +ERROR_INVALID_LABEL +ERROR_INVALID_LB_MESSAGE +ERROR_INVALID_LDT_DESCRIPTOR +ERROR_INVALID_LDT_OFFSET +ERROR_INVALID_LDT_SIZE +ERROR_INVALID_LEVEL +ERROR_INVALID_LIST_FORMAT +ERROR_INVALID_LOCK_RANGE +ERROR_INVALID_LOGON_HOURS +ERROR_INVALID_LOGON_TYPE +ERROR_INVALID_MEMBER +ERROR_INVALID_MENU_HANDLE +ERROR_INVALID_MESSAGE +ERROR_INVALID_MESSAGEDEST +ERROR_INVALID_MESSAGENAME +ERROR_INVALID_MINALLOCSIZE +ERROR_INVALID_MODULETYPE +ERROR_INVALID_MONITOR_HANDLE +ERROR_INVALID_MSGBOX_STYLE +ERROR_INVALID_NAME +ERROR_INVALID_NETNAME +ERROR_INVALID_OPLOCK_PROTOCOL +ERROR_INVALID_ORDINAL +ERROR_INVALID_OWNER +ERROR_INVALID_PACKAGE_SID_LENGTH +ERROR_INVALID_PARAMETER +ERROR_INVALID_PASSWORD +ERROR_INVALID_PASSWORDNAME +ERROR_INVALID_PATCH_XML +ERROR_INVALID_PEP_INFO_VERSION +ERROR_INVALID_PLUGPLAY_DEVICE_PATH +ERROR_INVALID_PORT_ATTRIBUTES +ERROR_INVALID_PRIMARY_GROUP +ERROR_INVALID_PRINTER_COMMAND +ERROR_INVALID_PRINTER_NAME +ERROR_INVALID_PRINTER_STATE +ERROR_INVALID_PRIORITY +ERROR_INVALID_QUOTA_LOWER +ERROR_INVALID_REPARSE_DATA +ERROR_INVALID_SCROLLBAR_RANGE +ERROR_INVALID_SECURITY_DESCR +ERROR_INVALID_SEGDPL +ERROR_INVALID_SEGMENT_NUMBER +ERROR_INVALID_SEPARATOR_FILE +ERROR_INVALID_SERVER_STATE +ERROR_INVALID_SERVICE_ACCOUNT +ERROR_INVALID_SERVICE_CONTROL +ERROR_INVALID_SERVICE_LOCK +ERROR_INVALID_SERVICENAME +ERROR_INVALID_SHARENAME +ERROR_INVALID_SHOWWIN_COMMAND +ERROR_INVALID_SID +ERROR_INVALID_SIGNAL_NUMBER +ERROR_INVALID_SPI_VALUE +ERROR_INVALID_STACKSEG +ERROR_INVALID_STARTING_CODESEG +ERROR_INVALID_SUB_AUTHORITY +ERROR_INVALID_TABLE +ERROR_INVALID_TARGET_HANDLE +ERROR_INVALID_TASK_INDEX +ERROR_INVALID_TASK_NAME +ERROR_INVALID_THREAD_ID +ERROR_INVALID_TIME +ERROR_INVALID_TOKEN +ERROR_INVALID_UNWIND_TARGET +ERROR_INVALID_USER_BUFFER +ERROR_INVALID_USER_PRINCIPAL_NAME +ERROR_INVALID_VARIANT +ERROR_INVALID_VERIFY_SWITCH +ERROR_INVALID_WINDOW_HANDLE +ERROR_INVALID_WORKSTATION +ERROR_IO_DEVICE +ERROR_IO_INCOMPLETE +ERROR_IO_PENDING +ERROR_IO_PRIVILEGE_FAILED +ERROR_IO_REISSUE_AS_CACHED +ERROR_IOPL_NOT_ENABLED +ERROR_IP_ADDRESS_CONFLICT1 +ERROR_IP_ADDRESS_CONFLICT2 +ERROR_IPSEC_IKE_TIMED_OUT +ERROR_IRQ_BUSY +ERROR_IS_JOIN_PATH +ERROR_IS_JOIN_TARGET +ERROR_IS_JOINED +ERROR_IS_SUBST_PATH +ERROR_IS_SUBST_TARGET +ERROR_IS_SUBSTED +ERROR_ITERATED_DATA_EXCEEDS_64k +ERROR_JOB_NO_CONTAINER +ERROR_JOIN_TO_JOIN +ERROR_JOIN_TO_SUBST +ERROR_JOURNAL_DELETE_IN_PROGRESS +ERROR_JOURNAL_ENTRY_DELETED +ERROR_JOURNAL_HOOK_SET +ERROR_JOURNAL_NOT_ACTIVE +ERROR_KERNEL_APC +ERROR_KEY_DELETED +ERROR_KEY_HAS_CHILDREN +ERROR_KM_DRIVER_BLOCKED +ERROR_LABEL_TOO_LONG +ERROR_LAST_ADMIN +ERROR_LB_WITHOUT_TABSTOPS +ERROR_LICENSE_QUOTA_EXCEEDED +ERROR_LINUX_SUBSYSTEM_NOT_PRESENT +ERROR_LINUX_SUBSYSTEM_UPDATE_REQUIRED +ERROR_LISTBOX_ID_NOT_FOUND +ERROR_LM_CROSS_ENCRYPTION_REQUIRED +ERROR_LOCAL_POLICY_MODIFICATION_NOT_SUPPORTED +ERROR_LOCAL_USER_SESSION_KEY +ERROR_LOCK_FAILED +ERROR_LOCK_VIOLATION +ERROR_LOCKED +ERROR_LOG_FILE_FULL +ERROR_LOG_HARD_ERROR +ERROR_LOGIN_TIME_RESTRICTION +ERROR_LOGIN_WKSTA_RESTRICTION +ERROR_LOGON_FAILURE +ERROR_LOGON_NOT_GRANTED +ERROR_LOGON_SERVER_CONFLICT +ERROR_LOGON_SESSION_COLLISION +ERROR_LOGON_SESSION_EXISTS +ERROR_LOGON_TYPE_NOT_GRANTED +ERROR_LONGJUMP +ERROR_LOST_MODE_LOGON_RESTRICTION +ERROR_LOST_WRITEBEHIND_DATA +ERROR_LOST_WRITEBEHIND_DATA_LOCAL_DISK_ERROR +ERROR_LOST_WRITEBEHIND_DATA_NETWORK_DISCONNECTED +ERROR_LOST_WRITEBEHIND_DATA_NETWORK_SERVER_ERROR +ERROR_LUIDS_EXHAUSTED +ERROR_MACHINE_LOCKED +ERROR_MAGAZINE_NOT_PRESENT +ERROR_MAPPED_ALIGNMENT +ERROR_MARKED_TO_DISALLOW_WRITES +ERROR_MARSHALL_OVERFLOW +ERROR_MAX_SESSIONS_REACHED +ERROR_MAX_THRDS_REACHED +ERROR_MCA_EXCEPTION +ERROR_MCA_OCCURED +ERROR_MEDIA_CHANGED +ERROR_MEDIA_CHECK +ERROR_MEMBER_IN_ALIAS +ERROR_MEMBER_IN_GROUP +ERROR_MEMBER_NOT_IN_ALIAS +ERROR_MEMBER_NOT_IN_GROUP +ERROR_MEMBERS_PRIMARY_GROUP +ERROR_MEMORY_HARDWARE +ERROR_MENU_ITEM_NOT_FOUND +ERROR_MESSAGE_SYNC_ONLY +ERROR_META_EXPANSION_TOO_LONG +ERROR_MISSING_SYSTEMFILE +ERROR_MOD_NOT_FOUND +ERROR_MORE_DATA +ERROR_MORE_WRITES +ERROR_MOUNT_POINT_NOT_RESOLVED +ERROR_MP_PROCESSOR_MISMATCH +ERROR_MR_MID_NOT_FOUND +ERROR_MULTIPLE_FAULT_VIOLATION +ERROR_MUTANT_LIMIT_EXCEEDED +ERROR_MUTUAL_AUTH_FAILED +ERROR_NEGATIVE_SEEK +ERROR_NESTING_NOT_ALLOWED +ERROR_NET_OPEN_FAILED +ERROR_NET_WRITE_FAULT +ERROR_NETLOGON_NOT_STARTED +ERROR_NETNAME_DELETED +ERROR_NETWORK_ACCESS_DENIED +ERROR_NETWORK_ACCESS_DENIED_EDP +ERROR_NETWORK_BUSY +ERROR_NETWORK_UNREACHABLE +ERROR_NO_ACE_CONDITION +ERROR_NO_ASSOCIATION +ERROR_NO_BYPASSIO_DRIVER_SUPPORT +ERROR_NO_CALLBACK_ACTIVE +ERROR_NO_DATA +ERROR_NO_DATA_DETECTED +ERROR_NO_EFS +ERROR_NO_EVENT_PAIR +ERROR_NO_GUID_TRANSLATION +ERROR_NO_IMPERSONATION_TOKEN +ERROR_NO_INHERITANCE +ERROR_NO_LOG_SPACE +ERROR_NO_LOGON_SERVERS +ERROR_NO_MATCH +ERROR_NO_MEDIA_IN_DRIVE +ERROR_NO_MORE_DEVICES +ERROR_NO_MORE_FILES +ERROR_NO_MORE_ITEMS +ERROR_NO_MORE_MATCHES +ERROR_NO_MORE_SEARCH_HANDLES +ERROR_NO_MORE_USER_HANDLES +ERROR_NO_NET_OR_BAD_PATH +ERROR_NO_NETWORK +ERROR_NO_NVRAM_RESOURCES +ERROR_NO_PAGEFILE +ERROR_NO_PHYSICALLY_ALIGNED_FREE_SPACE_FOUND +ERROR_NO_PROC_SLOTS +ERROR_NO_PROMOTION_ACTIVE +ERROR_NO_QUOTAS_FOR_ACCOUNT +ERROR_NO_RANGES_PROCESSED +ERROR_NO_RECOVERY_POLICY +ERROR_NO_RECOVERY_PROGRAM +ERROR_NO_SCROLLBARS +ERROR_NO_SECRETS +ERROR_NO_SECURITY_ON_OBJECT +ERROR_NO_SHUTDOWN_IN_PROGRESS +ERROR_NO_SIGNAL_SENT +ERROR_NO_SITE_SETTINGS_OBJECT +ERROR_NO_SITENAME +ERROR_NO_SPOOL_SPACE +ERROR_NO_SUCH_ALIAS +ERROR_NO_SUCH_DEVICE +ERROR_NO_SUCH_DOMAIN +ERROR_NO_SUCH_GROUP +ERROR_NO_SUCH_LOGON_SESSION +ERROR_NO_SUCH_MEMBER +ERROR_NO_SUCH_PACKAGE +ERROR_NO_SUCH_PRIVILEGE +ERROR_NO_SUCH_SITE +ERROR_NO_SUCH_USER +ERROR_NO_SYSTEM_MENU +ERROR_NO_SYSTEM_RESOURCES +ERROR_NO_TASK_QUEUE +ERROR_NO_TOKEN +ERROR_NO_TRACKING_SERVICE +ERROR_NO_TRUST_LSA_SECRET +ERROR_NO_TRUST_SAM_ACCOUNT +ERROR_NO_UNICODE_TRANSLATION +ERROR_NO_USER_KEYS +ERROR_NO_USER_SESSION_KEY +ERROR_NO_VOLUME_ID +ERROR_NO_VOLUME_LABEL +ERROR_NO_WILDCARD_CHARACTERS +ERROR_NO_WORK_DONE +ERROR_NO_WRITABLE_DC_FOUND +ERROR_NO_YIELD_PERFORMED +ERROR_NOACCESS +ERROR_NOINTERFACE +ERROR_NOLOGON_INTERDOMAIN_TRUST_ACCOUNT +ERROR_NOLOGON_SERVER_TRUST_ACCOUNT +ERROR_NOLOGON_WORKSTATION_TRUST_ACCOUNT +ERROR_NON_ACCOUNT_SID +ERROR_NON_DOMAIN_SID +ERROR_NON_MDICHILD_WINDOW +ERROR_NONE_MAPPED +ERROR_NONPAGED_SYSTEM_RESOURCES +ERROR_NOT_A_CLOUD_FILE +ERROR_NOT_A_CLOUD_SYNC_ROOT +ERROR_NOT_A_DAX_VOLUME +ERROR_NOT_A_REPARSE_POINT +ERROR_NOT_ALL_ASSIGNED +ERROR_NOT_ALLOWED_ON_SYSTEM_FILE +ERROR_NOT_APPCONTAINER +ERROR_NOT_AUTHENTICATED +ERROR_NOT_CAPABLE +ERROR_NOT_CHILD_WINDOW +ERROR_NOT_CONNECTED +ERROR_NOT_CONTAINER +ERROR_NOT_DAX_MAPPABLE +ERROR_NOT_DOS_DISK +ERROR_NOT_ENOUGH_MEMORY +ERROR_NOT_ENOUGH_QUOTA +ERROR_NOT_ENOUGH_SERVER_MEMORY +ERROR_NOT_EXPORT_FORMAT +ERROR_NOT_FOUND +ERROR_NOT_GUI_PROCESS +ERROR_NOT_JOINED +ERROR_NOT_LOCKED +ERROR_NOT_LOGGED_ON +ERROR_NOT_LOGON_PROCESS +ERROR_NOT_OWNER +ERROR_NOT_READ_FROM_COPY +ERROR_NOT_READY +ERROR_NOT_REDUNDANT_STORAGE +ERROR_NOT_REGISTRY_FILE +ERROR_NOT_SAFE_MODE_DRIVER +ERROR_NOT_SAFEBOOT_SERVICE +ERROR_NOT_SAME_DEVICE +ERROR_NOT_SAME_OBJECT +ERROR_NOT_SUBSTED +ERROR_NOT_SUPPORTED +ERROR_NOT_SUPPORTED_IN_APPCONTAINER +ERROR_NOT_SUPPORTED_ON_DAX +ERROR_NOT_SUPPORTED_ON_SBS +ERROR_NOT_SUPPORTED_ON_STANDARD_SERVER +ERROR_NOT_SUPPORTED_WITH_AUDITING +ERROR_NOT_SUPPORTED_WITH_BTT +ERROR_NOT_SUPPORTED_WITH_BYPASSIO +ERROR_NOT_SUPPORTED_WITH_CACHED_HANDLE +ERROR_NOT_SUPPORTED_WITH_COMPRESSION +ERROR_NOT_SUPPORTED_WITH_DEDUPLICATION +ERROR_NOT_SUPPORTED_WITH_ENCRYPTION +ERROR_NOT_SUPPORTED_WITH_MONITORING +ERROR_NOT_SUPPORTED_WITH_REPLICATION +ERROR_NOT_SUPPORTED_WITH_SNAPSHOT +ERROR_NOT_SUPPORTED_WITH_VIRTUALIZATION +ERROR_NOT_TINY_STREAM +ERROR_NOTHING_TO_TERMINATE +ERROR_NOTIFICATION_GUID_ALREADY_DEFINED +ERROR_NOTIFY_CLEANUP +ERROR_NOTIFY_ENUM_DIR +ERROR_NT_CROSS_ENCRYPTION_REQUIRED +ERROR_NTLM_BLOCKED +ERROR_NULL_LM_PASSWORD +ERROR_OBJECT_IS_IMMUTABLE +ERROR_OBJECT_NAME_EXISTS +ERROR_OBJECT_NOT_EXTERNALLY_BACKED +ERROR_OFFLOAD_READ_FILE_NOT_SUPPORTED +ERROR_OFFLOAD_READ_FLT_NOT_SUPPORTED +ERROR_OFFLOAD_WRITE_FILE_NOT_SUPPORTED +ERROR_OFFLOAD_WRITE_FLT_NOT_SUPPORTED +ERROR_OFFSET_ALIGNMENT_VIOLATION +ERROR_OLD_WIN_VERSION +ERROR_ONLY_IF_CONNECTED +ERROR_OPEN_FAILED +ERROR_OPEN_FILES +ERROR_OPERATION_ABORTED +ERROR_OPERATION_IN_PROGRESS +ERROR_OPLOCK_BREAK_IN_PROGRESS +ERROR_OPLOCK_HANDLE_CLOSED +ERROR_OPLOCK_NOT_GRANTED +ERROR_OPLOCK_SWITCHED_TO_NEW_HANDLE +ERROR_ORPHAN_NAME_EXHAUSTED +ERROR_OUT_OF_PAPER +ERROR_OUT_OF_STRUCTURES +ERROR_OUTOFMEMORY +ERROR_OVERRIDE_NOCHANGES +ERROR_PAGE_FAULT_COPY_ON_WRITE +ERROR_PAGE_FAULT_DEMAND_ZERO +ERROR_PAGE_FAULT_GUARD_PAGE +ERROR_PAGE_FAULT_PAGING_FILE +ERROR_PAGE_FAULT_TRANSITION +ERROR_PAGED_SYSTEM_RESOURCES +ERROR_PAGEFILE_CREATE_FAILED +ERROR_PAGEFILE_NOT_SUPPORTED +ERROR_PAGEFILE_QUOTA +ERROR_PAGEFILE_QUOTA_EXCEEDED +ERROR_PARAMETER_QUOTA_EXCEEDED +ERROR_PARTIAL_COPY +ERROR_PARTITION_FAILURE +ERROR_PARTITION_TERMINATING +ERROR_PASSWORD_CHANGE_REQUIRED +ERROR_PASSWORD_EXPIRED +ERROR_PASSWORD_MUST_CHANGE +ERROR_PASSWORD_RESTRICTION +ERROR_PATCH_MANAGED_ADVERTISED_PRODUCT +ERROR_PATCH_NO_SEQUENCE +ERROR_PATCH_PACKAGE_INVALID +ERROR_PATCH_PACKAGE_OPEN_FAILED +ERROR_PATCH_PACKAGE_REJECTED +ERROR_PATCH_PACKAGE_UNSUPPORTED +ERROR_PATCH_REMOVAL_DISALLOWED +ERROR_PATCH_REMOVAL_UNSUPPORTED +ERROR_PATCH_TARGET_NOT_FOUND +ERROR_PATH_BUSY +ERROR_PATH_NOT_FOUND +ERROR_PER_USER_TRUST_QUOTA_EXCEEDED +ERROR_PIPE_BUSY +ERROR_PIPE_CONNECTED +ERROR_PIPE_LISTENING +ERROR_PIPE_LOCAL +ERROR_PIPE_NOT_CONNECTED +ERROR_PKINIT_FAILURE +ERROR_PLUGPLAY_QUERY_VETOED +ERROR_PNP_BAD_MPS_TABLE +ERROR_PNP_INVALID_ID +ERROR_PNP_IRQ_TRANSLATION_FAILED +ERROR_PNP_QUERY_REMOVE_DEVICE_TIMEOUT +ERROR_PNP_QUERY_REMOVE_RELATED_DEVICE_TIMEOUT +ERROR_PNP_QUERY_REMOVE_UNRELATED_DEVICE_TIMEOUT +ERROR_PNP_REBOOT_REQUIRED +ERROR_PNP_RESTART_ENUMERATION +ERROR_PNP_TRANSLATION_FAILED +ERROR_POINT_NOT_FOUND +ERROR_POLICY_OBJECT_NOT_FOUND +ERROR_POLICY_ONLY_IN_DS +ERROR_POPUP_ALREADY_ACTIVE +ERROR_PORT_MESSAGE_TOO_LONG +ERROR_PORT_NOT_SET +ERROR_PORT_UNREACHABLE +ERROR_POSSIBLE_DEADLOCK +ERROR_POTENTIAL_FILE_FOUND +ERROR_PREDEFINED_HANDLE +ERROR_PRIMARY_TRANSPORT_CONNECT_FAILED +ERROR_PRINT_CANCELLED +ERROR_PRINTER_ALREADY_EXISTS +ERROR_PRINTER_DELETED +ERROR_PRINTER_DRIVER_ALREADY_INSTALLED +ERROR_PRINTQ_FULL +ERROR_PRIVATE_DIALOG_INDEX +ERROR_PRIVILEGE_NOT_HELD +ERROR_PROC_NOT_FOUND +ERROR_PROCESS_ABORTED +ERROR_PROCESS_IN_JOB +ERROR_PROCESS_IS_PROTECTED +ERROR_PROCESS_MODE_ALREADY_BACKGROUND +ERROR_PROCESS_MODE_NOT_BACKGROUND +ERROR_PROCESS_NOT_IN_JOB +ERROR_PRODUCT_UNINSTALLED +ERROR_PRODUCT_VERSION +ERROR_PROFILING_AT_LIMIT +ERROR_PROFILING_NOT_STARTED +ERROR_PROFILING_NOT_STOPPED +ERROR_PROMOTION_ACTIVE +ERROR_PROTOCOL_UNREACHABLE +ERROR_PWD_HISTORY_CONFLICT +ERROR_PWD_TOO_LONG +ERROR_PWD_TOO_RECENT +ERROR_PWD_TOO_SHORT +ERROR_QUOTA_ACTIVITY +ERROR_QUOTA_LIST_INCONSISTENT +ERROR_RANGE_LIST_CONFLICT +ERROR_RANGE_NOT_FOUND +ERROR_READ_FAULT +ERROR_RECEIVE_EXPEDITED +ERROR_RECEIVE_PARTIAL +ERROR_RECEIVE_PARTIAL_EXPEDITED +ERROR_RECOVERY_FAILURE +ERROR_REDIR_PAUSED +ERROR_REDIRECTOR_HAS_OPEN_HANDLES +ERROR_REG_NAT_CONSUMPTION +ERROR_REGISTRY_CORRUPT +ERROR_REGISTRY_HIVE_RECOVERED +ERROR_REGISTRY_IO_FAILED +ERROR_REGISTRY_QUOTA_LIMIT +ERROR_REGISTRY_RECOVERED +ERROR_RELOC_CHAIN_XEEDS_SEGLIM +ERROR_REM_NOT_LIST +ERROR_REMOTE_PRINT_CONNECTIONS_BLOCKED +ERROR_REMOTE_SESSION_LIMIT_EXCEEDED +ERROR_REMOTE_STORAGE_MEDIA_ERROR +ERROR_REMOTE_STORAGE_NOT_ACTIVE +ERROR_REPARSE +ERROR_REPARSE_ATTRIBUTE_CONFLICT +ERROR_REPARSE_OBJECT +ERROR_REPARSE_POINT_ENCOUNTERED +ERROR_REPARSE_TAG_INVALID +ERROR_REPARSE_TAG_MISMATCH +ERROR_REPLY_MESSAGE_MISMATCH +ERROR_REQ_NOT_ACCEP +ERROR_REQUEST_ABORTED +ERROR_REQUEST_OUT_OF_SEQUENCE +ERROR_REQUEST_PAUSED +ERROR_REQUIRES_INTERACTIVE_WINDOWSTATION +ERROR_RESIDENT_FILE_NOT_SUPPORTED +ERROR_RESOURCE_CALL_TIMED_OUT +ERROR_RESOURCE_DATA_NOT_FOUND +ERROR_RESOURCE_LANG_NOT_FOUND +ERROR_RESOURCE_NAME_NOT_FOUND +ERROR_RESOURCE_REQUIREMENTS_CHANGED +ERROR_RESOURCE_TYPE_NOT_FOUND +ERROR_RESTART_APPLICATION +ERROR_RESUME_HIBERNATION +ERROR_RETRY +ERROR_RETURN_ADDRESS_HIJACK_ATTEMPT +ERROR_REVISION_MISMATCH +ERROR_RING2_STACK_IN_USE +ERROR_RING2SEG_MUST_BE_MOVABLE +ERROR_RMODE_APP +ERROR_ROWSNOTRELEASED +ERROR_RUNLEVEL_SWITCH_AGENT_TIMEOUT +ERROR_RUNLEVEL_SWITCH_TIMEOUT +ERROR_RWRAW_ENCRYPTED_FILE_NOT_ENCRYPTED +ERROR_RWRAW_ENCRYPTED_INVALID_EDATAINFO_FILEOFFSET +ERROR_RWRAW_ENCRYPTED_INVALID_EDATAINFO_FILERANGE +ERROR_RWRAW_ENCRYPTED_INVALID_EDATAINFO_PARAMETER +ERROR_RXACT_COMMIT_FAILURE +ERROR_RXACT_COMMIT_NECESSARY +ERROR_RXACT_COMMITTED +ERROR_RXACT_INVALID_STATE +ERROR_RXACT_STATE_CREATED +ERROR_SAM_INIT_FAILURE +ERROR_SAME_DRIVE +ERROR_SCOPE_NOT_FOUND +ERROR_SCREEN_ALREADY_LOCKED +ERROR_SCRUB_DATA_DISABLED +ERROR_SECRET_TOO_LONG +ERROR_SECTION_DIRECT_MAP_ONLY +ERROR_SECTOR_NOT_FOUND +ERROR_SECURITY_DENIES_OPERATION +ERROR_SECURITY_STREAM_IS_INCONSISTENT +ERROR_SEEK +ERROR_SEEK_ON_DEVICE +ERROR_SEGMENT_NOTIFICATION +ERROR_SEM_IS_SET +ERROR_SEM_NOT_FOUND +ERROR_SEM_OWNER_DIED +ERROR_SEM_TIMEOUT +ERROR_SEM_USER_LIMIT +ERROR_SERIAL_NO_DEVICE +ERROR_SERVER_DISABLED +ERROR_SERVER_HAS_OPEN_HANDLES +ERROR_SERVER_NOT_DISABLED +ERROR_SERVER_SHUTDOWN_IN_PROGRESS +ERROR_SERVER_SID_MISMATCH +ERROR_SERVER_TRANSPORT_CONFLICT +ERROR_SERVICE_ALREADY_RUNNING +ERROR_SERVICE_CANNOT_ACCEPT_CTRL +ERROR_SERVICE_DATABASE_LOCKED +ERROR_SERVICE_DEPENDENCY_DELETED +ERROR_SERVICE_DEPENDENCY_FAIL +ERROR_SERVICE_DISABLED +ERROR_SERVICE_DOES_NOT_EXIST +ERROR_SERVICE_EXISTS +ERROR_SERVICE_LOGON_FAILED +ERROR_SERVICE_MARKED_FOR_DELETE +ERROR_SERVICE_NEVER_STARTED +ERROR_SERVICE_NO_THREAD +ERROR_SERVICE_NOT_ACTIVE +ERROR_SERVICE_NOT_FOUND +ERROR_SERVICE_NOT_IN_EXE +ERROR_SERVICE_NOTIFICATION +ERROR_SERVICE_NOTIFY_CLIENT_LAGGING +ERROR_SERVICE_REQUEST_TIMEOUT +ERROR_SERVICE_SPECIFIC_ERROR +ERROR_SERVICE_START_HANG +ERROR_SESSION_CREDENTIAL_CONFLICT +ERROR_SESSION_KEY_TOO_SHORT +ERROR_SET_CONTEXT_DENIED +ERROR_SET_NOT_FOUND +ERROR_SET_POWER_STATE_FAILED +ERROR_SET_POWER_STATE_VETOED +ERROR_SETCOUNT_ON_BAD_LB +ERROR_SETMARK_DETECTED +ERROR_SHARED_POLICY +ERROR_SHARING_BUFFER_EXCEEDED +ERROR_SHARING_PAUSED +ERROR_SHARING_VIOLATION +ERROR_SHORT_NAMES_NOT_ENABLED_ON_VOLUME +ERROR_SHUTDOWN_DISKS_NOT_IN_MAINTENANCE_MODE +ERROR_SHUTDOWN_IN_PROGRESS +ERROR_SHUTDOWN_IS_SCHEDULED +ERROR_SHUTDOWN_USERS_LOGGED_ON +ERROR_SIGNAL_PENDING +ERROR_SIGNAL_REFUSED +ERROR_SINGLE_INSTANCE_APP +ERROR_SMARTCARD_SUBSYSTEM_FAILURE +ERROR_SMB1_NOT_AVAILABLE +ERROR_SMB_GUEST_LOGON_BLOCKED +ERROR_SMR_GARBAGE_COLLECTION_REQUIRED +ERROR_SOME_NOT_MAPPED +ERROR_SOURCE_ELEMENT_EMPTY +ERROR_SPARSE_FILE_NOT_SUPPORTED +ERROR_SPECIAL_ACCOUNT +ERROR_SPECIAL_GROUP +ERROR_SPECIAL_USER +ERROR_SRC_SRV_DLL_LOAD_FAILED +ERROR_STACK_BUFFER_OVERRUN +ERROR_STACK_OVERFLOW +ERROR_STACK_OVERFLOW_READ +ERROR_STOPPED_ON_SYMLINK +ERROR_STORAGE_LOST_DATA_PERSISTENCE +ERROR_STORAGE_RESERVE_ALREADY_EXISTS +ERROR_STORAGE_RESERVE_DOES_NOT_EXIST +ERROR_STORAGE_RESERVE_ID_INVALID +ERROR_STORAGE_RESERVE_NOT_EMPTY +ERROR_STORAGE_STACK_ACCESS_DENIED +ERROR_STORAGE_TOPOLOGY_ID_MISMATCH +ERROR_STRICT_CFG_VIOLATION +ERROR_SUBST_TO_JOIN +ERROR_SUBST_TO_SUBST +ERROR_SUCCESS +ERROR_SUCCESS_REBOOT_INITIATED +ERROR_SWAPERROR +ERROR_SYMLINK_CLASS_DISABLED +ERROR_SYMLINK_NOT_SUPPORTED +ERROR_SYNC_FOREGROUND_REFRESH_REQUIRED +ERROR_SYNCHRONIZATION_REQUIRED +ERROR_SYSTEM_HIVE_TOO_LARGE +ERROR_SYSTEM_IMAGE_BAD_SIGNATURE +ERROR_SYSTEM_POWERSTATE_COMPLEX_TRANSITION +ERROR_SYSTEM_POWERSTATE_TRANSITION +ERROR_SYSTEM_PROCESS_TERMINATED +ERROR_SYSTEM_SHUTDOWN +ERROR_SYSTEM_TRACE +ERROR_THREAD_1_INACTIVE +ERROR_THREAD_ALREADY_IN_TASK +ERROR_THREAD_MODE_ALREADY_BACKGROUND +ERROR_THREAD_MODE_NOT_BACKGROUND +ERROR_THREAD_NOT_IN_PROCESS +ERROR_THREAD_WAS_SUSPENDED +ERROR_TIME_SENSITIVE_THREAD +ERROR_TIME_SKEW +ERROR_TIMEOUT +ERROR_TIMER_NOT_CANCELED +ERROR_TIMER_RESOLUTION_NOT_SET +ERROR_TIMER_RESUME_IGNORED +ERROR_TLW_WITH_WSCHILD +ERROR_TOKEN_ALREADY_IN_USE +ERROR_TOO_MANY_CMDS +ERROR_TOO_MANY_CONTEXT_IDS +ERROR_TOO_MANY_DESCRIPTORS +ERROR_TOO_MANY_LINKS +ERROR_TOO_MANY_LUIDS_REQUESTED +ERROR_TOO_MANY_MODULES +ERROR_TOO_MANY_MUXWAITERS +ERROR_TOO_MANY_NAMES +ERROR_TOO_MANY_OPEN_FILES +ERROR_TOO_MANY_POSTS +ERROR_TOO_MANY_SECRETS +ERROR_TOO_MANY_SEM_REQUESTS +ERROR_TOO_MANY_SEMAPHORES +ERROR_TOO_MANY_SESS +ERROR_TOO_MANY_SIDS +ERROR_TOO_MANY_TCBS +ERROR_TOO_MANY_THREADS +ERROR_TRANSLATION_COMPLETE +ERROR_TRUST_FAILURE +ERROR_TRUSTED_DOMAIN_FAILURE +ERROR_TRUSTED_RELATIONSHIP_FAILURE +ERROR_UNABLE_TO_LOCK_MEDIA +ERROR_UNABLE_TO_MOVE_REPLACEMENT +ERROR_UNABLE_TO_MOVE_REPLACEMENT_2 +ERROR_UNABLE_TO_REMOVE_REPLACED +ERROR_UNABLE_TO_UNLOAD_MEDIA +ERROR_UNDEFINED_CHARACTER +ERROR_UNDEFINED_SCOPE +ERROR_UNEXP_NET_ERR +ERROR_UNEXPECTED_MM_CREATE_ERR +ERROR_UNEXPECTED_MM_EXTEND_ERR +ERROR_UNEXPECTED_MM_MAP_ERROR +ERROR_UNEXPECTED_NTCACHEMANAGER_ERROR +ERROR_UNHANDLED_EXCEPTION +ERROR_UNIDENTIFIED_ERROR +ERROR_UNKNOWN_COMPONENT +ERROR_UNKNOWN_FEATURE +ERROR_UNKNOWN_PATCH +ERROR_UNKNOWN_PORT +ERROR_UNKNOWN_PRINTER_DRIVER +ERROR_UNKNOWN_PRINTPROCESSOR +ERROR_UNKNOWN_PRODUCT +ERROR_UNKNOWN_PROPERTY +ERROR_UNKNOWN_REVISION +ERROR_UNRECOGNIZED_MEDIA +ERROR_UNRECOGNIZED_VOLUME +ERROR_UNSATISFIED_DEPENDENCIES +ERROR_UNSUPPORTED_COMPRESSION +ERROR_UNSUPPORTED_TYPE +ERROR_UNTRUSTED_MOUNT_POINT +ERROR_UNWIND +ERROR_UNWIND_CONSOLIDATE +ERROR_USER_APC +ERROR_USER_DELETE_TRUST_QUOTA_EXCEEDED +ERROR_USER_EXISTS +ERROR_USER_MAPPED_FILE +ERROR_USER_PROFILE_LOAD +ERROR_VALIDATE_CONTINUE +ERROR_VC_DISCONNECTED +ERROR_VDM_DISALLOWED +ERROR_VDM_HARD_ERROR +ERROR_VERIFIER_STOP +ERROR_VERSION_PARSE_ERROR +ERROR_VIRUS_DELETED +ERROR_VIRUS_INFECTED +ERROR_VOLSNAP_HIBERNATE_READY +ERROR_VOLSNAP_PREPARE_HIBERNATE +ERROR_VOLUME_MOUNTED +ERROR_VOLUME_NOT_CLUSTER_ALIGNED +ERROR_VOLUME_NOT_SIS_ENABLED +ERROR_VOLUME_NOT_SUPPORT_EFS +ERROR_VOLUME_NOT_SUPPORTED +ERROR_VOLUME_WRITE_ACCESS_DENIED +ERROR_WAIT_1 +ERROR_WAIT_2 +ERROR_WAIT_3 +ERROR_WAIT_63 +ERROR_WAIT_FOR_OPLOCK +ERROR_WAIT_NO_CHILDREN +ERROR_WAKE_SYSTEM +ERROR_WAKE_SYSTEM_DEBUGGER +ERROR_WAS_LOCKED +ERROR_WAS_UNLOCKED +ERROR_WEAK_WHFBKEY_BLOCKED +ERROR_WINDOW_NOT_COMBOBOX +ERROR_WINDOW_NOT_DIALOG +ERROR_WINDOW_OF_OTHER_THREAD +ERROR_WIP_ENCRYPTION_FAILED +ERROR_WOF_FILE_RESOURCE_TABLE_CORRUPT +ERROR_WOF_WIM_HEADER_CORRUPT +ERROR_WOF_WIM_RESOURCE_TABLE_CORRUPT +ERROR_WORKING_SET_QUOTA +ERROR_WOW_ASSERTION +ERROR_WRITE_FAULT +ERROR_WRITE_PROTECT +ERROR_WRONG_COMPARTMENT +ERROR_WRONG_DISK +ERROR_WRONG_EFS +ERROR_WRONG_PASSWORD +ERROR_WRONG_TARGET_NAME +ERROR_WX86_ERROR +ERROR_WX86_WARNING +ERROR_XML_PARSE_ERROR +ERROR_XMLDSIG_ERROR +EXCEPTION_DISPOSITION +EXCEPTION_MAXIMUM_PARAMETERS +EXCEPTION_RECORD +EXCEPTION_STACK_OVERFLOW +ExceptionCollidedUnwind +ExceptionContinueExecution +ExceptionContinueSearch +ExceptionNestedException +ExitProcess +EXTENDED_STARTUPINFO_PRESENT +FACILITY_CODE +FACILITY_NT_BIT +FALSE +FARPROC +FAST_FAIL_FATAL_APP_EXIT +FD_SET +FILE_ACCESS_RIGHTS +FILE_ADD_FILE +FILE_ADD_SUBDIRECTORY +FILE_ALL_ACCESS +FILE_ALLOCATION_INFO +FILE_APPEND_DATA +FILE_ATTRIBUTE_ARCHIVE +FILE_ATTRIBUTE_COMPRESSED +FILE_ATTRIBUTE_DEVICE +FILE_ATTRIBUTE_DIRECTORY +FILE_ATTRIBUTE_EA +FILE_ATTRIBUTE_ENCRYPTED +FILE_ATTRIBUTE_HIDDEN +FILE_ATTRIBUTE_INTEGRITY_STREAM +FILE_ATTRIBUTE_NO_SCRUB_DATA +FILE_ATTRIBUTE_NORMAL +FILE_ATTRIBUTE_NOT_CONTENT_INDEXED +FILE_ATTRIBUTE_OFFLINE +FILE_ATTRIBUTE_PINNED +FILE_ATTRIBUTE_READONLY +FILE_ATTRIBUTE_RECALL_ON_DATA_ACCESS +FILE_ATTRIBUTE_RECALL_ON_OPEN +FILE_ATTRIBUTE_REPARSE_POINT +FILE_ATTRIBUTE_SPARSE_FILE +FILE_ATTRIBUTE_SYSTEM +FILE_ATTRIBUTE_TAG_INFO +FILE_ATTRIBUTE_TEMPORARY +FILE_ATTRIBUTE_UNPINNED +FILE_ATTRIBUTE_VIRTUAL +FILE_BASIC_INFO +FILE_BEGIN +FILE_COMPLETE_IF_OPLOCKED +FILE_CONTAINS_EXTENDED_CREATE_INFORMATION +FILE_CREATE +FILE_CREATE_PIPE_INSTANCE +FILE_CREATE_TREE_CONNECTION +FILE_CREATION_DISPOSITION +FILE_CURRENT +FILE_DELETE_CHILD +FILE_DELETE_ON_CLOSE +FILE_DIRECTORY_FILE +FILE_DISALLOW_EXCLUSIVE +FILE_DISPOSITION_FLAG_DELETE +FILE_DISPOSITION_FLAG_DO_NOT_DELETE +FILE_DISPOSITION_FLAG_FORCE_IMAGE_SECTION_CHECK +FILE_DISPOSITION_FLAG_IGNORE_READONLY_ATTRIBUTE +FILE_DISPOSITION_FLAG_ON_CLOSE +FILE_DISPOSITION_FLAG_POSIX_SEMANTICS +FILE_DISPOSITION_INFO +FILE_DISPOSITION_INFO_EX +FILE_DISPOSITION_INFO_EX_FLAGS +FILE_END +FILE_END_OF_FILE_INFO +FILE_EXECUTE +FILE_FLAG_BACKUP_SEMANTICS +FILE_FLAG_DELETE_ON_CLOSE +FILE_FLAG_FIRST_PIPE_INSTANCE +FILE_FLAG_NO_BUFFERING +FILE_FLAG_OPEN_NO_RECALL +FILE_FLAG_OPEN_REPARSE_POINT +FILE_FLAG_OVERLAPPED +FILE_FLAG_POSIX_SEMANTICS +FILE_FLAG_RANDOM_ACCESS +FILE_FLAG_SEQUENTIAL_SCAN +FILE_FLAG_SESSION_AWARE +FILE_FLAG_WRITE_THROUGH +FILE_FLAGS_AND_ATTRIBUTES +FILE_GENERIC_EXECUTE +FILE_GENERIC_READ +FILE_GENERIC_WRITE +FILE_ID_BOTH_DIR_INFO +FILE_INFO_BY_HANDLE_CLASS +FILE_IO_PRIORITY_HINT_INFO +FILE_LIST_DIRECTORY +FILE_NAME_NORMALIZED +FILE_NAME_OPENED +FILE_NO_EA_KNOWLEDGE +FILE_NO_INTERMEDIATE_BUFFERING +FILE_NON_DIRECTORY_FILE +FILE_OPEN +FILE_OPEN_BY_FILE_ID +FILE_OPEN_FOR_BACKUP_INTENT +FILE_OPEN_FOR_FREE_SPACE_QUERY +FILE_OPEN_IF +FILE_OPEN_REPARSE_POINT +FILE_OPEN_REQUIRING_OPLOCK +FILE_OVERWRITE +FILE_OVERWRITE_IF +FILE_RANDOM_ACCESS +FILE_READ_ATTRIBUTES +FILE_READ_DATA +FILE_READ_EA +FILE_RENAME_FLAG_POSIX_SEMANTICS +FILE_RENAME_FLAG_REPLACE_IF_EXISTS +FILE_RENAME_INFO +FILE_RESERVE_OPFILTER +FILE_SEQUENTIAL_ONLY +FILE_SESSION_AWARE +FILE_SHARE_DELETE +FILE_SHARE_MODE +FILE_SHARE_NONE +FILE_SHARE_READ +FILE_SHARE_WRITE +FILE_STANDARD_INFO +FILE_SUPERSEDE +FILE_SYNCHRONOUS_IO_ALERT +FILE_SYNCHRONOUS_IO_NONALERT +FILE_TRAVERSE +FILE_TYPE +FILE_TYPE_CHAR +FILE_TYPE_DISK +FILE_TYPE_PIPE +FILE_TYPE_REMOTE +FILE_TYPE_UNKNOWN +FILE_WRITE_ATTRIBUTES +FILE_WRITE_DATA +FILE_WRITE_EA +FILE_WRITE_THROUGH +FileAlignmentInfo +FileAllocationInfo +FileAttributeTagInfo +FileBasicInfo +FileCaseSensitiveInfo +FileCompressionInfo +FileDispositionInfo +FileDispositionInfoEx +FileEndOfFileInfo +FileFullDirectoryInfo +FileFullDirectoryRestartInfo +FileIdBothDirectoryInfo +FileIdBothDirectoryRestartInfo +FileIdExtdDirectoryInfo +FileIdExtdDirectoryRestartInfo +FileIdInfo +FileIoPriorityHintInfo +FileNameInfo +FileNormalizedNameInfo +FileRemoteProtocolInfo +FileRenameInfo +FileRenameInfoEx +FileStandardInfo +FileStorageInfo +FileStreamInfo +FILETIME +FindClose +FindExInfoBasic +FindExSearchNameMatch +FindFirstFileExW +FindNextFileW +FIONBIO +FlushFileBuffers +FORMAT_MESSAGE_ALLOCATE_BUFFER +FORMAT_MESSAGE_ARGUMENT_ARRAY +FORMAT_MESSAGE_FROM_HMODULE +FORMAT_MESSAGE_FROM_STRING +FORMAT_MESSAGE_FROM_SYSTEM +FORMAT_MESSAGE_IGNORE_INSERTS +FORMAT_MESSAGE_OPTIONS +FormatMessageW +freeaddrinfo +FreeEnvironmentStringsW +FRS_ERR_SYSVOL_POPULATE_TIMEOUT +FSCTL_GET_REPARSE_POINT +FSCTL_SET_REPARSE_POINT +GENERIC_ACCESS_RIGHTS +GENERIC_ALL +GENERIC_EXECUTE +GENERIC_READ +GENERIC_WRITE +GetActiveProcessorCount +getaddrinfo +GetCommandLineW +GetConsoleMode +GetConsoleOutputCP +GetCurrentDirectoryW +GetCurrentProcess +GetCurrentProcessId +GetCurrentThread +GetEnvironmentStringsW +GetEnvironmentVariableW +GetExitCodeProcess +GetFileAttributesW +GetFileInformationByHandle +GetFileInformationByHandleEx +GetFileType +GETFINALPATHNAMEBYHANDLE_FLAGS +GetFinalPathNameByHandleW +GetFullPathNameW +GetLastError +GetModuleFileNameW +GetModuleHandleA +GetModuleHandleW +GetOverlappedResult +getpeername +GetProcAddress +GetProcessId +getsockname +getsockopt +GetStdHandle +GetSystemDirectoryW +GetSystemInfo +GetSystemTimeAsFileTime +GetSystemTimePreciseAsFileTime +GetTempPathW +GetUserProfileDirectoryW +GetWindowsDirectoryW +HANDLE +HANDLE_FLAG_INHERIT +HANDLE_FLAG_PROTECT_FROM_CLOSE +HANDLE_FLAGS +HIGH_PRIORITY_CLASS +HMODULE +IDLE_PRIORITY_CLASS +IN6_ADDR +IN_ADDR +INFINITE +INHERIT_CALLER_PRIORITY +INHERIT_PARENT_AFFINITY +INIT_ONCE_INIT_FAILED +InitializeProcThreadAttributeList +InitOnceBeginInitialize +InitOnceComplete +INVALID_FILE_ATTRIBUTES +INVALID_SOCKET +IO_REPARSE_TAG_MOUNT_POINT +IO_REPARSE_TAG_SYMLINK +ioctlsocket +IP_ADD_MEMBERSHIP +IP_DROP_MEMBERSHIP +IP_MREQ +IP_MULTICAST_LOOP +IP_MULTICAST_TTL +IP_TTL +IPPROTO +IPPROTO_AH +IPPROTO_CBT +IPPROTO_DSTOPTS +IPPROTO_EGP +IPPROTO_ESP +IPPROTO_FRAGMENT +IPPROTO_GGP +IPPROTO_HOPOPTS +IPPROTO_ICLFXBM +IPPROTO_ICMP +IPPROTO_ICMPV6 +IPPROTO_IDP +IPPROTO_IGMP +IPPROTO_IGP +IPPROTO_IP +IPPROTO_IPV4 +IPPROTO_IPV6 +IPPROTO_L2TP +IPPROTO_MAX +IPPROTO_ND +IPPROTO_NONE +IPPROTO_PGM +IPPROTO_PIM +IPPROTO_PUP +IPPROTO_RAW +IPPROTO_RDP +IPPROTO_RESERVED_IPSEC +IPPROTO_RESERVED_IPSECOFFLOAD +IPPROTO_RESERVED_MAX +IPPROTO_RESERVED_RAW +IPPROTO_RESERVED_WNV +IPPROTO_RM +IPPROTO_ROUTING +IPPROTO_SCTP +IPPROTO_ST +IPPROTO_TCP +IPPROTO_UDP +IPV6_ADD_MEMBERSHIP +IPV6_DROP_MEMBERSHIP +IPV6_MREQ +IPV6_MULTICAST_LOOP +IPV6_V6ONLY +LINGER +listen +LocalFree +LOCKFILE_EXCLUSIVE_LOCK +LOCKFILE_FAIL_IMMEDIATELY +LockFileEx +LPOVERLAPPED_COMPLETION_ROUTINE +LPPROC_THREAD_ATTRIBUTE_LIST +LPPROGRESS_ROUTINE +LPPROGRESS_ROUTINE_CALLBACK_REASON +LPTHREAD_START_ROUTINE +LPWSAOVERLAPPED_COMPLETION_ROUTINE +M128A +MAX_PATH +MAXIMUM_REPARSE_DATA_BUFFER_SIZE +MaximumFileInfoByHandleClass +MB_COMPOSITE +MB_ERR_INVALID_CHARS +MB_PRECOMPOSED +MB_USEGLYPHCHARS +MOVE_FILE_FLAGS +MOVEFILE_COPY_ALLOWED +MOVEFILE_CREATE_HARDLINK +MOVEFILE_DELAY_UNTIL_REBOOT +MOVEFILE_FAIL_IF_NOT_TRACKABLE +MOVEFILE_REPLACE_EXISTING +MOVEFILE_WRITE_THROUGH +MoveFileExW +MSG_DONTROUTE +MSG_OOB +MSG_PEEK +MSG_PUSH_IMMEDIATE +MSG_WAITALL +MULTI_BYTE_TO_WIDE_CHAR_FLAGS +MultiByteToWideChar +NAMED_PIPE_MODE +NO_ERROR +NORMAL_PRIORITY_CLASS +NtCreateFile +NTCREATEFILE_CREATE_DISPOSITION +NTCREATEFILE_CREATE_OPTIONS +NtOpenFile +NtReadFile +NTSTATUS +NtWriteFile +OBJ_DONT_REPARSE +OPEN_ALWAYS +OPEN_EXISTING +OpenProcessToken +OVERLAPPED +PIPE_ACCEPT_REMOTE_CLIENTS +PIPE_ACCESS_DUPLEX +PIPE_ACCESS_INBOUND +PIPE_ACCESS_OUTBOUND +PIPE_CLIENT_END +PIPE_NOWAIT +PIPE_READMODE_BYTE +PIPE_READMODE_MESSAGE +PIPE_REJECT_REMOTE_CLIENTS +PIPE_SERVER_END +PIPE_TYPE_BYTE +PIPE_TYPE_MESSAGE +PIPE_WAIT +PROCESS_CREATION_FLAGS +PROCESS_INFORMATION +PROCESS_MODE_BACKGROUND_BEGIN +PROCESS_MODE_BACKGROUND_END +PROCESSOR_ARCHITECTURE +PROFILE_KERNEL +PROFILE_SERVER +PROFILE_USER +PROGRESS_CONTINUE +QueryPerformanceCounter +QueryPerformanceFrequency +READ_CONTROL +ReadConsoleW +ReadFile +ReadFileEx +REALTIME_PRIORITY_CLASS +recv +recvfrom +ReleaseSRWLockExclusive +ReleaseSRWLockShared +RemoveDirectoryW +RtlGenRandom +RtlNtStatusToDosError +SD_BOTH +SD_RECEIVE +SD_SEND +SECURITY_ANONYMOUS +SECURITY_ATTRIBUTES +SECURITY_CONTEXT_TRACKING +SECURITY_DELEGATION +SECURITY_EFFECTIVE_ONLY +SECURITY_IDENTIFICATION +SECURITY_IMPERSONATION +SECURITY_SQOS_PRESENT +SECURITY_VALID_SQOS_FLAGS +select +send +SEND_RECV_FLAGS +sendto +SET_FILE_POINTER_MOVE_METHOD +SetCurrentDirectoryW +SetEnvironmentVariableW +SetFileAttributesW +SetFileInformationByHandle +SetFilePointerEx +SetFileTime +SetHandleInformation +SetLastError +setsockopt +SetThreadStackGuarantee +SetWaitableTimer +shutdown +Sleep +SleepConditionVariableSRW +SleepEx +SO_BROADCAST +SO_ERROR +SO_LINGER +SO_RCVTIMEO +SO_SNDTIMEO +SOCK_DGRAM +SOCK_RAW +SOCK_RDM +SOCK_SEQPACKET +SOCK_STREAM +SOCKADDR +SOCKADDR_STORAGE +SOCKADDR_UN +SOCKET +SOCKET_ERROR +SOL_SOCKET +SPECIFIC_RIGHTS_ALL +STACK_SIZE_PARAM_IS_A_RESERVATION +STANDARD_RIGHTS_ALL +STANDARD_RIGHTS_EXECUTE +STANDARD_RIGHTS_READ +STANDARD_RIGHTS_REQUIRED +STANDARD_RIGHTS_WRITE +STARTF_FORCEOFFFEEDBACK +STARTF_FORCEONFEEDBACK +STARTF_PREVENTPINNING +STARTF_RUNFULLSCREEN +STARTF_TITLEISAPPID +STARTF_TITLEISLINKNAME +STARTF_UNTRUSTEDSOURCE +STARTF_USECOUNTCHARS +STARTF_USEFILLATTRIBUTE +STARTF_USEHOTKEY +STARTF_USEPOSITION +STARTF_USESHOWWINDOW +STARTF_USESIZE +STARTF_USESTDHANDLES +STARTUPINFOEXW +STARTUPINFOW +STARTUPINFOW_FLAGS +STATUS_DELETE_PENDING +STATUS_DIRECTORY_NOT_EMPTY +STATUS_END_OF_FILE +STATUS_FILE_DELETED +STATUS_INVALID_HANDLE +STATUS_INVALID_PARAMETER +STATUS_NOT_IMPLEMENTED +STATUS_PENDING +STATUS_SHARING_VIOLATION +STATUS_SUCCESS +STD_ERROR_HANDLE +STD_HANDLE +STD_INPUT_HANDLE +STD_OUTPUT_HANDLE +SwitchToThread +SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE +SYMBOLIC_LINK_FLAG_DIRECTORY +SYMBOLIC_LINK_FLAGS +SYMLINK_FLAG_RELATIVE +SYNCHRONIZE +SYSTEM_INFO +TCP_NODELAY +TerminateProcess +THREAD_CREATE_RUN_IMMEDIATELY +THREAD_CREATE_SUSPENDED +THREAD_CREATION_FLAGS +TIMER_ALL_ACCESS +TIMER_MODIFY_STATE +TIMEVAL +TLS_OUT_OF_INDEXES +TlsAlloc +TlsFree +TlsGetValue +TlsSetValue +TOKEN_ACCESS_MASK +TOKEN_ACCESS_PSEUDO_HANDLE +TOKEN_ACCESS_PSEUDO_HANDLE_WIN8 +TOKEN_ACCESS_SYSTEM_SECURITY +TOKEN_ADJUST_DEFAULT +TOKEN_ADJUST_GROUPS +TOKEN_ADJUST_PRIVILEGES +TOKEN_ADJUST_SESSIONID +TOKEN_ALL_ACCESS +TOKEN_ASSIGN_PRIMARY +TOKEN_DELETE +TOKEN_DUPLICATE +TOKEN_EXECUTE +TOKEN_IMPERSONATE +TOKEN_QUERY +TOKEN_QUERY_SOURCE +TOKEN_READ +TOKEN_READ_CONTROL +TOKEN_TRUST_CONSTRAINT_MASK +TOKEN_WRITE +TOKEN_WRITE_DAC +TOKEN_WRITE_OWNER +TRUE +TRUNCATE_EXISTING +TryAcquireSRWLockExclusive +TryAcquireSRWLockShared +UNICODE_STRING +UnlockFile +UpdateProcThreadAttribute +VOLUME_NAME_DOS +VOLUME_NAME_GUID +VOLUME_NAME_NONE +WAIT_ABANDONED +WAIT_ABANDONED_0 +WAIT_FAILED +WAIT_IO_COMPLETION +WAIT_OBJECT_0 +WAIT_TIMEOUT +WaitForMultipleObjects +WaitForSingleObject +WakeAllConditionVariable +WakeConditionVariable +WC_ERR_INVALID_CHARS +WideCharToMultiByte +WIN32_ERROR +WIN32_FIND_DATAW Windows.Wdk.Storage.FileSystem.FILE_NO_COMPRESSION -Windows.Wdk.Storage.FileSystem.FILE_NO_EA_KNOWLEDGE -Windows.Wdk.Storage.FileSystem.FILE_NO_INTERMEDIATE_BUFFERING -Windows.Wdk.Storage.FileSystem.FILE_NON_DIRECTORY_FILE -Windows.Wdk.Storage.FileSystem.FILE_OPEN -Windows.Wdk.Storage.FileSystem.FILE_OPEN_BY_FILE_ID -Windows.Wdk.Storage.FileSystem.FILE_OPEN_FOR_BACKUP_INTENT -Windows.Wdk.Storage.FileSystem.FILE_OPEN_FOR_FREE_SPACE_QUERY -Windows.Wdk.Storage.FileSystem.FILE_OPEN_IF Windows.Wdk.Storage.FileSystem.FILE_OPEN_NO_RECALL -Windows.Wdk.Storage.FileSystem.FILE_OPEN_REPARSE_POINT -Windows.Wdk.Storage.FileSystem.FILE_OPEN_REQUIRING_OPLOCK -Windows.Wdk.Storage.FileSystem.FILE_OVERWRITE -Windows.Wdk.Storage.FileSystem.FILE_OVERWRITE_IF -Windows.Wdk.Storage.FileSystem.FILE_RANDOM_ACCESS -Windows.Wdk.Storage.FileSystem.FILE_RESERVE_OPFILTER -Windows.Wdk.Storage.FileSystem.FILE_SEQUENTIAL_ONLY -Windows.Wdk.Storage.FileSystem.FILE_SESSION_AWARE -Windows.Wdk.Storage.FileSystem.FILE_SUPERSEDE -Windows.Wdk.Storage.FileSystem.FILE_SYNCHRONOUS_IO_ALERT -Windows.Wdk.Storage.FileSystem.FILE_SYNCHRONOUS_IO_NONALERT -Windows.Wdk.Storage.FileSystem.FILE_WRITE_THROUGH -Windows.Wdk.Storage.FileSystem.NtCreateFile -Windows.Wdk.Storage.FileSystem.NTCREATEFILE_CREATE_DISPOSITION -Windows.Wdk.Storage.FileSystem.NTCREATEFILE_CREATE_OPTIONS -Windows.Wdk.Storage.FileSystem.NtOpenFile -Windows.Wdk.Storage.FileSystem.NtReadFile -Windows.Wdk.Storage.FileSystem.NtWriteFile -Windows.Wdk.Storage.FileSystem.SYMLINK_FLAG_RELATIVE -Windows.Win32.Foundation.BOOL -Windows.Win32.Foundation.BOOLEAN -Windows.Win32.Foundation.CloseHandle -Windows.Win32.Foundation.DNS_ERROR_ADDRESS_REQUIRED -Windows.Win32.Foundation.DNS_ERROR_ALIAS_LOOP -Windows.Win32.Foundation.DNS_ERROR_AUTOZONE_ALREADY_EXISTS -Windows.Win32.Foundation.DNS_ERROR_AXFR -Windows.Win32.Foundation.DNS_ERROR_BACKGROUND_LOADING -Windows.Win32.Foundation.DNS_ERROR_BAD_KEYMASTER -Windows.Win32.Foundation.DNS_ERROR_BAD_PACKET -Windows.Win32.Foundation.DNS_ERROR_CANNOT_FIND_ROOT_HINTS -Windows.Win32.Foundation.DNS_ERROR_CLIENT_SUBNET_ALREADY_EXISTS -Windows.Win32.Foundation.DNS_ERROR_CLIENT_SUBNET_DOES_NOT_EXIST -Windows.Win32.Foundation.DNS_ERROR_CLIENT_SUBNET_IS_ACCESSED -Windows.Win32.Foundation.DNS_ERROR_CNAME_COLLISION -Windows.Win32.Foundation.DNS_ERROR_CNAME_LOOP -Windows.Win32.Foundation.DNS_ERROR_DATAFILE_OPEN_FAILURE -Windows.Win32.Foundation.DNS_ERROR_DATAFILE_PARSING -Windows.Win32.Foundation.DNS_ERROR_DEFAULT_SCOPE -Windows.Win32.Foundation.DNS_ERROR_DEFAULT_VIRTUALIZATION_INSTANCE -Windows.Win32.Foundation.DNS_ERROR_DEFAULT_ZONESCOPE -Windows.Win32.Foundation.DNS_ERROR_DELEGATION_REQUIRED -Windows.Win32.Foundation.DNS_ERROR_DNAME_COLLISION -Windows.Win32.Foundation.DNS_ERROR_DNSSEC_IS_DISABLED -Windows.Win32.Foundation.DNS_ERROR_DP_ALREADY_ENLISTED -Windows.Win32.Foundation.DNS_ERROR_DP_ALREADY_EXISTS -Windows.Win32.Foundation.DNS_ERROR_DP_DOES_NOT_EXIST -Windows.Win32.Foundation.DNS_ERROR_DP_FSMO_ERROR -Windows.Win32.Foundation.DNS_ERROR_DP_NOT_AVAILABLE -Windows.Win32.Foundation.DNS_ERROR_DP_NOT_ENLISTED -Windows.Win32.Foundation.DNS_ERROR_DS_UNAVAILABLE -Windows.Win32.Foundation.DNS_ERROR_DS_ZONE_ALREADY_EXISTS -Windows.Win32.Foundation.DNS_ERROR_DWORD_VALUE_TOO_LARGE -Windows.Win32.Foundation.DNS_ERROR_DWORD_VALUE_TOO_SMALL -Windows.Win32.Foundation.DNS_ERROR_FILE_WRITEBACK_FAILED -Windows.Win32.Foundation.DNS_ERROR_FORWARDER_ALREADY_EXISTS -Windows.Win32.Foundation.DNS_ERROR_INCONSISTENT_ROOT_HINTS -Windows.Win32.Foundation.DNS_ERROR_INVAILD_VIRTUALIZATION_INSTANCE_NAME -Windows.Win32.Foundation.DNS_ERROR_INVALID_CLIENT_SUBNET_NAME -Windows.Win32.Foundation.DNS_ERROR_INVALID_DATA -Windows.Win32.Foundation.DNS_ERROR_INVALID_DATAFILE_NAME -Windows.Win32.Foundation.DNS_ERROR_INVALID_INITIAL_ROLLOVER_OFFSET -Windows.Win32.Foundation.DNS_ERROR_INVALID_IP_ADDRESS -Windows.Win32.Foundation.DNS_ERROR_INVALID_KEY_SIZE -Windows.Win32.Foundation.DNS_ERROR_INVALID_NAME -Windows.Win32.Foundation.DNS_ERROR_INVALID_NAME_CHAR -Windows.Win32.Foundation.DNS_ERROR_INVALID_NSEC3_ITERATION_COUNT -Windows.Win32.Foundation.DNS_ERROR_INVALID_POLICY_TABLE -Windows.Win32.Foundation.DNS_ERROR_INVALID_PROPERTY -Windows.Win32.Foundation.DNS_ERROR_INVALID_ROLLOVER_PERIOD -Windows.Win32.Foundation.DNS_ERROR_INVALID_SCOPE_NAME -Windows.Win32.Foundation.DNS_ERROR_INVALID_SCOPE_OPERATION -Windows.Win32.Foundation.DNS_ERROR_INVALID_SIGNATURE_VALIDITY_PERIOD -Windows.Win32.Foundation.DNS_ERROR_INVALID_TYPE -Windows.Win32.Foundation.DNS_ERROR_INVALID_XML -Windows.Win32.Foundation.DNS_ERROR_INVALID_ZONE_OPERATION -Windows.Win32.Foundation.DNS_ERROR_INVALID_ZONE_TYPE -Windows.Win32.Foundation.DNS_ERROR_INVALID_ZONESCOPE_NAME -Windows.Win32.Foundation.DNS_ERROR_KEYMASTER_REQUIRED -Windows.Win32.Foundation.DNS_ERROR_KSP_DOES_NOT_SUPPORT_PROTECTION -Windows.Win32.Foundation.DNS_ERROR_KSP_NOT_ACCESSIBLE -Windows.Win32.Foundation.DNS_ERROR_LOAD_ZONESCOPE_FAILED -Windows.Win32.Foundation.DNS_ERROR_NAME_DOES_NOT_EXIST -Windows.Win32.Foundation.DNS_ERROR_NAME_NOT_IN_ZONE -Windows.Win32.Foundation.DNS_ERROR_NBSTAT_INIT_FAILED -Windows.Win32.Foundation.DNS_ERROR_NEED_SECONDARY_ADDRESSES -Windows.Win32.Foundation.DNS_ERROR_NEED_WINS_SERVERS -Windows.Win32.Foundation.DNS_ERROR_NO_BOOTFILE_IF_DS_ZONE -Windows.Win32.Foundation.DNS_ERROR_NO_CREATE_CACHE_DATA -Windows.Win32.Foundation.DNS_ERROR_NO_DNS_SERVERS -Windows.Win32.Foundation.DNS_ERROR_NO_MEMORY -Windows.Win32.Foundation.DNS_ERROR_NO_PACKET -Windows.Win32.Foundation.DNS_ERROR_NO_TCPIP -Windows.Win32.Foundation.DNS_ERROR_NO_VALID_TRUST_ANCHORS -Windows.Win32.Foundation.DNS_ERROR_NO_ZONE_INFO -Windows.Win32.Foundation.DNS_ERROR_NODE_CREATION_FAILED -Windows.Win32.Foundation.DNS_ERROR_NODE_IS_CNAME -Windows.Win32.Foundation.DNS_ERROR_NODE_IS_DNAME -Windows.Win32.Foundation.DNS_ERROR_NON_RFC_NAME -Windows.Win32.Foundation.DNS_ERROR_NOT_ALLOWED_ON_ACTIVE_SKD -Windows.Win32.Foundation.DNS_ERROR_NOT_ALLOWED_ON_RODC -Windows.Win32.Foundation.DNS_ERROR_NOT_ALLOWED_ON_ROOT_SERVER -Windows.Win32.Foundation.DNS_ERROR_NOT_ALLOWED_ON_SIGNED_ZONE -Windows.Win32.Foundation.DNS_ERROR_NOT_ALLOWED_ON_UNSIGNED_ZONE -Windows.Win32.Foundation.DNS_ERROR_NOT_ALLOWED_ON_ZSK -Windows.Win32.Foundation.DNS_ERROR_NOT_ALLOWED_UNDER_DELEGATION -Windows.Win32.Foundation.DNS_ERROR_NOT_ALLOWED_UNDER_DNAME -Windows.Win32.Foundation.DNS_ERROR_NOT_ALLOWED_WITH_ZONESCOPES -Windows.Win32.Foundation.DNS_ERROR_NOT_ENOUGH_SIGNING_KEY_DESCRIPTORS -Windows.Win32.Foundation.DNS_ERROR_NOT_UNIQUE -Windows.Win32.Foundation.DNS_ERROR_NSEC3_INCOMPATIBLE_WITH_RSA_SHA1 -Windows.Win32.Foundation.DNS_ERROR_NSEC3_NAME_COLLISION -Windows.Win32.Foundation.DNS_ERROR_NSEC_INCOMPATIBLE_WITH_NSEC3_RSA_SHA1 -Windows.Win32.Foundation.DNS_ERROR_NUMERIC_NAME -Windows.Win32.Foundation.DNS_ERROR_POLICY_ALREADY_EXISTS -Windows.Win32.Foundation.DNS_ERROR_POLICY_DOES_NOT_EXIST -Windows.Win32.Foundation.DNS_ERROR_POLICY_INVALID_CRITERIA -Windows.Win32.Foundation.DNS_ERROR_POLICY_INVALID_CRITERIA_CLIENT_SUBNET -Windows.Win32.Foundation.DNS_ERROR_POLICY_INVALID_CRITERIA_FQDN -Windows.Win32.Foundation.DNS_ERROR_POLICY_INVALID_CRITERIA_INTERFACE -Windows.Win32.Foundation.DNS_ERROR_POLICY_INVALID_CRITERIA_NETWORK_PROTOCOL -Windows.Win32.Foundation.DNS_ERROR_POLICY_INVALID_CRITERIA_QUERY_TYPE -Windows.Win32.Foundation.DNS_ERROR_POLICY_INVALID_CRITERIA_TIME_OF_DAY -Windows.Win32.Foundation.DNS_ERROR_POLICY_INVALID_CRITERIA_TRANSPORT_PROTOCOL -Windows.Win32.Foundation.DNS_ERROR_POLICY_INVALID_NAME -Windows.Win32.Foundation.DNS_ERROR_POLICY_INVALID_SETTINGS -Windows.Win32.Foundation.DNS_ERROR_POLICY_INVALID_WEIGHT -Windows.Win32.Foundation.DNS_ERROR_POLICY_LOCKED -Windows.Win32.Foundation.DNS_ERROR_POLICY_MISSING_CRITERIA -Windows.Win32.Foundation.DNS_ERROR_POLICY_PROCESSING_ORDER_INVALID -Windows.Win32.Foundation.DNS_ERROR_POLICY_SCOPE_MISSING -Windows.Win32.Foundation.DNS_ERROR_POLICY_SCOPE_NOT_ALLOWED -Windows.Win32.Foundation.DNS_ERROR_PRIMARY_REQUIRES_DATAFILE -Windows.Win32.Foundation.DNS_ERROR_RCODE -Windows.Win32.Foundation.DNS_ERROR_RCODE_BADKEY -Windows.Win32.Foundation.DNS_ERROR_RCODE_BADSIG -Windows.Win32.Foundation.DNS_ERROR_RCODE_BADTIME -Windows.Win32.Foundation.DNS_ERROR_RCODE_FORMAT_ERROR -Windows.Win32.Foundation.DNS_ERROR_RCODE_NAME_ERROR -Windows.Win32.Foundation.DNS_ERROR_RCODE_NOT_IMPLEMENTED -Windows.Win32.Foundation.DNS_ERROR_RCODE_NOTAUTH -Windows.Win32.Foundation.DNS_ERROR_RCODE_NOTZONE -Windows.Win32.Foundation.DNS_ERROR_RCODE_NXRRSET -Windows.Win32.Foundation.DNS_ERROR_RCODE_REFUSED -Windows.Win32.Foundation.DNS_ERROR_RCODE_SERVER_FAILURE -Windows.Win32.Foundation.DNS_ERROR_RCODE_YXDOMAIN -Windows.Win32.Foundation.DNS_ERROR_RCODE_YXRRSET -Windows.Win32.Foundation.DNS_ERROR_RECORD_ALREADY_EXISTS -Windows.Win32.Foundation.DNS_ERROR_RECORD_DOES_NOT_EXIST -Windows.Win32.Foundation.DNS_ERROR_RECORD_FORMAT -Windows.Win32.Foundation.DNS_ERROR_RECORD_ONLY_AT_ZONE_ROOT -Windows.Win32.Foundation.DNS_ERROR_RECORD_TIMED_OUT -Windows.Win32.Foundation.DNS_ERROR_ROLLOVER_ALREADY_QUEUED -Windows.Win32.Foundation.DNS_ERROR_ROLLOVER_IN_PROGRESS -Windows.Win32.Foundation.DNS_ERROR_ROLLOVER_NOT_POKEABLE -Windows.Win32.Foundation.DNS_ERROR_RRL_INVALID_IPV4_PREFIX -Windows.Win32.Foundation.DNS_ERROR_RRL_INVALID_IPV6_PREFIX -Windows.Win32.Foundation.DNS_ERROR_RRL_INVALID_LEAK_RATE -Windows.Win32.Foundation.DNS_ERROR_RRL_INVALID_TC_RATE -Windows.Win32.Foundation.DNS_ERROR_RRL_INVALID_WINDOW_SIZE -Windows.Win32.Foundation.DNS_ERROR_RRL_LEAK_RATE_LESSTHAN_TC_RATE -Windows.Win32.Foundation.DNS_ERROR_RRL_NOT_ENABLED -Windows.Win32.Foundation.DNS_ERROR_SCOPE_ALREADY_EXISTS -Windows.Win32.Foundation.DNS_ERROR_SCOPE_DOES_NOT_EXIST -Windows.Win32.Foundation.DNS_ERROR_SCOPE_LOCKED -Windows.Win32.Foundation.DNS_ERROR_SECONDARY_DATA -Windows.Win32.Foundation.DNS_ERROR_SECONDARY_REQUIRES_MASTER_IP -Windows.Win32.Foundation.DNS_ERROR_SERVERSCOPE_IS_REFERENCED -Windows.Win32.Foundation.DNS_ERROR_SIGNING_KEY_NOT_ACCESSIBLE -Windows.Win32.Foundation.DNS_ERROR_SOA_DELETE_INVALID -Windows.Win32.Foundation.DNS_ERROR_STANDBY_KEY_NOT_PRESENT -Windows.Win32.Foundation.DNS_ERROR_SUBNET_ALREADY_EXISTS -Windows.Win32.Foundation.DNS_ERROR_SUBNET_DOES_NOT_EXIST -Windows.Win32.Foundation.DNS_ERROR_TOO_MANY_SKDS -Windows.Win32.Foundation.DNS_ERROR_TRY_AGAIN_LATER -Windows.Win32.Foundation.DNS_ERROR_UNEXPECTED_CNG_ERROR -Windows.Win32.Foundation.DNS_ERROR_UNEXPECTED_DATA_PROTECTION_ERROR -Windows.Win32.Foundation.DNS_ERROR_UNKNOWN_RECORD_TYPE -Windows.Win32.Foundation.DNS_ERROR_UNKNOWN_SIGNING_PARAMETER_VERSION -Windows.Win32.Foundation.DNS_ERROR_UNSECURE_PACKET -Windows.Win32.Foundation.DNS_ERROR_UNSUPPORTED_ALGORITHM -Windows.Win32.Foundation.DNS_ERROR_VIRTUALIZATION_INSTANCE_ALREADY_EXISTS -Windows.Win32.Foundation.DNS_ERROR_VIRTUALIZATION_INSTANCE_DOES_NOT_EXIST -Windows.Win32.Foundation.DNS_ERROR_VIRTUALIZATION_TREE_LOCKED -Windows.Win32.Foundation.DNS_ERROR_WINS_INIT_FAILED -Windows.Win32.Foundation.DNS_ERROR_ZONE_ALREADY_EXISTS -Windows.Win32.Foundation.DNS_ERROR_ZONE_CONFIGURATION_ERROR -Windows.Win32.Foundation.DNS_ERROR_ZONE_CREATION_FAILED -Windows.Win32.Foundation.DNS_ERROR_ZONE_DOES_NOT_EXIST -Windows.Win32.Foundation.DNS_ERROR_ZONE_HAS_NO_NS_RECORDS -Windows.Win32.Foundation.DNS_ERROR_ZONE_HAS_NO_SOA_RECORD -Windows.Win32.Foundation.DNS_ERROR_ZONE_IS_SHUTDOWN -Windows.Win32.Foundation.DNS_ERROR_ZONE_LOCKED -Windows.Win32.Foundation.DNS_ERROR_ZONE_LOCKED_FOR_SIGNING -Windows.Win32.Foundation.DNS_ERROR_ZONE_NOT_SECONDARY -Windows.Win32.Foundation.DNS_ERROR_ZONE_REQUIRES_MASTER_IP -Windows.Win32.Foundation.DNS_ERROR_ZONESCOPE_ALREADY_EXISTS -Windows.Win32.Foundation.DNS_ERROR_ZONESCOPE_DOES_NOT_EXIST -Windows.Win32.Foundation.DNS_ERROR_ZONESCOPE_FILE_WRITEBACK_FAILED -Windows.Win32.Foundation.DNS_ERROR_ZONESCOPE_IS_REFERENCED -Windows.Win32.Foundation.DUPLICATE_CLOSE_SOURCE -Windows.Win32.Foundation.DUPLICATE_HANDLE_OPTIONS -Windows.Win32.Foundation.DUPLICATE_SAME_ACCESS -Windows.Win32.Foundation.DuplicateHandle -Windows.Win32.Foundation.E_NOTIMPL -Windows.Win32.Foundation.ERROR_ABANDON_HIBERFILE -Windows.Win32.Foundation.ERROR_ABANDONED_WAIT_0 -Windows.Win32.Foundation.ERROR_ABANDONED_WAIT_63 -Windows.Win32.Foundation.ERROR_ABIOS_ERROR -Windows.Win32.Foundation.ERROR_ACCESS_AUDIT_BY_POLICY -Windows.Win32.Foundation.ERROR_ACCESS_DENIED -Windows.Win32.Foundation.ERROR_ACCESS_DENIED_APPDATA -Windows.Win32.Foundation.ERROR_ACCESS_DISABLED_BY_POLICY -Windows.Win32.Foundation.ERROR_ACCESS_DISABLED_NO_SAFER_UI_BY_POLICY -Windows.Win32.Foundation.ERROR_ACCESS_DISABLED_WEBBLADE -Windows.Win32.Foundation.ERROR_ACCESS_DISABLED_WEBBLADE_TAMPER -Windows.Win32.Foundation.ERROR_ACCOUNT_DISABLED -Windows.Win32.Foundation.ERROR_ACCOUNT_EXPIRED -Windows.Win32.Foundation.ERROR_ACCOUNT_LOCKED_OUT -Windows.Win32.Foundation.ERROR_ACCOUNT_RESTRICTION -Windows.Win32.Foundation.ERROR_ACPI_ERROR -Windows.Win32.Foundation.ERROR_ACTIVE_CONNECTIONS -Windows.Win32.Foundation.ERROR_ADAP_HDW_ERR -Windows.Win32.Foundation.ERROR_ADDRESS_ALREADY_ASSOCIATED -Windows.Win32.Foundation.ERROR_ADDRESS_NOT_ASSOCIATED -Windows.Win32.Foundation.ERROR_ALERTED -Windows.Win32.Foundation.ERROR_ALIAS_EXISTS -Windows.Win32.Foundation.ERROR_ALL_USER_TRUST_QUOTA_EXCEEDED -Windows.Win32.Foundation.ERROR_ALLOCATE_BUCKET -Windows.Win32.Foundation.ERROR_ALLOTTED_SPACE_EXCEEDED -Windows.Win32.Foundation.ERROR_ALREADY_ASSIGNED -Windows.Win32.Foundation.ERROR_ALREADY_EXISTS -Windows.Win32.Foundation.ERROR_ALREADY_FIBER -Windows.Win32.Foundation.ERROR_ALREADY_HAS_STREAM_ID -Windows.Win32.Foundation.ERROR_ALREADY_INITIALIZED -Windows.Win32.Foundation.ERROR_ALREADY_REGISTERED -Windows.Win32.Foundation.ERROR_ALREADY_RUNNING_LKG -Windows.Win32.Foundation.ERROR_ALREADY_THREAD -Windows.Win32.Foundation.ERROR_ALREADY_WAITING -Windows.Win32.Foundation.ERROR_ALREADY_WIN32 -Windows.Win32.Foundation.ERROR_API_UNAVAILABLE -Windows.Win32.Foundation.ERROR_APP_HANG -Windows.Win32.Foundation.ERROR_APP_INIT_FAILURE -Windows.Win32.Foundation.ERROR_APP_WRONG_OS -Windows.Win32.Foundation.ERROR_APPCONTAINER_REQUIRED -Windows.Win32.Foundation.ERROR_APPEXEC_APP_COMPAT_BLOCK -Windows.Win32.Foundation.ERROR_APPEXEC_CALLER_WAIT_TIMEOUT -Windows.Win32.Foundation.ERROR_APPEXEC_CALLER_WAIT_TIMEOUT_LICENSING -Windows.Win32.Foundation.ERROR_APPEXEC_CALLER_WAIT_TIMEOUT_RESOURCES -Windows.Win32.Foundation.ERROR_APPEXEC_CALLER_WAIT_TIMEOUT_TERMINATION -Windows.Win32.Foundation.ERROR_APPEXEC_CONDITION_NOT_SATISFIED -Windows.Win32.Foundation.ERROR_APPEXEC_HANDLE_INVALIDATED -Windows.Win32.Foundation.ERROR_APPEXEC_HOST_ID_MISMATCH -Windows.Win32.Foundation.ERROR_APPEXEC_INVALID_HOST_GENERATION -Windows.Win32.Foundation.ERROR_APPEXEC_INVALID_HOST_STATE -Windows.Win32.Foundation.ERROR_APPEXEC_NO_DONOR -Windows.Win32.Foundation.ERROR_APPEXEC_UNEXPECTED_PROCESS_REGISTRATION -Windows.Win32.Foundation.ERROR_APPEXEC_UNKNOWN_USER -Windows.Win32.Foundation.ERROR_APPHELP_BLOCK -Windows.Win32.Foundation.ERROR_APPX_FILE_NOT_ENCRYPTED -Windows.Win32.Foundation.ERROR_ARBITRATION_UNHANDLED -Windows.Win32.Foundation.ERROR_ARENA_TRASHED -Windows.Win32.Foundation.ERROR_ARITHMETIC_OVERFLOW -Windows.Win32.Foundation.ERROR_ASSERTION_FAILURE -Windows.Win32.Foundation.ERROR_ATOMIC_LOCKS_NOT_SUPPORTED -Windows.Win32.Foundation.ERROR_AUDIT_FAILED -Windows.Win32.Foundation.ERROR_AUTHENTICATION_FIREWALL_FAILED -Windows.Win32.Foundation.ERROR_AUTHIP_FAILURE -Windows.Win32.Foundation.ERROR_AUTODATASEG_EXCEEDS_64k -Windows.Win32.Foundation.ERROR_BACKUP_CONTROLLER -Windows.Win32.Foundation.ERROR_BAD_ACCESSOR_FLAGS -Windows.Win32.Foundation.ERROR_BAD_ARGUMENTS -Windows.Win32.Foundation.ERROR_BAD_COMMAND -Windows.Win32.Foundation.ERROR_BAD_COMPRESSION_BUFFER -Windows.Win32.Foundation.ERROR_BAD_CONFIGURATION -Windows.Win32.Foundation.ERROR_BAD_CURRENT_DIRECTORY -Windows.Win32.Foundation.ERROR_BAD_DESCRIPTOR_FORMAT -Windows.Win32.Foundation.ERROR_BAD_DEV_TYPE -Windows.Win32.Foundation.ERROR_BAD_DEVICE -Windows.Win32.Foundation.ERROR_BAD_DEVICE_PATH -Windows.Win32.Foundation.ERROR_BAD_DLL_ENTRYPOINT -Windows.Win32.Foundation.ERROR_BAD_DRIVER_LEVEL -Windows.Win32.Foundation.ERROR_BAD_ENVIRONMENT -Windows.Win32.Foundation.ERROR_BAD_EXE_FORMAT -Windows.Win32.Foundation.ERROR_BAD_FILE_TYPE -Windows.Win32.Foundation.ERROR_BAD_FORMAT -Windows.Win32.Foundation.ERROR_BAD_FUNCTION_TABLE -Windows.Win32.Foundation.ERROR_BAD_IMPERSONATION_LEVEL -Windows.Win32.Foundation.ERROR_BAD_INHERITANCE_ACL -Windows.Win32.Foundation.ERROR_BAD_LENGTH -Windows.Win32.Foundation.ERROR_BAD_LOGON_SESSION_STATE -Windows.Win32.Foundation.ERROR_BAD_MCFG_TABLE -Windows.Win32.Foundation.ERROR_BAD_NET_NAME -Windows.Win32.Foundation.ERROR_BAD_NET_RESP -Windows.Win32.Foundation.ERROR_BAD_NETPATH -Windows.Win32.Foundation.ERROR_BAD_PATHNAME -Windows.Win32.Foundation.ERROR_BAD_PIPE -Windows.Win32.Foundation.ERROR_BAD_PROFILE -Windows.Win32.Foundation.ERROR_BAD_PROVIDER -Windows.Win32.Foundation.ERROR_BAD_QUERY_SYNTAX -Windows.Win32.Foundation.ERROR_BAD_RECOVERY_POLICY -Windows.Win32.Foundation.ERROR_BAD_REM_ADAP -Windows.Win32.Foundation.ERROR_BAD_SERVICE_ENTRYPOINT -Windows.Win32.Foundation.ERROR_BAD_STACK -Windows.Win32.Foundation.ERROR_BAD_THREADID_ADDR -Windows.Win32.Foundation.ERROR_BAD_TOKEN_TYPE -Windows.Win32.Foundation.ERROR_BAD_UNIT -Windows.Win32.Foundation.ERROR_BAD_USER_PROFILE -Windows.Win32.Foundation.ERROR_BAD_USERNAME -Windows.Win32.Foundation.ERROR_BAD_VALIDATION_CLASS -Windows.Win32.Foundation.ERROR_BADDB -Windows.Win32.Foundation.ERROR_BADKEY -Windows.Win32.Foundation.ERROR_BADSTARTPOSITION -Windows.Win32.Foundation.ERROR_BEGINNING_OF_MEDIA -Windows.Win32.Foundation.ERROR_BEYOND_VDL -Windows.Win32.Foundation.ERROR_BIOS_FAILED_TO_CONNECT_INTERRUPT -Windows.Win32.Foundation.ERROR_BLOCK_SHARED -Windows.Win32.Foundation.ERROR_BLOCK_SOURCE_WEAK_REFERENCE_INVALID -Windows.Win32.Foundation.ERROR_BLOCK_TARGET_WEAK_REFERENCE_INVALID -Windows.Win32.Foundation.ERROR_BLOCK_TOO_MANY_REFERENCES -Windows.Win32.Foundation.ERROR_BLOCK_WEAK_REFERENCE_INVALID -Windows.Win32.Foundation.ERROR_BLOCKED_BY_PARENTAL_CONTROLS -Windows.Win32.Foundation.ERROR_BOOT_ALREADY_ACCEPTED -Windows.Win32.Foundation.ERROR_BROKEN_PIPE -Windows.Win32.Foundation.ERROR_BUFFER_ALL_ZEROS -Windows.Win32.Foundation.ERROR_BUFFER_OVERFLOW -Windows.Win32.Foundation.ERROR_BUS_RESET -Windows.Win32.Foundation.ERROR_BUSY -Windows.Win32.Foundation.ERROR_BUSY_DRIVE -Windows.Win32.Foundation.ERROR_BYPASSIO_FLT_NOT_SUPPORTED -Windows.Win32.Foundation.ERROR_CACHE_PAGE_LOCKED -Windows.Win32.Foundation.ERROR_CALL_NOT_IMPLEMENTED -Windows.Win32.Foundation.ERROR_CALLBACK_INVOKE_INLINE -Windows.Win32.Foundation.ERROR_CALLBACK_POP_STACK -Windows.Win32.Foundation.ERROR_CALLBACK_SUPPLIED_INVALID_DATA -Windows.Win32.Foundation.ERROR_CAN_NOT_COMPLETE -Windows.Win32.Foundation.ERROR_CANCEL_VIOLATION -Windows.Win32.Foundation.ERROR_CANCELLED -Windows.Win32.Foundation.ERROR_CANNOT_BREAK_OPLOCK -Windows.Win32.Foundation.ERROR_CANNOT_COPY -Windows.Win32.Foundation.ERROR_CANNOT_DETECT_DRIVER_FAILURE -Windows.Win32.Foundation.ERROR_CANNOT_DETECT_PROCESS_ABORT -Windows.Win32.Foundation.ERROR_CANNOT_FIND_WND_CLASS -Windows.Win32.Foundation.ERROR_CANNOT_GRANT_REQUESTED_OPLOCK -Windows.Win32.Foundation.ERROR_CANNOT_IMPERSONATE -Windows.Win32.Foundation.ERROR_CANNOT_LOAD_REGISTRY_FILE -Windows.Win32.Foundation.ERROR_CANNOT_MAKE -Windows.Win32.Foundation.ERROR_CANNOT_OPEN_PROFILE -Windows.Win32.Foundation.ERROR_CANT_ACCESS_DOMAIN_INFO -Windows.Win32.Foundation.ERROR_CANT_ACCESS_FILE -Windows.Win32.Foundation.ERROR_CANT_CLEAR_ENCRYPTION_FLAG -Windows.Win32.Foundation.ERROR_CANT_DISABLE_MANDATORY -Windows.Win32.Foundation.ERROR_CANT_ENABLE_DENY_ONLY -Windows.Win32.Foundation.ERROR_CANT_OPEN_ANONYMOUS -Windows.Win32.Foundation.ERROR_CANT_RESOLVE_FILENAME -Windows.Win32.Foundation.ERROR_CANT_TERMINATE_SELF -Windows.Win32.Foundation.ERROR_CANT_WAIT -Windows.Win32.Foundation.ERROR_CANTFETCHBACKWARDS -Windows.Win32.Foundation.ERROR_CANTOPEN -Windows.Win32.Foundation.ERROR_CANTREAD -Windows.Win32.Foundation.ERROR_CANTSCROLLBACKWARDS -Windows.Win32.Foundation.ERROR_CANTWRITE -Windows.Win32.Foundation.ERROR_CAPAUTHZ_CHANGE_TYPE -Windows.Win32.Foundation.ERROR_CAPAUTHZ_DB_CORRUPTED -Windows.Win32.Foundation.ERROR_CAPAUTHZ_NO_POLICY -Windows.Win32.Foundation.ERROR_CAPAUTHZ_NOT_AUTHORIZED -Windows.Win32.Foundation.ERROR_CAPAUTHZ_NOT_DEVUNLOCKED -Windows.Win32.Foundation.ERROR_CAPAUTHZ_NOT_PROVISIONED -Windows.Win32.Foundation.ERROR_CAPAUTHZ_SCCD_DEV_MODE_REQUIRED -Windows.Win32.Foundation.ERROR_CAPAUTHZ_SCCD_INVALID_CATALOG -Windows.Win32.Foundation.ERROR_CAPAUTHZ_SCCD_NO_AUTH_ENTITY -Windows.Win32.Foundation.ERROR_CAPAUTHZ_SCCD_NO_CAPABILITY_MATCH -Windows.Win32.Foundation.ERROR_CAPAUTHZ_SCCD_PARSE_ERROR -Windows.Win32.Foundation.ERROR_CARDBUS_NOT_SUPPORTED -Windows.Win32.Foundation.ERROR_CASE_DIFFERING_NAMES_IN_DIR -Windows.Win32.Foundation.ERROR_CASE_SENSITIVE_PATH -Windows.Win32.Foundation.ERROR_CERTIFICATE_VALIDATION_PREFERENCE_CONFLICT -Windows.Win32.Foundation.ERROR_CHECKING_FILE_SYSTEM -Windows.Win32.Foundation.ERROR_CHECKOUT_REQUIRED -Windows.Win32.Foundation.ERROR_CHILD_MUST_BE_VOLATILE -Windows.Win32.Foundation.ERROR_CHILD_NOT_COMPLETE -Windows.Win32.Foundation.ERROR_CHILD_PROCESS_BLOCKED -Windows.Win32.Foundation.ERROR_CHILD_WINDOW_MENU -Windows.Win32.Foundation.ERROR_CIMFS_IMAGE_CORRUPT -Windows.Win32.Foundation.ERROR_CIMFS_IMAGE_VERSION_NOT_SUPPORTED -Windows.Win32.Foundation.ERROR_CIRCULAR_DEPENDENCY -Windows.Win32.Foundation.ERROR_CLASS_ALREADY_EXISTS -Windows.Win32.Foundation.ERROR_CLASS_DOES_NOT_EXIST -Windows.Win32.Foundation.ERROR_CLASS_HAS_WINDOWS -Windows.Win32.Foundation.ERROR_CLIENT_SERVER_PARAMETERS_INVALID -Windows.Win32.Foundation.ERROR_CLIPBOARD_NOT_OPEN -Windows.Win32.Foundation.ERROR_CLOUD_FILE_ACCESS_DENIED -Windows.Win32.Foundation.ERROR_CLOUD_FILE_ALREADY_CONNECTED -Windows.Win32.Foundation.ERROR_CLOUD_FILE_AUTHENTICATION_FAILED -Windows.Win32.Foundation.ERROR_CLOUD_FILE_CONNECTED_PROVIDER_ONLY -Windows.Win32.Foundation.ERROR_CLOUD_FILE_DEHYDRATION_DISALLOWED -Windows.Win32.Foundation.ERROR_CLOUD_FILE_IN_USE -Windows.Win32.Foundation.ERROR_CLOUD_FILE_INCOMPATIBLE_HARDLINKS -Windows.Win32.Foundation.ERROR_CLOUD_FILE_INSUFFICIENT_RESOURCES -Windows.Win32.Foundation.ERROR_CLOUD_FILE_INVALID_REQUEST -Windows.Win32.Foundation.ERROR_CLOUD_FILE_METADATA_CORRUPT -Windows.Win32.Foundation.ERROR_CLOUD_FILE_METADATA_TOO_LARGE -Windows.Win32.Foundation.ERROR_CLOUD_FILE_NETWORK_UNAVAILABLE -Windows.Win32.Foundation.ERROR_CLOUD_FILE_NOT_IN_SYNC -Windows.Win32.Foundation.ERROR_CLOUD_FILE_NOT_SUPPORTED -Windows.Win32.Foundation.ERROR_CLOUD_FILE_NOT_UNDER_SYNC_ROOT -Windows.Win32.Foundation.ERROR_CLOUD_FILE_PINNED -Windows.Win32.Foundation.ERROR_CLOUD_FILE_PROPERTY_BLOB_CHECKSUM_MISMATCH -Windows.Win32.Foundation.ERROR_CLOUD_FILE_PROPERTY_BLOB_TOO_LARGE -Windows.Win32.Foundation.ERROR_CLOUD_FILE_PROPERTY_CORRUPT -Windows.Win32.Foundation.ERROR_CLOUD_FILE_PROPERTY_LOCK_CONFLICT -Windows.Win32.Foundation.ERROR_CLOUD_FILE_PROPERTY_VERSION_NOT_SUPPORTED -Windows.Win32.Foundation.ERROR_CLOUD_FILE_PROVIDER_NOT_RUNNING -Windows.Win32.Foundation.ERROR_CLOUD_FILE_PROVIDER_TERMINATED -Windows.Win32.Foundation.ERROR_CLOUD_FILE_READ_ONLY_VOLUME -Windows.Win32.Foundation.ERROR_CLOUD_FILE_REQUEST_ABORTED -Windows.Win32.Foundation.ERROR_CLOUD_FILE_REQUEST_CANCELED -Windows.Win32.Foundation.ERROR_CLOUD_FILE_REQUEST_TIMEOUT -Windows.Win32.Foundation.ERROR_CLOUD_FILE_SYNC_ROOT_METADATA_CORRUPT -Windows.Win32.Foundation.ERROR_CLOUD_FILE_TOO_MANY_PROPERTY_BLOBS -Windows.Win32.Foundation.ERROR_CLOUD_FILE_UNSUCCESSFUL -Windows.Win32.Foundation.ERROR_CLOUD_FILE_US_MESSAGE_TIMEOUT -Windows.Win32.Foundation.ERROR_CLOUD_FILE_VALIDATION_FAILED -Windows.Win32.Foundation.ERROR_COMMITMENT_LIMIT -Windows.Win32.Foundation.ERROR_COMMITMENT_MINIMUM -Windows.Win32.Foundation.ERROR_COMPRESSED_FILE_NOT_SUPPORTED -Windows.Win32.Foundation.ERROR_COMPRESSION_DISABLED -Windows.Win32.Foundation.ERROR_COMPRESSION_NOT_BENEFICIAL -Windows.Win32.Foundation.ERROR_CONNECTED_OTHER_PASSWORD -Windows.Win32.Foundation.ERROR_CONNECTED_OTHER_PASSWORD_DEFAULT -Windows.Win32.Foundation.ERROR_CONNECTION_ABORTED -Windows.Win32.Foundation.ERROR_CONNECTION_ACTIVE -Windows.Win32.Foundation.ERROR_CONNECTION_COUNT_LIMIT -Windows.Win32.Foundation.ERROR_CONNECTION_INVALID -Windows.Win32.Foundation.ERROR_CONNECTION_REFUSED -Windows.Win32.Foundation.ERROR_CONNECTION_UNAVAIL -Windows.Win32.Foundation.ERROR_CONTAINER_ASSIGNED -Windows.Win32.Foundation.ERROR_CONTENT_BLOCKED -Windows.Win32.Foundation.ERROR_CONTEXT_EXPIRED -Windows.Win32.Foundation.ERROR_CONTINUE -Windows.Win32.Foundation.ERROR_CONTROL_C_EXIT -Windows.Win32.Foundation.ERROR_CONTROL_ID_NOT_FOUND -Windows.Win32.Foundation.ERROR_CONVERT_TO_LARGE -Windows.Win32.Foundation.ERROR_CORRUPT_LOG_CLEARED -Windows.Win32.Foundation.ERROR_CORRUPT_LOG_CORRUPTED -Windows.Win32.Foundation.ERROR_CORRUPT_LOG_DELETED_FULL -Windows.Win32.Foundation.ERROR_CORRUPT_LOG_OVERFULL -Windows.Win32.Foundation.ERROR_CORRUPT_LOG_UNAVAILABLE -Windows.Win32.Foundation.ERROR_CORRUPT_SYSTEM_FILE -Windows.Win32.Foundation.ERROR_COULD_NOT_INTERPRET -Windows.Win32.Foundation.ERROR_COUNTER_TIMEOUT -Windows.Win32.Foundation.ERROR_CPU_SET_INVALID -Windows.Win32.Foundation.ERROR_CRASH_DUMP -Windows.Win32.Foundation.ERROR_CRC -Windows.Win32.Foundation.ERROR_CREATE_FAILED -Windows.Win32.Foundation.ERROR_CROSS_PARTITION_VIOLATION -Windows.Win32.Foundation.ERROR_CS_ENCRYPTION_EXISTING_ENCRYPTED_FILE -Windows.Win32.Foundation.ERROR_CS_ENCRYPTION_FILE_NOT_CSE -Windows.Win32.Foundation.ERROR_CS_ENCRYPTION_INVALID_SERVER_RESPONSE -Windows.Win32.Foundation.ERROR_CS_ENCRYPTION_NEW_ENCRYPTED_FILE -Windows.Win32.Foundation.ERROR_CS_ENCRYPTION_UNSUPPORTED_SERVER -Windows.Win32.Foundation.ERROR_CSCSHARE_OFFLINE -Windows.Win32.Foundation.ERROR_CTX_CLIENT_QUERY_TIMEOUT -Windows.Win32.Foundation.ERROR_CTX_MODEM_RESPONSE_TIMEOUT -Windows.Win32.Foundation.ERROR_CURRENT_DIRECTORY -Windows.Win32.Foundation.ERROR_CURRENT_DOMAIN_NOT_ALLOWED -Windows.Win32.Foundation.ERROR_DATA_CHECKSUM_ERROR -Windows.Win32.Foundation.ERROR_DATA_NOT_ACCEPTED -Windows.Win32.Foundation.ERROR_DATABASE_DOES_NOT_EXIST -Windows.Win32.Foundation.ERROR_DATATYPE_MISMATCH -Windows.Win32.Foundation.ERROR_DAX_MAPPING_EXISTS -Windows.Win32.Foundation.ERROR_DBG_COMMAND_EXCEPTION -Windows.Win32.Foundation.ERROR_DBG_CONTINUE -Windows.Win32.Foundation.ERROR_DBG_CONTROL_BREAK -Windows.Win32.Foundation.ERROR_DBG_CONTROL_C -Windows.Win32.Foundation.ERROR_DBG_EXCEPTION_HANDLED -Windows.Win32.Foundation.ERROR_DBG_EXCEPTION_NOT_HANDLED -Windows.Win32.Foundation.ERROR_DBG_PRINTEXCEPTION_C -Windows.Win32.Foundation.ERROR_DBG_REPLY_LATER -Windows.Win32.Foundation.ERROR_DBG_RIPEXCEPTION -Windows.Win32.Foundation.ERROR_DBG_TERMINATE_PROCESS -Windows.Win32.Foundation.ERROR_DBG_TERMINATE_THREAD -Windows.Win32.Foundation.ERROR_DBG_UNABLE_TO_PROVIDE_HANDLE -Windows.Win32.Foundation.ERROR_DC_NOT_FOUND -Windows.Win32.Foundation.ERROR_DDE_FAIL -Windows.Win32.Foundation.ERROR_DEBUG_ATTACH_FAILED -Windows.Win32.Foundation.ERROR_DEBUGGER_INACTIVE -Windows.Win32.Foundation.ERROR_DECRYPTION_FAILED -Windows.Win32.Foundation.ERROR_DELAY_LOAD_FAILED -Windows.Win32.Foundation.ERROR_DELETE_PENDING -Windows.Win32.Foundation.ERROR_DEPENDENT_SERVICES_RUNNING -Windows.Win32.Foundation.ERROR_DESTINATION_ELEMENT_FULL -Windows.Win32.Foundation.ERROR_DESTROY_OBJECT_OF_OTHER_THREAD -Windows.Win32.Foundation.ERROR_DEV_NOT_EXIST -Windows.Win32.Foundation.ERROR_DEVICE_ALREADY_ATTACHED -Windows.Win32.Foundation.ERROR_DEVICE_ALREADY_REMEMBERED -Windows.Win32.Foundation.ERROR_DEVICE_DOOR_OPEN -Windows.Win32.Foundation.ERROR_DEVICE_ENUMERATION_ERROR -Windows.Win32.Foundation.ERROR_DEVICE_FEATURE_NOT_SUPPORTED -Windows.Win32.Foundation.ERROR_DEVICE_HARDWARE_ERROR -Windows.Win32.Foundation.ERROR_DEVICE_HINT_NAME_BUFFER_TOO_SMALL -Windows.Win32.Foundation.ERROR_DEVICE_IN_MAINTENANCE -Windows.Win32.Foundation.ERROR_DEVICE_IN_USE -Windows.Win32.Foundation.ERROR_DEVICE_NO_RESOURCES -Windows.Win32.Foundation.ERROR_DEVICE_NOT_CONNECTED -Windows.Win32.Foundation.ERROR_DEVICE_NOT_PARTITIONED -Windows.Win32.Foundation.ERROR_DEVICE_REINITIALIZATION_NEEDED -Windows.Win32.Foundation.ERROR_DEVICE_REMOVED -Windows.Win32.Foundation.ERROR_DEVICE_REQUIRES_CLEANING -Windows.Win32.Foundation.ERROR_DEVICE_RESET_REQUIRED -Windows.Win32.Foundation.ERROR_DEVICE_SUPPORT_IN_PROGRESS -Windows.Win32.Foundation.ERROR_DEVICE_UNREACHABLE -Windows.Win32.Foundation.ERROR_DHCP_ADDRESS_CONFLICT -Windows.Win32.Foundation.ERROR_DIFFERENT_SERVICE_ACCOUNT -Windows.Win32.Foundation.ERROR_DIR_EFS_DISALLOWED -Windows.Win32.Foundation.ERROR_DIR_NOT_EMPTY -Windows.Win32.Foundation.ERROR_DIR_NOT_ROOT -Windows.Win32.Foundation.ERROR_DIRECT_ACCESS_HANDLE -Windows.Win32.Foundation.ERROR_DIRECTORY -Windows.Win32.Foundation.ERROR_DIRECTORY_NOT_SUPPORTED -Windows.Win32.Foundation.ERROR_DISCARDED -Windows.Win32.Foundation.ERROR_DISK_CHANGE -Windows.Win32.Foundation.ERROR_DISK_CORRUPT -Windows.Win32.Foundation.ERROR_DISK_FULL -Windows.Win32.Foundation.ERROR_DISK_OPERATION_FAILED -Windows.Win32.Foundation.ERROR_DISK_QUOTA_EXCEEDED -Windows.Win32.Foundation.ERROR_DISK_RECALIBRATE_FAILED -Windows.Win32.Foundation.ERROR_DISK_REPAIR_DISABLED -Windows.Win32.Foundation.ERROR_DISK_REPAIR_REDIRECTED -Windows.Win32.Foundation.ERROR_DISK_REPAIR_UNSUCCESSFUL -Windows.Win32.Foundation.ERROR_DISK_RESET_FAILED -Windows.Win32.Foundation.ERROR_DISK_RESOURCES_EXHAUSTED -Windows.Win32.Foundation.ERROR_DISK_TOO_FRAGMENTED -Windows.Win32.Foundation.ERROR_DLL_INIT_FAILED -Windows.Win32.Foundation.ERROR_DLL_INIT_FAILED_LOGOFF -Windows.Win32.Foundation.ERROR_DLL_MIGHT_BE_INCOMPATIBLE -Windows.Win32.Foundation.ERROR_DLL_MIGHT_BE_INSECURE -Windows.Win32.Foundation.ERROR_DLL_NOT_FOUND -Windows.Win32.Foundation.ERROR_DLP_POLICY_DENIES_OPERATION -Windows.Win32.Foundation.ERROR_DLP_POLICY_SILENTLY_FAIL -Windows.Win32.Foundation.ERROR_DLP_POLICY_WARNS_AGAINST_OPERATION -Windows.Win32.Foundation.ERROR_DOMAIN_CONTROLLER_EXISTS -Windows.Win32.Foundation.ERROR_DOMAIN_CONTROLLER_NOT_FOUND -Windows.Win32.Foundation.ERROR_DOMAIN_CTRLR_CONFIG_ERROR -Windows.Win32.Foundation.ERROR_DOMAIN_EXISTS -Windows.Win32.Foundation.ERROR_DOMAIN_LIMIT_EXCEEDED -Windows.Win32.Foundation.ERROR_DOMAIN_SID_SAME_AS_LOCAL_WORKSTATION -Windows.Win32.Foundation.ERROR_DOMAIN_TRUST_INCONSISTENT -Windows.Win32.Foundation.ERROR_DOWNGRADE_DETECTED -Windows.Win32.Foundation.ERROR_DPL_NOT_SUPPORTED_FOR_USER -Windows.Win32.Foundation.ERROR_DRIVE_LOCKED -Windows.Win32.Foundation.ERROR_DRIVER_BLOCKED -Windows.Win32.Foundation.ERROR_DRIVER_CANCEL_TIMEOUT -Windows.Win32.Foundation.ERROR_DRIVER_DATABASE_ERROR -Windows.Win32.Foundation.ERROR_DRIVER_FAILED_PRIOR_UNLOAD -Windows.Win32.Foundation.ERROR_DRIVER_FAILED_SLEEP -Windows.Win32.Foundation.ERROR_DRIVER_PROCESS_TERMINATED -Windows.Win32.Foundation.ERROR_DRIVERS_LEAKING_LOCKED_PAGES -Windows.Win32.Foundation.ERROR_DS_ADD_REPLICA_INHIBITED -Windows.Win32.Foundation.ERROR_DS_ADMIN_LIMIT_EXCEEDED -Windows.Win32.Foundation.ERROR_DS_AFFECTS_MULTIPLE_DSAS -Windows.Win32.Foundation.ERROR_DS_AG_CANT_HAVE_UNIVERSAL_MEMBER -Windows.Win32.Foundation.ERROR_DS_ALIAS_DEREF_PROBLEM -Windows.Win32.Foundation.ERROR_DS_ALIAS_POINTS_TO_ALIAS -Windows.Win32.Foundation.ERROR_DS_ALIAS_PROBLEM -Windows.Win32.Foundation.ERROR_DS_ALIASED_OBJ_MISSING -Windows.Win32.Foundation.ERROR_DS_ATT_ALREADY_EXISTS -Windows.Win32.Foundation.ERROR_DS_ATT_IS_NOT_ON_OBJ -Windows.Win32.Foundation.ERROR_DS_ATT_NOT_DEF_FOR_CLASS -Windows.Win32.Foundation.ERROR_DS_ATT_NOT_DEF_IN_SCHEMA -Windows.Win32.Foundation.ERROR_DS_ATT_SCHEMA_REQ_ID -Windows.Win32.Foundation.ERROR_DS_ATT_SCHEMA_REQ_SYNTAX -Windows.Win32.Foundation.ERROR_DS_ATT_VAL_ALREADY_EXISTS -Windows.Win32.Foundation.ERROR_DS_ATTRIBUTE_OR_VALUE_EXISTS -Windows.Win32.Foundation.ERROR_DS_ATTRIBUTE_OWNED_BY_SAM -Windows.Win32.Foundation.ERROR_DS_ATTRIBUTE_TYPE_UNDEFINED -Windows.Win32.Foundation.ERROR_DS_AUDIT_FAILURE -Windows.Win32.Foundation.ERROR_DS_AUTH_METHOD_NOT_SUPPORTED -Windows.Win32.Foundation.ERROR_DS_AUTH_UNKNOWN -Windows.Win32.Foundation.ERROR_DS_AUTHORIZATION_FAILED -Windows.Win32.Foundation.ERROR_DS_AUX_CLS_TEST_FAIL -Windows.Win32.Foundation.ERROR_DS_BACKLINK_WITHOUT_LINK -Windows.Win32.Foundation.ERROR_DS_BAD_ATT_SCHEMA_SYNTAX -Windows.Win32.Foundation.ERROR_DS_BAD_HIERARCHY_FILE -Windows.Win32.Foundation.ERROR_DS_BAD_INSTANCE_TYPE -Windows.Win32.Foundation.ERROR_DS_BAD_NAME_SYNTAX -Windows.Win32.Foundation.ERROR_DS_BAD_RDN_ATT_ID_SYNTAX -Windows.Win32.Foundation.ERROR_DS_BUILD_HIERARCHY_TABLE_FAILED -Windows.Win32.Foundation.ERROR_DS_BUSY -Windows.Win32.Foundation.ERROR_DS_CANT_ACCESS_REMOTE_PART_OF_AD -Windows.Win32.Foundation.ERROR_DS_CANT_ADD_ATT_VALUES -Windows.Win32.Foundation.ERROR_DS_CANT_ADD_SYSTEM_ONLY -Windows.Win32.Foundation.ERROR_DS_CANT_ADD_TO_GC -Windows.Win32.Foundation.ERROR_DS_CANT_CACHE_ATT -Windows.Win32.Foundation.ERROR_DS_CANT_CACHE_CLASS -Windows.Win32.Foundation.ERROR_DS_CANT_CREATE_IN_NONDOMAIN_NC -Windows.Win32.Foundation.ERROR_DS_CANT_CREATE_UNDER_SCHEMA -Windows.Win32.Foundation.ERROR_DS_CANT_DEL_MASTER_CROSSREF -Windows.Win32.Foundation.ERROR_DS_CANT_DELETE -Windows.Win32.Foundation.ERROR_DS_CANT_DELETE_DSA_OBJ -Windows.Win32.Foundation.ERROR_DS_CANT_DEMOTE_WITH_WRITEABLE_NC -Windows.Win32.Foundation.ERROR_DS_CANT_DEREF_ALIAS -Windows.Win32.Foundation.ERROR_DS_CANT_DERIVE_SPN_FOR_DELETED_DOMAIN -Windows.Win32.Foundation.ERROR_DS_CANT_DERIVE_SPN_WITHOUT_SERVER_REF -Windows.Win32.Foundation.ERROR_DS_CANT_FIND_DC_FOR_SRC_DOMAIN -Windows.Win32.Foundation.ERROR_DS_CANT_FIND_DSA_OBJ -Windows.Win32.Foundation.ERROR_DS_CANT_FIND_EXPECTED_NC -Windows.Win32.Foundation.ERROR_DS_CANT_FIND_NC_IN_CACHE -Windows.Win32.Foundation.ERROR_DS_CANT_MIX_MASTER_AND_REPS -Windows.Win32.Foundation.ERROR_DS_CANT_MOD_OBJ_CLASS -Windows.Win32.Foundation.ERROR_DS_CANT_MOD_PRIMARYGROUPID -Windows.Win32.Foundation.ERROR_DS_CANT_MOD_SYSTEM_ONLY -Windows.Win32.Foundation.ERROR_DS_CANT_MOVE_ACCOUNT_GROUP -Windows.Win32.Foundation.ERROR_DS_CANT_MOVE_APP_BASIC_GROUP -Windows.Win32.Foundation.ERROR_DS_CANT_MOVE_APP_QUERY_GROUP -Windows.Win32.Foundation.ERROR_DS_CANT_MOVE_DELETED_OBJECT -Windows.Win32.Foundation.ERROR_DS_CANT_MOVE_RESOURCE_GROUP -Windows.Win32.Foundation.ERROR_DS_CANT_ON_NON_LEAF -Windows.Win32.Foundation.ERROR_DS_CANT_ON_RDN -Windows.Win32.Foundation.ERROR_DS_CANT_REM_MISSING_ATT -Windows.Win32.Foundation.ERROR_DS_CANT_REM_MISSING_ATT_VAL -Windows.Win32.Foundation.ERROR_DS_CANT_REMOVE_ATT_CACHE -Windows.Win32.Foundation.ERROR_DS_CANT_REMOVE_CLASS_CACHE -Windows.Win32.Foundation.ERROR_DS_CANT_REPLACE_HIDDEN_REC -Windows.Win32.Foundation.ERROR_DS_CANT_RETRIEVE_ATTS -Windows.Win32.Foundation.ERROR_DS_CANT_RETRIEVE_CHILD -Windows.Win32.Foundation.ERROR_DS_CANT_RETRIEVE_DN -Windows.Win32.Foundation.ERROR_DS_CANT_RETRIEVE_INSTANCE -Windows.Win32.Foundation.ERROR_DS_CANT_RETRIEVE_SD -Windows.Win32.Foundation.ERROR_DS_CANT_START -Windows.Win32.Foundation.ERROR_DS_CANT_TREE_DELETE_CRITICAL_OBJ -Windows.Win32.Foundation.ERROR_DS_CANT_WITH_ACCT_GROUP_MEMBERSHPS -Windows.Win32.Foundation.ERROR_DS_CHILDREN_EXIST -Windows.Win32.Foundation.ERROR_DS_CLASS_MUST_BE_CONCRETE -Windows.Win32.Foundation.ERROR_DS_CLASS_NOT_DSA -Windows.Win32.Foundation.ERROR_DS_CLIENT_LOOP -Windows.Win32.Foundation.ERROR_DS_CODE_INCONSISTENCY -Windows.Win32.Foundation.ERROR_DS_COMPARE_FALSE -Windows.Win32.Foundation.ERROR_DS_COMPARE_TRUE -Windows.Win32.Foundation.ERROR_DS_CONFIDENTIALITY_REQUIRED -Windows.Win32.Foundation.ERROR_DS_CONFIG_PARAM_MISSING -Windows.Win32.Foundation.ERROR_DS_CONSTRAINT_VIOLATION -Windows.Win32.Foundation.ERROR_DS_CONSTRUCTED_ATT_MOD -Windows.Win32.Foundation.ERROR_DS_CONTROL_NOT_FOUND -Windows.Win32.Foundation.ERROR_DS_COULDNT_CONTACT_FSMO -Windows.Win32.Foundation.ERROR_DS_COULDNT_IDENTIFY_OBJECTS_FOR_TREE_DELETE -Windows.Win32.Foundation.ERROR_DS_COULDNT_LOCK_TREE_FOR_DELETE -Windows.Win32.Foundation.ERROR_DS_COULDNT_UPDATE_SPNS -Windows.Win32.Foundation.ERROR_DS_COUNTING_AB_INDICES_FAILED -Windows.Win32.Foundation.ERROR_DS_CR_IMPOSSIBLE_TO_VALIDATE -Windows.Win32.Foundation.ERROR_DS_CR_IMPOSSIBLE_TO_VALIDATE_V2 -Windows.Win32.Foundation.ERROR_DS_CROSS_DOM_MOVE_ERROR -Windows.Win32.Foundation.ERROR_DS_CROSS_DOMAIN_CLEANUP_REQD -Windows.Win32.Foundation.ERROR_DS_CROSS_NC_DN_RENAME -Windows.Win32.Foundation.ERROR_DS_CROSS_REF_BUSY -Windows.Win32.Foundation.ERROR_DS_CROSS_REF_EXISTS -Windows.Win32.Foundation.ERROR_DS_DATABASE_ERROR -Windows.Win32.Foundation.ERROR_DS_DECODING_ERROR -Windows.Win32.Foundation.ERROR_DS_DESTINATION_AUDITING_NOT_ENABLED -Windows.Win32.Foundation.ERROR_DS_DESTINATION_DOMAIN_NOT_IN_FOREST -Windows.Win32.Foundation.ERROR_DS_DIFFERENT_REPL_EPOCHS -Windows.Win32.Foundation.ERROR_DS_DISALLOWED_IN_SYSTEM_CONTAINER -Windows.Win32.Foundation.ERROR_DS_DISALLOWED_NC_REDIRECT -Windows.Win32.Foundation.ERROR_DS_DNS_LOOKUP_FAILURE -Windows.Win32.Foundation.ERROR_DS_DOMAIN_NAME_EXISTS_IN_FOREST -Windows.Win32.Foundation.ERROR_DS_DOMAIN_RENAME_IN_PROGRESS -Windows.Win32.Foundation.ERROR_DS_DOMAIN_VERSION_TOO_HIGH -Windows.Win32.Foundation.ERROR_DS_DOMAIN_VERSION_TOO_LOW -Windows.Win32.Foundation.ERROR_DS_DRA_ABANDON_SYNC -Windows.Win32.Foundation.ERROR_DS_DRA_ACCESS_DENIED -Windows.Win32.Foundation.ERROR_DS_DRA_BAD_DN -Windows.Win32.Foundation.ERROR_DS_DRA_BAD_INSTANCE_TYPE -Windows.Win32.Foundation.ERROR_DS_DRA_BAD_NC -Windows.Win32.Foundation.ERROR_DS_DRA_BUSY -Windows.Win32.Foundation.ERROR_DS_DRA_CONNECTION_FAILED -Windows.Win32.Foundation.ERROR_DS_DRA_CORRUPT_UTD_VECTOR -Windows.Win32.Foundation.ERROR_DS_DRA_DB_ERROR -Windows.Win32.Foundation.ERROR_DS_DRA_DN_EXISTS -Windows.Win32.Foundation.ERROR_DS_DRA_EARLIER_SCHEMA_CONFLICT -Windows.Win32.Foundation.ERROR_DS_DRA_EXTN_CONNECTION_FAILED -Windows.Win32.Foundation.ERROR_DS_DRA_GENERIC -Windows.Win32.Foundation.ERROR_DS_DRA_INCOMPATIBLE_PARTIAL_SET -Windows.Win32.Foundation.ERROR_DS_DRA_INCONSISTENT_DIT -Windows.Win32.Foundation.ERROR_DS_DRA_INTERNAL_ERROR -Windows.Win32.Foundation.ERROR_DS_DRA_INVALID_PARAMETER -Windows.Win32.Foundation.ERROR_DS_DRA_MAIL_PROBLEM -Windows.Win32.Foundation.ERROR_DS_DRA_MISSING_KRBTGT_SECRET -Windows.Win32.Foundation.ERROR_DS_DRA_MISSING_PARENT -Windows.Win32.Foundation.ERROR_DS_DRA_NAME_COLLISION -Windows.Win32.Foundation.ERROR_DS_DRA_NO_REPLICA -Windows.Win32.Foundation.ERROR_DS_DRA_NOT_SUPPORTED -Windows.Win32.Foundation.ERROR_DS_DRA_OBJ_IS_REP_SOURCE -Windows.Win32.Foundation.ERROR_DS_DRA_OBJ_NC_MISMATCH -Windows.Win32.Foundation.ERROR_DS_DRA_OUT_OF_MEM -Windows.Win32.Foundation.ERROR_DS_DRA_OUT_SCHEDULE_WINDOW -Windows.Win32.Foundation.ERROR_DS_DRA_PREEMPTED -Windows.Win32.Foundation.ERROR_DS_DRA_RECYCLED_TARGET -Windows.Win32.Foundation.ERROR_DS_DRA_REF_ALREADY_EXISTS -Windows.Win32.Foundation.ERROR_DS_DRA_REF_NOT_FOUND -Windows.Win32.Foundation.ERROR_DS_DRA_REPL_PENDING -Windows.Win32.Foundation.ERROR_DS_DRA_RPC_CANCELLED -Windows.Win32.Foundation.ERROR_DS_DRA_SCHEMA_CONFLICT -Windows.Win32.Foundation.ERROR_DS_DRA_SCHEMA_INFO_SHIP -Windows.Win32.Foundation.ERROR_DS_DRA_SCHEMA_MISMATCH -Windows.Win32.Foundation.ERROR_DS_DRA_SECRETS_DENIED -Windows.Win32.Foundation.ERROR_DS_DRA_SHUTDOWN -Windows.Win32.Foundation.ERROR_DS_DRA_SINK_DISABLED -Windows.Win32.Foundation.ERROR_DS_DRA_SOURCE_DISABLED -Windows.Win32.Foundation.ERROR_DS_DRA_SOURCE_IS_PARTIAL_REPLICA -Windows.Win32.Foundation.ERROR_DS_DRA_SOURCE_REINSTALLED -Windows.Win32.Foundation.ERROR_DS_DRS_EXTENSIONS_CHANGED -Windows.Win32.Foundation.ERROR_DS_DS_REQUIRED -Windows.Win32.Foundation.ERROR_DS_DSA_MUST_BE_INT_MASTER -Windows.Win32.Foundation.ERROR_DS_DST_DOMAIN_NOT_NATIVE -Windows.Win32.Foundation.ERROR_DS_DST_NC_MISMATCH -Windows.Win32.Foundation.ERROR_DS_DUP_LDAP_DISPLAY_NAME -Windows.Win32.Foundation.ERROR_DS_DUP_LINK_ID -Windows.Win32.Foundation.ERROR_DS_DUP_MAPI_ID -Windows.Win32.Foundation.ERROR_DS_DUP_MSDS_INTID -Windows.Win32.Foundation.ERROR_DS_DUP_OID -Windows.Win32.Foundation.ERROR_DS_DUP_RDN -Windows.Win32.Foundation.ERROR_DS_DUP_SCHEMA_ID_GUID -Windows.Win32.Foundation.ERROR_DS_DUPLICATE_ID_FOUND -Windows.Win32.Foundation.ERROR_DS_ENCODING_ERROR -Windows.Win32.Foundation.ERROR_DS_EPOCH_MISMATCH -Windows.Win32.Foundation.ERROR_DS_EXISTING_AD_CHILD_NC -Windows.Win32.Foundation.ERROR_DS_EXISTS_IN_AUX_CLS -Windows.Win32.Foundation.ERROR_DS_EXISTS_IN_MAY_HAVE -Windows.Win32.Foundation.ERROR_DS_EXISTS_IN_MUST_HAVE -Windows.Win32.Foundation.ERROR_DS_EXISTS_IN_POSS_SUP -Windows.Win32.Foundation.ERROR_DS_EXISTS_IN_RDNATTID -Windows.Win32.Foundation.ERROR_DS_EXISTS_IN_SUB_CLS -Windows.Win32.Foundation.ERROR_DS_FILTER_UNKNOWN -Windows.Win32.Foundation.ERROR_DS_FILTER_USES_CONTRUCTED_ATTRS -Windows.Win32.Foundation.ERROR_DS_FLAT_NAME_EXISTS_IN_FOREST -Windows.Win32.Foundation.ERROR_DS_FOREST_VERSION_TOO_HIGH -Windows.Win32.Foundation.ERROR_DS_FOREST_VERSION_TOO_LOW -Windows.Win32.Foundation.ERROR_DS_GC_NOT_AVAILABLE -Windows.Win32.Foundation.ERROR_DS_GC_REQUIRED -Windows.Win32.Foundation.ERROR_DS_GCVERIFY_ERROR -Windows.Win32.Foundation.ERROR_DS_GENERIC_ERROR -Windows.Win32.Foundation.ERROR_DS_GLOBAL_CANT_HAVE_CROSSDOMAIN_MEMBER -Windows.Win32.Foundation.ERROR_DS_GLOBAL_CANT_HAVE_LOCAL_MEMBER -Windows.Win32.Foundation.ERROR_DS_GLOBAL_CANT_HAVE_UNIVERSAL_MEMBER -Windows.Win32.Foundation.ERROR_DS_GOVERNSID_MISSING -Windows.Win32.Foundation.ERROR_DS_GROUP_CONVERSION_ERROR -Windows.Win32.Foundation.ERROR_DS_HAVE_PRIMARY_MEMBERS -Windows.Win32.Foundation.ERROR_DS_HIERARCHY_TABLE_MALLOC_FAILED -Windows.Win32.Foundation.ERROR_DS_HIERARCHY_TABLE_TOO_DEEP -Windows.Win32.Foundation.ERROR_DS_HIGH_ADLDS_FFL -Windows.Win32.Foundation.ERROR_DS_HIGH_DSA_VERSION -Windows.Win32.Foundation.ERROR_DS_ILLEGAL_BASE_SCHEMA_MOD -Windows.Win32.Foundation.ERROR_DS_ILLEGAL_MOD_OPERATION -Windows.Win32.Foundation.ERROR_DS_ILLEGAL_SUPERIOR -Windows.Win32.Foundation.ERROR_DS_ILLEGAL_XDOM_MOVE_OPERATION -Windows.Win32.Foundation.ERROR_DS_INAPPROPRIATE_AUTH -Windows.Win32.Foundation.ERROR_DS_INAPPROPRIATE_MATCHING -Windows.Win32.Foundation.ERROR_DS_INCOMPATIBLE_CONTROLS_USED -Windows.Win32.Foundation.ERROR_DS_INCOMPATIBLE_VERSION -Windows.Win32.Foundation.ERROR_DS_INCORRECT_ROLE_OWNER -Windows.Win32.Foundation.ERROR_DS_INIT_FAILURE -Windows.Win32.Foundation.ERROR_DS_INIT_FAILURE_CONSOLE -Windows.Win32.Foundation.ERROR_DS_INSTALL_NO_SCH_VERSION_IN_INIFILE -Windows.Win32.Foundation.ERROR_DS_INSTALL_NO_SRC_SCH_VERSION -Windows.Win32.Foundation.ERROR_DS_INSTALL_SCHEMA_MISMATCH -Windows.Win32.Foundation.ERROR_DS_INSUFF_ACCESS_RIGHTS -Windows.Win32.Foundation.ERROR_DS_INSUFFICIENT_ATTR_TO_CREATE_OBJECT -Windows.Win32.Foundation.ERROR_DS_INTERNAL_FAILURE -Windows.Win32.Foundation.ERROR_DS_INVALID_ATTRIBUTE_SYNTAX -Windows.Win32.Foundation.ERROR_DS_INVALID_DMD -Windows.Win32.Foundation.ERROR_DS_INVALID_DN_SYNTAX -Windows.Win32.Foundation.ERROR_DS_INVALID_GROUP_TYPE -Windows.Win32.Foundation.ERROR_DS_INVALID_LDAP_DISPLAY_NAME -Windows.Win32.Foundation.ERROR_DS_INVALID_NAME_FOR_SPN -Windows.Win32.Foundation.ERROR_DS_INVALID_ROLE_OWNER -Windows.Win32.Foundation.ERROR_DS_INVALID_SCRIPT -Windows.Win32.Foundation.ERROR_DS_INVALID_SEARCH_FLAG -Windows.Win32.Foundation.ERROR_DS_INVALID_SEARCH_FLAG_SUBTREE -Windows.Win32.Foundation.ERROR_DS_INVALID_SEARCH_FLAG_TUPLE -Windows.Win32.Foundation.ERROR_DS_IS_LEAF -Windows.Win32.Foundation.ERROR_DS_KEY_NOT_UNIQUE -Windows.Win32.Foundation.ERROR_DS_LDAP_SEND_QUEUE_FULL -Windows.Win32.Foundation.ERROR_DS_LINK_ID_NOT_AVAILABLE -Windows.Win32.Foundation.ERROR_DS_LOCAL_CANT_HAVE_CROSSDOMAIN_LOCAL_MEMBER -Windows.Win32.Foundation.ERROR_DS_LOCAL_ERROR -Windows.Win32.Foundation.ERROR_DS_LOCAL_MEMBER_OF_LOCAL_ONLY -Windows.Win32.Foundation.ERROR_DS_LOOP_DETECT -Windows.Win32.Foundation.ERROR_DS_LOW_ADLDS_FFL -Windows.Win32.Foundation.ERROR_DS_LOW_DSA_VERSION -Windows.Win32.Foundation.ERROR_DS_MACHINE_ACCOUNT_CREATED_PRENT4 -Windows.Win32.Foundation.ERROR_DS_MACHINE_ACCOUNT_QUOTA_EXCEEDED -Windows.Win32.Foundation.ERROR_DS_MAPI_ID_NOT_AVAILABLE -Windows.Win32.Foundation.ERROR_DS_MASTERDSA_REQUIRED -Windows.Win32.Foundation.ERROR_DS_MAX_OBJ_SIZE_EXCEEDED -Windows.Win32.Foundation.ERROR_DS_MEMBERSHIP_EVALUATED_LOCALLY -Windows.Win32.Foundation.ERROR_DS_MISSING_EXPECTED_ATT -Windows.Win32.Foundation.ERROR_DS_MISSING_FOREST_TRUST -Windows.Win32.Foundation.ERROR_DS_MISSING_FSMO_SETTINGS -Windows.Win32.Foundation.ERROR_DS_MISSING_INFRASTRUCTURE_CONTAINER -Windows.Win32.Foundation.ERROR_DS_MISSING_REQUIRED_ATT -Windows.Win32.Foundation.ERROR_DS_MISSING_SUPREF -Windows.Win32.Foundation.ERROR_DS_MODIFYDN_DISALLOWED_BY_FLAG -Windows.Win32.Foundation.ERROR_DS_MODIFYDN_DISALLOWED_BY_INSTANCE_TYPE -Windows.Win32.Foundation.ERROR_DS_MODIFYDN_WRONG_GRANDPARENT -Windows.Win32.Foundation.ERROR_DS_MUST_BE_RUN_ON_DST_DC -Windows.Win32.Foundation.ERROR_DS_NAME_ERROR_DOMAIN_ONLY -Windows.Win32.Foundation.ERROR_DS_NAME_ERROR_NO_MAPPING -Windows.Win32.Foundation.ERROR_DS_NAME_ERROR_NO_SYNTACTICAL_MAPPING -Windows.Win32.Foundation.ERROR_DS_NAME_ERROR_NOT_FOUND -Windows.Win32.Foundation.ERROR_DS_NAME_ERROR_NOT_UNIQUE -Windows.Win32.Foundation.ERROR_DS_NAME_ERROR_RESOLVING -Windows.Win32.Foundation.ERROR_DS_NAME_ERROR_TRUST_REFERRAL -Windows.Win32.Foundation.ERROR_DS_NAME_NOT_UNIQUE -Windows.Win32.Foundation.ERROR_DS_NAME_REFERENCE_INVALID -Windows.Win32.Foundation.ERROR_DS_NAME_TOO_LONG -Windows.Win32.Foundation.ERROR_DS_NAME_TOO_MANY_PARTS -Windows.Win32.Foundation.ERROR_DS_NAME_TYPE_UNKNOWN -Windows.Win32.Foundation.ERROR_DS_NAME_UNPARSEABLE -Windows.Win32.Foundation.ERROR_DS_NAME_VALUE_TOO_LONG -Windows.Win32.Foundation.ERROR_DS_NAMING_MASTER_GC -Windows.Win32.Foundation.ERROR_DS_NAMING_VIOLATION -Windows.Win32.Foundation.ERROR_DS_NC_MUST_HAVE_NC_PARENT -Windows.Win32.Foundation.ERROR_DS_NC_STILL_HAS_DSAS -Windows.Win32.Foundation.ERROR_DS_NCNAME_MISSING_CR_REF -Windows.Win32.Foundation.ERROR_DS_NCNAME_MUST_BE_NC -Windows.Win32.Foundation.ERROR_DS_NO_ATTRIBUTE_OR_VALUE -Windows.Win32.Foundation.ERROR_DS_NO_BEHAVIOR_VERSION_IN_MIXEDDOMAIN -Windows.Win32.Foundation.ERROR_DS_NO_CHAINED_EVAL -Windows.Win32.Foundation.ERROR_DS_NO_CHAINING -Windows.Win32.Foundation.ERROR_DS_NO_CHECKPOINT_WITH_PDC -Windows.Win32.Foundation.ERROR_DS_NO_CROSSREF_FOR_NC -Windows.Win32.Foundation.ERROR_DS_NO_DELETED_NAME -Windows.Win32.Foundation.ERROR_DS_NO_FPO_IN_UNIVERSAL_GROUPS -Windows.Win32.Foundation.ERROR_DS_NO_MORE_RIDS -Windows.Win32.Foundation.ERROR_DS_NO_MSDS_INTID -Windows.Win32.Foundation.ERROR_DS_NO_NEST_GLOBALGROUP_IN_MIXEDDOMAIN -Windows.Win32.Foundation.ERROR_DS_NO_NEST_LOCALGROUP_IN_MIXEDDOMAIN -Windows.Win32.Foundation.ERROR_DS_NO_NTDSA_OBJECT -Windows.Win32.Foundation.ERROR_DS_NO_OBJECT_MOVE_IN_SCHEMA_NC -Windows.Win32.Foundation.ERROR_DS_NO_PARENT_OBJECT -Windows.Win32.Foundation.ERROR_DS_NO_PKT_PRIVACY_ON_CONNECTION -Windows.Win32.Foundation.ERROR_DS_NO_RDN_DEFINED_IN_SCHEMA -Windows.Win32.Foundation.ERROR_DS_NO_REF_DOMAIN -Windows.Win32.Foundation.ERROR_DS_NO_REQUESTED_ATTS_FOUND -Windows.Win32.Foundation.ERROR_DS_NO_RESULTS_RETURNED -Windows.Win32.Foundation.ERROR_DS_NO_RIDS_ALLOCATED -Windows.Win32.Foundation.ERROR_DS_NO_SERVER_OBJECT -Windows.Win32.Foundation.ERROR_DS_NO_SUCH_OBJECT -Windows.Win32.Foundation.ERROR_DS_NO_TREE_DELETE_ABOVE_NC -Windows.Win32.Foundation.ERROR_DS_NON_ASQ_SEARCH -Windows.Win32.Foundation.ERROR_DS_NON_BASE_SEARCH -Windows.Win32.Foundation.ERROR_DS_NONEXISTENT_MAY_HAVE -Windows.Win32.Foundation.ERROR_DS_NONEXISTENT_MUST_HAVE -Windows.Win32.Foundation.ERROR_DS_NONEXISTENT_POSS_SUP -Windows.Win32.Foundation.ERROR_DS_NONSAFE_SCHEMA_CHANGE -Windows.Win32.Foundation.ERROR_DS_NOT_AN_OBJECT -Windows.Win32.Foundation.ERROR_DS_NOT_AUTHORITIVE_FOR_DST_NC -Windows.Win32.Foundation.ERROR_DS_NOT_CLOSEST -Windows.Win32.Foundation.ERROR_DS_NOT_INSTALLED -Windows.Win32.Foundation.ERROR_DS_NOT_ON_BACKLINK -Windows.Win32.Foundation.ERROR_DS_NOT_SUPPORTED -Windows.Win32.Foundation.ERROR_DS_NOT_SUPPORTED_SORT_ORDER -Windows.Win32.Foundation.ERROR_DS_NOTIFY_FILTER_TOO_COMPLEX -Windows.Win32.Foundation.ERROR_DS_NTDSCRIPT_PROCESS_ERROR -Windows.Win32.Foundation.ERROR_DS_NTDSCRIPT_SYNTAX_ERROR -Windows.Win32.Foundation.ERROR_DS_OBJ_CLASS_NOT_DEFINED -Windows.Win32.Foundation.ERROR_DS_OBJ_CLASS_NOT_SUBCLASS -Windows.Win32.Foundation.ERROR_DS_OBJ_CLASS_VIOLATION -Windows.Win32.Foundation.ERROR_DS_OBJ_GUID_EXISTS -Windows.Win32.Foundation.ERROR_DS_OBJ_NOT_FOUND -Windows.Win32.Foundation.ERROR_DS_OBJ_STRING_NAME_EXISTS -Windows.Win32.Foundation.ERROR_DS_OBJ_TOO_LARGE -Windows.Win32.Foundation.ERROR_DS_OBJECT_BEING_REMOVED -Windows.Win32.Foundation.ERROR_DS_OBJECT_CLASS_REQUIRED -Windows.Win32.Foundation.ERROR_DS_OBJECT_RESULTS_TOO_LARGE -Windows.Win32.Foundation.ERROR_DS_OFFSET_RANGE_ERROR -Windows.Win32.Foundation.ERROR_DS_OID_MAPPED_GROUP_CANT_HAVE_MEMBERS -Windows.Win32.Foundation.ERROR_DS_OID_NOT_FOUND -Windows.Win32.Foundation.ERROR_DS_OPERATIONS_ERROR -Windows.Win32.Foundation.ERROR_DS_OUT_OF_SCOPE -Windows.Win32.Foundation.ERROR_DS_OUT_OF_VERSION_STORE -Windows.Win32.Foundation.ERROR_DS_PARAM_ERROR -Windows.Win32.Foundation.ERROR_DS_PARENT_IS_AN_ALIAS -Windows.Win32.Foundation.ERROR_DS_PDC_OPERATION_IN_PROGRESS -Windows.Win32.Foundation.ERROR_DS_PER_ATTRIBUTE_AUTHZ_FAILED_DURING_ADD -Windows.Win32.Foundation.ERROR_DS_POLICY_NOT_KNOWN -Windows.Win32.Foundation.ERROR_DS_PROTOCOL_ERROR -Windows.Win32.Foundation.ERROR_DS_RANGE_CONSTRAINT -Windows.Win32.Foundation.ERROR_DS_RDN_DOESNT_MATCH_SCHEMA -Windows.Win32.Foundation.ERROR_DS_RECALCSCHEMA_FAILED -Windows.Win32.Foundation.ERROR_DS_REFERRAL -Windows.Win32.Foundation.ERROR_DS_REFERRAL_LIMIT_EXCEEDED -Windows.Win32.Foundation.ERROR_DS_REFUSING_FSMO_ROLES -Windows.Win32.Foundation.ERROR_DS_REMOTE_CROSSREF_OP_FAILED -Windows.Win32.Foundation.ERROR_DS_REPL_LIFETIME_EXCEEDED -Windows.Win32.Foundation.ERROR_DS_REPLICA_SET_CHANGE_NOT_ALLOWED_ON_DISABLED_CR -Windows.Win32.Foundation.ERROR_DS_REPLICATOR_ONLY -Windows.Win32.Foundation.ERROR_DS_RESERVED_LINK_ID -Windows.Win32.Foundation.ERROR_DS_RESERVED_MAPI_ID -Windows.Win32.Foundation.ERROR_DS_RIDMGR_DISABLED -Windows.Win32.Foundation.ERROR_DS_RIDMGR_INIT_ERROR -Windows.Win32.Foundation.ERROR_DS_ROLE_NOT_VERIFIED -Windows.Win32.Foundation.ERROR_DS_ROOT_CANT_BE_SUBREF -Windows.Win32.Foundation.ERROR_DS_ROOT_MUST_BE_NC -Windows.Win32.Foundation.ERROR_DS_ROOT_REQUIRES_CLASS_TOP -Windows.Win32.Foundation.ERROR_DS_SAM_INIT_FAILURE -Windows.Win32.Foundation.ERROR_DS_SAM_INIT_FAILURE_CONSOLE -Windows.Win32.Foundation.ERROR_DS_SAM_NEED_BOOTKEY_FLOPPY -Windows.Win32.Foundation.ERROR_DS_SAM_NEED_BOOTKEY_PASSWORD -Windows.Win32.Foundation.ERROR_DS_SCHEMA_ALLOC_FAILED -Windows.Win32.Foundation.ERROR_DS_SCHEMA_NOT_LOADED -Windows.Win32.Foundation.ERROR_DS_SCHEMA_UPDATE_DISALLOWED -Windows.Win32.Foundation.ERROR_DS_SEC_DESC_INVALID -Windows.Win32.Foundation.ERROR_DS_SEC_DESC_TOO_SHORT -Windows.Win32.Foundation.ERROR_DS_SECURITY_CHECKING_ERROR -Windows.Win32.Foundation.ERROR_DS_SECURITY_ILLEGAL_MODIFY -Windows.Win32.Foundation.ERROR_DS_SEMANTIC_ATT_TEST -Windows.Win32.Foundation.ERROR_DS_SENSITIVE_GROUP_VIOLATION -Windows.Win32.Foundation.ERROR_DS_SERVER_DOWN -Windows.Win32.Foundation.ERROR_DS_SHUTTING_DOWN -Windows.Win32.Foundation.ERROR_DS_SINGLE_USER_MODE_FAILED -Windows.Win32.Foundation.ERROR_DS_SINGLE_VALUE_CONSTRAINT -Windows.Win32.Foundation.ERROR_DS_SIZELIMIT_EXCEEDED -Windows.Win32.Foundation.ERROR_DS_SORT_CONTROL_MISSING -Windows.Win32.Foundation.ERROR_DS_SOURCE_AUDITING_NOT_ENABLED -Windows.Win32.Foundation.ERROR_DS_SOURCE_DOMAIN_IN_FOREST -Windows.Win32.Foundation.ERROR_DS_SPN_VALUE_NOT_UNIQUE_IN_FOREST -Windows.Win32.Foundation.ERROR_DS_SRC_AND_DST_NC_IDENTICAL -Windows.Win32.Foundation.ERROR_DS_SRC_AND_DST_OBJECT_CLASS_MISMATCH -Windows.Win32.Foundation.ERROR_DS_SRC_DC_MUST_BE_SP4_OR_GREATER -Windows.Win32.Foundation.ERROR_DS_SRC_GUID_MISMATCH -Windows.Win32.Foundation.ERROR_DS_SRC_NAME_MISMATCH -Windows.Win32.Foundation.ERROR_DS_SRC_OBJ_NOT_GROUP_OR_USER -Windows.Win32.Foundation.ERROR_DS_SRC_SID_EXISTS_IN_FOREST -Windows.Win32.Foundation.ERROR_DS_STRING_SD_CONVERSION_FAILED -Windows.Win32.Foundation.ERROR_DS_STRONG_AUTH_REQUIRED -Windows.Win32.Foundation.ERROR_DS_SUB_CLS_TEST_FAIL -Windows.Win32.Foundation.ERROR_DS_SUBREF_MUST_HAVE_PARENT -Windows.Win32.Foundation.ERROR_DS_SUBTREE_NOTIFY_NOT_NC_HEAD -Windows.Win32.Foundation.ERROR_DS_SYNTAX_MISMATCH -Windows.Win32.Foundation.ERROR_DS_THREAD_LIMIT_EXCEEDED -Windows.Win32.Foundation.ERROR_DS_TIMELIMIT_EXCEEDED -Windows.Win32.Foundation.ERROR_DS_TREE_DELETE_NOT_FINISHED -Windows.Win32.Foundation.ERROR_DS_UNABLE_TO_SURRENDER_ROLES -Windows.Win32.Foundation.ERROR_DS_UNAVAILABLE -Windows.Win32.Foundation.ERROR_DS_UNAVAILABLE_CRIT_EXTENSION -Windows.Win32.Foundation.ERROR_DS_UNDELETE_SAM_VALIDATION_FAILED -Windows.Win32.Foundation.ERROR_DS_UNICODEPWD_NOT_IN_QUOTES -Windows.Win32.Foundation.ERROR_DS_UNIVERSAL_CANT_HAVE_LOCAL_MEMBER -Windows.Win32.Foundation.ERROR_DS_UNKNOWN_ERROR -Windows.Win32.Foundation.ERROR_DS_UNKNOWN_OPERATION -Windows.Win32.Foundation.ERROR_DS_UNWILLING_TO_PERFORM -Windows.Win32.Foundation.ERROR_DS_UPN_VALUE_NOT_UNIQUE_IN_FOREST -Windows.Win32.Foundation.ERROR_DS_USER_BUFFER_TO_SMALL -Windows.Win32.Foundation.ERROR_DS_VALUE_KEY_NOT_UNIQUE -Windows.Win32.Foundation.ERROR_DS_VERSION_CHECK_FAILURE -Windows.Win32.Foundation.ERROR_DS_WKO_CONTAINER_CANNOT_BE_SPECIAL -Windows.Win32.Foundation.ERROR_DS_WRONG_LINKED_ATT_SYNTAX -Windows.Win32.Foundation.ERROR_DS_WRONG_OM_OBJ_CLASS -Windows.Win32.Foundation.ERROR_DUP_DOMAINNAME -Windows.Win32.Foundation.ERROR_DUP_NAME -Windows.Win32.Foundation.ERROR_DUPLICATE_PRIVILEGES -Windows.Win32.Foundation.ERROR_DUPLICATE_SERVICE_NAME -Windows.Win32.Foundation.ERROR_DYNAMIC_CODE_BLOCKED -Windows.Win32.Foundation.ERROR_DYNLINK_FROM_INVALID_RING -Windows.Win32.Foundation.ERROR_EA_ACCESS_DENIED -Windows.Win32.Foundation.ERROR_EA_FILE_CORRUPT -Windows.Win32.Foundation.ERROR_EA_LIST_INCONSISTENT -Windows.Win32.Foundation.ERROR_EA_TABLE_FULL -Windows.Win32.Foundation.ERROR_EAS_DIDNT_FIT -Windows.Win32.Foundation.ERROR_EAS_NOT_SUPPORTED -Windows.Win32.Foundation.ERROR_EDP_DPL_POLICY_CANT_BE_SATISFIED -Windows.Win32.Foundation.ERROR_EDP_POLICY_DENIES_OPERATION -Windows.Win32.Foundation.ERROR_EFS_ALG_BLOB_TOO_BIG -Windows.Win32.Foundation.ERROR_EFS_DISABLED -Windows.Win32.Foundation.ERROR_EFS_SERVER_NOT_TRUSTED -Windows.Win32.Foundation.ERROR_EFS_VERSION_NOT_SUPPORT -Windows.Win32.Foundation.ERROR_ELEVATION_REQUIRED -Windows.Win32.Foundation.ERROR_ENCLAVE_FAILURE -Windows.Win32.Foundation.ERROR_ENCLAVE_NOT_TERMINATED -Windows.Win32.Foundation.ERROR_ENCLAVE_VIOLATION -Windows.Win32.Foundation.ERROR_ENCRYPTED_FILE_NOT_SUPPORTED -Windows.Win32.Foundation.ERROR_ENCRYPTED_IO_NOT_POSSIBLE -Windows.Win32.Foundation.ERROR_ENCRYPTING_METADATA_DISALLOWED -Windows.Win32.Foundation.ERROR_ENCRYPTION_DISABLED -Windows.Win32.Foundation.ERROR_ENCRYPTION_FAILED -Windows.Win32.Foundation.ERROR_ENCRYPTION_POLICY_DENIES_OPERATION -Windows.Win32.Foundation.ERROR_END_OF_MEDIA -Windows.Win32.Foundation.ERROR_ENVVAR_NOT_FOUND -Windows.Win32.Foundation.ERROR_EOM_OVERFLOW -Windows.Win32.Foundation.ERROR_ERRORS_ENCOUNTERED -Windows.Win32.Foundation.ERROR_EVALUATION_EXPIRATION -Windows.Win32.Foundation.ERROR_EVENT_DONE -Windows.Win32.Foundation.ERROR_EVENT_PENDING -Windows.Win32.Foundation.ERROR_EVENTLOG_CANT_START -Windows.Win32.Foundation.ERROR_EVENTLOG_FILE_CHANGED -Windows.Win32.Foundation.ERROR_EVENTLOG_FILE_CORRUPT -Windows.Win32.Foundation.ERROR_EXCEPTION_IN_SERVICE -Windows.Win32.Foundation.ERROR_EXCL_SEM_ALREADY_OWNED -Windows.Win32.Foundation.ERROR_EXE_CANNOT_MODIFY_SIGNED_BINARY -Windows.Win32.Foundation.ERROR_EXE_CANNOT_MODIFY_STRONG_SIGNED_BINARY -Windows.Win32.Foundation.ERROR_EXE_MACHINE_TYPE_MISMATCH -Windows.Win32.Foundation.ERROR_EXE_MARKED_INVALID -Windows.Win32.Foundation.ERROR_EXTENDED_ERROR -Windows.Win32.Foundation.ERROR_EXTERNAL_BACKING_PROVIDER_UNKNOWN -Windows.Win32.Foundation.ERROR_EXTERNAL_SYSKEY_NOT_SUPPORTED -Windows.Win32.Foundation.ERROR_EXTRANEOUS_INFORMATION -Windows.Win32.Foundation.ERROR_FAIL_FAST_EXCEPTION -Windows.Win32.Foundation.ERROR_FAIL_I24 -Windows.Win32.Foundation.ERROR_FAIL_NOACTION_REBOOT -Windows.Win32.Foundation.ERROR_FAIL_RESTART -Windows.Win32.Foundation.ERROR_FAIL_SHUTDOWN -Windows.Win32.Foundation.ERROR_FAILED_DRIVER_ENTRY -Windows.Win32.Foundation.ERROR_FAILED_SERVICE_CONTROLLER_CONNECT -Windows.Win32.Foundation.ERROR_FATAL_APP_EXIT -Windows.Win32.Foundation.ERROR_FILE_CHECKED_OUT -Windows.Win32.Foundation.ERROR_FILE_CORRUPT -Windows.Win32.Foundation.ERROR_FILE_ENCRYPTED -Windows.Win32.Foundation.ERROR_FILE_EXISTS -Windows.Win32.Foundation.ERROR_FILE_HANDLE_REVOKED -Windows.Win32.Foundation.ERROR_FILE_INVALID -Windows.Win32.Foundation.ERROR_FILE_LEVEL_TRIM_NOT_SUPPORTED -Windows.Win32.Foundation.ERROR_FILE_METADATA_OPTIMIZATION_IN_PROGRESS -Windows.Win32.Foundation.ERROR_FILE_NOT_ENCRYPTED -Windows.Win32.Foundation.ERROR_FILE_NOT_FOUND -Windows.Win32.Foundation.ERROR_FILE_NOT_SUPPORTED -Windows.Win32.Foundation.ERROR_FILE_OFFLINE -Windows.Win32.Foundation.ERROR_FILE_PROTECTED_UNDER_DPL -Windows.Win32.Foundation.ERROR_FILE_READ_ONLY -Windows.Win32.Foundation.ERROR_FILE_SNAP_IN_PROGRESS -Windows.Win32.Foundation.ERROR_FILE_SNAP_INVALID_PARAMETER -Windows.Win32.Foundation.ERROR_FILE_SNAP_IO_NOT_COORDINATED -Windows.Win32.Foundation.ERROR_FILE_SNAP_MODIFY_NOT_SUPPORTED -Windows.Win32.Foundation.ERROR_FILE_SNAP_UNEXPECTED_ERROR -Windows.Win32.Foundation.ERROR_FILE_SNAP_USER_SECTION_NOT_SUPPORTED -Windows.Win32.Foundation.ERROR_FILE_SYSTEM_LIMITATION -Windows.Win32.Foundation.ERROR_FILE_SYSTEM_VIRTUALIZATION_BUSY -Windows.Win32.Foundation.ERROR_FILE_SYSTEM_VIRTUALIZATION_INVALID_OPERATION -Windows.Win32.Foundation.ERROR_FILE_SYSTEM_VIRTUALIZATION_METADATA_CORRUPT -Windows.Win32.Foundation.ERROR_FILE_SYSTEM_VIRTUALIZATION_PROVIDER_UNKNOWN -Windows.Win32.Foundation.ERROR_FILE_SYSTEM_VIRTUALIZATION_UNAVAILABLE -Windows.Win32.Foundation.ERROR_FILE_TOO_LARGE -Windows.Win32.Foundation.ERROR_FILEMARK_DETECTED -Windows.Win32.Foundation.ERROR_FILENAME_EXCED_RANGE -Windows.Win32.Foundation.ERROR_FIRMWARE_UPDATED -Windows.Win32.Foundation.ERROR_FLOAT_MULTIPLE_FAULTS -Windows.Win32.Foundation.ERROR_FLOAT_MULTIPLE_TRAPS -Windows.Win32.Foundation.ERROR_FLOPPY_BAD_REGISTERS -Windows.Win32.Foundation.ERROR_FLOPPY_ID_MARK_NOT_FOUND -Windows.Win32.Foundation.ERROR_FLOPPY_UNKNOWN_ERROR -Windows.Win32.Foundation.ERROR_FLOPPY_VOLUME -Windows.Win32.Foundation.ERROR_FLOPPY_WRONG_CYLINDER -Windows.Win32.Foundation.ERROR_FORMS_AUTH_REQUIRED -Windows.Win32.Foundation.ERROR_FOUND_OUT_OF_SCOPE -Windows.Win32.Foundation.ERROR_FS_DRIVER_REQUIRED -Windows.Win32.Foundation.ERROR_FS_METADATA_INCONSISTENT -Windows.Win32.Foundation.ERROR_FSFILTER_OP_COMPLETED_SUCCESSFULLY -Windows.Win32.Foundation.ERROR_FT_DI_SCAN_REQUIRED -Windows.Win32.Foundation.ERROR_FT_READ_FAILURE -Windows.Win32.Foundation.ERROR_FT_READ_FROM_COPY_FAILURE -Windows.Win32.Foundation.ERROR_FT_READ_RECOVERY_FROM_BACKUP -Windows.Win32.Foundation.ERROR_FT_WRITE_FAILURE -Windows.Win32.Foundation.ERROR_FT_WRITE_RECOVERY -Windows.Win32.Foundation.ERROR_FULLSCREEN_MODE -Windows.Win32.Foundation.ERROR_FUNCTION_FAILED -Windows.Win32.Foundation.ERROR_FUNCTION_NOT_CALLED -Windows.Win32.Foundation.ERROR_GDI_HANDLE_LEAK -Windows.Win32.Foundation.ERROR_GEN_FAILURE -Windows.Win32.Foundation.ERROR_GENERIC_NOT_MAPPED -Windows.Win32.Foundation.ERROR_GLOBAL_ONLY_HOOK -Windows.Win32.Foundation.ERROR_GRACEFUL_DISCONNECT -Windows.Win32.Foundation.ERROR_GROUP_EXISTS -Windows.Win32.Foundation.ERROR_GUID_SUBSTITUTION_MADE -Windows.Win32.Foundation.ERROR_HANDLE_DISK_FULL -Windows.Win32.Foundation.ERROR_HANDLE_EOF -Windows.Win32.Foundation.ERROR_HANDLE_REVOKED -Windows.Win32.Foundation.ERROR_HANDLES_CLOSED -Windows.Win32.Foundation.ERROR_HAS_SYSTEM_CRITICAL_FILES -Windows.Win32.Foundation.ERROR_HIBERNATED -Windows.Win32.Foundation.ERROR_HIBERNATION_FAILURE -Windows.Win32.Foundation.ERROR_HOOK_NEEDS_HMOD -Windows.Win32.Foundation.ERROR_HOOK_NOT_INSTALLED -Windows.Win32.Foundation.ERROR_HOOK_TYPE_NOT_ALLOWED -Windows.Win32.Foundation.ERROR_HOST_DOWN -Windows.Win32.Foundation.ERROR_HOST_UNREACHABLE -Windows.Win32.Foundation.ERROR_HOTKEY_ALREADY_REGISTERED -Windows.Win32.Foundation.ERROR_HOTKEY_NOT_REGISTERED -Windows.Win32.Foundation.ERROR_HWNDS_HAVE_DIFF_PARENT -Windows.Win32.Foundation.ERROR_ILL_FORMED_PASSWORD -Windows.Win32.Foundation.ERROR_ILLEGAL_CHARACTER -Windows.Win32.Foundation.ERROR_ILLEGAL_DLL_RELOCATION -Windows.Win32.Foundation.ERROR_ILLEGAL_ELEMENT_ADDRESS -Windows.Win32.Foundation.ERROR_ILLEGAL_FLOAT_CONTEXT -Windows.Win32.Foundation.ERROR_IMAGE_AT_DIFFERENT_BASE -Windows.Win32.Foundation.ERROR_IMAGE_MACHINE_TYPE_MISMATCH -Windows.Win32.Foundation.ERROR_IMAGE_MACHINE_TYPE_MISMATCH_EXE -Windows.Win32.Foundation.ERROR_IMAGE_NOT_AT_BASE -Windows.Win32.Foundation.ERROR_IMAGE_SUBSYSTEM_NOT_PRESENT -Windows.Win32.Foundation.ERROR_IMPLEMENTATION_LIMIT -Windows.Win32.Foundation.ERROR_INCOMPATIBLE_SERVICE_PRIVILEGE -Windows.Win32.Foundation.ERROR_INCOMPATIBLE_SERVICE_SID_TYPE -Windows.Win32.Foundation.ERROR_INCOMPATIBLE_WITH_GLOBAL_SHORT_NAME_REGISTRY_SETTING -Windows.Win32.Foundation.ERROR_INCORRECT_ACCOUNT_TYPE -Windows.Win32.Foundation.ERROR_INCORRECT_ADDRESS -Windows.Win32.Foundation.ERROR_INCORRECT_SIZE -Windows.Win32.Foundation.ERROR_INDEX_ABSENT -Windows.Win32.Foundation.ERROR_INDEX_OUT_OF_BOUNDS -Windows.Win32.Foundation.ERROR_INFLOOP_IN_RELOC_CHAIN -Windows.Win32.Foundation.ERROR_INSTALL_ALREADY_RUNNING -Windows.Win32.Foundation.ERROR_INSTALL_FAILURE -Windows.Win32.Foundation.ERROR_INSTALL_LANGUAGE_UNSUPPORTED -Windows.Win32.Foundation.ERROR_INSTALL_LOG_FAILURE -Windows.Win32.Foundation.ERROR_INSTALL_NOTUSED -Windows.Win32.Foundation.ERROR_INSTALL_PACKAGE_INVALID -Windows.Win32.Foundation.ERROR_INSTALL_PACKAGE_OPEN_FAILED -Windows.Win32.Foundation.ERROR_INSTALL_PACKAGE_REJECTED -Windows.Win32.Foundation.ERROR_INSTALL_PACKAGE_VERSION -Windows.Win32.Foundation.ERROR_INSTALL_PLATFORM_UNSUPPORTED -Windows.Win32.Foundation.ERROR_INSTALL_REJECTED -Windows.Win32.Foundation.ERROR_INSTALL_REMOTE_DISALLOWED -Windows.Win32.Foundation.ERROR_INSTALL_REMOTE_PROHIBITED -Windows.Win32.Foundation.ERROR_INSTALL_SERVICE_FAILURE -Windows.Win32.Foundation.ERROR_INSTALL_SERVICE_SAFEBOOT -Windows.Win32.Foundation.ERROR_INSTALL_SOURCE_ABSENT -Windows.Win32.Foundation.ERROR_INSTALL_SUSPEND -Windows.Win32.Foundation.ERROR_INSTALL_TEMP_UNWRITABLE -Windows.Win32.Foundation.ERROR_INSTALL_TRANSFORM_FAILURE -Windows.Win32.Foundation.ERROR_INSTALL_TRANSFORM_REJECTED -Windows.Win32.Foundation.ERROR_INSTALL_UI_FAILURE -Windows.Win32.Foundation.ERROR_INSTALL_USEREXIT -Windows.Win32.Foundation.ERROR_INSTRUCTION_MISALIGNMENT -Windows.Win32.Foundation.ERROR_INSUFFICIENT_BUFFER -Windows.Win32.Foundation.ERROR_INSUFFICIENT_LOGON_INFO -Windows.Win32.Foundation.ERROR_INSUFFICIENT_POWER -Windows.Win32.Foundation.ERROR_INSUFFICIENT_RESOURCE_FOR_SPECIFIED_SHARED_SECTION_SIZE -Windows.Win32.Foundation.ERROR_INSUFFICIENT_VIRTUAL_ADDR_RESOURCES -Windows.Win32.Foundation.ERROR_INTERMIXED_KERNEL_EA_OPERATION -Windows.Win32.Foundation.ERROR_INTERNAL_DB_CORRUPTION -Windows.Win32.Foundation.ERROR_INTERNAL_DB_ERROR -Windows.Win32.Foundation.ERROR_INTERNAL_ERROR -Windows.Win32.Foundation.ERROR_INTERRUPT_STILL_CONNECTED -Windows.Win32.Foundation.ERROR_INTERRUPT_VECTOR_ALREADY_CONNECTED -Windows.Win32.Foundation.ERROR_INVALID_ACCEL_HANDLE -Windows.Win32.Foundation.ERROR_INVALID_ACCESS -Windows.Win32.Foundation.ERROR_INVALID_ACCOUNT_NAME -Windows.Win32.Foundation.ERROR_INVALID_ACE_CONDITION -Windows.Win32.Foundation.ERROR_INVALID_ACL -Windows.Win32.Foundation.ERROR_INVALID_ADDRESS -Windows.Win32.Foundation.ERROR_INVALID_AT_INTERRUPT_TIME -Windows.Win32.Foundation.ERROR_INVALID_BLOCK -Windows.Win32.Foundation.ERROR_INVALID_BLOCK_LENGTH -Windows.Win32.Foundation.ERROR_INVALID_CAP -Windows.Win32.Foundation.ERROR_INVALID_CATEGORY -Windows.Win32.Foundation.ERROR_INVALID_COMBOBOX_MESSAGE -Windows.Win32.Foundation.ERROR_INVALID_COMMAND_LINE -Windows.Win32.Foundation.ERROR_INVALID_COMPUTERNAME -Windows.Win32.Foundation.ERROR_INVALID_CRUNTIME_PARAMETER -Windows.Win32.Foundation.ERROR_INVALID_CURSOR_HANDLE -Windows.Win32.Foundation.ERROR_INVALID_DATA -Windows.Win32.Foundation.ERROR_INVALID_DATATYPE -Windows.Win32.Foundation.ERROR_INVALID_DEVICE_OBJECT_PARAMETER -Windows.Win32.Foundation.ERROR_INVALID_DLL -Windows.Win32.Foundation.ERROR_INVALID_DOMAIN_ROLE -Windows.Win32.Foundation.ERROR_INVALID_DOMAIN_STATE -Windows.Win32.Foundation.ERROR_INVALID_DOMAINNAME -Windows.Win32.Foundation.ERROR_INVALID_DRIVE -Windows.Win32.Foundation.ERROR_INVALID_DWP_HANDLE -Windows.Win32.Foundation.ERROR_INVALID_EA_HANDLE -Windows.Win32.Foundation.ERROR_INVALID_EA_NAME -Windows.Win32.Foundation.ERROR_INVALID_EDIT_HEIGHT -Windows.Win32.Foundation.ERROR_INVALID_ENVIRONMENT -Windows.Win32.Foundation.ERROR_INVALID_EVENT_COUNT -Windows.Win32.Foundation.ERROR_INVALID_EVENTNAME -Windows.Win32.Foundation.ERROR_INVALID_EXCEPTION_HANDLER -Windows.Win32.Foundation.ERROR_INVALID_EXE_SIGNATURE -Windows.Win32.Foundation.ERROR_INVALID_FIELD -Windows.Win32.Foundation.ERROR_INVALID_FIELD_IN_PARAMETER_LIST -Windows.Win32.Foundation.ERROR_INVALID_FILTER_PROC -Windows.Win32.Foundation.ERROR_INVALID_FLAG_NUMBER -Windows.Win32.Foundation.ERROR_INVALID_FLAGS -Windows.Win32.Foundation.ERROR_INVALID_FORM_NAME -Windows.Win32.Foundation.ERROR_INVALID_FORM_SIZE -Windows.Win32.Foundation.ERROR_INVALID_FUNCTION -Windows.Win32.Foundation.ERROR_INVALID_GROUP_ATTRIBUTES -Windows.Win32.Foundation.ERROR_INVALID_GROUPNAME -Windows.Win32.Foundation.ERROR_INVALID_GW_COMMAND -Windows.Win32.Foundation.ERROR_INVALID_HANDLE -Windows.Win32.Foundation.ERROR_INVALID_HANDLE_STATE -Windows.Win32.Foundation.ERROR_INVALID_HOOK_FILTER -Windows.Win32.Foundation.ERROR_INVALID_HOOK_HANDLE -Windows.Win32.Foundation.ERROR_INVALID_HW_PROFILE -Windows.Win32.Foundation.ERROR_INVALID_ICON_HANDLE -Windows.Win32.Foundation.ERROR_INVALID_ID_AUTHORITY -Windows.Win32.Foundation.ERROR_INVALID_IMAGE_HASH -Windows.Win32.Foundation.ERROR_INVALID_IMPORT_OF_NON_DLL -Windows.Win32.Foundation.ERROR_INVALID_INDEX -Windows.Win32.Foundation.ERROR_INVALID_KERNEL_INFO_VERSION -Windows.Win32.Foundation.ERROR_INVALID_KEYBOARD_HANDLE -Windows.Win32.Foundation.ERROR_INVALID_LABEL -Windows.Win32.Foundation.ERROR_INVALID_LB_MESSAGE -Windows.Win32.Foundation.ERROR_INVALID_LDT_DESCRIPTOR -Windows.Win32.Foundation.ERROR_INVALID_LDT_OFFSET -Windows.Win32.Foundation.ERROR_INVALID_LDT_SIZE -Windows.Win32.Foundation.ERROR_INVALID_LEVEL -Windows.Win32.Foundation.ERROR_INVALID_LIST_FORMAT -Windows.Win32.Foundation.ERROR_INVALID_LOCK_RANGE -Windows.Win32.Foundation.ERROR_INVALID_LOGON_HOURS -Windows.Win32.Foundation.ERROR_INVALID_LOGON_TYPE -Windows.Win32.Foundation.ERROR_INVALID_MEMBER -Windows.Win32.Foundation.ERROR_INVALID_MENU_HANDLE -Windows.Win32.Foundation.ERROR_INVALID_MESSAGE -Windows.Win32.Foundation.ERROR_INVALID_MESSAGEDEST -Windows.Win32.Foundation.ERROR_INVALID_MESSAGENAME -Windows.Win32.Foundation.ERROR_INVALID_MINALLOCSIZE -Windows.Win32.Foundation.ERROR_INVALID_MODULETYPE -Windows.Win32.Foundation.ERROR_INVALID_MONITOR_HANDLE -Windows.Win32.Foundation.ERROR_INVALID_MSGBOX_STYLE -Windows.Win32.Foundation.ERROR_INVALID_NAME -Windows.Win32.Foundation.ERROR_INVALID_NETNAME -Windows.Win32.Foundation.ERROR_INVALID_OPLOCK_PROTOCOL -Windows.Win32.Foundation.ERROR_INVALID_ORDINAL -Windows.Win32.Foundation.ERROR_INVALID_OWNER -Windows.Win32.Foundation.ERROR_INVALID_PACKAGE_SID_LENGTH -Windows.Win32.Foundation.ERROR_INVALID_PARAMETER -Windows.Win32.Foundation.ERROR_INVALID_PASSWORD -Windows.Win32.Foundation.ERROR_INVALID_PASSWORDNAME -Windows.Win32.Foundation.ERROR_INVALID_PATCH_XML -Windows.Win32.Foundation.ERROR_INVALID_PEP_INFO_VERSION -Windows.Win32.Foundation.ERROR_INVALID_PLUGPLAY_DEVICE_PATH -Windows.Win32.Foundation.ERROR_INVALID_PORT_ATTRIBUTES -Windows.Win32.Foundation.ERROR_INVALID_PRIMARY_GROUP -Windows.Win32.Foundation.ERROR_INVALID_PRINTER_COMMAND -Windows.Win32.Foundation.ERROR_INVALID_PRINTER_NAME -Windows.Win32.Foundation.ERROR_INVALID_PRINTER_STATE -Windows.Win32.Foundation.ERROR_INVALID_PRIORITY -Windows.Win32.Foundation.ERROR_INVALID_QUOTA_LOWER -Windows.Win32.Foundation.ERROR_INVALID_REPARSE_DATA -Windows.Win32.Foundation.ERROR_INVALID_SCROLLBAR_RANGE -Windows.Win32.Foundation.ERROR_INVALID_SECURITY_DESCR -Windows.Win32.Foundation.ERROR_INVALID_SEGDPL -Windows.Win32.Foundation.ERROR_INVALID_SEGMENT_NUMBER -Windows.Win32.Foundation.ERROR_INVALID_SEPARATOR_FILE -Windows.Win32.Foundation.ERROR_INVALID_SERVER_STATE -Windows.Win32.Foundation.ERROR_INVALID_SERVICE_ACCOUNT -Windows.Win32.Foundation.ERROR_INVALID_SERVICE_CONTROL -Windows.Win32.Foundation.ERROR_INVALID_SERVICE_LOCK -Windows.Win32.Foundation.ERROR_INVALID_SERVICENAME -Windows.Win32.Foundation.ERROR_INVALID_SHARENAME -Windows.Win32.Foundation.ERROR_INVALID_SHOWWIN_COMMAND -Windows.Win32.Foundation.ERROR_INVALID_SID -Windows.Win32.Foundation.ERROR_INVALID_SIGNAL_NUMBER -Windows.Win32.Foundation.ERROR_INVALID_SPI_VALUE -Windows.Win32.Foundation.ERROR_INVALID_STACKSEG -Windows.Win32.Foundation.ERROR_INVALID_STARTING_CODESEG -Windows.Win32.Foundation.ERROR_INVALID_SUB_AUTHORITY -Windows.Win32.Foundation.ERROR_INVALID_TABLE -Windows.Win32.Foundation.ERROR_INVALID_TARGET_HANDLE -Windows.Win32.Foundation.ERROR_INVALID_TASK_INDEX -Windows.Win32.Foundation.ERROR_INVALID_TASK_NAME -Windows.Win32.Foundation.ERROR_INVALID_THREAD_ID -Windows.Win32.Foundation.ERROR_INVALID_TIME -Windows.Win32.Foundation.ERROR_INVALID_TOKEN -Windows.Win32.Foundation.ERROR_INVALID_UNWIND_TARGET -Windows.Win32.Foundation.ERROR_INVALID_USER_BUFFER -Windows.Win32.Foundation.ERROR_INVALID_USER_PRINCIPAL_NAME -Windows.Win32.Foundation.ERROR_INVALID_VARIANT -Windows.Win32.Foundation.ERROR_INVALID_VERIFY_SWITCH -Windows.Win32.Foundation.ERROR_INVALID_WINDOW_HANDLE -Windows.Win32.Foundation.ERROR_INVALID_WORKSTATION -Windows.Win32.Foundation.ERROR_IO_DEVICE -Windows.Win32.Foundation.ERROR_IO_INCOMPLETE -Windows.Win32.Foundation.ERROR_IO_PENDING -Windows.Win32.Foundation.ERROR_IO_PRIVILEGE_FAILED -Windows.Win32.Foundation.ERROR_IO_REISSUE_AS_CACHED -Windows.Win32.Foundation.ERROR_IOPL_NOT_ENABLED -Windows.Win32.Foundation.ERROR_IP_ADDRESS_CONFLICT1 -Windows.Win32.Foundation.ERROR_IP_ADDRESS_CONFLICT2 -Windows.Win32.Foundation.ERROR_IPSEC_IKE_TIMED_OUT -Windows.Win32.Foundation.ERROR_IRQ_BUSY -Windows.Win32.Foundation.ERROR_IS_JOIN_PATH -Windows.Win32.Foundation.ERROR_IS_JOIN_TARGET -Windows.Win32.Foundation.ERROR_IS_JOINED -Windows.Win32.Foundation.ERROR_IS_SUBST_PATH -Windows.Win32.Foundation.ERROR_IS_SUBST_TARGET -Windows.Win32.Foundation.ERROR_IS_SUBSTED -Windows.Win32.Foundation.ERROR_ITERATED_DATA_EXCEEDS_64k -Windows.Win32.Foundation.ERROR_JOB_NO_CONTAINER -Windows.Win32.Foundation.ERROR_JOIN_TO_JOIN -Windows.Win32.Foundation.ERROR_JOIN_TO_SUBST -Windows.Win32.Foundation.ERROR_JOURNAL_DELETE_IN_PROGRESS -Windows.Win32.Foundation.ERROR_JOURNAL_ENTRY_DELETED -Windows.Win32.Foundation.ERROR_JOURNAL_HOOK_SET -Windows.Win32.Foundation.ERROR_JOURNAL_NOT_ACTIVE -Windows.Win32.Foundation.ERROR_KERNEL_APC -Windows.Win32.Foundation.ERROR_KEY_DELETED -Windows.Win32.Foundation.ERROR_KEY_HAS_CHILDREN -Windows.Win32.Foundation.ERROR_KM_DRIVER_BLOCKED -Windows.Win32.Foundation.ERROR_LABEL_TOO_LONG -Windows.Win32.Foundation.ERROR_LAST_ADMIN -Windows.Win32.Foundation.ERROR_LB_WITHOUT_TABSTOPS -Windows.Win32.Foundation.ERROR_LICENSE_QUOTA_EXCEEDED -Windows.Win32.Foundation.ERROR_LINUX_SUBSYSTEM_NOT_PRESENT -Windows.Win32.Foundation.ERROR_LINUX_SUBSYSTEM_UPDATE_REQUIRED -Windows.Win32.Foundation.ERROR_LISTBOX_ID_NOT_FOUND -Windows.Win32.Foundation.ERROR_LM_CROSS_ENCRYPTION_REQUIRED -Windows.Win32.Foundation.ERROR_LOCAL_POLICY_MODIFICATION_NOT_SUPPORTED -Windows.Win32.Foundation.ERROR_LOCAL_USER_SESSION_KEY -Windows.Win32.Foundation.ERROR_LOCK_FAILED -Windows.Win32.Foundation.ERROR_LOCK_VIOLATION -Windows.Win32.Foundation.ERROR_LOCKED -Windows.Win32.Foundation.ERROR_LOG_FILE_FULL -Windows.Win32.Foundation.ERROR_LOG_HARD_ERROR -Windows.Win32.Foundation.ERROR_LOGIN_TIME_RESTRICTION -Windows.Win32.Foundation.ERROR_LOGIN_WKSTA_RESTRICTION -Windows.Win32.Foundation.ERROR_LOGON_FAILURE -Windows.Win32.Foundation.ERROR_LOGON_NOT_GRANTED -Windows.Win32.Foundation.ERROR_LOGON_SERVER_CONFLICT -Windows.Win32.Foundation.ERROR_LOGON_SESSION_COLLISION -Windows.Win32.Foundation.ERROR_LOGON_SESSION_EXISTS -Windows.Win32.Foundation.ERROR_LOGON_TYPE_NOT_GRANTED -Windows.Win32.Foundation.ERROR_LONGJUMP -Windows.Win32.Foundation.ERROR_LOST_MODE_LOGON_RESTRICTION -Windows.Win32.Foundation.ERROR_LOST_WRITEBEHIND_DATA -Windows.Win32.Foundation.ERROR_LOST_WRITEBEHIND_DATA_LOCAL_DISK_ERROR -Windows.Win32.Foundation.ERROR_LOST_WRITEBEHIND_DATA_NETWORK_DISCONNECTED -Windows.Win32.Foundation.ERROR_LOST_WRITEBEHIND_DATA_NETWORK_SERVER_ERROR -Windows.Win32.Foundation.ERROR_LUIDS_EXHAUSTED -Windows.Win32.Foundation.ERROR_MACHINE_LOCKED -Windows.Win32.Foundation.ERROR_MAGAZINE_NOT_PRESENT -Windows.Win32.Foundation.ERROR_MAPPED_ALIGNMENT -Windows.Win32.Foundation.ERROR_MARKED_TO_DISALLOW_WRITES -Windows.Win32.Foundation.ERROR_MARSHALL_OVERFLOW -Windows.Win32.Foundation.ERROR_MAX_SESSIONS_REACHED -Windows.Win32.Foundation.ERROR_MAX_THRDS_REACHED -Windows.Win32.Foundation.ERROR_MCA_EXCEPTION -Windows.Win32.Foundation.ERROR_MCA_OCCURED -Windows.Win32.Foundation.ERROR_MEDIA_CHANGED -Windows.Win32.Foundation.ERROR_MEDIA_CHECK -Windows.Win32.Foundation.ERROR_MEMBER_IN_ALIAS -Windows.Win32.Foundation.ERROR_MEMBER_IN_GROUP -Windows.Win32.Foundation.ERROR_MEMBER_NOT_IN_ALIAS -Windows.Win32.Foundation.ERROR_MEMBER_NOT_IN_GROUP -Windows.Win32.Foundation.ERROR_MEMBERS_PRIMARY_GROUP -Windows.Win32.Foundation.ERROR_MEMORY_HARDWARE -Windows.Win32.Foundation.ERROR_MENU_ITEM_NOT_FOUND -Windows.Win32.Foundation.ERROR_MESSAGE_SYNC_ONLY -Windows.Win32.Foundation.ERROR_META_EXPANSION_TOO_LONG -Windows.Win32.Foundation.ERROR_MISSING_SYSTEMFILE -Windows.Win32.Foundation.ERROR_MOD_NOT_FOUND -Windows.Win32.Foundation.ERROR_MORE_DATA -Windows.Win32.Foundation.ERROR_MORE_WRITES -Windows.Win32.Foundation.ERROR_MOUNT_POINT_NOT_RESOLVED -Windows.Win32.Foundation.ERROR_MP_PROCESSOR_MISMATCH -Windows.Win32.Foundation.ERROR_MR_MID_NOT_FOUND -Windows.Win32.Foundation.ERROR_MULTIPLE_FAULT_VIOLATION -Windows.Win32.Foundation.ERROR_MUTANT_LIMIT_EXCEEDED -Windows.Win32.Foundation.ERROR_MUTUAL_AUTH_FAILED -Windows.Win32.Foundation.ERROR_NEGATIVE_SEEK -Windows.Win32.Foundation.ERROR_NESTING_NOT_ALLOWED -Windows.Win32.Foundation.ERROR_NET_OPEN_FAILED -Windows.Win32.Foundation.ERROR_NET_WRITE_FAULT -Windows.Win32.Foundation.ERROR_NETLOGON_NOT_STARTED -Windows.Win32.Foundation.ERROR_NETNAME_DELETED -Windows.Win32.Foundation.ERROR_NETWORK_ACCESS_DENIED -Windows.Win32.Foundation.ERROR_NETWORK_ACCESS_DENIED_EDP -Windows.Win32.Foundation.ERROR_NETWORK_BUSY -Windows.Win32.Foundation.ERROR_NETWORK_UNREACHABLE -Windows.Win32.Foundation.ERROR_NO_ACE_CONDITION -Windows.Win32.Foundation.ERROR_NO_ASSOCIATION -Windows.Win32.Foundation.ERROR_NO_BYPASSIO_DRIVER_SUPPORT -Windows.Win32.Foundation.ERROR_NO_CALLBACK_ACTIVE -Windows.Win32.Foundation.ERROR_NO_DATA -Windows.Win32.Foundation.ERROR_NO_DATA_DETECTED -Windows.Win32.Foundation.ERROR_NO_EFS -Windows.Win32.Foundation.ERROR_NO_EVENT_PAIR -Windows.Win32.Foundation.ERROR_NO_GUID_TRANSLATION -Windows.Win32.Foundation.ERROR_NO_IMPERSONATION_TOKEN -Windows.Win32.Foundation.ERROR_NO_INHERITANCE -Windows.Win32.Foundation.ERROR_NO_LOG_SPACE -Windows.Win32.Foundation.ERROR_NO_LOGON_SERVERS -Windows.Win32.Foundation.ERROR_NO_MATCH -Windows.Win32.Foundation.ERROR_NO_MEDIA_IN_DRIVE -Windows.Win32.Foundation.ERROR_NO_MORE_DEVICES -Windows.Win32.Foundation.ERROR_NO_MORE_FILES -Windows.Win32.Foundation.ERROR_NO_MORE_ITEMS -Windows.Win32.Foundation.ERROR_NO_MORE_MATCHES -Windows.Win32.Foundation.ERROR_NO_MORE_SEARCH_HANDLES -Windows.Win32.Foundation.ERROR_NO_MORE_USER_HANDLES -Windows.Win32.Foundation.ERROR_NO_NET_OR_BAD_PATH -Windows.Win32.Foundation.ERROR_NO_NETWORK -Windows.Win32.Foundation.ERROR_NO_NVRAM_RESOURCES -Windows.Win32.Foundation.ERROR_NO_PAGEFILE -Windows.Win32.Foundation.ERROR_NO_PHYSICALLY_ALIGNED_FREE_SPACE_FOUND -Windows.Win32.Foundation.ERROR_NO_PROC_SLOTS -Windows.Win32.Foundation.ERROR_NO_PROMOTION_ACTIVE -Windows.Win32.Foundation.ERROR_NO_QUOTAS_FOR_ACCOUNT -Windows.Win32.Foundation.ERROR_NO_RANGES_PROCESSED -Windows.Win32.Foundation.ERROR_NO_RECOVERY_POLICY -Windows.Win32.Foundation.ERROR_NO_RECOVERY_PROGRAM -Windows.Win32.Foundation.ERROR_NO_SCROLLBARS -Windows.Win32.Foundation.ERROR_NO_SECRETS -Windows.Win32.Foundation.ERROR_NO_SECURITY_ON_OBJECT -Windows.Win32.Foundation.ERROR_NO_SHUTDOWN_IN_PROGRESS -Windows.Win32.Foundation.ERROR_NO_SIGNAL_SENT -Windows.Win32.Foundation.ERROR_NO_SITE_SETTINGS_OBJECT -Windows.Win32.Foundation.ERROR_NO_SITENAME -Windows.Win32.Foundation.ERROR_NO_SPOOL_SPACE -Windows.Win32.Foundation.ERROR_NO_SUCH_ALIAS -Windows.Win32.Foundation.ERROR_NO_SUCH_DEVICE -Windows.Win32.Foundation.ERROR_NO_SUCH_DOMAIN -Windows.Win32.Foundation.ERROR_NO_SUCH_GROUP -Windows.Win32.Foundation.ERROR_NO_SUCH_LOGON_SESSION -Windows.Win32.Foundation.ERROR_NO_SUCH_MEMBER -Windows.Win32.Foundation.ERROR_NO_SUCH_PACKAGE -Windows.Win32.Foundation.ERROR_NO_SUCH_PRIVILEGE -Windows.Win32.Foundation.ERROR_NO_SUCH_SITE -Windows.Win32.Foundation.ERROR_NO_SUCH_USER -Windows.Win32.Foundation.ERROR_NO_SYSTEM_MENU -Windows.Win32.Foundation.ERROR_NO_SYSTEM_RESOURCES -Windows.Win32.Foundation.ERROR_NO_TASK_QUEUE -Windows.Win32.Foundation.ERROR_NO_TOKEN -Windows.Win32.Foundation.ERROR_NO_TRACKING_SERVICE -Windows.Win32.Foundation.ERROR_NO_TRUST_LSA_SECRET -Windows.Win32.Foundation.ERROR_NO_TRUST_SAM_ACCOUNT -Windows.Win32.Foundation.ERROR_NO_UNICODE_TRANSLATION -Windows.Win32.Foundation.ERROR_NO_USER_KEYS -Windows.Win32.Foundation.ERROR_NO_USER_SESSION_KEY -Windows.Win32.Foundation.ERROR_NO_VOLUME_ID -Windows.Win32.Foundation.ERROR_NO_VOLUME_LABEL -Windows.Win32.Foundation.ERROR_NO_WILDCARD_CHARACTERS -Windows.Win32.Foundation.ERROR_NO_WORK_DONE -Windows.Win32.Foundation.ERROR_NO_WRITABLE_DC_FOUND -Windows.Win32.Foundation.ERROR_NO_YIELD_PERFORMED -Windows.Win32.Foundation.ERROR_NOACCESS -Windows.Win32.Foundation.ERROR_NOINTERFACE -Windows.Win32.Foundation.ERROR_NOLOGON_INTERDOMAIN_TRUST_ACCOUNT -Windows.Win32.Foundation.ERROR_NOLOGON_SERVER_TRUST_ACCOUNT -Windows.Win32.Foundation.ERROR_NOLOGON_WORKSTATION_TRUST_ACCOUNT -Windows.Win32.Foundation.ERROR_NON_ACCOUNT_SID -Windows.Win32.Foundation.ERROR_NON_DOMAIN_SID -Windows.Win32.Foundation.ERROR_NON_MDICHILD_WINDOW -Windows.Win32.Foundation.ERROR_NONE_MAPPED -Windows.Win32.Foundation.ERROR_NONPAGED_SYSTEM_RESOURCES -Windows.Win32.Foundation.ERROR_NOT_A_CLOUD_FILE -Windows.Win32.Foundation.ERROR_NOT_A_CLOUD_SYNC_ROOT -Windows.Win32.Foundation.ERROR_NOT_A_DAX_VOLUME -Windows.Win32.Foundation.ERROR_NOT_A_REPARSE_POINT -Windows.Win32.Foundation.ERROR_NOT_ALL_ASSIGNED -Windows.Win32.Foundation.ERROR_NOT_ALLOWED_ON_SYSTEM_FILE -Windows.Win32.Foundation.ERROR_NOT_APPCONTAINER -Windows.Win32.Foundation.ERROR_NOT_AUTHENTICATED -Windows.Win32.Foundation.ERROR_NOT_CAPABLE -Windows.Win32.Foundation.ERROR_NOT_CHILD_WINDOW -Windows.Win32.Foundation.ERROR_NOT_CONNECTED -Windows.Win32.Foundation.ERROR_NOT_CONTAINER -Windows.Win32.Foundation.ERROR_NOT_DAX_MAPPABLE -Windows.Win32.Foundation.ERROR_NOT_DOS_DISK -Windows.Win32.Foundation.ERROR_NOT_ENOUGH_MEMORY -Windows.Win32.Foundation.ERROR_NOT_ENOUGH_QUOTA -Windows.Win32.Foundation.ERROR_NOT_ENOUGH_SERVER_MEMORY -Windows.Win32.Foundation.ERROR_NOT_EXPORT_FORMAT -Windows.Win32.Foundation.ERROR_NOT_FOUND -Windows.Win32.Foundation.ERROR_NOT_GUI_PROCESS -Windows.Win32.Foundation.ERROR_NOT_JOINED -Windows.Win32.Foundation.ERROR_NOT_LOCKED -Windows.Win32.Foundation.ERROR_NOT_LOGGED_ON -Windows.Win32.Foundation.ERROR_NOT_LOGON_PROCESS -Windows.Win32.Foundation.ERROR_NOT_OWNER -Windows.Win32.Foundation.ERROR_NOT_READ_FROM_COPY -Windows.Win32.Foundation.ERROR_NOT_READY -Windows.Win32.Foundation.ERROR_NOT_REDUNDANT_STORAGE -Windows.Win32.Foundation.ERROR_NOT_REGISTRY_FILE -Windows.Win32.Foundation.ERROR_NOT_SAFE_MODE_DRIVER -Windows.Win32.Foundation.ERROR_NOT_SAFEBOOT_SERVICE -Windows.Win32.Foundation.ERROR_NOT_SAME_DEVICE -Windows.Win32.Foundation.ERROR_NOT_SAME_OBJECT -Windows.Win32.Foundation.ERROR_NOT_SUBSTED -Windows.Win32.Foundation.ERROR_NOT_SUPPORTED -Windows.Win32.Foundation.ERROR_NOT_SUPPORTED_IN_APPCONTAINER -Windows.Win32.Foundation.ERROR_NOT_SUPPORTED_ON_DAX -Windows.Win32.Foundation.ERROR_NOT_SUPPORTED_ON_SBS -Windows.Win32.Foundation.ERROR_NOT_SUPPORTED_ON_STANDARD_SERVER -Windows.Win32.Foundation.ERROR_NOT_SUPPORTED_WITH_AUDITING -Windows.Win32.Foundation.ERROR_NOT_SUPPORTED_WITH_BTT -Windows.Win32.Foundation.ERROR_NOT_SUPPORTED_WITH_BYPASSIO -Windows.Win32.Foundation.ERROR_NOT_SUPPORTED_WITH_CACHED_HANDLE -Windows.Win32.Foundation.ERROR_NOT_SUPPORTED_WITH_COMPRESSION -Windows.Win32.Foundation.ERROR_NOT_SUPPORTED_WITH_DEDUPLICATION -Windows.Win32.Foundation.ERROR_NOT_SUPPORTED_WITH_ENCRYPTION -Windows.Win32.Foundation.ERROR_NOT_SUPPORTED_WITH_MONITORING -Windows.Win32.Foundation.ERROR_NOT_SUPPORTED_WITH_REPLICATION -Windows.Win32.Foundation.ERROR_NOT_SUPPORTED_WITH_SNAPSHOT -Windows.Win32.Foundation.ERROR_NOT_SUPPORTED_WITH_VIRTUALIZATION -Windows.Win32.Foundation.ERROR_NOT_TINY_STREAM -Windows.Win32.Foundation.ERROR_NOTHING_TO_TERMINATE -Windows.Win32.Foundation.ERROR_NOTIFICATION_GUID_ALREADY_DEFINED -Windows.Win32.Foundation.ERROR_NOTIFY_CLEANUP -Windows.Win32.Foundation.ERROR_NOTIFY_ENUM_DIR -Windows.Win32.Foundation.ERROR_NT_CROSS_ENCRYPTION_REQUIRED -Windows.Win32.Foundation.ERROR_NTLM_BLOCKED -Windows.Win32.Foundation.ERROR_NULL_LM_PASSWORD -Windows.Win32.Foundation.ERROR_OBJECT_IS_IMMUTABLE -Windows.Win32.Foundation.ERROR_OBJECT_NAME_EXISTS -Windows.Win32.Foundation.ERROR_OBJECT_NOT_EXTERNALLY_BACKED -Windows.Win32.Foundation.ERROR_OFFLOAD_READ_FILE_NOT_SUPPORTED -Windows.Win32.Foundation.ERROR_OFFLOAD_READ_FLT_NOT_SUPPORTED -Windows.Win32.Foundation.ERROR_OFFLOAD_WRITE_FILE_NOT_SUPPORTED -Windows.Win32.Foundation.ERROR_OFFLOAD_WRITE_FLT_NOT_SUPPORTED -Windows.Win32.Foundation.ERROR_OFFSET_ALIGNMENT_VIOLATION -Windows.Win32.Foundation.ERROR_OLD_WIN_VERSION -Windows.Win32.Foundation.ERROR_ONLY_IF_CONNECTED -Windows.Win32.Foundation.ERROR_OPEN_FAILED -Windows.Win32.Foundation.ERROR_OPEN_FILES -Windows.Win32.Foundation.ERROR_OPERATION_ABORTED -Windows.Win32.Foundation.ERROR_OPERATION_IN_PROGRESS -Windows.Win32.Foundation.ERROR_OPLOCK_BREAK_IN_PROGRESS -Windows.Win32.Foundation.ERROR_OPLOCK_HANDLE_CLOSED -Windows.Win32.Foundation.ERROR_OPLOCK_NOT_GRANTED -Windows.Win32.Foundation.ERROR_OPLOCK_SWITCHED_TO_NEW_HANDLE -Windows.Win32.Foundation.ERROR_ORPHAN_NAME_EXHAUSTED -Windows.Win32.Foundation.ERROR_OUT_OF_PAPER -Windows.Win32.Foundation.ERROR_OUT_OF_STRUCTURES -Windows.Win32.Foundation.ERROR_OUTOFMEMORY -Windows.Win32.Foundation.ERROR_OVERRIDE_NOCHANGES -Windows.Win32.Foundation.ERROR_PAGE_FAULT_COPY_ON_WRITE -Windows.Win32.Foundation.ERROR_PAGE_FAULT_DEMAND_ZERO -Windows.Win32.Foundation.ERROR_PAGE_FAULT_GUARD_PAGE -Windows.Win32.Foundation.ERROR_PAGE_FAULT_PAGING_FILE -Windows.Win32.Foundation.ERROR_PAGE_FAULT_TRANSITION -Windows.Win32.Foundation.ERROR_PAGED_SYSTEM_RESOURCES -Windows.Win32.Foundation.ERROR_PAGEFILE_CREATE_FAILED -Windows.Win32.Foundation.ERROR_PAGEFILE_NOT_SUPPORTED -Windows.Win32.Foundation.ERROR_PAGEFILE_QUOTA -Windows.Win32.Foundation.ERROR_PAGEFILE_QUOTA_EXCEEDED -Windows.Win32.Foundation.ERROR_PARAMETER_QUOTA_EXCEEDED -Windows.Win32.Foundation.ERROR_PARTIAL_COPY -Windows.Win32.Foundation.ERROR_PARTITION_FAILURE -Windows.Win32.Foundation.ERROR_PARTITION_TERMINATING -Windows.Win32.Foundation.ERROR_PASSWORD_CHANGE_REQUIRED -Windows.Win32.Foundation.ERROR_PASSWORD_EXPIRED -Windows.Win32.Foundation.ERROR_PASSWORD_MUST_CHANGE -Windows.Win32.Foundation.ERROR_PASSWORD_RESTRICTION -Windows.Win32.Foundation.ERROR_PATCH_MANAGED_ADVERTISED_PRODUCT -Windows.Win32.Foundation.ERROR_PATCH_NO_SEQUENCE -Windows.Win32.Foundation.ERROR_PATCH_PACKAGE_INVALID -Windows.Win32.Foundation.ERROR_PATCH_PACKAGE_OPEN_FAILED -Windows.Win32.Foundation.ERROR_PATCH_PACKAGE_REJECTED -Windows.Win32.Foundation.ERROR_PATCH_PACKAGE_UNSUPPORTED -Windows.Win32.Foundation.ERROR_PATCH_REMOVAL_DISALLOWED -Windows.Win32.Foundation.ERROR_PATCH_REMOVAL_UNSUPPORTED -Windows.Win32.Foundation.ERROR_PATCH_TARGET_NOT_FOUND -Windows.Win32.Foundation.ERROR_PATH_BUSY -Windows.Win32.Foundation.ERROR_PATH_NOT_FOUND -Windows.Win32.Foundation.ERROR_PER_USER_TRUST_QUOTA_EXCEEDED -Windows.Win32.Foundation.ERROR_PIPE_BUSY -Windows.Win32.Foundation.ERROR_PIPE_CONNECTED -Windows.Win32.Foundation.ERROR_PIPE_LISTENING -Windows.Win32.Foundation.ERROR_PIPE_LOCAL -Windows.Win32.Foundation.ERROR_PIPE_NOT_CONNECTED -Windows.Win32.Foundation.ERROR_PKINIT_FAILURE -Windows.Win32.Foundation.ERROR_PLUGPLAY_QUERY_VETOED -Windows.Win32.Foundation.ERROR_PNP_BAD_MPS_TABLE -Windows.Win32.Foundation.ERROR_PNP_INVALID_ID -Windows.Win32.Foundation.ERROR_PNP_IRQ_TRANSLATION_FAILED -Windows.Win32.Foundation.ERROR_PNP_QUERY_REMOVE_DEVICE_TIMEOUT -Windows.Win32.Foundation.ERROR_PNP_QUERY_REMOVE_RELATED_DEVICE_TIMEOUT -Windows.Win32.Foundation.ERROR_PNP_QUERY_REMOVE_UNRELATED_DEVICE_TIMEOUT -Windows.Win32.Foundation.ERROR_PNP_REBOOT_REQUIRED -Windows.Win32.Foundation.ERROR_PNP_RESTART_ENUMERATION -Windows.Win32.Foundation.ERROR_PNP_TRANSLATION_FAILED -Windows.Win32.Foundation.ERROR_POINT_NOT_FOUND -Windows.Win32.Foundation.ERROR_POLICY_OBJECT_NOT_FOUND -Windows.Win32.Foundation.ERROR_POLICY_ONLY_IN_DS -Windows.Win32.Foundation.ERROR_POPUP_ALREADY_ACTIVE -Windows.Win32.Foundation.ERROR_PORT_MESSAGE_TOO_LONG -Windows.Win32.Foundation.ERROR_PORT_NOT_SET -Windows.Win32.Foundation.ERROR_PORT_UNREACHABLE -Windows.Win32.Foundation.ERROR_POSSIBLE_DEADLOCK -Windows.Win32.Foundation.ERROR_POTENTIAL_FILE_FOUND -Windows.Win32.Foundation.ERROR_PREDEFINED_HANDLE -Windows.Win32.Foundation.ERROR_PRIMARY_TRANSPORT_CONNECT_FAILED -Windows.Win32.Foundation.ERROR_PRINT_CANCELLED -Windows.Win32.Foundation.ERROR_PRINTER_ALREADY_EXISTS -Windows.Win32.Foundation.ERROR_PRINTER_DELETED -Windows.Win32.Foundation.ERROR_PRINTER_DRIVER_ALREADY_INSTALLED -Windows.Win32.Foundation.ERROR_PRINTQ_FULL -Windows.Win32.Foundation.ERROR_PRIVATE_DIALOG_INDEX -Windows.Win32.Foundation.ERROR_PRIVILEGE_NOT_HELD -Windows.Win32.Foundation.ERROR_PROC_NOT_FOUND -Windows.Win32.Foundation.ERROR_PROCESS_ABORTED -Windows.Win32.Foundation.ERROR_PROCESS_IN_JOB -Windows.Win32.Foundation.ERROR_PROCESS_IS_PROTECTED -Windows.Win32.Foundation.ERROR_PROCESS_MODE_ALREADY_BACKGROUND -Windows.Win32.Foundation.ERROR_PROCESS_MODE_NOT_BACKGROUND -Windows.Win32.Foundation.ERROR_PROCESS_NOT_IN_JOB -Windows.Win32.Foundation.ERROR_PRODUCT_UNINSTALLED -Windows.Win32.Foundation.ERROR_PRODUCT_VERSION -Windows.Win32.Foundation.ERROR_PROFILING_AT_LIMIT -Windows.Win32.Foundation.ERROR_PROFILING_NOT_STARTED -Windows.Win32.Foundation.ERROR_PROFILING_NOT_STOPPED -Windows.Win32.Foundation.ERROR_PROMOTION_ACTIVE -Windows.Win32.Foundation.ERROR_PROTOCOL_UNREACHABLE -Windows.Win32.Foundation.ERROR_PWD_HISTORY_CONFLICT -Windows.Win32.Foundation.ERROR_PWD_TOO_LONG -Windows.Win32.Foundation.ERROR_PWD_TOO_RECENT -Windows.Win32.Foundation.ERROR_PWD_TOO_SHORT -Windows.Win32.Foundation.ERROR_QUOTA_ACTIVITY -Windows.Win32.Foundation.ERROR_QUOTA_LIST_INCONSISTENT -Windows.Win32.Foundation.ERROR_RANGE_LIST_CONFLICT -Windows.Win32.Foundation.ERROR_RANGE_NOT_FOUND -Windows.Win32.Foundation.ERROR_READ_FAULT -Windows.Win32.Foundation.ERROR_RECEIVE_EXPEDITED -Windows.Win32.Foundation.ERROR_RECEIVE_PARTIAL -Windows.Win32.Foundation.ERROR_RECEIVE_PARTIAL_EXPEDITED -Windows.Win32.Foundation.ERROR_RECOVERY_FAILURE -Windows.Win32.Foundation.ERROR_REDIR_PAUSED -Windows.Win32.Foundation.ERROR_REDIRECTOR_HAS_OPEN_HANDLES -Windows.Win32.Foundation.ERROR_REG_NAT_CONSUMPTION -Windows.Win32.Foundation.ERROR_REGISTRY_CORRUPT -Windows.Win32.Foundation.ERROR_REGISTRY_HIVE_RECOVERED -Windows.Win32.Foundation.ERROR_REGISTRY_IO_FAILED -Windows.Win32.Foundation.ERROR_REGISTRY_QUOTA_LIMIT -Windows.Win32.Foundation.ERROR_REGISTRY_RECOVERED -Windows.Win32.Foundation.ERROR_RELOC_CHAIN_XEEDS_SEGLIM -Windows.Win32.Foundation.ERROR_REM_NOT_LIST -Windows.Win32.Foundation.ERROR_REMOTE_PRINT_CONNECTIONS_BLOCKED -Windows.Win32.Foundation.ERROR_REMOTE_SESSION_LIMIT_EXCEEDED -Windows.Win32.Foundation.ERROR_REMOTE_STORAGE_MEDIA_ERROR -Windows.Win32.Foundation.ERROR_REMOTE_STORAGE_NOT_ACTIVE -Windows.Win32.Foundation.ERROR_REPARSE -Windows.Win32.Foundation.ERROR_REPARSE_ATTRIBUTE_CONFLICT -Windows.Win32.Foundation.ERROR_REPARSE_OBJECT -Windows.Win32.Foundation.ERROR_REPARSE_POINT_ENCOUNTERED -Windows.Win32.Foundation.ERROR_REPARSE_TAG_INVALID -Windows.Win32.Foundation.ERROR_REPARSE_TAG_MISMATCH -Windows.Win32.Foundation.ERROR_REPLY_MESSAGE_MISMATCH -Windows.Win32.Foundation.ERROR_REQ_NOT_ACCEP -Windows.Win32.Foundation.ERROR_REQUEST_ABORTED -Windows.Win32.Foundation.ERROR_REQUEST_OUT_OF_SEQUENCE -Windows.Win32.Foundation.ERROR_REQUEST_PAUSED -Windows.Win32.Foundation.ERROR_REQUIRES_INTERACTIVE_WINDOWSTATION -Windows.Win32.Foundation.ERROR_RESIDENT_FILE_NOT_SUPPORTED -Windows.Win32.Foundation.ERROR_RESOURCE_CALL_TIMED_OUT -Windows.Win32.Foundation.ERROR_RESOURCE_DATA_NOT_FOUND -Windows.Win32.Foundation.ERROR_RESOURCE_LANG_NOT_FOUND -Windows.Win32.Foundation.ERROR_RESOURCE_NAME_NOT_FOUND -Windows.Win32.Foundation.ERROR_RESOURCE_REQUIREMENTS_CHANGED -Windows.Win32.Foundation.ERROR_RESOURCE_TYPE_NOT_FOUND -Windows.Win32.Foundation.ERROR_RESTART_APPLICATION -Windows.Win32.Foundation.ERROR_RESUME_HIBERNATION -Windows.Win32.Foundation.ERROR_RETRY -Windows.Win32.Foundation.ERROR_RETURN_ADDRESS_HIJACK_ATTEMPT -Windows.Win32.Foundation.ERROR_REVISION_MISMATCH -Windows.Win32.Foundation.ERROR_RING2_STACK_IN_USE -Windows.Win32.Foundation.ERROR_RING2SEG_MUST_BE_MOVABLE -Windows.Win32.Foundation.ERROR_RMODE_APP -Windows.Win32.Foundation.ERROR_ROWSNOTRELEASED -Windows.Win32.Foundation.ERROR_RUNLEVEL_SWITCH_AGENT_TIMEOUT -Windows.Win32.Foundation.ERROR_RUNLEVEL_SWITCH_TIMEOUT -Windows.Win32.Foundation.ERROR_RWRAW_ENCRYPTED_FILE_NOT_ENCRYPTED -Windows.Win32.Foundation.ERROR_RWRAW_ENCRYPTED_INVALID_EDATAINFO_FILEOFFSET -Windows.Win32.Foundation.ERROR_RWRAW_ENCRYPTED_INVALID_EDATAINFO_FILERANGE -Windows.Win32.Foundation.ERROR_RWRAW_ENCRYPTED_INVALID_EDATAINFO_PARAMETER -Windows.Win32.Foundation.ERROR_RXACT_COMMIT_FAILURE -Windows.Win32.Foundation.ERROR_RXACT_COMMIT_NECESSARY -Windows.Win32.Foundation.ERROR_RXACT_COMMITTED -Windows.Win32.Foundation.ERROR_RXACT_INVALID_STATE -Windows.Win32.Foundation.ERROR_RXACT_STATE_CREATED -Windows.Win32.Foundation.ERROR_SAM_INIT_FAILURE -Windows.Win32.Foundation.ERROR_SAME_DRIVE -Windows.Win32.Foundation.ERROR_SCOPE_NOT_FOUND -Windows.Win32.Foundation.ERROR_SCREEN_ALREADY_LOCKED -Windows.Win32.Foundation.ERROR_SCRUB_DATA_DISABLED -Windows.Win32.Foundation.ERROR_SECRET_TOO_LONG -Windows.Win32.Foundation.ERROR_SECTION_DIRECT_MAP_ONLY -Windows.Win32.Foundation.ERROR_SECTOR_NOT_FOUND -Windows.Win32.Foundation.ERROR_SECURITY_DENIES_OPERATION -Windows.Win32.Foundation.ERROR_SECURITY_STREAM_IS_INCONSISTENT -Windows.Win32.Foundation.ERROR_SEEK -Windows.Win32.Foundation.ERROR_SEEK_ON_DEVICE -Windows.Win32.Foundation.ERROR_SEGMENT_NOTIFICATION -Windows.Win32.Foundation.ERROR_SEM_IS_SET -Windows.Win32.Foundation.ERROR_SEM_NOT_FOUND -Windows.Win32.Foundation.ERROR_SEM_OWNER_DIED -Windows.Win32.Foundation.ERROR_SEM_TIMEOUT -Windows.Win32.Foundation.ERROR_SEM_USER_LIMIT -Windows.Win32.Foundation.ERROR_SERIAL_NO_DEVICE -Windows.Win32.Foundation.ERROR_SERVER_DISABLED -Windows.Win32.Foundation.ERROR_SERVER_HAS_OPEN_HANDLES -Windows.Win32.Foundation.ERROR_SERVER_NOT_DISABLED -Windows.Win32.Foundation.ERROR_SERVER_SHUTDOWN_IN_PROGRESS -Windows.Win32.Foundation.ERROR_SERVER_SID_MISMATCH -Windows.Win32.Foundation.ERROR_SERVER_TRANSPORT_CONFLICT -Windows.Win32.Foundation.ERROR_SERVICE_ALREADY_RUNNING -Windows.Win32.Foundation.ERROR_SERVICE_CANNOT_ACCEPT_CTRL -Windows.Win32.Foundation.ERROR_SERVICE_DATABASE_LOCKED -Windows.Win32.Foundation.ERROR_SERVICE_DEPENDENCY_DELETED -Windows.Win32.Foundation.ERROR_SERVICE_DEPENDENCY_FAIL -Windows.Win32.Foundation.ERROR_SERVICE_DISABLED -Windows.Win32.Foundation.ERROR_SERVICE_DOES_NOT_EXIST -Windows.Win32.Foundation.ERROR_SERVICE_EXISTS -Windows.Win32.Foundation.ERROR_SERVICE_LOGON_FAILED -Windows.Win32.Foundation.ERROR_SERVICE_MARKED_FOR_DELETE -Windows.Win32.Foundation.ERROR_SERVICE_NEVER_STARTED -Windows.Win32.Foundation.ERROR_SERVICE_NO_THREAD -Windows.Win32.Foundation.ERROR_SERVICE_NOT_ACTIVE -Windows.Win32.Foundation.ERROR_SERVICE_NOT_FOUND -Windows.Win32.Foundation.ERROR_SERVICE_NOT_IN_EXE -Windows.Win32.Foundation.ERROR_SERVICE_NOTIFICATION -Windows.Win32.Foundation.ERROR_SERVICE_NOTIFY_CLIENT_LAGGING -Windows.Win32.Foundation.ERROR_SERVICE_REQUEST_TIMEOUT -Windows.Win32.Foundation.ERROR_SERVICE_SPECIFIC_ERROR -Windows.Win32.Foundation.ERROR_SERVICE_START_HANG -Windows.Win32.Foundation.ERROR_SESSION_CREDENTIAL_CONFLICT -Windows.Win32.Foundation.ERROR_SESSION_KEY_TOO_SHORT -Windows.Win32.Foundation.ERROR_SET_CONTEXT_DENIED -Windows.Win32.Foundation.ERROR_SET_NOT_FOUND -Windows.Win32.Foundation.ERROR_SET_POWER_STATE_FAILED -Windows.Win32.Foundation.ERROR_SET_POWER_STATE_VETOED -Windows.Win32.Foundation.ERROR_SETCOUNT_ON_BAD_LB -Windows.Win32.Foundation.ERROR_SETMARK_DETECTED -Windows.Win32.Foundation.ERROR_SHARED_POLICY -Windows.Win32.Foundation.ERROR_SHARING_BUFFER_EXCEEDED -Windows.Win32.Foundation.ERROR_SHARING_PAUSED -Windows.Win32.Foundation.ERROR_SHARING_VIOLATION -Windows.Win32.Foundation.ERROR_SHORT_NAMES_NOT_ENABLED_ON_VOLUME -Windows.Win32.Foundation.ERROR_SHUTDOWN_DISKS_NOT_IN_MAINTENANCE_MODE -Windows.Win32.Foundation.ERROR_SHUTDOWN_IN_PROGRESS -Windows.Win32.Foundation.ERROR_SHUTDOWN_IS_SCHEDULED -Windows.Win32.Foundation.ERROR_SHUTDOWN_USERS_LOGGED_ON -Windows.Win32.Foundation.ERROR_SIGNAL_PENDING -Windows.Win32.Foundation.ERROR_SIGNAL_REFUSED -Windows.Win32.Foundation.ERROR_SINGLE_INSTANCE_APP -Windows.Win32.Foundation.ERROR_SMARTCARD_SUBSYSTEM_FAILURE -Windows.Win32.Foundation.ERROR_SMB1_NOT_AVAILABLE -Windows.Win32.Foundation.ERROR_SMB_GUEST_LOGON_BLOCKED -Windows.Win32.Foundation.ERROR_SMR_GARBAGE_COLLECTION_REQUIRED -Windows.Win32.Foundation.ERROR_SOME_NOT_MAPPED -Windows.Win32.Foundation.ERROR_SOURCE_ELEMENT_EMPTY -Windows.Win32.Foundation.ERROR_SPARSE_FILE_NOT_SUPPORTED -Windows.Win32.Foundation.ERROR_SPECIAL_ACCOUNT -Windows.Win32.Foundation.ERROR_SPECIAL_GROUP -Windows.Win32.Foundation.ERROR_SPECIAL_USER -Windows.Win32.Foundation.ERROR_SRC_SRV_DLL_LOAD_FAILED -Windows.Win32.Foundation.ERROR_STACK_BUFFER_OVERRUN -Windows.Win32.Foundation.ERROR_STACK_OVERFLOW -Windows.Win32.Foundation.ERROR_STACK_OVERFLOW_READ -Windows.Win32.Foundation.ERROR_STOPPED_ON_SYMLINK -Windows.Win32.Foundation.ERROR_STORAGE_LOST_DATA_PERSISTENCE -Windows.Win32.Foundation.ERROR_STORAGE_RESERVE_ALREADY_EXISTS -Windows.Win32.Foundation.ERROR_STORAGE_RESERVE_DOES_NOT_EXIST -Windows.Win32.Foundation.ERROR_STORAGE_RESERVE_ID_INVALID -Windows.Win32.Foundation.ERROR_STORAGE_RESERVE_NOT_EMPTY -Windows.Win32.Foundation.ERROR_STORAGE_STACK_ACCESS_DENIED -Windows.Win32.Foundation.ERROR_STORAGE_TOPOLOGY_ID_MISMATCH -Windows.Win32.Foundation.ERROR_STRICT_CFG_VIOLATION -Windows.Win32.Foundation.ERROR_SUBST_TO_JOIN -Windows.Win32.Foundation.ERROR_SUBST_TO_SUBST -Windows.Win32.Foundation.ERROR_SUCCESS -Windows.Win32.Foundation.ERROR_SUCCESS_REBOOT_INITIATED -Windows.Win32.Foundation.ERROR_SWAPERROR -Windows.Win32.Foundation.ERROR_SYMLINK_CLASS_DISABLED -Windows.Win32.Foundation.ERROR_SYMLINK_NOT_SUPPORTED -Windows.Win32.Foundation.ERROR_SYNC_FOREGROUND_REFRESH_REQUIRED -Windows.Win32.Foundation.ERROR_SYNCHRONIZATION_REQUIRED -Windows.Win32.Foundation.ERROR_SYSTEM_HIVE_TOO_LARGE -Windows.Win32.Foundation.ERROR_SYSTEM_IMAGE_BAD_SIGNATURE -Windows.Win32.Foundation.ERROR_SYSTEM_POWERSTATE_COMPLEX_TRANSITION -Windows.Win32.Foundation.ERROR_SYSTEM_POWERSTATE_TRANSITION -Windows.Win32.Foundation.ERROR_SYSTEM_PROCESS_TERMINATED -Windows.Win32.Foundation.ERROR_SYSTEM_SHUTDOWN -Windows.Win32.Foundation.ERROR_SYSTEM_TRACE -Windows.Win32.Foundation.ERROR_THREAD_1_INACTIVE -Windows.Win32.Foundation.ERROR_THREAD_ALREADY_IN_TASK -Windows.Win32.Foundation.ERROR_THREAD_MODE_ALREADY_BACKGROUND -Windows.Win32.Foundation.ERROR_THREAD_MODE_NOT_BACKGROUND -Windows.Win32.Foundation.ERROR_THREAD_NOT_IN_PROCESS -Windows.Win32.Foundation.ERROR_THREAD_WAS_SUSPENDED -Windows.Win32.Foundation.ERROR_TIME_SENSITIVE_THREAD -Windows.Win32.Foundation.ERROR_TIME_SKEW -Windows.Win32.Foundation.ERROR_TIMEOUT -Windows.Win32.Foundation.ERROR_TIMER_NOT_CANCELED -Windows.Win32.Foundation.ERROR_TIMER_RESOLUTION_NOT_SET -Windows.Win32.Foundation.ERROR_TIMER_RESUME_IGNORED -Windows.Win32.Foundation.ERROR_TLW_WITH_WSCHILD -Windows.Win32.Foundation.ERROR_TOKEN_ALREADY_IN_USE -Windows.Win32.Foundation.ERROR_TOO_MANY_CMDS -Windows.Win32.Foundation.ERROR_TOO_MANY_CONTEXT_IDS -Windows.Win32.Foundation.ERROR_TOO_MANY_DESCRIPTORS -Windows.Win32.Foundation.ERROR_TOO_MANY_LINKS -Windows.Win32.Foundation.ERROR_TOO_MANY_LUIDS_REQUESTED -Windows.Win32.Foundation.ERROR_TOO_MANY_MODULES -Windows.Win32.Foundation.ERROR_TOO_MANY_MUXWAITERS -Windows.Win32.Foundation.ERROR_TOO_MANY_NAMES -Windows.Win32.Foundation.ERROR_TOO_MANY_OPEN_FILES -Windows.Win32.Foundation.ERROR_TOO_MANY_POSTS -Windows.Win32.Foundation.ERROR_TOO_MANY_SECRETS -Windows.Win32.Foundation.ERROR_TOO_MANY_SEM_REQUESTS -Windows.Win32.Foundation.ERROR_TOO_MANY_SEMAPHORES -Windows.Win32.Foundation.ERROR_TOO_MANY_SESS -Windows.Win32.Foundation.ERROR_TOO_MANY_SIDS -Windows.Win32.Foundation.ERROR_TOO_MANY_TCBS -Windows.Win32.Foundation.ERROR_TOO_MANY_THREADS -Windows.Win32.Foundation.ERROR_TRANSLATION_COMPLETE -Windows.Win32.Foundation.ERROR_TRUST_FAILURE -Windows.Win32.Foundation.ERROR_TRUSTED_DOMAIN_FAILURE -Windows.Win32.Foundation.ERROR_TRUSTED_RELATIONSHIP_FAILURE -Windows.Win32.Foundation.ERROR_UNABLE_TO_LOCK_MEDIA -Windows.Win32.Foundation.ERROR_UNABLE_TO_MOVE_REPLACEMENT -Windows.Win32.Foundation.ERROR_UNABLE_TO_MOVE_REPLACEMENT_2 -Windows.Win32.Foundation.ERROR_UNABLE_TO_REMOVE_REPLACED -Windows.Win32.Foundation.ERROR_UNABLE_TO_UNLOAD_MEDIA -Windows.Win32.Foundation.ERROR_UNDEFINED_CHARACTER -Windows.Win32.Foundation.ERROR_UNDEFINED_SCOPE -Windows.Win32.Foundation.ERROR_UNEXP_NET_ERR -Windows.Win32.Foundation.ERROR_UNEXPECTED_MM_CREATE_ERR -Windows.Win32.Foundation.ERROR_UNEXPECTED_MM_EXTEND_ERR -Windows.Win32.Foundation.ERROR_UNEXPECTED_MM_MAP_ERROR -Windows.Win32.Foundation.ERROR_UNEXPECTED_NTCACHEMANAGER_ERROR -Windows.Win32.Foundation.ERROR_UNHANDLED_EXCEPTION -Windows.Win32.Foundation.ERROR_UNIDENTIFIED_ERROR -Windows.Win32.Foundation.ERROR_UNKNOWN_COMPONENT -Windows.Win32.Foundation.ERROR_UNKNOWN_FEATURE -Windows.Win32.Foundation.ERROR_UNKNOWN_PATCH -Windows.Win32.Foundation.ERROR_UNKNOWN_PORT -Windows.Win32.Foundation.ERROR_UNKNOWN_PRINTER_DRIVER -Windows.Win32.Foundation.ERROR_UNKNOWN_PRINTPROCESSOR -Windows.Win32.Foundation.ERROR_UNKNOWN_PRODUCT -Windows.Win32.Foundation.ERROR_UNKNOWN_PROPERTY -Windows.Win32.Foundation.ERROR_UNKNOWN_REVISION -Windows.Win32.Foundation.ERROR_UNRECOGNIZED_MEDIA -Windows.Win32.Foundation.ERROR_UNRECOGNIZED_VOLUME -Windows.Win32.Foundation.ERROR_UNSATISFIED_DEPENDENCIES -Windows.Win32.Foundation.ERROR_UNSUPPORTED_COMPRESSION -Windows.Win32.Foundation.ERROR_UNSUPPORTED_TYPE -Windows.Win32.Foundation.ERROR_UNTRUSTED_MOUNT_POINT -Windows.Win32.Foundation.ERROR_UNWIND -Windows.Win32.Foundation.ERROR_UNWIND_CONSOLIDATE -Windows.Win32.Foundation.ERROR_USER_APC -Windows.Win32.Foundation.ERROR_USER_DELETE_TRUST_QUOTA_EXCEEDED -Windows.Win32.Foundation.ERROR_USER_EXISTS -Windows.Win32.Foundation.ERROR_USER_MAPPED_FILE -Windows.Win32.Foundation.ERROR_USER_PROFILE_LOAD -Windows.Win32.Foundation.ERROR_VALIDATE_CONTINUE -Windows.Win32.Foundation.ERROR_VC_DISCONNECTED -Windows.Win32.Foundation.ERROR_VDM_DISALLOWED -Windows.Win32.Foundation.ERROR_VDM_HARD_ERROR -Windows.Win32.Foundation.ERROR_VERIFIER_STOP -Windows.Win32.Foundation.ERROR_VERSION_PARSE_ERROR -Windows.Win32.Foundation.ERROR_VIRUS_DELETED -Windows.Win32.Foundation.ERROR_VIRUS_INFECTED -Windows.Win32.Foundation.ERROR_VOLSNAP_HIBERNATE_READY -Windows.Win32.Foundation.ERROR_VOLSNAP_PREPARE_HIBERNATE -Windows.Win32.Foundation.ERROR_VOLUME_MOUNTED -Windows.Win32.Foundation.ERROR_VOLUME_NOT_CLUSTER_ALIGNED -Windows.Win32.Foundation.ERROR_VOLUME_NOT_SIS_ENABLED -Windows.Win32.Foundation.ERROR_VOLUME_NOT_SUPPORT_EFS -Windows.Win32.Foundation.ERROR_VOLUME_NOT_SUPPORTED -Windows.Win32.Foundation.ERROR_VOLUME_WRITE_ACCESS_DENIED -Windows.Win32.Foundation.ERROR_WAIT_1 -Windows.Win32.Foundation.ERROR_WAIT_2 -Windows.Win32.Foundation.ERROR_WAIT_3 -Windows.Win32.Foundation.ERROR_WAIT_63 -Windows.Win32.Foundation.ERROR_WAIT_FOR_OPLOCK -Windows.Win32.Foundation.ERROR_WAIT_NO_CHILDREN -Windows.Win32.Foundation.ERROR_WAKE_SYSTEM -Windows.Win32.Foundation.ERROR_WAKE_SYSTEM_DEBUGGER -Windows.Win32.Foundation.ERROR_WAS_LOCKED -Windows.Win32.Foundation.ERROR_WAS_UNLOCKED -Windows.Win32.Foundation.ERROR_WEAK_WHFBKEY_BLOCKED -Windows.Win32.Foundation.ERROR_WINDOW_NOT_COMBOBOX -Windows.Win32.Foundation.ERROR_WINDOW_NOT_DIALOG -Windows.Win32.Foundation.ERROR_WINDOW_OF_OTHER_THREAD -Windows.Win32.Foundation.ERROR_WIP_ENCRYPTION_FAILED -Windows.Win32.Foundation.ERROR_WOF_FILE_RESOURCE_TABLE_CORRUPT -Windows.Win32.Foundation.ERROR_WOF_WIM_HEADER_CORRUPT -Windows.Win32.Foundation.ERROR_WOF_WIM_RESOURCE_TABLE_CORRUPT -Windows.Win32.Foundation.ERROR_WORKING_SET_QUOTA -Windows.Win32.Foundation.ERROR_WOW_ASSERTION -Windows.Win32.Foundation.ERROR_WRITE_FAULT -Windows.Win32.Foundation.ERROR_WRITE_PROTECT -Windows.Win32.Foundation.ERROR_WRONG_COMPARTMENT -Windows.Win32.Foundation.ERROR_WRONG_DISK -Windows.Win32.Foundation.ERROR_WRONG_EFS -Windows.Win32.Foundation.ERROR_WRONG_PASSWORD -Windows.Win32.Foundation.ERROR_WRONG_TARGET_NAME -Windows.Win32.Foundation.ERROR_WX86_ERROR -Windows.Win32.Foundation.ERROR_WX86_WARNING -Windows.Win32.Foundation.ERROR_XML_PARSE_ERROR -Windows.Win32.Foundation.ERROR_XMLDSIG_ERROR -Windows.Win32.Foundation.EXCEPTION_STACK_OVERFLOW -Windows.Win32.Foundation.FALSE -Windows.Win32.Foundation.FARPROC -Windows.Win32.Foundation.FILETIME -Windows.Win32.Foundation.FRS_ERR_SYSVOL_POPULATE_TIMEOUT -Windows.Win32.Foundation.GENERIC_ACCESS_RIGHTS -Windows.Win32.Foundation.GENERIC_ALL -Windows.Win32.Foundation.GENERIC_EXECUTE -Windows.Win32.Foundation.GENERIC_READ -Windows.Win32.Foundation.GENERIC_WRITE -Windows.Win32.Foundation.GetLastError -Windows.Win32.Foundation.HANDLE -Windows.Win32.Foundation.HANDLE_FLAG_INHERIT -Windows.Win32.Foundation.HANDLE_FLAG_PROTECT_FROM_CLOSE -Windows.Win32.Foundation.HANDLE_FLAGS -Windows.Win32.Foundation.HMODULE -Windows.Win32.Foundation.LocalFree -Windows.Win32.Foundation.MAX_PATH -Windows.Win32.Foundation.NO_ERROR -Windows.Win32.Foundation.NTSTATUS -Windows.Win32.Foundation.RtlNtStatusToDosError -Windows.Win32.Foundation.SetHandleInformation -Windows.Win32.Foundation.SetLastError -Windows.Win32.Foundation.STATUS_DELETE_PENDING -Windows.Win32.Foundation.STATUS_DIRECTORY_NOT_EMPTY -Windows.Win32.Foundation.STATUS_END_OF_FILE -Windows.Win32.Foundation.STATUS_FILE_DELETED -Windows.Win32.Foundation.STATUS_INVALID_HANDLE -Windows.Win32.Foundation.STATUS_INVALID_PARAMETER -Windows.Win32.Foundation.STATUS_NOT_IMPLEMENTED -Windows.Win32.Foundation.STATUS_PENDING -Windows.Win32.Foundation.STATUS_SHARING_VIOLATION -Windows.Win32.Foundation.STATUS_SUCCESS -Windows.Win32.Foundation.TRUE -Windows.Win32.Foundation.UNICODE_STRING -Windows.Win32.Foundation.WAIT_ABANDONED -Windows.Win32.Foundation.WAIT_ABANDONED_0 -Windows.Win32.Foundation.WAIT_FAILED -Windows.Win32.Foundation.WAIT_IO_COMPLETION -Windows.Win32.Foundation.WAIT_OBJECT_0 -Windows.Win32.Foundation.WAIT_TIMEOUT -Windows.Win32.Foundation.WIN32_ERROR -Windows.Win32.Globalization.COMPARESTRING_RESULT -Windows.Win32.Globalization.CompareStringOrdinal -Windows.Win32.Globalization.CP_UTF8 -Windows.Win32.Globalization.CSTR_EQUAL -Windows.Win32.Globalization.CSTR_GREATER_THAN -Windows.Win32.Globalization.CSTR_LESS_THAN -Windows.Win32.Globalization.MB_COMPOSITE -Windows.Win32.Globalization.MB_ERR_INVALID_CHARS -Windows.Win32.Globalization.MB_PRECOMPOSED -Windows.Win32.Globalization.MB_USEGLYPHCHARS -Windows.Win32.Globalization.MULTI_BYTE_TO_WIDE_CHAR_FLAGS -Windows.Win32.Globalization.MultiByteToWideChar -Windows.Win32.Globalization.WC_ERR_INVALID_CHARS -Windows.Win32.Globalization.WideCharToMultiByte -Windows.Win32.Networking.WinSock.accept -Windows.Win32.Networking.WinSock.ADDRESS_FAMILY -Windows.Win32.Networking.WinSock.ADDRINFOA -Windows.Win32.Networking.WinSock.AF_INET -Windows.Win32.Networking.WinSock.AF_INET6 -Windows.Win32.Networking.WinSock.AF_UNIX -Windows.Win32.Networking.WinSock.AF_UNSPEC -Windows.Win32.Networking.WinSock.bind -Windows.Win32.Networking.WinSock.closesocket -Windows.Win32.Networking.WinSock.connect -Windows.Win32.Networking.WinSock.FD_SET -Windows.Win32.Networking.WinSock.FIONBIO -Windows.Win32.Networking.WinSock.freeaddrinfo -Windows.Win32.Networking.WinSock.getaddrinfo -Windows.Win32.Networking.WinSock.getpeername -Windows.Win32.Networking.WinSock.getsockname -Windows.Win32.Networking.WinSock.getsockopt -Windows.Win32.Networking.WinSock.IN6_ADDR -Windows.Win32.Networking.WinSock.IN_ADDR -Windows.Win32.Networking.WinSock.INVALID_SOCKET -Windows.Win32.Networking.WinSock.ioctlsocket -Windows.Win32.Networking.WinSock.IP_ADD_MEMBERSHIP -Windows.Win32.Networking.WinSock.IP_DROP_MEMBERSHIP -Windows.Win32.Networking.WinSock.IP_MREQ -Windows.Win32.Networking.WinSock.IP_MULTICAST_LOOP -Windows.Win32.Networking.WinSock.IP_MULTICAST_TTL -Windows.Win32.Networking.WinSock.IP_TTL -Windows.Win32.Networking.WinSock.IPPROTO -Windows.Win32.Networking.WinSock.IPPROTO_AH -Windows.Win32.Networking.WinSock.IPPROTO_CBT -Windows.Win32.Networking.WinSock.IPPROTO_DSTOPTS -Windows.Win32.Networking.WinSock.IPPROTO_EGP -Windows.Win32.Networking.WinSock.IPPROTO_ESP -Windows.Win32.Networking.WinSock.IPPROTO_FRAGMENT -Windows.Win32.Networking.WinSock.IPPROTO_GGP -Windows.Win32.Networking.WinSock.IPPROTO_HOPOPTS -Windows.Win32.Networking.WinSock.IPPROTO_ICLFXBM -Windows.Win32.Networking.WinSock.IPPROTO_ICMP -Windows.Win32.Networking.WinSock.IPPROTO_ICMPV6 -Windows.Win32.Networking.WinSock.IPPROTO_IDP -Windows.Win32.Networking.WinSock.IPPROTO_IGMP -Windows.Win32.Networking.WinSock.IPPROTO_IGP -Windows.Win32.Networking.WinSock.IPPROTO_IP -Windows.Win32.Networking.WinSock.IPPROTO_IPV4 -Windows.Win32.Networking.WinSock.IPPROTO_IPV6 -Windows.Win32.Networking.WinSock.IPPROTO_L2TP -Windows.Win32.Networking.WinSock.IPPROTO_MAX -Windows.Win32.Networking.WinSock.IPPROTO_ND -Windows.Win32.Networking.WinSock.IPPROTO_NONE -Windows.Win32.Networking.WinSock.IPPROTO_PGM -Windows.Win32.Networking.WinSock.IPPROTO_PIM -Windows.Win32.Networking.WinSock.IPPROTO_PUP -Windows.Win32.Networking.WinSock.IPPROTO_RAW -Windows.Win32.Networking.WinSock.IPPROTO_RDP -Windows.Win32.Networking.WinSock.IPPROTO_RESERVED_IPSEC -Windows.Win32.Networking.WinSock.IPPROTO_RESERVED_IPSECOFFLOAD -Windows.Win32.Networking.WinSock.IPPROTO_RESERVED_MAX -Windows.Win32.Networking.WinSock.IPPROTO_RESERVED_RAW -Windows.Win32.Networking.WinSock.IPPROTO_RESERVED_WNV -Windows.Win32.Networking.WinSock.IPPROTO_RM -Windows.Win32.Networking.WinSock.IPPROTO_ROUTING -Windows.Win32.Networking.WinSock.IPPROTO_SCTP -Windows.Win32.Networking.WinSock.IPPROTO_ST -Windows.Win32.Networking.WinSock.IPPROTO_TCP -Windows.Win32.Networking.WinSock.IPPROTO_UDP -Windows.Win32.Networking.WinSock.IPV6_ADD_MEMBERSHIP -Windows.Win32.Networking.WinSock.IPV6_DROP_MEMBERSHIP -Windows.Win32.Networking.WinSock.IPV6_MREQ -Windows.Win32.Networking.WinSock.IPV6_MULTICAST_LOOP -Windows.Win32.Networking.WinSock.IPV6_V6ONLY -Windows.Win32.Networking.WinSock.LINGER -Windows.Win32.Networking.WinSock.listen -Windows.Win32.Networking.WinSock.LPWSAOVERLAPPED_COMPLETION_ROUTINE -Windows.Win32.Networking.WinSock.MSG_DONTROUTE -Windows.Win32.Networking.WinSock.MSG_OOB -Windows.Win32.Networking.WinSock.MSG_PEEK -Windows.Win32.Networking.WinSock.MSG_PUSH_IMMEDIATE -Windows.Win32.Networking.WinSock.MSG_WAITALL -Windows.Win32.Networking.WinSock.recv -Windows.Win32.Networking.WinSock.recvfrom -Windows.Win32.Networking.WinSock.SD_BOTH -Windows.Win32.Networking.WinSock.SD_RECEIVE -Windows.Win32.Networking.WinSock.SD_SEND -Windows.Win32.Networking.WinSock.select -Windows.Win32.Networking.WinSock.send -Windows.Win32.Networking.WinSock.SEND_RECV_FLAGS -Windows.Win32.Networking.WinSock.sendto -Windows.Win32.Networking.WinSock.setsockopt -Windows.Win32.Networking.WinSock.shutdown -Windows.Win32.Networking.WinSock.SO_BROADCAST -Windows.Win32.Networking.WinSock.SO_ERROR -Windows.Win32.Networking.WinSock.SO_LINGER -Windows.Win32.Networking.WinSock.SO_RCVTIMEO -Windows.Win32.Networking.WinSock.SO_SNDTIMEO -Windows.Win32.Networking.WinSock.SOCK_DGRAM -Windows.Win32.Networking.WinSock.SOCK_RAW -Windows.Win32.Networking.WinSock.SOCK_RDM -Windows.Win32.Networking.WinSock.SOCK_SEQPACKET -Windows.Win32.Networking.WinSock.SOCK_STREAM -Windows.Win32.Networking.WinSock.SOCKADDR -Windows.Win32.Networking.WinSock.SOCKADDR_STORAGE -Windows.Win32.Networking.WinSock.SOCKADDR_UN -Windows.Win32.Networking.WinSock.SOCKET -Windows.Win32.Networking.WinSock.SOCKET_ERROR -Windows.Win32.Networking.WinSock.SOL_SOCKET -Windows.Win32.Networking.WinSock.TCP_NODELAY -Windows.Win32.Networking.WinSock.TIMEVAL -Windows.Win32.Networking.WinSock.WINSOCK_SHUTDOWN_HOW -Windows.Win32.Networking.WinSock.WINSOCK_SOCKET_TYPE -Windows.Win32.Networking.WinSock.WSA_E_CANCELLED -Windows.Win32.Networking.WinSock.WSA_E_NO_MORE -Windows.Win32.Networking.WinSock.WSA_ERROR -Windows.Win32.Networking.WinSock.WSA_FLAG_NO_HANDLE_INHERIT -Windows.Win32.Networking.WinSock.WSA_FLAG_OVERLAPPED -Windows.Win32.Networking.WinSock.WSA_INVALID_HANDLE -Windows.Win32.Networking.WinSock.WSA_INVALID_PARAMETER -Windows.Win32.Networking.WinSock.WSA_IO_INCOMPLETE -Windows.Win32.Networking.WinSock.WSA_IO_PENDING -Windows.Win32.Networking.WinSock.WSA_IPSEC_NAME_POLICY_ERROR -Windows.Win32.Networking.WinSock.WSA_NOT_ENOUGH_MEMORY -Windows.Win32.Networking.WinSock.WSA_OPERATION_ABORTED -Windows.Win32.Networking.WinSock.WSA_QOS_ADMISSION_FAILURE -Windows.Win32.Networking.WinSock.WSA_QOS_BAD_OBJECT -Windows.Win32.Networking.WinSock.WSA_QOS_BAD_STYLE -Windows.Win32.Networking.WinSock.WSA_QOS_EFILTERCOUNT -Windows.Win32.Networking.WinSock.WSA_QOS_EFILTERSTYLE -Windows.Win32.Networking.WinSock.WSA_QOS_EFILTERTYPE -Windows.Win32.Networking.WinSock.WSA_QOS_EFLOWCOUNT -Windows.Win32.Networking.WinSock.WSA_QOS_EFLOWDESC -Windows.Win32.Networking.WinSock.WSA_QOS_EFLOWSPEC -Windows.Win32.Networking.WinSock.WSA_QOS_EOBJLENGTH -Windows.Win32.Networking.WinSock.WSA_QOS_EPOLICYOBJ -Windows.Win32.Networking.WinSock.WSA_QOS_EPROVSPECBUF -Windows.Win32.Networking.WinSock.WSA_QOS_EPSFILTERSPEC -Windows.Win32.Networking.WinSock.WSA_QOS_EPSFLOWSPEC -Windows.Win32.Networking.WinSock.WSA_QOS_ESDMODEOBJ -Windows.Win32.Networking.WinSock.WSA_QOS_ESERVICETYPE -Windows.Win32.Networking.WinSock.WSA_QOS_ESHAPERATEOBJ -Windows.Win32.Networking.WinSock.WSA_QOS_EUNKOWNPSOBJ -Windows.Win32.Networking.WinSock.WSA_QOS_GENERIC_ERROR -Windows.Win32.Networking.WinSock.WSA_QOS_NO_RECEIVERS -Windows.Win32.Networking.WinSock.WSA_QOS_NO_SENDERS -Windows.Win32.Networking.WinSock.WSA_QOS_POLICY_FAILURE -Windows.Win32.Networking.WinSock.WSA_QOS_RECEIVERS -Windows.Win32.Networking.WinSock.WSA_QOS_REQUEST_CONFIRMED -Windows.Win32.Networking.WinSock.WSA_QOS_RESERVED_PETYPE -Windows.Win32.Networking.WinSock.WSA_QOS_SENDERS -Windows.Win32.Networking.WinSock.WSA_QOS_TRAFFIC_CTRL_ERROR -Windows.Win32.Networking.WinSock.WSA_SECURE_HOST_NOT_FOUND -Windows.Win32.Networking.WinSock.WSA_WAIT_EVENT_0 -Windows.Win32.Networking.WinSock.WSA_WAIT_IO_COMPLETION -Windows.Win32.Networking.WinSock.WSABASEERR -Windows.Win32.Networking.WinSock.WSABUF -Windows.Win32.Networking.WinSock.WSACleanup -Windows.Win32.Networking.WinSock.WSADATA -Windows.Win32.Networking.WinSock.WSADuplicateSocketW -Windows.Win32.Networking.WinSock.WSAEACCES -Windows.Win32.Networking.WinSock.WSAEADDRINUSE -Windows.Win32.Networking.WinSock.WSAEADDRNOTAVAIL -Windows.Win32.Networking.WinSock.WSAEAFNOSUPPORT -Windows.Win32.Networking.WinSock.WSAEALREADY -Windows.Win32.Networking.WinSock.WSAEBADF -Windows.Win32.Networking.WinSock.WSAECANCELLED -Windows.Win32.Networking.WinSock.WSAECONNABORTED -Windows.Win32.Networking.WinSock.WSAECONNREFUSED -Windows.Win32.Networking.WinSock.WSAECONNRESET -Windows.Win32.Networking.WinSock.WSAEDESTADDRREQ -Windows.Win32.Networking.WinSock.WSAEDISCON -Windows.Win32.Networking.WinSock.WSAEDQUOT -Windows.Win32.Networking.WinSock.WSAEFAULT -Windows.Win32.Networking.WinSock.WSAEHOSTDOWN -Windows.Win32.Networking.WinSock.WSAEHOSTUNREACH -Windows.Win32.Networking.WinSock.WSAEINPROGRESS -Windows.Win32.Networking.WinSock.WSAEINTR -Windows.Win32.Networking.WinSock.WSAEINVAL -Windows.Win32.Networking.WinSock.WSAEINVALIDPROCTABLE -Windows.Win32.Networking.WinSock.WSAEINVALIDPROVIDER -Windows.Win32.Networking.WinSock.WSAEISCONN -Windows.Win32.Networking.WinSock.WSAELOOP -Windows.Win32.Networking.WinSock.WSAEMFILE -Windows.Win32.Networking.WinSock.WSAEMSGSIZE -Windows.Win32.Networking.WinSock.WSAENAMETOOLONG -Windows.Win32.Networking.WinSock.WSAENETDOWN -Windows.Win32.Networking.WinSock.WSAENETRESET -Windows.Win32.Networking.WinSock.WSAENETUNREACH -Windows.Win32.Networking.WinSock.WSAENOBUFS -Windows.Win32.Networking.WinSock.WSAENOMORE -Windows.Win32.Networking.WinSock.WSAENOPROTOOPT -Windows.Win32.Networking.WinSock.WSAENOTCONN -Windows.Win32.Networking.WinSock.WSAENOTEMPTY -Windows.Win32.Networking.WinSock.WSAENOTSOCK -Windows.Win32.Networking.WinSock.WSAEOPNOTSUPP -Windows.Win32.Networking.WinSock.WSAEPFNOSUPPORT -Windows.Win32.Networking.WinSock.WSAEPROCLIM -Windows.Win32.Networking.WinSock.WSAEPROTONOSUPPORT -Windows.Win32.Networking.WinSock.WSAEPROTOTYPE -Windows.Win32.Networking.WinSock.WSAEPROVIDERFAILEDINIT -Windows.Win32.Networking.WinSock.WSAEREFUSED -Windows.Win32.Networking.WinSock.WSAEREMOTE -Windows.Win32.Networking.WinSock.WSAESHUTDOWN -Windows.Win32.Networking.WinSock.WSAESOCKTNOSUPPORT -Windows.Win32.Networking.WinSock.WSAESTALE -Windows.Win32.Networking.WinSock.WSAETIMEDOUT -Windows.Win32.Networking.WinSock.WSAETOOMANYREFS -Windows.Win32.Networking.WinSock.WSAEUSERS -Windows.Win32.Networking.WinSock.WSAEWOULDBLOCK -Windows.Win32.Networking.WinSock.WSAGetLastError -Windows.Win32.Networking.WinSock.WSAHOST_NOT_FOUND -Windows.Win32.Networking.WinSock.WSANO_DATA -Windows.Win32.Networking.WinSock.WSANO_RECOVERY -Windows.Win32.Networking.WinSock.WSANOTINITIALISED -Windows.Win32.Networking.WinSock.WSAPROTOCOL_INFOW -Windows.Win32.Networking.WinSock.WSAPROTOCOLCHAIN -Windows.Win32.Networking.WinSock.WSARecv -Windows.Win32.Networking.WinSock.WSASend -Windows.Win32.Networking.WinSock.WSASERVICE_NOT_FOUND -Windows.Win32.Networking.WinSock.WSASocketW -Windows.Win32.Networking.WinSock.WSAStartup -Windows.Win32.Networking.WinSock.WSASYSCALLFAILURE -Windows.Win32.Networking.WinSock.WSASYSNOTREADY -Windows.Win32.Networking.WinSock.WSATRY_AGAIN -Windows.Win32.Networking.WinSock.WSATYPE_NOT_FOUND -Windows.Win32.Networking.WinSock.WSAVERNOTSUPPORTED -Windows.Win32.Security.Authentication.Identity.RtlGenRandom -Windows.Win32.Security.SECURITY_ATTRIBUTES -Windows.Win32.Security.TOKEN_ACCESS_MASK -Windows.Win32.Security.TOKEN_ACCESS_PSEUDO_HANDLE -Windows.Win32.Security.TOKEN_ACCESS_PSEUDO_HANDLE_WIN8 -Windows.Win32.Security.TOKEN_ACCESS_SYSTEM_SECURITY -Windows.Win32.Security.TOKEN_ADJUST_DEFAULT -Windows.Win32.Security.TOKEN_ADJUST_GROUPS -Windows.Win32.Security.TOKEN_ADJUST_PRIVILEGES -Windows.Win32.Security.TOKEN_ADJUST_SESSIONID -Windows.Win32.Security.TOKEN_ALL_ACCESS -Windows.Win32.Security.TOKEN_ASSIGN_PRIMARY -Windows.Win32.Security.TOKEN_DELETE -Windows.Win32.Security.TOKEN_DUPLICATE -Windows.Win32.Security.TOKEN_EXECUTE -Windows.Win32.Security.TOKEN_IMPERSONATE -Windows.Win32.Security.TOKEN_QUERY -Windows.Win32.Security.TOKEN_QUERY_SOURCE -Windows.Win32.Security.TOKEN_READ -Windows.Win32.Security.TOKEN_READ_CONTROL -Windows.Win32.Security.TOKEN_TRUST_CONSTRAINT_MASK -Windows.Win32.Security.TOKEN_WRITE -Windows.Win32.Security.TOKEN_WRITE_DAC -Windows.Win32.Security.TOKEN_WRITE_OWNER -Windows.Win32.Storage.FileSystem.BY_HANDLE_FILE_INFORMATION -Windows.Win32.Storage.FileSystem.CALLBACK_CHUNK_FINISHED -Windows.Win32.Storage.FileSystem.CALLBACK_STREAM_SWITCH -Windows.Win32.Storage.FileSystem.CopyFileExW -Windows.Win32.Storage.FileSystem.CREATE_ALWAYS -Windows.Win32.Storage.FileSystem.CREATE_NEW -Windows.Win32.Storage.FileSystem.CreateDirectoryW -Windows.Win32.Storage.FileSystem.CreateFileW -Windows.Win32.Storage.FileSystem.CreateHardLinkW -Windows.Win32.Storage.FileSystem.CreateSymbolicLinkW -Windows.Win32.Storage.FileSystem.DELETE -Windows.Win32.Storage.FileSystem.DeleteFileW -Windows.Win32.Storage.FileSystem.FILE_ACCESS_RIGHTS -Windows.Win32.Storage.FileSystem.FILE_ADD_FILE -Windows.Win32.Storage.FileSystem.FILE_ADD_SUBDIRECTORY -Windows.Win32.Storage.FileSystem.FILE_ALL_ACCESS -Windows.Win32.Storage.FileSystem.FILE_ALLOCATION_INFO -Windows.Win32.Storage.FileSystem.FILE_APPEND_DATA -Windows.Win32.Storage.FileSystem.FILE_ATTRIBUTE_ARCHIVE -Windows.Win32.Storage.FileSystem.FILE_ATTRIBUTE_COMPRESSED -Windows.Win32.Storage.FileSystem.FILE_ATTRIBUTE_DEVICE -Windows.Win32.Storage.FileSystem.FILE_ATTRIBUTE_DIRECTORY -Windows.Win32.Storage.FileSystem.FILE_ATTRIBUTE_EA -Windows.Win32.Storage.FileSystem.FILE_ATTRIBUTE_ENCRYPTED -Windows.Win32.Storage.FileSystem.FILE_ATTRIBUTE_HIDDEN -Windows.Win32.Storage.FileSystem.FILE_ATTRIBUTE_INTEGRITY_STREAM -Windows.Win32.Storage.FileSystem.FILE_ATTRIBUTE_NO_SCRUB_DATA -Windows.Win32.Storage.FileSystem.FILE_ATTRIBUTE_NORMAL -Windows.Win32.Storage.FileSystem.FILE_ATTRIBUTE_NOT_CONTENT_INDEXED -Windows.Win32.Storage.FileSystem.FILE_ATTRIBUTE_OFFLINE -Windows.Win32.Storage.FileSystem.FILE_ATTRIBUTE_PINNED -Windows.Win32.Storage.FileSystem.FILE_ATTRIBUTE_READONLY -Windows.Win32.Storage.FileSystem.FILE_ATTRIBUTE_RECALL_ON_DATA_ACCESS -Windows.Win32.Storage.FileSystem.FILE_ATTRIBUTE_RECALL_ON_OPEN -Windows.Win32.Storage.FileSystem.FILE_ATTRIBUTE_REPARSE_POINT -Windows.Win32.Storage.FileSystem.FILE_ATTRIBUTE_SPARSE_FILE -Windows.Win32.Storage.FileSystem.FILE_ATTRIBUTE_SYSTEM -Windows.Win32.Storage.FileSystem.FILE_ATTRIBUTE_TAG_INFO -Windows.Win32.Storage.FileSystem.FILE_ATTRIBUTE_TEMPORARY -Windows.Win32.Storage.FileSystem.FILE_ATTRIBUTE_UNPINNED -Windows.Win32.Storage.FileSystem.FILE_ATTRIBUTE_VIRTUAL -Windows.Win32.Storage.FileSystem.FILE_BASIC_INFO -Windows.Win32.Storage.FileSystem.FILE_BEGIN -Windows.Win32.Storage.FileSystem.FILE_CREATE_PIPE_INSTANCE -Windows.Win32.Storage.FileSystem.FILE_CREATION_DISPOSITION -Windows.Win32.Storage.FileSystem.FILE_CURRENT -Windows.Win32.Storage.FileSystem.FILE_DELETE_CHILD -Windows.Win32.Storage.FileSystem.FILE_DISPOSITION_FLAG_DELETE -Windows.Win32.Storage.FileSystem.FILE_DISPOSITION_FLAG_DO_NOT_DELETE -Windows.Win32.Storage.FileSystem.FILE_DISPOSITION_FLAG_FORCE_IMAGE_SECTION_CHECK -Windows.Win32.Storage.FileSystem.FILE_DISPOSITION_FLAG_IGNORE_READONLY_ATTRIBUTE -Windows.Win32.Storage.FileSystem.FILE_DISPOSITION_FLAG_ON_CLOSE -Windows.Win32.Storage.FileSystem.FILE_DISPOSITION_FLAG_POSIX_SEMANTICS -Windows.Win32.Storage.FileSystem.FILE_DISPOSITION_INFO -Windows.Win32.Storage.FileSystem.FILE_DISPOSITION_INFO_EX -Windows.Win32.Storage.FileSystem.FILE_DISPOSITION_INFO_EX_FLAGS -Windows.Win32.Storage.FileSystem.FILE_END -Windows.Win32.Storage.FileSystem.FILE_END_OF_FILE_INFO -Windows.Win32.Storage.FileSystem.FILE_EXECUTE -Windows.Win32.Storage.FileSystem.FILE_FLAG_BACKUP_SEMANTICS -Windows.Win32.Storage.FileSystem.FILE_FLAG_DELETE_ON_CLOSE -Windows.Win32.Storage.FileSystem.FILE_FLAG_FIRST_PIPE_INSTANCE -Windows.Win32.Storage.FileSystem.FILE_FLAG_NO_BUFFERING -Windows.Win32.Storage.FileSystem.FILE_FLAG_OPEN_NO_RECALL -Windows.Win32.Storage.FileSystem.FILE_FLAG_OPEN_REPARSE_POINT -Windows.Win32.Storage.FileSystem.FILE_FLAG_OVERLAPPED -Windows.Win32.Storage.FileSystem.FILE_FLAG_POSIX_SEMANTICS -Windows.Win32.Storage.FileSystem.FILE_FLAG_RANDOM_ACCESS -Windows.Win32.Storage.FileSystem.FILE_FLAG_SEQUENTIAL_SCAN -Windows.Win32.Storage.FileSystem.FILE_FLAG_SESSION_AWARE -Windows.Win32.Storage.FileSystem.FILE_FLAG_WRITE_THROUGH -Windows.Win32.Storage.FileSystem.FILE_FLAGS_AND_ATTRIBUTES -Windows.Win32.Storage.FileSystem.FILE_GENERIC_EXECUTE -Windows.Win32.Storage.FileSystem.FILE_GENERIC_READ -Windows.Win32.Storage.FileSystem.FILE_GENERIC_WRITE -Windows.Win32.Storage.FileSystem.FILE_ID_BOTH_DIR_INFO -Windows.Win32.Storage.FileSystem.FILE_INFO_BY_HANDLE_CLASS -Windows.Win32.Storage.FileSystem.FILE_IO_PRIORITY_HINT_INFO -Windows.Win32.Storage.FileSystem.FILE_LIST_DIRECTORY -Windows.Win32.Storage.FileSystem.FILE_NAME_NORMALIZED -Windows.Win32.Storage.FileSystem.FILE_NAME_OPENED -Windows.Win32.Storage.FileSystem.FILE_READ_ATTRIBUTES -Windows.Win32.Storage.FileSystem.FILE_READ_DATA -Windows.Win32.Storage.FileSystem.FILE_READ_EA -Windows.Win32.Storage.FileSystem.FILE_RENAME_INFO -Windows.Win32.Storage.FileSystem.FILE_SHARE_DELETE -Windows.Win32.Storage.FileSystem.FILE_SHARE_MODE -Windows.Win32.Storage.FileSystem.FILE_SHARE_NONE -Windows.Win32.Storage.FileSystem.FILE_SHARE_READ -Windows.Win32.Storage.FileSystem.FILE_SHARE_WRITE -Windows.Win32.Storage.FileSystem.FILE_STANDARD_INFO -Windows.Win32.Storage.FileSystem.FILE_TRAVERSE -Windows.Win32.Storage.FileSystem.FILE_TYPE -Windows.Win32.Storage.FileSystem.FILE_TYPE_CHAR -Windows.Win32.Storage.FileSystem.FILE_TYPE_DISK -Windows.Win32.Storage.FileSystem.FILE_TYPE_PIPE -Windows.Win32.Storage.FileSystem.FILE_TYPE_REMOTE -Windows.Win32.Storage.FileSystem.FILE_TYPE_UNKNOWN -Windows.Win32.Storage.FileSystem.FILE_WRITE_ATTRIBUTES -Windows.Win32.Storage.FileSystem.FILE_WRITE_DATA -Windows.Win32.Storage.FileSystem.FILE_WRITE_EA -Windows.Win32.Storage.FileSystem.FileAlignmentInfo -Windows.Win32.Storage.FileSystem.FileAllocationInfo -Windows.Win32.Storage.FileSystem.FileAttributeTagInfo -Windows.Win32.Storage.FileSystem.FileBasicInfo -Windows.Win32.Storage.FileSystem.FileCaseSensitiveInfo -Windows.Win32.Storage.FileSystem.FileCompressionInfo -Windows.Win32.Storage.FileSystem.FileDispositionInfo -Windows.Win32.Storage.FileSystem.FileDispositionInfoEx -Windows.Win32.Storage.FileSystem.FileEndOfFileInfo -Windows.Win32.Storage.FileSystem.FileFullDirectoryInfo -Windows.Win32.Storage.FileSystem.FileFullDirectoryRestartInfo -Windows.Win32.Storage.FileSystem.FileIdBothDirectoryInfo -Windows.Win32.Storage.FileSystem.FileIdBothDirectoryRestartInfo -Windows.Win32.Storage.FileSystem.FileIdExtdDirectoryInfo -Windows.Win32.Storage.FileSystem.FileIdExtdDirectoryRestartInfo -Windows.Win32.Storage.FileSystem.FileIdInfo -Windows.Win32.Storage.FileSystem.FileIoPriorityHintInfo -Windows.Win32.Storage.FileSystem.FileNameInfo -Windows.Win32.Storage.FileSystem.FileNormalizedNameInfo -Windows.Win32.Storage.FileSystem.FileRemoteProtocolInfo -Windows.Win32.Storage.FileSystem.FileRenameInfo -Windows.Win32.Storage.FileSystem.FileRenameInfoEx -Windows.Win32.Storage.FileSystem.FileStandardInfo -Windows.Win32.Storage.FileSystem.FileStorageInfo -Windows.Win32.Storage.FileSystem.FileStreamInfo -Windows.Win32.Storage.FileSystem.FindClose -Windows.Win32.Storage.FileSystem.FindExInfoBasic -Windows.Win32.Storage.FileSystem.FindExSearchNameMatch -Windows.Win32.Storage.FileSystem.FindFirstFileExW -Windows.Win32.Storage.FileSystem.FindNextFileW -Windows.Win32.Storage.FileSystem.FlushFileBuffers -Windows.Win32.Storage.FileSystem.GetFileAttributesW -Windows.Win32.Storage.FileSystem.GetFileInformationByHandle -Windows.Win32.Storage.FileSystem.GetFileInformationByHandleEx -Windows.Win32.Storage.FileSystem.GetFileType -Windows.Win32.Storage.FileSystem.GETFINALPATHNAMEBYHANDLE_FLAGS -Windows.Win32.Storage.FileSystem.GetFinalPathNameByHandleW -Windows.Win32.Storage.FileSystem.GetFullPathNameW -Windows.Win32.Storage.FileSystem.GetTempPathW -Windows.Win32.Storage.FileSystem.INVALID_FILE_ATTRIBUTES -Windows.Win32.Storage.FileSystem.LOCKFILE_EXCLUSIVE_LOCK -Windows.Win32.Storage.FileSystem.LOCKFILE_FAIL_IMMEDIATELY -Windows.Win32.Storage.FileSystem.LockFileEx -Windows.Win32.Storage.FileSystem.LPPROGRESS_ROUTINE -Windows.Win32.Storage.FileSystem.LPPROGRESS_ROUTINE_CALLBACK_REASON -Windows.Win32.Storage.FileSystem.MAXIMUM_REPARSE_DATA_BUFFER_SIZE -Windows.Win32.Storage.FileSystem.MaximumFileInfoByHandleClass -Windows.Win32.Storage.FileSystem.MOVE_FILE_FLAGS -Windows.Win32.Storage.FileSystem.MOVEFILE_COPY_ALLOWED -Windows.Win32.Storage.FileSystem.MOVEFILE_CREATE_HARDLINK -Windows.Win32.Storage.FileSystem.MOVEFILE_DELAY_UNTIL_REBOOT -Windows.Win32.Storage.FileSystem.MOVEFILE_FAIL_IF_NOT_TRACKABLE -Windows.Win32.Storage.FileSystem.MOVEFILE_REPLACE_EXISTING -Windows.Win32.Storage.FileSystem.MOVEFILE_WRITE_THROUGH -Windows.Win32.Storage.FileSystem.MoveFileExW -Windows.Win32.Storage.FileSystem.OPEN_ALWAYS -Windows.Win32.Storage.FileSystem.OPEN_EXISTING -Windows.Win32.Storage.FileSystem.PIPE_ACCESS_DUPLEX -Windows.Win32.Storage.FileSystem.PIPE_ACCESS_INBOUND -Windows.Win32.Storage.FileSystem.PIPE_ACCESS_OUTBOUND -Windows.Win32.Storage.FileSystem.READ_CONTROL -Windows.Win32.Storage.FileSystem.ReadFile -Windows.Win32.Storage.FileSystem.ReadFileEx -Windows.Win32.Storage.FileSystem.RemoveDirectoryW -Windows.Win32.Storage.FileSystem.SECURITY_ANONYMOUS -Windows.Win32.Storage.FileSystem.SECURITY_CONTEXT_TRACKING -Windows.Win32.Storage.FileSystem.SECURITY_DELEGATION -Windows.Win32.Storage.FileSystem.SECURITY_EFFECTIVE_ONLY -Windows.Win32.Storage.FileSystem.SECURITY_IDENTIFICATION -Windows.Win32.Storage.FileSystem.SECURITY_IMPERSONATION -Windows.Win32.Storage.FileSystem.SECURITY_SQOS_PRESENT -Windows.Win32.Storage.FileSystem.SECURITY_VALID_SQOS_FLAGS -Windows.Win32.Storage.FileSystem.SET_FILE_POINTER_MOVE_METHOD -Windows.Win32.Storage.FileSystem.SetFileAttributesW -Windows.Win32.Storage.FileSystem.SetFileInformationByHandle -Windows.Win32.Storage.FileSystem.SetFilePointerEx -Windows.Win32.Storage.FileSystem.SetFileTime -Windows.Win32.Storage.FileSystem.SPECIFIC_RIGHTS_ALL -Windows.Win32.Storage.FileSystem.STANDARD_RIGHTS_ALL -Windows.Win32.Storage.FileSystem.STANDARD_RIGHTS_EXECUTE -Windows.Win32.Storage.FileSystem.STANDARD_RIGHTS_READ -Windows.Win32.Storage.FileSystem.STANDARD_RIGHTS_REQUIRED -Windows.Win32.Storage.FileSystem.STANDARD_RIGHTS_WRITE -Windows.Win32.Storage.FileSystem.SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE -Windows.Win32.Storage.FileSystem.SYMBOLIC_LINK_FLAG_DIRECTORY -Windows.Win32.Storage.FileSystem.SYMBOLIC_LINK_FLAGS -Windows.Win32.Storage.FileSystem.SYNCHRONIZE -Windows.Win32.Storage.FileSystem.TRUNCATE_EXISTING -Windows.Win32.Storage.FileSystem.UnlockFile -Windows.Win32.Storage.FileSystem.VOLUME_NAME_DOS -Windows.Win32.Storage.FileSystem.VOLUME_NAME_GUID -Windows.Win32.Storage.FileSystem.VOLUME_NAME_NONE -Windows.Win32.Storage.FileSystem.WIN32_FIND_DATAW -Windows.Win32.Storage.FileSystem.WRITE_DAC -Windows.Win32.Storage.FileSystem.WRITE_OWNER -Windows.Win32.Storage.FileSystem.WriteFileEx -Windows.Win32.System.Console.CONSOLE_MODE -Windows.Win32.System.Console.CONSOLE_READCONSOLE_CONTROL -Windows.Win32.System.Console.DISABLE_NEWLINE_AUTO_RETURN -Windows.Win32.System.Console.ENABLE_AUTO_POSITION -Windows.Win32.System.Console.ENABLE_ECHO_INPUT -Windows.Win32.System.Console.ENABLE_EXTENDED_FLAGS -Windows.Win32.System.Console.ENABLE_INSERT_MODE -Windows.Win32.System.Console.ENABLE_LINE_INPUT -Windows.Win32.System.Console.ENABLE_LVB_GRID_WORLDWIDE -Windows.Win32.System.Console.ENABLE_MOUSE_INPUT -Windows.Win32.System.Console.ENABLE_PROCESSED_INPUT -Windows.Win32.System.Console.ENABLE_PROCESSED_OUTPUT -Windows.Win32.System.Console.ENABLE_QUICK_EDIT_MODE -Windows.Win32.System.Console.ENABLE_VIRTUAL_TERMINAL_INPUT -Windows.Win32.System.Console.ENABLE_VIRTUAL_TERMINAL_PROCESSING -Windows.Win32.System.Console.ENABLE_WINDOW_INPUT -Windows.Win32.System.Console.ENABLE_WRAP_AT_EOL_OUTPUT -Windows.Win32.System.Console.GetConsoleMode -Windows.Win32.System.Console.GetConsoleOutputCP -Windows.Win32.System.Console.GetStdHandle -Windows.Win32.System.Console.ReadConsoleW -Windows.Win32.System.Console.STD_ERROR_HANDLE -Windows.Win32.System.Console.STD_HANDLE -Windows.Win32.System.Console.STD_INPUT_HANDLE -Windows.Win32.System.Console.STD_OUTPUT_HANDLE -Windows.Win32.System.Console.WriteConsoleW -Windows.Win32.System.Diagnostics.Debug.AddVectoredExceptionHandler -Windows.Win32.System.Diagnostics.Debug.ARM64_NT_NEON128 -Windows.Win32.System.Diagnostics.Debug.CONTEXT -Windows.Win32.System.Diagnostics.Debug.EXCEPTION_RECORD -Windows.Win32.System.Diagnostics.Debug.FACILITY_CODE -Windows.Win32.System.Diagnostics.Debug.FACILITY_NT_BIT -Windows.Win32.System.Diagnostics.Debug.FORMAT_MESSAGE_ALLOCATE_BUFFER -Windows.Win32.System.Diagnostics.Debug.FORMAT_MESSAGE_ARGUMENT_ARRAY -Windows.Win32.System.Diagnostics.Debug.FORMAT_MESSAGE_FROM_HMODULE -Windows.Win32.System.Diagnostics.Debug.FORMAT_MESSAGE_FROM_STRING -Windows.Win32.System.Diagnostics.Debug.FORMAT_MESSAGE_FROM_SYSTEM -Windows.Win32.System.Diagnostics.Debug.FORMAT_MESSAGE_IGNORE_INSERTS -Windows.Win32.System.Diagnostics.Debug.FORMAT_MESSAGE_OPTIONS -Windows.Win32.System.Diagnostics.Debug.FormatMessageW -Windows.Win32.System.Diagnostics.Debug.M128A Windows.Win32.System.Diagnostics.Debug.XSAVE_FORMAT -Windows.Win32.System.Environment.FreeEnvironmentStringsW -Windows.Win32.System.Environment.GetCommandLineW -Windows.Win32.System.Environment.GetCurrentDirectoryW -Windows.Win32.System.Environment.GetEnvironmentStringsW -Windows.Win32.System.Environment.GetEnvironmentVariableW -Windows.Win32.System.Environment.SetCurrentDirectoryW -Windows.Win32.System.Environment.SetEnvironmentVariableW -Windows.Win32.System.IO.CancelIo -Windows.Win32.System.IO.DeviceIoControl -Windows.Win32.System.IO.GetOverlappedResult -Windows.Win32.System.IO.LPOVERLAPPED_COMPLETION_ROUTINE -Windows.Win32.System.IO.OVERLAPPED -Windows.Win32.System.Ioctl.FSCTL_GET_REPARSE_POINT -Windows.Win32.System.Ioctl.FSCTL_SET_REPARSE_POINT -Windows.Win32.System.Kernel.EXCEPTION_DISPOSITION -Windows.Win32.System.Kernel.ExceptionCollidedUnwind -Windows.Win32.System.Kernel.ExceptionContinueExecution -Windows.Win32.System.Kernel.ExceptionContinueSearch -Windows.Win32.System.Kernel.ExceptionNestedException Windows.Win32.System.Kernel.FLOATING_SAVE_AREA -Windows.Win32.System.Kernel.OBJ_DONT_REPARSE -Windows.Win32.System.LibraryLoader.GetModuleFileNameW -Windows.Win32.System.LibraryLoader.GetModuleHandleA -Windows.Win32.System.LibraryLoader.GetModuleHandleW -Windows.Win32.System.LibraryLoader.GetProcAddress -Windows.Win32.System.Performance.QueryPerformanceCounter -Windows.Win32.System.Performance.QueryPerformanceFrequency -Windows.Win32.System.Pipes.CreateNamedPipeW -Windows.Win32.System.Pipes.CreatePipe -Windows.Win32.System.Pipes.NAMED_PIPE_MODE -Windows.Win32.System.Pipes.PIPE_ACCEPT_REMOTE_CLIENTS -Windows.Win32.System.Pipes.PIPE_CLIENT_END -Windows.Win32.System.Pipes.PIPE_NOWAIT -Windows.Win32.System.Pipes.PIPE_READMODE_BYTE -Windows.Win32.System.Pipes.PIPE_READMODE_MESSAGE -Windows.Win32.System.Pipes.PIPE_REJECT_REMOTE_CLIENTS -Windows.Win32.System.Pipes.PIPE_SERVER_END -Windows.Win32.System.Pipes.PIPE_TYPE_BYTE -Windows.Win32.System.Pipes.PIPE_TYPE_MESSAGE -Windows.Win32.System.Pipes.PIPE_WAIT -Windows.Win32.System.SystemInformation.GetSystemDirectoryW -Windows.Win32.System.SystemInformation.GetSystemInfo -Windows.Win32.System.SystemInformation.GetSystemTimeAsFileTime -Windows.Win32.System.SystemInformation.GetSystemTimePreciseAsFileTime -Windows.Win32.System.SystemInformation.GetWindowsDirectoryW -Windows.Win32.System.SystemInformation.PROCESSOR_ARCHITECTURE -Windows.Win32.System.SystemInformation.SYSTEM_INFO -Windows.Win32.System.SystemServices.DLL_PROCESS_DETACH -Windows.Win32.System.SystemServices.DLL_THREAD_DETACH -Windows.Win32.System.SystemServices.EXCEPTION_MAXIMUM_PARAMETERS -Windows.Win32.System.SystemServices.FAST_FAIL_FATAL_APP_EXIT -Windows.Win32.System.SystemServices.IO_REPARSE_TAG_MOUNT_POINT -Windows.Win32.System.SystemServices.IO_REPARSE_TAG_SYMLINK -Windows.Win32.System.Threading.ABOVE_NORMAL_PRIORITY_CLASS -Windows.Win32.System.Threading.AcquireSRWLockExclusive -Windows.Win32.System.Threading.AcquireSRWLockShared -Windows.Win32.System.Threading.ALL_PROCESSOR_GROUPS -Windows.Win32.System.Threading.BELOW_NORMAL_PRIORITY_CLASS -Windows.Win32.System.Threading.CREATE_BREAKAWAY_FROM_JOB -Windows.Win32.System.Threading.CREATE_DEFAULT_ERROR_MODE -Windows.Win32.System.Threading.CREATE_FORCEDOS -Windows.Win32.System.Threading.CREATE_IGNORE_SYSTEM_DEFAULT -Windows.Win32.System.Threading.CREATE_NEW_CONSOLE -Windows.Win32.System.Threading.CREATE_NEW_PROCESS_GROUP -Windows.Win32.System.Threading.CREATE_NO_WINDOW -Windows.Win32.System.Threading.CREATE_PRESERVE_CODE_AUTHZ_LEVEL -Windows.Win32.System.Threading.CREATE_PROTECTED_PROCESS -Windows.Win32.System.Threading.CREATE_SECURE_PROCESS -Windows.Win32.System.Threading.CREATE_SEPARATE_WOW_VDM -Windows.Win32.System.Threading.CREATE_SHARED_WOW_VDM -Windows.Win32.System.Threading.CREATE_SUSPENDED -Windows.Win32.System.Threading.CREATE_UNICODE_ENVIRONMENT -Windows.Win32.System.Threading.CREATE_WAITABLE_TIMER_HIGH_RESOLUTION -Windows.Win32.System.Threading.CREATE_WAITABLE_TIMER_MANUAL_RESET -Windows.Win32.System.Threading.CreateEventW -Windows.Win32.System.Threading.CreateProcessW -Windows.Win32.System.Threading.CreateThread -Windows.Win32.System.Threading.CreateWaitableTimerExW -Windows.Win32.System.Threading.DEBUG_ONLY_THIS_PROCESS -Windows.Win32.System.Threading.DEBUG_PROCESS -Windows.Win32.System.Threading.DeleteProcThreadAttributeList -Windows.Win32.System.Threading.DETACHED_PROCESS -Windows.Win32.System.Threading.ExitProcess -Windows.Win32.System.Threading.EXTENDED_STARTUPINFO_PRESENT -Windows.Win32.System.Threading.GetActiveProcessorCount -Windows.Win32.System.Threading.GetCurrentProcess -Windows.Win32.System.Threading.GetCurrentProcessId -Windows.Win32.System.Threading.GetCurrentThread -Windows.Win32.System.Threading.GetExitCodeProcess -Windows.Win32.System.Threading.GetProcessId -Windows.Win32.System.Threading.HIGH_PRIORITY_CLASS -Windows.Win32.System.Threading.IDLE_PRIORITY_CLASS -Windows.Win32.System.Threading.INFINITE -Windows.Win32.System.Threading.INHERIT_CALLER_PRIORITY -Windows.Win32.System.Threading.INHERIT_PARENT_AFFINITY -Windows.Win32.System.Threading.INIT_ONCE_INIT_FAILED -Windows.Win32.System.Threading.InitializeProcThreadAttributeList -Windows.Win32.System.Threading.InitOnceBeginInitialize -Windows.Win32.System.Threading.InitOnceComplete -Windows.Win32.System.Threading.LPPROC_THREAD_ATTRIBUTE_LIST -Windows.Win32.System.Threading.LPTHREAD_START_ROUTINE -Windows.Win32.System.Threading.NORMAL_PRIORITY_CLASS -Windows.Win32.System.Threading.OpenProcessToken -Windows.Win32.System.Threading.PROCESS_CREATION_FLAGS -Windows.Win32.System.Threading.PROCESS_INFORMATION -Windows.Win32.System.Threading.PROCESS_MODE_BACKGROUND_BEGIN -Windows.Win32.System.Threading.PROCESS_MODE_BACKGROUND_END -Windows.Win32.System.Threading.PROFILE_KERNEL -Windows.Win32.System.Threading.PROFILE_SERVER -Windows.Win32.System.Threading.PROFILE_USER -Windows.Win32.System.Threading.REALTIME_PRIORITY_CLASS -Windows.Win32.System.Threading.ReleaseSRWLockExclusive -Windows.Win32.System.Threading.ReleaseSRWLockShared -Windows.Win32.System.Threading.SetThreadStackGuarantee -Windows.Win32.System.Threading.SetWaitableTimer -Windows.Win32.System.Threading.Sleep -Windows.Win32.System.Threading.SleepConditionVariableSRW -Windows.Win32.System.Threading.SleepEx -Windows.Win32.System.Threading.STACK_SIZE_PARAM_IS_A_RESERVATION -Windows.Win32.System.Threading.STARTF_FORCEOFFFEEDBACK -Windows.Win32.System.Threading.STARTF_FORCEONFEEDBACK -Windows.Win32.System.Threading.STARTF_PREVENTPINNING -Windows.Win32.System.Threading.STARTF_RUNFULLSCREEN -Windows.Win32.System.Threading.STARTF_TITLEISAPPID -Windows.Win32.System.Threading.STARTF_TITLEISLINKNAME -Windows.Win32.System.Threading.STARTF_UNTRUSTEDSOURCE -Windows.Win32.System.Threading.STARTF_USECOUNTCHARS -Windows.Win32.System.Threading.STARTF_USEFILLATTRIBUTE -Windows.Win32.System.Threading.STARTF_USEHOTKEY -Windows.Win32.System.Threading.STARTF_USEPOSITION -Windows.Win32.System.Threading.STARTF_USESHOWWINDOW -Windows.Win32.System.Threading.STARTF_USESIZE -Windows.Win32.System.Threading.STARTF_USESTDHANDLES -Windows.Win32.System.Threading.STARTUPINFOEXW -Windows.Win32.System.Threading.STARTUPINFOW -Windows.Win32.System.Threading.STARTUPINFOW_FLAGS -Windows.Win32.System.Threading.SwitchToThread -Windows.Win32.System.Threading.TerminateProcess -Windows.Win32.System.Threading.THREAD_CREATE_RUN_IMMEDIATELY -Windows.Win32.System.Threading.THREAD_CREATE_SUSPENDED -Windows.Win32.System.Threading.THREAD_CREATION_FLAGS -Windows.Win32.System.Threading.TIMER_ALL_ACCESS -Windows.Win32.System.Threading.TIMER_MODIFY_STATE -Windows.Win32.System.Threading.TLS_OUT_OF_INDEXES -Windows.Win32.System.Threading.TlsAlloc -Windows.Win32.System.Threading.TlsFree -Windows.Win32.System.Threading.TlsGetValue -Windows.Win32.System.Threading.TlsSetValue -Windows.Win32.System.Threading.TryAcquireSRWLockExclusive -Windows.Win32.System.Threading.TryAcquireSRWLockShared -Windows.Win32.System.Threading.UpdateProcThreadAttribute -Windows.Win32.System.Threading.WaitForMultipleObjects -Windows.Win32.System.Threading.WaitForSingleObject -Windows.Win32.System.Threading.WakeAllConditionVariable -Windows.Win32.System.Threading.WakeConditionVariable -Windows.Win32.System.WindowsProgramming.FILE_RENAME_FLAG_POSIX_SEMANTICS -Windows.Win32.System.WindowsProgramming.FILE_RENAME_FLAG_REPLACE_IF_EXISTS -Windows.Win32.System.WindowsProgramming.PROGRESS_CONTINUE -Windows.Win32.UI.Shell.GetUserProfileDirectoryW +WINSOCK_SHUTDOWN_HOW +WINSOCK_SOCKET_TYPE +WRITE_DAC +WRITE_OWNER +WriteConsoleW +WriteFileEx +WSA_E_CANCELLED +WSA_E_NO_MORE +WSA_ERROR +WSA_FLAG_NO_HANDLE_INHERIT +WSA_FLAG_OVERLAPPED +WSA_INVALID_HANDLE +WSA_INVALID_PARAMETER +WSA_IO_INCOMPLETE +WSA_IO_PENDING +WSA_IPSEC_NAME_POLICY_ERROR +WSA_NOT_ENOUGH_MEMORY +WSA_OPERATION_ABORTED +WSA_QOS_ADMISSION_FAILURE +WSA_QOS_BAD_OBJECT +WSA_QOS_BAD_STYLE +WSA_QOS_EFILTERCOUNT +WSA_QOS_EFILTERSTYLE +WSA_QOS_EFILTERTYPE +WSA_QOS_EFLOWCOUNT +WSA_QOS_EFLOWDESC +WSA_QOS_EFLOWSPEC +WSA_QOS_EOBJLENGTH +WSA_QOS_EPOLICYOBJ +WSA_QOS_EPROVSPECBUF +WSA_QOS_EPSFILTERSPEC +WSA_QOS_EPSFLOWSPEC +WSA_QOS_ESDMODEOBJ +WSA_QOS_ESERVICETYPE +WSA_QOS_ESHAPERATEOBJ +WSA_QOS_EUNKOWNPSOBJ +WSA_QOS_GENERIC_ERROR +WSA_QOS_NO_RECEIVERS +WSA_QOS_NO_SENDERS +WSA_QOS_POLICY_FAILURE +WSA_QOS_RECEIVERS +WSA_QOS_REQUEST_CONFIRMED +WSA_QOS_RESERVED_PETYPE +WSA_QOS_SENDERS +WSA_QOS_TRAFFIC_CTRL_ERROR +WSA_SECURE_HOST_NOT_FOUND +WSA_WAIT_EVENT_0 +WSA_WAIT_IO_COMPLETION +WSABASEERR +WSABUF +WSACleanup +WSADATA +WSADuplicateSocketW +WSAEACCES +WSAEADDRINUSE +WSAEADDRNOTAVAIL +WSAEAFNOSUPPORT +WSAEALREADY +WSAEBADF +WSAECANCELLED +WSAECONNABORTED +WSAECONNREFUSED +WSAECONNRESET +WSAEDESTADDRREQ +WSAEDISCON +WSAEDQUOT +WSAEFAULT +WSAEHOSTDOWN +WSAEHOSTUNREACH +WSAEINPROGRESS +WSAEINTR +WSAEINVAL +WSAEINVALIDPROCTABLE +WSAEINVALIDPROVIDER +WSAEISCONN +WSAELOOP +WSAEMFILE +WSAEMSGSIZE +WSAENAMETOOLONG +WSAENETDOWN +WSAENETRESET +WSAENETUNREACH +WSAENOBUFS +WSAENOMORE +WSAENOPROTOOPT +WSAENOTCONN +WSAENOTEMPTY +WSAENOTSOCK +WSAEOPNOTSUPP +WSAEPFNOSUPPORT +WSAEPROCLIM +WSAEPROTONOSUPPORT +WSAEPROTOTYPE +WSAEPROVIDERFAILEDINIT +WSAEREFUSED +WSAEREMOTE +WSAESHUTDOWN +WSAESOCKTNOSUPPORT +WSAESTALE +WSAETIMEDOUT +WSAETOOMANYREFS +WSAEUSERS +WSAEWOULDBLOCK +WSAGetLastError +WSAHOST_NOT_FOUND +WSANO_DATA +WSANO_RECOVERY +WSANOTINITIALISED +WSAPROTOCOL_INFOW +WSAPROTOCOLCHAIN +WSARecv +WSASend +WSASERVICE_NOT_FOUND +WSASocketW +WSAStartup +WSASYSCALLFAILURE +WSASYSNOTREADY +WSATRY_AGAIN +WSATYPE_NOT_FOUND +WSAVERNOTSUPPORTED diff --git a/std/src/sys/pal/windows/c/windows_sys.rs b/std/src/sys/pal/windows/c/windows_sys.rs index 79513d33a1ac7..1d0e89f5d0f0e 100644 --- a/std/src/sys/pal/windows/c/windows_sys.rs +++ b/std/src/sys/pal/windows/c/windows_sys.rs @@ -1,15 +1,14 @@ -// Bindings generated by `windows-bindgen` 0.58.0 +// Bindings generated by `windows-bindgen` 0.59.0 #![allow(non_snake_case, non_upper_case_globals, non_camel_case_types, dead_code, clippy::all)] -windows_targets::link!("advapi32.dll" "system" fn OpenProcessToken(processhandle : HANDLE, desiredaccess : TOKEN_ACCESS_MASK, tokenhandle : *mut HANDLE) -> BOOL); -windows_targets::link!("advapi32.dll" "system" "SystemFunction036" fn RtlGenRandom(randombuffer : *mut core::ffi::c_void, randombufferlength : u32) -> BOOLEAN); + windows_targets::link!("kernel32.dll" "system" fn AcquireSRWLockExclusive(srwlock : *mut SRWLOCK)); windows_targets::link!("kernel32.dll" "system" fn AcquireSRWLockShared(srwlock : *mut SRWLOCK)); windows_targets::link!("kernel32.dll" "system" fn AddVectoredExceptionHandler(first : u32, handler : PVECTORED_EXCEPTION_HANDLER) -> *mut core::ffi::c_void); windows_targets::link!("kernel32.dll" "system" fn CancelIo(hfile : HANDLE) -> BOOL); windows_targets::link!("kernel32.dll" "system" fn CloseHandle(hobject : HANDLE) -> BOOL); windows_targets::link!("kernel32.dll" "system" fn CompareStringOrdinal(lpstring1 : PCWSTR, cchcount1 : i32, lpstring2 : PCWSTR, cchcount2 : i32, bignorecase : BOOL) -> COMPARESTRING_RESULT); -windows_targets::link!("kernel32.dll" "system" fn CopyFileExW(lpexistingfilename : PCWSTR, lpnewfilename : PCWSTR, lpprogressroutine : LPPROGRESS_ROUTINE, lpdata : *const core::ffi::c_void, pbcancel : *mut BOOL, dwcopyflags : u32) -> BOOL); +windows_targets::link!("kernel32.dll" "system" fn CopyFileExW(lpexistingfilename : PCWSTR, lpnewfilename : PCWSTR, lpprogressroutine : LPPROGRESS_ROUTINE, lpdata : *const core::ffi::c_void, pbcancel : *mut BOOL, dwcopyflags : COPYFILE_FLAGS) -> BOOL); windows_targets::link!("kernel32.dll" "system" fn CreateDirectoryW(lppathname : PCWSTR, lpsecurityattributes : *const SECURITY_ATTRIBUTES) -> BOOL); windows_targets::link!("kernel32.dll" "system" fn CreateEventW(lpeventattributes : *const SECURITY_ATTRIBUTES, bmanualreset : BOOL, binitialstate : BOOL, lpname : PCWSTR) -> HANDLE); windows_targets::link!("kernel32.dll" "system" fn CreateFileW(lpfilename : PCWSTR, dwdesiredaccess : u32, dwsharemode : FILE_SHARE_MODE, lpsecurityattributes : *const SECURITY_ATTRIBUTES, dwcreationdisposition : FILE_CREATION_DISPOSITION, dwflagsandattributes : FILE_FLAGS_AND_ATTRIBUTES, htemplatefile : HANDLE) -> HANDLE); @@ -17,7 +16,7 @@ windows_targets::link!("kernel32.dll" "system" fn CreateHardLinkW(lpfilename : P windows_targets::link!("kernel32.dll" "system" fn CreateNamedPipeW(lpname : PCWSTR, dwopenmode : FILE_FLAGS_AND_ATTRIBUTES, dwpipemode : NAMED_PIPE_MODE, nmaxinstances : u32, noutbuffersize : u32, ninbuffersize : u32, ndefaulttimeout : u32, lpsecurityattributes : *const SECURITY_ATTRIBUTES) -> HANDLE); windows_targets::link!("kernel32.dll" "system" fn CreatePipe(hreadpipe : *mut HANDLE, hwritepipe : *mut HANDLE, lppipeattributes : *const SECURITY_ATTRIBUTES, nsize : u32) -> BOOL); windows_targets::link!("kernel32.dll" "system" fn CreateProcessW(lpapplicationname : PCWSTR, lpcommandline : PWSTR, lpprocessattributes : *const SECURITY_ATTRIBUTES, lpthreadattributes : *const SECURITY_ATTRIBUTES, binherithandles : BOOL, dwcreationflags : PROCESS_CREATION_FLAGS, lpenvironment : *const core::ffi::c_void, lpcurrentdirectory : PCWSTR, lpstartupinfo : *const STARTUPINFOW, lpprocessinformation : *mut PROCESS_INFORMATION) -> BOOL); -windows_targets::link!("kernel32.dll" "system" fn CreateSymbolicLinkW(lpsymlinkfilename : PCWSTR, lptargetfilename : PCWSTR, dwflags : SYMBOLIC_LINK_FLAGS) -> BOOLEAN); +windows_targets::link!("kernel32.dll" "system" fn CreateSymbolicLinkW(lpsymlinkfilename : PCWSTR, lptargetfilename : PCWSTR, dwflags : SYMBOLIC_LINK_FLAGS) -> bool); windows_targets::link!("kernel32.dll" "system" fn CreateThread(lpthreadattributes : *const SECURITY_ATTRIBUTES, dwstacksize : usize, lpstartaddress : LPTHREAD_START_ROUTINE, lpparameter : *const core::ffi::c_void, dwcreationflags : THREAD_CREATION_FLAGS, lpthreadid : *mut u32) -> HANDLE); windows_targets::link!("kernel32.dll" "system" fn CreateWaitableTimerExW(lptimerattributes : *const SECURITY_ATTRIBUTES, lptimername : PCWSTR, dwflags : u32, dwdesiredaccess : u32) -> HANDLE); windows_targets::link!("kernel32.dll" "system" fn DeleteFileW(lpfilename : PCWSTR) -> BOOL); @@ -61,6 +60,7 @@ windows_targets::link!("kernel32.dll" "system" fn GetSystemInfo(lpsysteminfo : * windows_targets::link!("kernel32.dll" "system" fn GetSystemTimeAsFileTime(lpsystemtimeasfiletime : *mut FILETIME)); windows_targets::link!("kernel32.dll" "system" fn GetSystemTimePreciseAsFileTime(lpsystemtimeasfiletime : *mut FILETIME)); windows_targets::link!("kernel32.dll" "system" fn GetTempPathW(nbufferlength : u32, lpbuffer : PWSTR) -> u32); +windows_targets::link!("userenv.dll" "system" fn GetUserProfileDirectoryW(htoken : HANDLE, lpprofiledir : PWSTR, lpcchsize : *mut u32) -> BOOL); windows_targets::link!("kernel32.dll" "system" fn GetWindowsDirectoryW(lpbuffer : PWSTR, usize : u32) -> u32); windows_targets::link!("kernel32.dll" "system" fn InitOnceBeginInitialize(lpinitonce : *mut INIT_ONCE, dwflags : u32, fpending : *mut BOOL, lpcontext : *mut *mut core::ffi::c_void) -> BOOL); windows_targets::link!("kernel32.dll" "system" fn InitOnceComplete(lpinitonce : *mut INIT_ONCE, dwflags : u32, lpcontext : *const core::ffi::c_void) -> BOOL); @@ -69,6 +69,11 @@ windows_targets::link!("kernel32.dll" "system" fn LocalFree(hmem : HLOCAL) -> HL windows_targets::link!("kernel32.dll" "system" fn LockFileEx(hfile : HANDLE, dwflags : LOCK_FILE_FLAGS, dwreserved : u32, nnumberofbytestolocklow : u32, nnumberofbytestolockhigh : u32, lpoverlapped : *mut OVERLAPPED) -> BOOL); windows_targets::link!("kernel32.dll" "system" fn MoveFileExW(lpexistingfilename : PCWSTR, lpnewfilename : PCWSTR, dwflags : MOVE_FILE_FLAGS) -> BOOL); windows_targets::link!("kernel32.dll" "system" fn MultiByteToWideChar(codepage : u32, dwflags : MULTI_BYTE_TO_WIDE_CHAR_FLAGS, lpmultibytestr : PCSTR, cbmultibyte : i32, lpwidecharstr : PWSTR, cchwidechar : i32) -> i32); +windows_targets::link!("ntdll.dll" "system" fn NtCreateFile(filehandle : *mut HANDLE, desiredaccess : FILE_ACCESS_RIGHTS, objectattributes : *const OBJECT_ATTRIBUTES, iostatusblock : *mut IO_STATUS_BLOCK, allocationsize : *const i64, fileattributes : FILE_FLAGS_AND_ATTRIBUTES, shareaccess : FILE_SHARE_MODE, createdisposition : NTCREATEFILE_CREATE_DISPOSITION, createoptions : NTCREATEFILE_CREATE_OPTIONS, eabuffer : *const core::ffi::c_void, ealength : u32) -> NTSTATUS); +windows_targets::link!("ntdll.dll" "system" fn NtOpenFile(filehandle : *mut HANDLE, desiredaccess : u32, objectattributes : *const OBJECT_ATTRIBUTES, iostatusblock : *mut IO_STATUS_BLOCK, shareaccess : u32, openoptions : u32) -> NTSTATUS); +windows_targets::link!("ntdll.dll" "system" fn NtReadFile(filehandle : HANDLE, event : HANDLE, apcroutine : PIO_APC_ROUTINE, apccontext : *const core::ffi::c_void, iostatusblock : *mut IO_STATUS_BLOCK, buffer : *mut core::ffi::c_void, length : u32, byteoffset : *const i64, key : *const u32) -> NTSTATUS); +windows_targets::link!("ntdll.dll" "system" fn NtWriteFile(filehandle : HANDLE, event : HANDLE, apcroutine : PIO_APC_ROUTINE, apccontext : *const core::ffi::c_void, iostatusblock : *mut IO_STATUS_BLOCK, buffer : *const core::ffi::c_void, length : u32, byteoffset : *const i64, key : *const u32) -> NTSTATUS); +windows_targets::link!("advapi32.dll" "system" fn OpenProcessToken(processhandle : HANDLE, desiredaccess : TOKEN_ACCESS_MASK, tokenhandle : *mut HANDLE) -> BOOL); windows_targets::link!("kernel32.dll" "system" fn QueryPerformanceCounter(lpperformancecount : *mut i64) -> BOOL); windows_targets::link!("kernel32.dll" "system" fn QueryPerformanceFrequency(lpfrequency : *mut i64) -> BOOL); windows_targets::link!("kernel32.dll" "system" fn ReadConsoleW(hconsoleinput : HANDLE, lpbuffer : *mut core::ffi::c_void, nnumberofcharstoread : u32, lpnumberofcharsread : *mut u32, pinputcontrol : *const CONSOLE_READCONSOLE_CONTROL) -> BOOL); @@ -77,6 +82,8 @@ windows_targets::link!("kernel32.dll" "system" fn ReadFileEx(hfile : HANDLE, lpb windows_targets::link!("kernel32.dll" "system" fn ReleaseSRWLockExclusive(srwlock : *mut SRWLOCK)); windows_targets::link!("kernel32.dll" "system" fn ReleaseSRWLockShared(srwlock : *mut SRWLOCK)); windows_targets::link!("kernel32.dll" "system" fn RemoveDirectoryW(lppathname : PCWSTR) -> BOOL); +windows_targets::link!("advapi32.dll" "system" "SystemFunction036" fn RtlGenRandom(randombuffer : *mut core::ffi::c_void, randombufferlength : u32) -> bool); +windows_targets::link!("ntdll.dll" "system" fn RtlNtStatusToDosError(status : NTSTATUS) -> u32); windows_targets::link!("kernel32.dll" "system" fn SetCurrentDirectoryW(lppathname : PCWSTR) -> BOOL); windows_targets::link!("kernel32.dll" "system" fn SetEnvironmentVariableW(lpname : PCWSTR, lpvalue : PCWSTR) -> BOOL); windows_targets::link!("kernel32.dll" "system" fn SetFileAttributesW(lpfilename : PCWSTR, dwfileattributes : FILE_FLAGS_AND_ATTRIBUTES) -> BOOL); @@ -96,23 +103,10 @@ windows_targets::link!("kernel32.dll" "system" fn TlsAlloc() -> u32); windows_targets::link!("kernel32.dll" "system" fn TlsFree(dwtlsindex : u32) -> BOOL); windows_targets::link!("kernel32.dll" "system" fn TlsGetValue(dwtlsindex : u32) -> *mut core::ffi::c_void); windows_targets::link!("kernel32.dll" "system" fn TlsSetValue(dwtlsindex : u32, lptlsvalue : *const core::ffi::c_void) -> BOOL); -windows_targets::link!("kernel32.dll" "system" fn TryAcquireSRWLockExclusive(srwlock : *mut SRWLOCK) -> BOOLEAN); -windows_targets::link!("kernel32.dll" "system" fn TryAcquireSRWLockShared(srwlock : *mut SRWLOCK) -> BOOLEAN); +windows_targets::link!("kernel32.dll" "system" fn TryAcquireSRWLockExclusive(srwlock : *mut SRWLOCK) -> bool); +windows_targets::link!("kernel32.dll" "system" fn TryAcquireSRWLockShared(srwlock : *mut SRWLOCK) -> bool); windows_targets::link!("kernel32.dll" "system" fn UnlockFile(hfile : HANDLE, dwfileoffsetlow : u32, dwfileoffsethigh : u32, nnumberofbytestounlocklow : u32, nnumberofbytestounlockhigh : u32) -> BOOL); windows_targets::link!("kernel32.dll" "system" fn UpdateProcThreadAttribute(lpattributelist : LPPROC_THREAD_ATTRIBUTE_LIST, dwflags : u32, attribute : usize, lpvalue : *const core::ffi::c_void, cbsize : usize, lppreviousvalue : *mut core::ffi::c_void, lpreturnsize : *const usize) -> BOOL); -windows_targets::link!("kernel32.dll" "system" fn WaitForMultipleObjects(ncount : u32, lphandles : *const HANDLE, bwaitall : BOOL, dwmilliseconds : u32) -> WAIT_EVENT); -windows_targets::link!("kernel32.dll" "system" fn WaitForSingleObject(hhandle : HANDLE, dwmilliseconds : u32) -> WAIT_EVENT); -windows_targets::link!("kernel32.dll" "system" fn WakeAllConditionVariable(conditionvariable : *mut CONDITION_VARIABLE)); -windows_targets::link!("kernel32.dll" "system" fn WakeConditionVariable(conditionvariable : *mut CONDITION_VARIABLE)); -windows_targets::link!("kernel32.dll" "system" fn WideCharToMultiByte(codepage : u32, dwflags : u32, lpwidecharstr : PCWSTR, cchwidechar : i32, lpmultibytestr : PSTR, cbmultibyte : i32, lpdefaultchar : PCSTR, lpuseddefaultchar : *mut BOOL) -> i32); -windows_targets::link!("kernel32.dll" "system" fn WriteConsoleW(hconsoleoutput : HANDLE, lpbuffer : PCWSTR, nnumberofcharstowrite : u32, lpnumberofcharswritten : *mut u32, lpreserved : *const core::ffi::c_void) -> BOOL); -windows_targets::link!("kernel32.dll" "system" fn WriteFileEx(hfile : HANDLE, lpbuffer : *const u8, nnumberofbytestowrite : u32, lpoverlapped : *mut OVERLAPPED, lpcompletionroutine : LPOVERLAPPED_COMPLETION_ROUTINE) -> BOOL); -windows_targets::link!("ntdll.dll" "system" fn NtCreateFile(filehandle : *mut HANDLE, desiredaccess : FILE_ACCESS_RIGHTS, objectattributes : *const OBJECT_ATTRIBUTES, iostatusblock : *mut IO_STATUS_BLOCK, allocationsize : *const i64, fileattributes : FILE_FLAGS_AND_ATTRIBUTES, shareaccess : FILE_SHARE_MODE, createdisposition : NTCREATEFILE_CREATE_DISPOSITION, createoptions : NTCREATEFILE_CREATE_OPTIONS, eabuffer : *const core::ffi::c_void, ealength : u32) -> NTSTATUS); -windows_targets::link!("ntdll.dll" "system" fn NtOpenFile(filehandle : *mut HANDLE, desiredaccess : u32, objectattributes : *const OBJECT_ATTRIBUTES, iostatusblock : *mut IO_STATUS_BLOCK, shareaccess : u32, openoptions : u32) -> NTSTATUS); -windows_targets::link!("ntdll.dll" "system" fn NtReadFile(filehandle : HANDLE, event : HANDLE, apcroutine : PIO_APC_ROUTINE, apccontext : *const core::ffi::c_void, iostatusblock : *mut IO_STATUS_BLOCK, buffer : *mut core::ffi::c_void, length : u32, byteoffset : *const i64, key : *const u32) -> NTSTATUS); -windows_targets::link!("ntdll.dll" "system" fn NtWriteFile(filehandle : HANDLE, event : HANDLE, apcroutine : PIO_APC_ROUTINE, apccontext : *const core::ffi::c_void, iostatusblock : *mut IO_STATUS_BLOCK, buffer : *const core::ffi::c_void, length : u32, byteoffset : *const i64, key : *const u32) -> NTSTATUS); -windows_targets::link!("ntdll.dll" "system" fn RtlNtStatusToDosError(status : NTSTATUS) -> u32); -windows_targets::link!("userenv.dll" "system" fn GetUserProfileDirectoryW(htoken : HANDLE, lpprofiledir : PWSTR, lpcchsize : *mut u32) -> BOOL); windows_targets::link!("ws2_32.dll" "system" fn WSACleanup() -> i32); windows_targets::link!("ws2_32.dll" "system" fn WSADuplicateSocketW(s : SOCKET, dwprocessid : u32, lpprotocolinfo : *mut WSAPROTOCOL_INFOW) -> i32); windows_targets::link!("ws2_32.dll" "system" fn WSAGetLastError() -> WSA_ERROR); @@ -120,6 +114,13 @@ windows_targets::link!("ws2_32.dll" "system" fn WSARecv(s : SOCKET, lpbuffers : windows_targets::link!("ws2_32.dll" "system" fn WSASend(s : SOCKET, lpbuffers : *const WSABUF, dwbuffercount : u32, lpnumberofbytessent : *mut u32, dwflags : u32, lpoverlapped : *mut OVERLAPPED, lpcompletionroutine : LPWSAOVERLAPPED_COMPLETION_ROUTINE) -> i32); windows_targets::link!("ws2_32.dll" "system" fn WSASocketW(af : i32, r#type : i32, protocol : i32, lpprotocolinfo : *const WSAPROTOCOL_INFOW, g : u32, dwflags : u32) -> SOCKET); windows_targets::link!("ws2_32.dll" "system" fn WSAStartup(wversionrequested : u16, lpwsadata : *mut WSADATA) -> i32); +windows_targets::link!("kernel32.dll" "system" fn WaitForMultipleObjects(ncount : u32, lphandles : *const HANDLE, bwaitall : BOOL, dwmilliseconds : u32) -> WAIT_EVENT); +windows_targets::link!("kernel32.dll" "system" fn WaitForSingleObject(hhandle : HANDLE, dwmilliseconds : u32) -> WAIT_EVENT); +windows_targets::link!("kernel32.dll" "system" fn WakeAllConditionVariable(conditionvariable : *mut CONDITION_VARIABLE)); +windows_targets::link!("kernel32.dll" "system" fn WakeConditionVariable(conditionvariable : *mut CONDITION_VARIABLE)); +windows_targets::link!("kernel32.dll" "system" fn WideCharToMultiByte(codepage : u32, dwflags : u32, lpwidecharstr : PCWSTR, cchwidechar : i32, lpmultibytestr : PSTR, cbmultibyte : i32, lpdefaultchar : PCSTR, lpuseddefaultchar : *mut BOOL) -> i32); +windows_targets::link!("kernel32.dll" "system" fn WriteConsoleW(hconsoleoutput : HANDLE, lpbuffer : PCWSTR, nnumberofcharstowrite : u32, lpnumberofcharswritten : *mut u32, lpreserved : *const core::ffi::c_void) -> BOOL); +windows_targets::link!("kernel32.dll" "system" fn WriteFileEx(hfile : HANDLE, lpbuffer : *const u8, nnumberofbytestowrite : u32, lpoverlapped : *mut OVERLAPPED, lpcompletionroutine : LPOVERLAPPED_COMPLETION_ROUTINE) -> BOOL); windows_targets::link!("ws2_32.dll" "system" fn accept(s : SOCKET, addr : *mut SOCKADDR, addrlen : *mut i32) -> SOCKET); windows_targets::link!("ws2_32.dll" "system" fn bind(s : SOCKET, name : *const SOCKADDR, namelen : i32) -> i32); windows_targets::link!("ws2_32.dll" "system" fn closesocket(s : SOCKET) -> i32); @@ -139,6 +140,15 @@ windows_targets::link!("ws2_32.dll" "system" fn sendto(s : SOCKET, buf : PCSTR, windows_targets::link!("ws2_32.dll" "system" fn setsockopt(s : SOCKET, level : i32, optname : i32, optval : PCSTR, optlen : i32) -> i32); windows_targets::link!("ws2_32.dll" "system" fn shutdown(s : SOCKET, how : WINSOCK_SHUTDOWN_HOW) -> i32); pub const ABOVE_NORMAL_PRIORITY_CLASS: PROCESS_CREATION_FLAGS = 32768u32; +#[repr(C)] +#[derive(Clone, Copy)] +pub struct ACL { + pub AclRevision: u8, + pub Sbz1: u8, + pub AclSize: u16, + pub AceCount: u16, + pub Sbz2: u16, +} pub type ADDRESS_FAMILY = u16; #[repr(C)] #[derive(Clone, Copy)] @@ -174,7 +184,6 @@ pub struct ARM64_NT_NEON128_0 { } pub const BELOW_NORMAL_PRIORITY_CLASS: PROCESS_CREATION_FLAGS = 16384u32; pub type BOOL = i32; -pub type BOOLEAN = u8; #[repr(C)] #[derive(Clone, Copy)] pub struct BY_HANDLE_FILE_INFORMATION { @@ -207,64 +216,34 @@ pub struct CONSOLE_READCONSOLE_CONTROL { pub dwControlKeyState: u32, } #[repr(C)] -#[cfg(target_arch = "aarch64")] +#[cfg(target_arch = "x86")] #[derive(Clone, Copy)] pub struct CONTEXT { pub ContextFlags: CONTEXT_FLAGS, - pub Cpsr: u32, - pub Anonymous: CONTEXT_0, - pub Sp: u64, - pub Pc: u64, - pub V: [ARM64_NT_NEON128; 32], - pub Fpcr: u32, - pub Fpsr: u32, - pub Bcr: [u32; 8], - pub Bvr: [u64; 8], - pub Wcr: [u32; 2], - pub Wvr: [u64; 2], -} -#[repr(C)] -#[cfg(target_arch = "aarch64")] -#[derive(Clone, Copy)] -pub union CONTEXT_0 { - pub Anonymous: CONTEXT_0_0, - pub X: [u64; 31], -} -#[repr(C)] -#[cfg(target_arch = "aarch64")] -#[derive(Clone, Copy)] -pub struct CONTEXT_0_0 { - pub X0: u64, - pub X1: u64, - pub X2: u64, - pub X3: u64, - pub X4: u64, - pub X5: u64, - pub X6: u64, - pub X7: u64, - pub X8: u64, - pub X9: u64, - pub X10: u64, - pub X11: u64, - pub X12: u64, - pub X13: u64, - pub X14: u64, - pub X15: u64, - pub X16: u64, - pub X17: u64, - pub X18: u64, - pub X19: u64, - pub X20: u64, - pub X21: u64, - pub X22: u64, - pub X23: u64, - pub X24: u64, - pub X25: u64, - pub X26: u64, - pub X27: u64, - pub X28: u64, - pub Fp: u64, - pub Lr: u64, + pub Dr0: u32, + pub Dr1: u32, + pub Dr2: u32, + pub Dr3: u32, + pub Dr6: u32, + pub Dr7: u32, + pub FloatSave: FLOATING_SAVE_AREA, + pub SegGs: u32, + pub SegFs: u32, + pub SegEs: u32, + pub SegDs: u32, + pub Edi: u32, + pub Esi: u32, + pub Ebx: u32, + pub Edx: u32, + pub Ecx: u32, + pub Eax: u32, + pub Ebp: u32, + pub Eip: u32, + pub SegCs: u32, + pub EFlags: u32, + pub Esp: u32, + pub SegSs: u32, + pub ExtendedRegisters: [u8; 512], } #[repr(C)] #[cfg(any(target_arch = "arm64ec", target_arch = "x86_64"))] @@ -348,36 +327,68 @@ pub struct CONTEXT_0_0 { pub Xmm15: M128A, } #[repr(C)] -#[cfg(target_arch = "x86")] +#[cfg(target_arch = "aarch64")] #[derive(Clone, Copy)] pub struct CONTEXT { pub ContextFlags: CONTEXT_FLAGS, - pub Dr0: u32, - pub Dr1: u32, - pub Dr2: u32, - pub Dr3: u32, - pub Dr6: u32, - pub Dr7: u32, - pub FloatSave: FLOATING_SAVE_AREA, - pub SegGs: u32, - pub SegFs: u32, - pub SegEs: u32, - pub SegDs: u32, - pub Edi: u32, - pub Esi: u32, - pub Ebx: u32, - pub Edx: u32, - pub Ecx: u32, - pub Eax: u32, - pub Ebp: u32, - pub Eip: u32, - pub SegCs: u32, - pub EFlags: u32, - pub Esp: u32, - pub SegSs: u32, - pub ExtendedRegisters: [u8; 512], + pub Cpsr: u32, + pub Anonymous: CONTEXT_0, + pub Sp: u64, + pub Pc: u64, + pub V: [ARM64_NT_NEON128; 32], + pub Fpcr: u32, + pub Fpsr: u32, + pub Bcr: [u32; 8], + pub Bvr: [u64; 8], + pub Wcr: [u32; 2], + pub Wvr: [u64; 2], +} +#[repr(C)] +#[cfg(target_arch = "aarch64")] +#[derive(Clone, Copy)] +pub union CONTEXT_0 { + pub Anonymous: CONTEXT_0_0, + pub X: [u64; 31], +} +#[repr(C)] +#[cfg(target_arch = "aarch64")] +#[derive(Clone, Copy)] +pub struct CONTEXT_0_0 { + pub X0: u64, + pub X1: u64, + pub X2: u64, + pub X3: u64, + pub X4: u64, + pub X5: u64, + pub X6: u64, + pub X7: u64, + pub X8: u64, + pub X9: u64, + pub X10: u64, + pub X11: u64, + pub X12: u64, + pub X13: u64, + pub X14: u64, + pub X15: u64, + pub X16: u64, + pub X17: u64, + pub X18: u64, + pub X19: u64, + pub X20: u64, + pub X21: u64, + pub X22: u64, + pub X23: u64, + pub X24: u64, + pub X25: u64, + pub X26: u64, + pub X27: u64, + pub X28: u64, + pub Fp: u64, + pub Lr: u64, } pub type CONTEXT_FLAGS = u32; +pub type COPYFILE_FLAGS = u32; +pub type COPYPROGRESSROUTINE_PROGRESS = u32; pub const CP_UTF8: u32 = 65001u32; pub const CREATE_ALWAYS: FILE_CREATION_DISPOSITION = 2u32; pub const CREATE_BREAKAWAY_FROM_JOB: PROCESS_CREATION_FLAGS = 16777216u32; @@ -2396,7 +2407,7 @@ pub const FILE_DISPOSITION_FLAG_POSIX_SEMANTICS: FILE_DISPOSITION_INFO_EX_FLAGS #[repr(C)] #[derive(Clone, Copy)] pub struct FILE_DISPOSITION_INFO { - pub DeleteFile: BOOLEAN, + pub DeleteFile: bool, } #[repr(C)] #[derive(Clone, Copy)] @@ -2486,7 +2497,7 @@ pub struct FILE_RENAME_INFO { #[repr(C)] #[derive(Clone, Copy)] pub union FILE_RENAME_INFO_0 { - pub ReplaceIfExists: BOOLEAN, + pub ReplaceIfExists: bool, pub Flags: u32, } pub const FILE_RESERVE_OPFILTER: NTCREATEFILE_CREATE_OPTIONS = 1048576u32; @@ -2503,8 +2514,8 @@ pub struct FILE_STANDARD_INFO { pub AllocationSize: i64, pub EndOfFile: i64, pub NumberOfLinks: u32, - pub DeletePending: BOOLEAN, - pub Directory: BOOLEAN, + pub DeletePending: bool, + pub Directory: bool, } pub const FILE_SUPERSEDE: NTCREATEFILE_CREATE_DISPOSITION = 0u32; pub const FILE_SYNCHRONOUS_IO_ALERT: NTCREATEFILE_CREATE_OPTIONS = 16u32; @@ -2525,7 +2536,7 @@ pub type FINDEX_SEARCH_OPS = i32; pub type FIND_FIRST_EX_FLAGS = u32; pub const FIONBIO: i32 = -2147195266i32; #[repr(C)] -#[cfg(any(target_arch = "aarch64", target_arch = "arm64ec", target_arch = "x86_64"))] +#[cfg(target_arch = "x86")] #[derive(Clone, Copy)] pub struct FLOATING_SAVE_AREA { pub ControlWord: u32, @@ -2536,10 +2547,10 @@ pub struct FLOATING_SAVE_AREA { pub DataOffset: u32, pub DataSelector: u32, pub RegisterArea: [u8; 80], - pub Cr0NpxState: u32, + pub Spare0: u32, } #[repr(C)] -#[cfg(target_arch = "x86")] +#[cfg(any(target_arch = "aarch64", target_arch = "arm64ec", target_arch = "x86_64"))] #[derive(Clone, Copy)] pub struct FLOATING_SAVE_AREA { pub ControlWord: u32, @@ -2550,7 +2561,7 @@ pub struct FLOATING_SAVE_AREA { pub DataOffset: u32, pub DataSelector: u32, pub RegisterArea: [u8; 80], - pub Spare0: u32, + pub Cr0NpxState: u32, } pub const FORMAT_MESSAGE_ALLOCATE_BUFFER: FORMAT_MESSAGE_OPTIONS = 256u32; pub const FORMAT_MESSAGE_ARGUMENT_ARRAY: FORMAT_MESSAGE_OPTIONS = 8192u32; @@ -2618,6 +2629,7 @@ pub type HANDLE_FLAGS = u32; pub const HANDLE_FLAG_INHERIT: HANDLE_FLAGS = 1u32; pub const HANDLE_FLAG_PROTECT_FROM_CLOSE: HANDLE_FLAGS = 2u32; pub const HIGH_PRIORITY_CLASS: PROCESS_CREATION_FLAGS = 128u32; +pub type HINSTANCE = *mut core::ffi::c_void; pub type HLOCAL = *mut core::ffi::c_void; pub type HMODULE = *mut core::ffi::c_void; pub type HRESULT = i32; @@ -2771,7 +2783,7 @@ pub type LPPROGRESS_ROUTINE = Option< hsourcefile: HANDLE, hdestinationfile: HANDLE, lpdata: *const core::ffi::c_void, - ) -> u32, + ) -> COPYPROGRESSROUTINE_PROGRESS, >; pub type LPPROGRESS_ROUTINE_CALLBACK_REASON = u32; pub type LPTHREAD_START_ROUTINE = @@ -2822,11 +2834,12 @@ pub struct OBJECT_ATTRIBUTES { pub Length: u32, pub RootDirectory: HANDLE, pub ObjectName: *const UNICODE_STRING, - pub Attributes: u32, - pub SecurityDescriptor: *const core::ffi::c_void, - pub SecurityQualityOfService: *const core::ffi::c_void, + pub Attributes: OBJECT_ATTRIBUTE_FLAGS, + pub SecurityDescriptor: *const SECURITY_DESCRIPTOR, + pub SecurityQualityOfService: *const SECURITY_QUALITY_OF_SERVICE, } -pub const OBJ_DONT_REPARSE: i32 = 4096i32; +pub type OBJECT_ATTRIBUTE_FLAGS = u32; +pub const OBJ_DONT_REPARSE: OBJECT_ATTRIBUTE_FLAGS = 4096u32; pub const OPEN_ALWAYS: FILE_CREATION_DISPOSITION = 4u32; pub const OPEN_EXISTING: FILE_CREATION_DISPOSITION = 3u32; #[repr(C)] @@ -2887,7 +2900,8 @@ pub const PROCESS_MODE_BACKGROUND_END: PROCESS_CREATION_FLAGS = 2097152u32; pub const PROFILE_KERNEL: PROCESS_CREATION_FLAGS = 536870912u32; pub const PROFILE_SERVER: PROCESS_CREATION_FLAGS = 1073741824u32; pub const PROFILE_USER: PROCESS_CREATION_FLAGS = 268435456u32; -pub const PROGRESS_CONTINUE: u32 = 0u32; +pub const PROGRESS_CONTINUE: COPYPROGRESSROUTINE_PROGRESS = 0u32; +pub type PSID = *mut core::ffi::c_void; pub type PSTR = *mut u8; pub type PTIMERAPCROUTINE = Option< unsafe extern "system" fn( @@ -2914,9 +2928,30 @@ pub struct SECURITY_ATTRIBUTES { } pub const SECURITY_CONTEXT_TRACKING: FILE_FLAGS_AND_ATTRIBUTES = 262144u32; pub const SECURITY_DELEGATION: FILE_FLAGS_AND_ATTRIBUTES = 196608u32; +#[repr(C)] +#[derive(Clone, Copy)] +pub struct SECURITY_DESCRIPTOR { + pub Revision: u8, + pub Sbz1: u8, + pub Control: SECURITY_DESCRIPTOR_CONTROL, + pub Owner: PSID, + pub Group: PSID, + pub Sacl: *mut ACL, + pub Dacl: *mut ACL, +} +pub type SECURITY_DESCRIPTOR_CONTROL = u16; pub const SECURITY_EFFECTIVE_ONLY: FILE_FLAGS_AND_ATTRIBUTES = 524288u32; pub const SECURITY_IDENTIFICATION: FILE_FLAGS_AND_ATTRIBUTES = 65536u32; pub const SECURITY_IMPERSONATION: FILE_FLAGS_AND_ATTRIBUTES = 131072u32; +pub type SECURITY_IMPERSONATION_LEVEL = i32; +#[repr(C)] +#[derive(Clone, Copy)] +pub struct SECURITY_QUALITY_OF_SERVICE { + pub Length: u32, + pub ImpersonationLevel: SECURITY_IMPERSONATION_LEVEL, + pub ContextTrackingMode: u8, + pub EffectiveOnly: bool, +} pub const SECURITY_SQOS_PRESENT: FILE_FLAGS_AND_ATTRIBUTES = 1048576u32; pub const SECURITY_VALID_SQOS_FLAGS: FILE_FLAGS_AND_ATTRIBUTES = 2031616u32; pub type SEND_RECV_FLAGS = i32; @@ -3137,28 +3172,28 @@ pub struct WSABUF { pub buf: PSTR, } #[repr(C)] -#[cfg(any(target_arch = "aarch64", target_arch = "arm64ec", target_arch = "x86_64"))] +#[cfg(target_arch = "x86")] #[derive(Clone, Copy)] pub struct WSADATA { pub wVersion: u16, pub wHighVersion: u16, + pub szDescription: [i8; 257], + pub szSystemStatus: [i8; 129], pub iMaxSockets: u16, pub iMaxUdpDg: u16, pub lpVendorInfo: PSTR, - pub szDescription: [i8; 257], - pub szSystemStatus: [i8; 129], } #[repr(C)] -#[cfg(target_arch = "x86")] +#[cfg(any(target_arch = "aarch64", target_arch = "arm64ec", target_arch = "x86_64"))] #[derive(Clone, Copy)] pub struct WSADATA { pub wVersion: u16, pub wHighVersion: u16, - pub szDescription: [i8; 257], - pub szSystemStatus: [i8; 129], pub iMaxSockets: u16, pub iMaxUdpDg: u16, pub lpVendorInfo: PSTR, + pub szDescription: [i8; 257], + pub szSystemStatus: [i8; 129], } pub const WSAEACCES: WSA_ERROR = 10013i32; pub const WSAEADDRINUSE: WSA_ERROR = 10048i32; @@ -3293,7 +3328,7 @@ pub const WSA_SECURE_HOST_NOT_FOUND: WSA_ERROR = 11032i32; pub const WSA_WAIT_EVENT_0: WSA_ERROR = 0i32; pub const WSA_WAIT_IO_COMPLETION: WSA_ERROR = 192i32; #[repr(C)] -#[cfg(any(target_arch = "aarch64", target_arch = "arm64ec", target_arch = "x86_64"))] +#[cfg(target_arch = "x86")] #[derive(Clone, Copy)] pub struct XSAVE_FORMAT { pub ControlWord: u16, @@ -3310,11 +3345,11 @@ pub struct XSAVE_FORMAT { pub MxCsr: u32, pub MxCsr_Mask: u32, pub FloatRegisters: [M128A; 8], - pub XmmRegisters: [M128A; 16], - pub Reserved4: [u8; 96], + pub XmmRegisters: [M128A; 8], + pub Reserved4: [u8; 224], } #[repr(C)] -#[cfg(target_arch = "x86")] +#[cfg(any(target_arch = "aarch64", target_arch = "arm64ec", target_arch = "x86_64"))] #[derive(Clone, Copy)] pub struct XSAVE_FORMAT { pub ControlWord: u16, @@ -3331,8 +3366,8 @@ pub struct XSAVE_FORMAT { pub MxCsr: u32, pub MxCsr_Mask: u32, pub FloatRegisters: [M128A; 8], - pub XmmRegisters: [M128A; 8], - pub Reserved4: [u8; 224], + pub XmmRegisters: [M128A; 16], + pub Reserved4: [u8; 96], } #[cfg(target_arch = "arm")] diff --git a/std/src/sys/pal/windows/compat.rs b/std/src/sys/pal/windows/compat.rs index 42999da166451..2b9838437e9c1 100644 --- a/std/src/sys/pal/windows/compat.rs +++ b/std/src/sys/pal/windows/compat.rs @@ -39,7 +39,7 @@ use crate::sys::c; // See https://docs.microsoft.com/en-us/cpp/c-runtime-library/crt-initialization?view=msvc-170 #[cfg(target_vendor = "win7")] #[used] -#[link_section = ".CRT$XCT"] +#[unsafe(link_section = ".CRT$XCT")] static INIT_TABLE_ENTRY: unsafe extern "C" fn() = init; /// Preload some imported functions. diff --git a/std/src/sys/pal/windows/fs.rs b/std/src/sys/pal/windows/fs.rs index bdb55643bb101..dce5a429cb0d4 100644 --- a/std/src/sys/pal/windows/fs.rs +++ b/std/src/sys/pal/windows/fs.rs @@ -1,4 +1,4 @@ -use super::api::{self, WinError}; +use super::api::{self, WinError, set_file_information_by_handle}; use super::{IoResult, to_u16s}; use crate::alloc::{alloc, handle_alloc_error}; use crate::borrow::Cow; @@ -44,7 +44,7 @@ pub struct FileType { } pub struct ReadDir { - handle: FindNextFileHandle, + handle: Option, root: Arc, first: Option, } @@ -113,13 +113,13 @@ impl fmt::Debug for ReadDir { impl Iterator for ReadDir { type Item = io::Result; fn next(&mut self) -> Option> { - if self.handle.0 == c::INVALID_HANDLE_VALUE { + let Some(handle) = self.handle.as_ref() else { // This iterator was initialized with an `INVALID_HANDLE_VALUE` as its handle. // Simply return `None` because this is only the case when `FindFirstFileExW` in // the construction of this iterator returns `ERROR_FILE_NOT_FOUND` which means // no matchhing files can be found. return None; - } + }; if let Some(first) = self.first.take() { if let Some(e) = DirEntry::new(&self.root, &first) { return Some(Ok(e)); @@ -128,7 +128,7 @@ impl Iterator for ReadDir { unsafe { let mut wfd = mem::zeroed(); loop { - if c::FindNextFileW(self.handle.0, &mut wfd) == 0 { + if c::FindNextFileW(handle.0, &mut wfd) == 0 { match api::get_last_error() { WinError::NO_MORE_FILES => return None, WinError { code } => { @@ -319,31 +319,17 @@ impl File { && creation == c::OPEN_ALWAYS && api::get_last_error() == WinError::ALREADY_EXISTS { - unsafe { - // This first tries `FileAllocationInfo` but falls back to - // `FileEndOfFileInfo` in order to support WINE. - // If WINE gains support for FileAllocationInfo, we should - // remove the fallback. - let alloc = c::FILE_ALLOCATION_INFO { AllocationSize: 0 }; - let result = c::SetFileInformationByHandle( - handle.as_raw_handle(), - c::FileAllocationInfo, - (&raw const alloc).cast::(), - mem::size_of::() as u32, - ); - if result == 0 { + // This first tries `FileAllocationInfo` but falls back to + // `FileEndOfFileInfo` in order to support WINE. + // If WINE gains support for FileAllocationInfo, we should + // remove the fallback. + let alloc = c::FILE_ALLOCATION_INFO { AllocationSize: 0 }; + set_file_information_by_handle(handle.as_raw_handle(), &alloc) + .or_else(|_| { let eof = c::FILE_END_OF_FILE_INFO { EndOfFile: 0 }; - let result = c::SetFileInformationByHandle( - handle.as_raw_handle(), - c::FileEndOfFileInfo, - (&raw const eof).cast::(), - mem::size_of::() as u32, - ); - if result == 0 { - return Err(io::Error::last_os_error()); - } - } - } + set_file_information_by_handle(handle.as_raw_handle(), &eof) + }) + .io_result()?; } Ok(File { handle: Handle::from_inner(handle) }) } else { @@ -631,6 +617,10 @@ impl File { Ok(newpos as u64) } + pub fn tell(&self) -> io::Result { + self.seek(SeekFrom::Current(0)) + } + pub fn duplicate(&self) -> io::Result { Ok(Self { handle: self.handle.try_clone()? }) } @@ -812,7 +802,7 @@ impl File { /// will prevent anyone from opening a new handle to the file. #[allow(unused)] fn win32_delete(&self) -> Result<(), WinError> { - let info = c::FILE_DISPOSITION_INFO { DeleteFile: c::TRUE as _ }; + let info = c::FILE_DISPOSITION_INFO { DeleteFile: true }; api::set_file_information_by_handle(self.handle.as_raw_handle(), &info) } @@ -1194,7 +1184,7 @@ pub fn readdir(p: &Path) -> io::Result { if find_handle != c::INVALID_HANDLE_VALUE { Ok(ReadDir { - handle: FindNextFileHandle(find_handle), + handle: Some(FindNextFileHandle(find_handle)), root: Arc::new(root), first: Some(wfd), }) @@ -1212,11 +1202,7 @@ pub fn readdir(p: &Path) -> io::Result { // See issue #120040: https://github.com/rust-lang/rust/issues/120040. let last_error = api::get_last_error(); if last_error == WinError::FILE_NOT_FOUND { - return Ok(ReadDir { - handle: FindNextFileHandle(find_handle), - root: Arc::new(root), - first: None, - }); + return Ok(ReadDir { handle: None, root: Arc::new(root), first: None }); } // Just return the error constructed from the raw OS error if the above is not the case. @@ -1376,7 +1362,7 @@ pub fn rename(old: &Path, new: &Path) -> io::Result<()> { if let Err(err) = result { if err.raw_os_error() == Some(c::ERROR_INVALID_PARAMETER as _) { // FileRenameInfoEx and FILE_RENAME_FLAG_POSIX_SEMANTICS were added in Windows 10 1607; retry with FileRenameInfo. - file_rename_info.Anonymous.ReplaceIfExists = 1; + file_rename_info.Anonymous.ReplaceIfExists = true; cvt(unsafe { c::SetFileInformationByHandle( @@ -1472,9 +1458,7 @@ pub fn link(original: &Path, link: &Path) -> io::Result<()> { #[cfg(target_vendor = "uwp")] pub fn link(_original: &Path, _link: &Path) -> io::Result<()> { - return Err( - io::const_error!(io::ErrorKind::Unsupported, "hard link are not supported on UWP",), - ); + return Err(io::const_error!(io::ErrorKind::Unsupported, "hard link are not supported on UWP")); } pub fn stat(path: &Path) -> io::Result { diff --git a/std/src/sys/pal/windows/process.rs b/std/src/sys/pal/windows/process.rs index 9332c9b49ffb9..6eff471f38670 100644 --- a/std/src/sys/pal/windows/process.rs +++ b/std/src/sys/pal/windows/process.rs @@ -260,9 +260,10 @@ impl Command { needs_stdin: bool, proc_thread_attribute_list: Option<&ProcThreadAttributeList<'_>>, ) -> io::Result<(Process, StdioPipes)> { + let env_saw_path = self.env.have_changed_path(); let maybe_env = self.env.capture_if_changed(); - let child_paths = if let Some(env) = maybe_env.as_ref() { + let child_paths = if env_saw_path && let Some(env) = maybe_env.as_ref() { env.get(&EnvKey::new("PATH")).map(|s| s.as_os_str()) } else { None @@ -435,9 +436,7 @@ fn resolve_exe<'a>( ) -> io::Result> { // Early return if there is no filename. if exe_path.is_empty() || path::has_trailing_slash(exe_path) { - return Err( - io::const_error!(io::ErrorKind::InvalidInput, "program path has no file name",), - ); + return Err(io::const_error!(io::ErrorKind::InvalidInput, "program path has no file name")); } // Test if the file name has the `exe` extension. // This does a case-insensitive `ends_with`. diff --git a/std/src/sys/pal/windows/process/tests.rs b/std/src/sys/pal/windows/process/tests.rs index 9a1eaf42fd9a8..1377e12162f2f 100644 --- a/std/src/sys/pal/windows/process/tests.rs +++ b/std/src/sys/pal/windows/process/tests.rs @@ -33,7 +33,7 @@ fn test_thread_handle() { assert!(p.is_ok()); let mut p = p.unwrap(); - extern "system" { + unsafe extern "system" { fn ResumeThread(_: BorrowedHandle<'_>) -> u32; } unsafe { @@ -138,8 +138,10 @@ fn windows_env_unicode_case() { let mut cmd = Command::new("cmd"); cmd.env(a, "1"); cmd.env(b, "2"); - env::set_var(a, "1"); - env::set_var(b, "2"); + unsafe { + env::set_var(a, "1"); + env::set_var(b, "2"); + } for (key, value) in cmd.get_envs() { assert_eq!( diff --git a/std/src/sys/pal/windows/stack_overflow_uwp.rs b/std/src/sys/pal/windows/stack_overflow_uwp.rs index 9e9b3efaf1b14..6f1ea12fc1e06 100644 --- a/std/src/sys/pal/windows/stack_overflow_uwp.rs +++ b/std/src/sys/pal/windows/stack_overflow_uwp.rs @@ -1,4 +1,4 @@ #![cfg_attr(test, allow(dead_code))] -pub unsafe fn reserve_stack() {} -pub unsafe fn init() {} +pub fn reserve_stack() {} +pub fn init() {} diff --git a/std/src/sys/pal/windows/stdio.rs b/std/src/sys/pal/windows/stdio.rs index fd3f559ba1901..1b245991aa797 100644 --- a/std/src/sys/pal/windows/stdio.rs +++ b/std/src/sys/pal/windows/stdio.rs @@ -1,5 +1,6 @@ #![unstable(issue = "none", feature = "windows_stdio")] +use core::char::MAX_LEN_UTF8; use core::str::utf8_char_width; use super::api::{self, WinError}; @@ -426,7 +427,7 @@ fn utf16_to_utf8(utf16: &[u16], utf8: &mut [u8]) -> io::Result { impl IncompleteUtf8 { pub const fn new() -> IncompleteUtf8 { - IncompleteUtf8 { bytes: [0; 4], len: 0 } + IncompleteUtf8 { bytes: [0; MAX_LEN_UTF8], len: 0 } } } diff --git a/std/src/sys/pal/xous/os.rs b/std/src/sys/pal/xous/os.rs index b0ab01a6383d2..2c87e7d91f27d 100644 --- a/std/src/sys/pal/xous/os.rs +++ b/std/src/sys/pal/xous/os.rs @@ -37,16 +37,16 @@ mod eh_unwinding { #[cfg(not(test))] mod c_compat { use crate::os::xous::ffi::exit; - extern "C" { + unsafe extern "C" { fn main() -> u32; } - #[no_mangle] + #[unsafe(no_mangle)] pub extern "C" fn abort() { exit(1); } - #[no_mangle] + #[unsafe(no_mangle)] pub extern "C" fn _start(eh_frame: usize, params_address: usize) { #[cfg(feature = "panic_unwind")] { @@ -67,7 +67,7 @@ mod c_compat { // This function is needed by the panic runtime. The symbol is named in // pre-link args for the target specification, so keep that in sync. - #[no_mangle] + #[unsafe(no_mangle)] // NB. used by both libunwind and libpanic_abort pub extern "C" fn __rust_abort() -> ! { exit(101); diff --git a/std/src/sys/pal/zkvm/abi.rs b/std/src/sys/pal/zkvm/abi.rs index 53332d90e02c0..d000574f6844d 100644 --- a/std/src/sys/pal/zkvm/abi.rs +++ b/std/src/sys/pal/zkvm/abi.rs @@ -18,7 +18,7 @@ pub mod fileno { pub const JOURNAL: u32 = 3; } -extern "C" { +unsafe extern "C" { // Wrappers around syscalls provided by risc0-zkvm-platform: pub fn sys_halt(); pub fn sys_output(output_id: u32, output_value: u32); diff --git a/std/src/sys/pal/zkvm/stdio.rs b/std/src/sys/pal/zkvm/stdio.rs index 5f1d06dd1d78d..0bcb54744b0b6 100644 --- a/std/src/sys/pal/zkvm/stdio.rs +++ b/std/src/sys/pal/zkvm/stdio.rs @@ -1,6 +1,6 @@ use super::abi; use super::abi::fileno; -use crate::io; +use crate::io::{self, BorrowedCursor}; pub struct Stdin; pub struct Stdout; @@ -16,6 +16,14 @@ impl io::Read for Stdin { fn read(&mut self, buf: &mut [u8]) -> io::Result { Ok(unsafe { abi::sys_read(fileno::STDIN, buf.as_mut_ptr(), buf.len()) }) } + + fn read_buf(&mut self, mut buf: BorrowedCursor<'_>) -> io::Result<()> { + unsafe { + let n = abi::sys_read(fileno::STDIN, buf.as_mut().as_mut_ptr().cast(), buf.capacity()); + buf.advance_unchecked(n); + } + Ok(()) + } } impl Stdout { diff --git a/std/src/sys/personality/gcc.rs b/std/src/sys/personality/gcc.rs index 88a25caeff0df..cd2c7899f4bf1 100644 --- a/std/src/sys/personality/gcc.rs +++ b/std/src/sys/personality/gcc.rs @@ -194,7 +194,7 @@ cfg_if::cfg_if! { } } // defined in libgcc - extern "C" { + unsafe extern "C" { fn __gnu_unwind_frame( exception_object: *mut uw::_Unwind_Exception, context: *mut uw::_Unwind_Context, diff --git a/std/src/sys/random/arc4random.rs b/std/src/sys/random/arc4random.rs index 32467e9ebaa64..e1957bceb9002 100644 --- a/std/src/sys/random/arc4random.rs +++ b/std/src/sys/random/arc4random.rs @@ -25,7 +25,7 @@ use libc::arc4random_buf; target_os = "vita", // See https://github.com/vitasdk/newlib/blob/b89e5bc183b516945f9ee07eef483ecb916e45ff/newlib/libc/include/stdlib.h#L74 ))] #[cfg_attr(target_os = "haiku", link(name = "bsd"))] -extern "C" { +unsafe extern "C" { fn arc4random_buf(buf: *mut core::ffi::c_void, nbytes: libc::size_t); } diff --git a/std/src/sys/random/espidf.rs b/std/src/sys/random/espidf.rs index fd52cb5559ce5..6f48f7f1f2952 100644 --- a/std/src/sys/random/espidf.rs +++ b/std/src/sys/random/espidf.rs @@ -1,6 +1,6 @@ use crate::ffi::c_void; -extern "C" { +unsafe extern "C" { fn esp_fill_random(buf: *mut c_void, len: usize); } diff --git a/std/src/sys/random/fuchsia.rs b/std/src/sys/random/fuchsia.rs index 77d72b3c5b784..269e0d9aeeb57 100644 --- a/std/src/sys/random/fuchsia.rs +++ b/std/src/sys/random/fuchsia.rs @@ -4,7 +4,7 @@ //! . #[link(name = "zircon")] -extern "C" { +unsafe extern "C" { fn zx_cprng_draw(buffer: *mut u8, len: usize); } diff --git a/std/src/sys/random/teeos.rs b/std/src/sys/random/teeos.rs index fd6b24e19e982..6ca59cc12c98f 100644 --- a/std/src/sys/random/teeos.rs +++ b/std/src/sys/random/teeos.rs @@ -1,4 +1,4 @@ -extern "C" { +unsafe extern "C" { fn TEE_GenerateRandom(randomBuffer: *mut core::ffi::c_void, randomBufferLen: libc::size_t); } diff --git a/std/src/sys/random/windows.rs b/std/src/sys/random/windows.rs index 7566000f9e6ff..f5da637f56ca9 100644 --- a/std/src/sys/random/windows.rs +++ b/std/src/sys/random/windows.rs @@ -14,7 +14,7 @@ pub fn fill_bytes(mut bytes: &mut [u8]) { while !bytes.is_empty() { let len = bytes.len().try_into().unwrap_or(u32::MAX); let ret = unsafe { c::RtlGenRandom(bytes.as_mut_ptr().cast(), len) }; - assert_ne!(ret, 0, "failed to generate random data"); + assert!(ret, "failed to generate random data"); bytes = &mut bytes[len as usize..]; } } diff --git a/std/src/sys/sync/mutex/windows7.rs b/std/src/sys/sync/mutex/windows7.rs index 689dba10f01ed..0b57de78ba6dd 100644 --- a/std/src/sys/sync/mutex/windows7.rs +++ b/std/src/sys/sync/mutex/windows7.rs @@ -44,7 +44,7 @@ impl Mutex { #[inline] pub fn try_lock(&self) -> bool { - unsafe { c::TryAcquireSRWLockExclusive(raw(self)) != 0 } + unsafe { c::TryAcquireSRWLockExclusive(raw(self)) } } #[inline] diff --git a/std/src/sys/sync/thread_parking/darwin.rs b/std/src/sys/sync/thread_parking/darwin.rs index 0553c5e19a91f..a0d24a91e7c69 100644 --- a/std/src/sys/sync/thread_parking/darwin.rs +++ b/std/src/sys/sync/thread_parking/darwin.rs @@ -24,7 +24,7 @@ const DISPATCH_TIME_NOW: dispatch_time_t = 0; const DISPATCH_TIME_FOREVER: dispatch_time_t = !0; // Contained in libSystem.dylib, which is linked by default. -extern "C" { +unsafe extern "C" { fn dispatch_time(when: dispatch_time_t, delta: i64) -> dispatch_time_t; fn dispatch_semaphore_create(val: isize) -> dispatch_semaphore_t; fn dispatch_semaphore_wait(dsema: dispatch_semaphore_t, timeout: dispatch_time_t) -> isize; diff --git a/std/src/sys/sync/thread_parking/windows7.rs b/std/src/sys/sync/thread_parking/windows7.rs index f7585e882f055..a1a0f8427cd83 100644 --- a/std/src/sys/sync/thread_parking/windows7.rs +++ b/std/src/sys/sync/thread_parking/windows7.rs @@ -195,7 +195,7 @@ mod keyed_events { pub unsafe fn park(parker: Pin<&Parker>) { // Wait for unpark() to produce this event. - c::NtWaitForKeyedEvent(keyed_event_handle(), parker.ptr(), 0, ptr::null_mut()); + c::NtWaitForKeyedEvent(keyed_event_handle(), parker.ptr(), false, ptr::null_mut()); // Set the state back to EMPTY (from either PARKED or NOTIFIED). // Note that we don't just write EMPTY, but use swap() to also // include an acquire-ordered read to synchronize with unpark()'s @@ -218,7 +218,7 @@ mod keyed_events { // Wait for unpark() to produce this event. let unparked = - c::NtWaitForKeyedEvent(handle, parker.ptr(), 0, &mut timeout) == c::STATUS_SUCCESS; + c::NtWaitForKeyedEvent(handle, parker.ptr(), false, &mut timeout) == c::STATUS_SUCCESS; // Set the state back to EMPTY (from either PARKED or NOTIFIED). let prev_state = parker.state.swap(EMPTY, Acquire); @@ -228,7 +228,7 @@ mod keyed_events { // was set to NOTIFIED, which means we *just* missed an // unpark(), which is now blocked on us to wait for it. // Wait for it to consume the event and unblock that thread. - c::NtWaitForKeyedEvent(handle, parker.ptr(), 0, ptr::null_mut()); + c::NtWaitForKeyedEvent(handle, parker.ptr(), false, ptr::null_mut()); } } pub unsafe fn unpark(parker: Pin<&Parker>) { @@ -239,7 +239,7 @@ mod keyed_events { // To prevent this thread from blocking indefinitely in that case, // park_impl() will, after seeing the state set to NOTIFIED after // waking up, call NtWaitForKeyedEvent again to unblock us. - c::NtReleaseKeyedEvent(keyed_event_handle(), parker.ptr(), 0, ptr::null_mut()); + c::NtReleaseKeyedEvent(keyed_event_handle(), parker.ptr(), false, ptr::null_mut()); } fn keyed_event_handle() -> c::HANDLE { diff --git a/std/src/sys/thread_local/destructors/linux_like.rs b/std/src/sys/thread_local/destructors/linux_like.rs index f473dc4d79df5..817941229eefe 100644 --- a/std/src/sys/thread_local/destructors/linux_like.rs +++ b/std/src/sys/thread_local/destructors/linux_like.rs @@ -27,7 +27,7 @@ pub unsafe fn register(t: *mut u8, dtor: unsafe extern "C" fn(*mut u8)) { #[allow(non_camel_case_types)] pub struct c_int(#[allow(dead_code)] pub core::ffi::c_int); - extern "C" { + unsafe extern "C" { #[linkage = "extern_weak"] static __dso_handle: *mut u8; #[linkage = "extern_weak"] diff --git a/std/src/sys/thread_local/guard/apple.rs b/std/src/sys/thread_local/guard/apple.rs index fa25b116622fc..edcedf21e9ec6 100644 --- a/std/src/sys/thread_local/guard/apple.rs +++ b/std/src/sys/thread_local/guard/apple.rs @@ -10,7 +10,7 @@ pub fn enable() { #[thread_local] static REGISTERED: Cell = Cell::new(false); - extern "C" { + unsafe extern "C" { fn _tlv_atexit(dtor: unsafe extern "C" fn(*mut u8), arg: *mut u8); } diff --git a/std/src/sys/thread_local/guard/windows.rs b/std/src/sys/thread_local/guard/windows.rs index 1752b0e1208af..b15a0d7c0bdfb 100644 --- a/std/src/sys/thread_local/guard/windows.rs +++ b/std/src/sys/thread_local/guard/windows.rs @@ -74,7 +74,7 @@ pub fn enable() { unsafe { ptr::from_ref(&CALLBACK).read_volatile() }; } -#[link_section = ".CRT$XLB"] +#[unsafe(link_section = ".CRT$XLB")] #[cfg_attr(miri, used)] // Miri only considers explicitly `#[used]` statics for `lookup_link_section` pub static CALLBACK: unsafe extern "system" fn(*mut c_void, u32, *mut c_void) = tls_callback; diff --git a/std/src/sys/thread_local/key/unix.rs b/std/src/sys/thread_local/key/unix.rs index b4b58b3470631..93bd0d1f66850 100644 --- a/std/src/sys/thread_local/key/unix.rs +++ b/std/src/sys/thread_local/key/unix.rs @@ -8,7 +8,7 @@ mod libc { #[allow(non_camel_case_types)] pub type pthread_key_t = ffi::c_uint; - extern "C" { + unsafe extern "C" { pub fn pthread_key_create( key: *mut pthread_key_t, destructor: unsafe extern "C" fn(*mut ffi::c_void), diff --git a/std/src/sys/thread_local/key/xous.rs b/std/src/sys/thread_local/key/xous.rs index 2ab4bba7d8e98..55ac5b20e1ab0 100644 --- a/std/src/sys/thread_local/key/xous.rs +++ b/std/src/sys/thread_local/key/xous.rs @@ -51,15 +51,15 @@ const TLS_MEMORY_SIZE: usize = 4096; /// TLS keys start at `1`. Index `0` is unused #[cfg(not(test))] -#[export_name = "_ZN16__rust_internals3std3sys4xous16thread_local_key13TLS_KEY_INDEXE"] +#[unsafe(export_name = "_ZN16__rust_internals3std3sys4xous16thread_local_key13TLS_KEY_INDEXE")] static TLS_KEY_INDEX: AtomicUsize = AtomicUsize::new(1); #[cfg(not(test))] -#[export_name = "_ZN16__rust_internals3std3sys4xous16thread_local_key9DTORSE"] +#[unsafe(export_name = "_ZN16__rust_internals3std3sys4xous16thread_local_key9DTORSE")] static DTORS: AtomicPtr = AtomicPtr::new(ptr::null_mut()); #[cfg(test)] -extern "Rust" { +unsafe extern "Rust" { #[link_name = "_ZN16__rust_internals3std3sys4xous16thread_local_key13TLS_KEY_INDEXE"] static TLS_KEY_INDEX: AtomicUsize; diff --git a/std/src/sys/thread_local/os.rs b/std/src/sys/thread_local/os.rs index 00d2e30bd6036..fe6af27db3a17 100644 --- a/std/src/sys/thread_local/os.rs +++ b/std/src/sys/thread_local/os.rs @@ -28,9 +28,7 @@ pub macro thread_local_inner { // user provided type or type alias with a matching name. Please update the shadowing test // in `tests/thread.rs` if these types are renamed. unsafe { - // Inlining does not work on windows-gnu due to linking errors around - // dllimports. See https://github.com/rust-lang/rust/issues/109797. - $crate::thread::LocalKey::new(#[cfg_attr(windows, inline(never))] |init| { + $crate::thread::LocalKey::new(|init| { static VAL: $crate::thread::local_impl::Storage<$t> = $crate::thread::local_impl::Storage::new(); VAL.get(init, __init) diff --git a/std/src/sys_common/wtf8.rs b/std/src/sys_common/wtf8.rs index 6c60d901ee904..f9ec112b19747 100644 --- a/std/src/sys_common/wtf8.rs +++ b/std/src/sys_common/wtf8.rs @@ -18,7 +18,7 @@ #[cfg(test)] mod tests; -use core::char::{encode_utf8_raw, encode_utf16_raw}; +use core::char::{MAX_LEN_UTF8, MAX_LEN_UTF16, encode_utf8_raw, encode_utf16_raw}; use core::clone::CloneToUninit; use core::str::next_code_point; @@ -156,9 +156,12 @@ impl ops::DerefMut for Wtf8Buf { } } -/// Format the string with double quotes, -/// and surrogates as `\u` followed by four hexadecimal digits. -/// Example: `"a\u{D800}"` for a string with code points [U+0061, U+D800] +/// Formats the string in double quotes, with characters escaped according to +/// [`char::escape_debug`] and unpaired surrogates represented as `\u{xxxx}`, +/// where each `x` is a hexadecimal digit. +/// +/// For example, the code units [U+0061, U+D800, U+000A] are formatted as +/// `"a\u{D800}\n"`. impl fmt::Debug for Wtf8Buf { #[inline] fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { @@ -166,6 +169,18 @@ impl fmt::Debug for Wtf8Buf { } } +/// Formats the string with unpaired surrogates substituted with the replacement +/// character, U+FFFD. +impl fmt::Display for Wtf8Buf { + fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { + if let Some(s) = self.as_known_utf8() { + fmt::Display::fmt(s, formatter) + } else { + fmt::Display::fmt(&**self, formatter) + } + } +} + impl Wtf8Buf { /// Creates a new, empty WTF-8 string. #[inline] @@ -181,7 +196,7 @@ impl Wtf8Buf { /// Creates a WTF-8 string from a WTF-8 byte vec. /// - /// Since the byte vec is not checked for valid WTF-8, this functions is + /// Since the byte vec is not checked for valid WTF-8, this function is /// marked unsafe. #[inline] pub unsafe fn from_bytes_unchecked(value: Vec) -> Wtf8Buf { @@ -205,7 +220,7 @@ impl Wtf8Buf { /// Since WTF-8 is a superset of UTF-8, this always succeeds. #[inline] pub fn from_str(s: &str) -> Wtf8Buf { - Wtf8Buf { bytes: <[_]>::to_vec(s.as_bytes()), is_known_utf8: true } + Wtf8Buf { bytes: s.as_bytes().to_vec(), is_known_utf8: true } } pub fn clear(&mut self) { @@ -237,10 +252,11 @@ impl Wtf8Buf { string } - /// Copied from String::push + /// Appends the given `char` to the end of this string. /// This does **not** include the WTF-8 concatenation check or `is_known_utf8` check. + /// Copied from String::push. fn push_code_point_unchecked(&mut self, code_point: CodePoint) { - let mut bytes = [0; 4]; + let mut bytes = [0; MAX_LEN_UTF8]; let bytes = encode_utf8_raw(code_point.value, &mut bytes); self.bytes.extend_from_slice(bytes) } @@ -258,22 +274,34 @@ impl Wtf8Buf { unsafe { Wtf8::from_mut_bytes_unchecked(&mut self.bytes) } } + /// Converts the string to UTF-8 without validation, if it was created from + /// valid UTF-8. + #[inline] + fn as_known_utf8(&self) -> Option<&str> { + if self.is_known_utf8 { + // SAFETY: The buffer is known to be valid UTF-8. + Some(unsafe { str::from_utf8_unchecked(self.as_bytes()) }) + } else { + None + } + } + /// Reserves capacity for at least `additional` more bytes to be inserted /// in the given `Wtf8Buf`. /// The collection may reserve more space to avoid frequent reallocations. /// /// # Panics /// - /// Panics if the new capacity overflows `usize`. + /// Panics if the new capacity exceeds `isize::MAX` bytes. #[inline] pub fn reserve(&mut self, additional: usize) { self.bytes.reserve(additional) } - /// Tries to reserve capacity for at least `additional` more length units - /// in the given `Wtf8Buf`. The `Wtf8Buf` may reserve more space to avoid - /// frequent reallocations. After calling `try_reserve`, capacity will be - /// greater than or equal to `self.len() + additional`. Does nothing if + /// Tries to reserve capacity for at least `additional` more bytes to be + /// inserted in the given `Wtf8Buf`. The `Wtf8Buf` may reserve more space to + /// avoid frequent reallocations. After calling `try_reserve`, capacity will + /// be greater than or equal to `self.len() + additional`. Does nothing if /// capacity is already sufficient. This method preserves the contents even /// if an error occurs. /// @@ -291,8 +319,8 @@ impl Wtf8Buf { self.bytes.reserve_exact(additional) } - /// Tries to reserve the minimum capacity for exactly `additional` - /// length units in the given `Wtf8Buf`. After calling + /// Tries to reserve the minimum capacity for exactly `additional` more + /// bytes to be inserted in the given `Wtf8Buf`. After calling /// `try_reserve_exact`, capacity will be greater than or equal to /// `self.len() + additional` if it returns `Ok(())`. /// Does nothing if the capacity is already sufficient. @@ -360,7 +388,7 @@ impl Wtf8Buf { _ => { // If we'll be pushing a string containing a surrogate, we may // no longer have UTF-8. - if other.next_surrogate(0).is_some() { + if self.is_known_utf8 && other.next_surrogate(0).is_some() { self.is_known_utf8 = false; } @@ -440,22 +468,17 @@ impl Wtf8Buf { /// /// Surrogates are replaced with `"\u{FFFD}"` (the replacement character “�”) pub fn into_string_lossy(mut self) -> String { - // Fast path: If we already have UTF-8, we can return it immediately. - if self.is_known_utf8 { - return unsafe { String::from_utf8_unchecked(self.bytes) }; - } - - let mut pos = 0; - loop { - match self.next_surrogate(pos) { - Some((surrogate_pos, _)) => { - pos = surrogate_pos + 3; - self.bytes[surrogate_pos..pos] - .copy_from_slice(UTF8_REPLACEMENT_CHARACTER.as_bytes()); - } - None => return unsafe { String::from_utf8_unchecked(self.bytes) }, + if !self.is_known_utf8 { + let mut pos = 0; + while let Some((surrogate_pos, _)) = self.next_surrogate(pos) { + pos = surrogate_pos + 3; + // Surrogates and the replacement character are all 3 bytes, so + // they can substituted in-place. + self.bytes[surrogate_pos..pos] + .copy_from_slice(UTF8_REPLACEMENT_CHARACTER.as_bytes()); } } + unsafe { String::from_utf8_unchecked(self.bytes) } } /// Converts this `Wtf8Buf` into a boxed `Wtf8`. @@ -535,9 +558,9 @@ impl AsInner<[u8]> for Wtf8 { } } -/// Format the slice with double quotes, -/// and surrogates as `\u` followed by four hexadecimal digits. -/// Example: `"a\u{D800}"` for a slice with code points [U+0061, U+D800] +/// Formats the string in double quotes, with characters escaped according to +/// [`char::escape_debug`] and unpaired surrogates represented as `\u{xxxx}`, +/// where each `x` is a hexadecimal digit. impl fmt::Debug for Wtf8 { fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { fn write_str_escaped(f: &mut fmt::Formatter<'_>, s: &str) -> fmt::Result { @@ -562,6 +585,8 @@ impl fmt::Debug for Wtf8 { } } +/// Formats the string with unpaired surrogates substituted with the replacement +/// character, U+FFFD. impl fmt::Display for Wtf8 { fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { let wtf8_bytes = &self.bytes; @@ -672,9 +697,8 @@ impl Wtf8 { /// /// This only copies the data if necessary (if it contains any surrogate). pub fn to_string_lossy(&self) -> Cow<'_, str> { - let surrogate_pos = match self.next_surrogate(0) { - None => return Cow::Borrowed(unsafe { str::from_utf8_unchecked(&self.bytes) }), - Some((pos, _)) => pos, + let Some((surrogate_pos, _)) = self.next_surrogate(0) else { + return Cow::Borrowed(unsafe { str::from_utf8_unchecked(&self.bytes) }); }; let wtf8_bytes = &self.bytes; let mut utf8_bytes = Vec::with_capacity(self.len()); @@ -964,7 +988,7 @@ pub struct Wtf8CodePoints<'a> { bytes: slice::Iter<'a, u8>, } -impl<'a> Iterator for Wtf8CodePoints<'a> { +impl Iterator for Wtf8CodePoints<'_> { type Item = CodePoint; #[inline] @@ -990,7 +1014,7 @@ pub struct EncodeWide<'a> { // Copied from libunicode/u_str.rs #[stable(feature = "rust1", since = "1.0.0")] -impl<'a> Iterator for EncodeWide<'a> { +impl Iterator for EncodeWide<'_> { type Item = u16; #[inline] @@ -1001,7 +1025,7 @@ impl<'a> Iterator for EncodeWide<'a> { return Some(tmp); } - let mut buf = [0; 2]; + let mut buf = [0; MAX_LEN_UTF16]; self.code_points.next().map(|code_point| { let n = encode_utf16_raw(code_point.value, &mut buf).len(); if n == 2 { diff --git a/std/src/thread/local.rs b/std/src/thread/local.rs index ca04aa4ada497..d5a5d10205dd8 100644 --- a/std/src/thread/local.rs +++ b/std/src/thread/local.rs @@ -50,7 +50,8 @@ use crate::fmt; /// use std::cell::Cell; /// use std::thread; /// -/// thread_local!(static FOO: Cell = Cell::new(1)); +/// // explicit `const {}` block enables more efficient initialization +/// thread_local!(static FOO: Cell = const { Cell::new(1) }); /// /// assert_eq!(FOO.get(), 1); /// FOO.set(2); @@ -138,7 +139,7 @@ impl fmt::Debug for LocalKey { /// use std::cell::{Cell, RefCell}; /// /// thread_local! { -/// pub static FOO: Cell = Cell::new(1); +/// pub static FOO: Cell = const { Cell::new(1) }; /// /// static BAR: RefCell> = RefCell::new(vec![1.0, 2.0]); /// } @@ -394,7 +395,7 @@ impl LocalKey> { /// use std::cell::Cell; /// /// thread_local! { - /// static X: Cell = Cell::new(1); + /// static X: Cell = const { Cell::new(1) }; /// } /// /// assert_eq!(X.get(), 1); @@ -423,7 +424,7 @@ impl LocalKey> { /// use std::cell::Cell; /// /// thread_local! { - /// static X: Cell> = Cell::new(Some(1)); + /// static X: Cell> = const { Cell::new(Some(1)) }; /// } /// /// assert_eq!(X.take(), Some(1)); @@ -453,7 +454,7 @@ impl LocalKey> { /// use std::cell::Cell; /// /// thread_local! { - /// static X: Cell = Cell::new(1); + /// static X: Cell = const { Cell::new(1) }; /// } /// /// assert_eq!(X.replace(2), 1); diff --git a/std/src/thread/mod.rs b/std/src/thread/mod.rs index 59b395336f2e3..3f3ba02361cc8 100644 --- a/std/src/thread/mod.rs +++ b/std/src/thread/mod.rs @@ -1739,7 +1739,16 @@ struct JoinInner<'scope, T> { impl<'scope, T> JoinInner<'scope, T> { fn join(mut self) -> Result { self.native.join(); - Arc::get_mut(&mut self.packet).unwrap().result.get_mut().take().unwrap() + Arc::get_mut(&mut self.packet) + // FIXME(fuzzypixelz): returning an error instead of panicking here + // would require updating the documentation of + // `std::thread::Result`; currently we can return `Err` if and only + // if the thread had panicked. + .expect("threads should not terminate unexpectedly") + .result + .get_mut() + .take() + .unwrap() } } diff --git a/std/src/time.rs b/std/src/time.rs index 88b3e9e0ceba0..5ab71413586dc 100644 --- a/std/src/time.rs +++ b/std/src/time.rs @@ -93,11 +93,17 @@ use crate::sys_common::{FromInner, IntoInner}; /// use std::time::{Instant, Duration}; /// /// let now = Instant::now(); -/// let max_seconds = u64::MAX / 1_000_000_000; -/// let duration = Duration::new(max_seconds, 0); +/// let days_per_10_millennia = 365_2425; +/// let solar_seconds_per_day = 60 * 60 * 24; +/// let millenium_in_solar_seconds = 31_556_952_000; +/// assert_eq!(millenium_in_solar_seconds, days_per_10_millennia * solar_seconds_per_day / 10); +/// +/// let duration = Duration::new(millenium_in_solar_seconds, 0); /// println!("{:?}", now + duration); /// ``` /// +/// For cross-platform code, you can comfortably use durations of up to around one hundred years. +/// /// # Underlying System calls /// /// The following system calls are [currently] being used by `now()` to find out diff --git a/std/tests/env_modify.rs b/std/tests/env_modify.rs index 6074744735005..ba84978b35f8f 100644 --- a/std/tests/env_modify.rs +++ b/std/tests/env_modify.rs @@ -4,7 +4,7 @@ use std::env::*; use std::ffi::{OsStr, OsString}; -use rand::distributions::{Alphanumeric, DistString}; +use rand::distr::{Alphanumeric, SampleString}; mod common; use std::thread; @@ -26,26 +26,32 @@ fn eq(a: Option, b: Option<&str>) { #[test] fn test_set_var() { let n = make_rand_name(); - set_var(&n, "VALUE"); + unsafe { + set_var(&n, "VALUE"); + } eq(var_os(&n), Some("VALUE")); } #[test] fn test_remove_var() { let n = make_rand_name(); - set_var(&n, "VALUE"); - remove_var(&n); + unsafe { + set_var(&n, "VALUE"); + remove_var(&n); + } eq(var_os(&n), None); } #[test] fn test_set_var_overwrite() { let n = make_rand_name(); - set_var(&n, "1"); - set_var(&n, "2"); - eq(var_os(&n), Some("2")); - set_var(&n, ""); - eq(var_os(&n), Some("")); + unsafe { + set_var(&n, "1"); + set_var(&n, "2"); + eq(var_os(&n), Some("2")); + set_var(&n, ""); + eq(var_os(&n), Some("")); + } } #[test] @@ -58,7 +64,9 @@ fn test_var_big() { i += 1; } let n = make_rand_name(); - set_var(&n, &s); + unsafe { + set_var(&n, &s); + } eq(var_os(&n), Some(&s)); } @@ -67,10 +75,12 @@ fn test_var_big() { fn test_env_set_get_huge() { let n = make_rand_name(); let s = "x".repeat(10000); - set_var(&n, &s); - eq(var_os(&n), Some(&s)); - remove_var(&n); - eq(var_os(&n), None); + unsafe { + set_var(&n, &s); + eq(var_os(&n), Some(&s)); + remove_var(&n); + eq(var_os(&n), None); + } } #[test] @@ -78,7 +88,9 @@ fn test_env_set_var() { let n = make_rand_name(); let mut e = vars_os(); - set_var(&n, "VALUE"); + unsafe { + set_var(&n, "VALUE"); + } assert!(!e.any(|(k, v)| { &*k == &*n && &*v == "VALUE" })); assert!(vars_os().any(|(k, v)| { &*k == &*n && &*v == "VALUE" })); @@ -102,10 +114,12 @@ fn env_home_dir() { if #[cfg(unix)] { let oldhome = var_to_os_string(var("HOME")); - set_var("HOME", "/home/MountainView"); - assert_eq!(home_dir(), Some(PathBuf::from("/home/MountainView"))); + unsafe { + set_var("HOME", "/home/MountainView"); + assert_eq!(home_dir(), Some(PathBuf::from("/home/MountainView"))); - remove_var("HOME"); + remove_var("HOME"); + } if cfg!(target_os = "android") { assert!(home_dir().is_none()); } else { @@ -115,33 +129,35 @@ fn env_home_dir() { assert_ne!(home_dir(), Some(PathBuf::from("/home/MountainView"))); } - if let Some(oldhome) = oldhome { set_var("HOME", oldhome); } + if let Some(oldhome) = oldhome { unsafe { set_var("HOME", oldhome); } } } else if #[cfg(windows)] { let oldhome = var_to_os_string(var("HOME")); let olduserprofile = var_to_os_string(var("USERPROFILE")); - remove_var("HOME"); - remove_var("USERPROFILE"); + unsafe { + remove_var("HOME"); + remove_var("USERPROFILE"); - assert!(home_dir().is_some()); + assert!(home_dir().is_some()); - set_var("HOME", "/home/PaloAlto"); - assert_ne!(home_dir(), Some(PathBuf::from("/home/PaloAlto")), "HOME must not be used"); + set_var("HOME", "/home/PaloAlto"); + assert_ne!(home_dir(), Some(PathBuf::from("/home/PaloAlto")), "HOME must not be used"); - set_var("USERPROFILE", "/home/MountainView"); - assert_eq!(home_dir(), Some(PathBuf::from("/home/MountainView"))); + set_var("USERPROFILE", "/home/MountainView"); + assert_eq!(home_dir(), Some(PathBuf::from("/home/MountainView"))); - remove_var("HOME"); + remove_var("HOME"); - assert_eq!(home_dir(), Some(PathBuf::from("/home/MountainView"))); + assert_eq!(home_dir(), Some(PathBuf::from("/home/MountainView"))); - set_var("USERPROFILE", ""); - assert_ne!(home_dir(), Some(PathBuf::from("")), "Empty USERPROFILE must be ignored"); + set_var("USERPROFILE", ""); + assert_ne!(home_dir(), Some(PathBuf::from("")), "Empty USERPROFILE must be ignored"); - remove_var("USERPROFILE"); + remove_var("USERPROFILE"); - if let Some(oldhome) = oldhome { set_var("HOME", oldhome); } - if let Some(olduserprofile) = olduserprofile { set_var("USERPROFILE", olduserprofile); } + if let Some(oldhome) = oldhome { set_var("HOME", oldhome); } + if let Some(olduserprofile) = olduserprofile { set_var("USERPROFILE", olduserprofile); } + } } } } @@ -157,7 +173,9 @@ fn test_env_get_set_multithreaded() { let setter = thread::spawn(|| { for _ in 0..100 { - set_var("foo", "bar"); + unsafe { + set_var("foo", "bar"); + } } }); diff --git a/std/tests/switch-stdout.rs b/std/tests/switch-stdout.rs index 42011a9b3da62..91fe0200f6cae 100644 --- a/std/tests/switch-stdout.rs +++ b/std/tests/switch-stdout.rs @@ -14,7 +14,7 @@ use std::os::windows::io::OwnedHandle; fn switch_stdout_to(file: OwnedFd) -> OwnedFd { use std::os::unix::prelude::*; - extern "C" { + unsafe extern "C" { fn dup(old: i32) -> i32; fn dup2(old: i32, new: i32) -> i32; } @@ -32,7 +32,7 @@ fn switch_stdout_to(file: OwnedFd) -> OwnedFd { fn switch_stdout_to(file: OwnedHandle) -> OwnedHandle { use std::os::windows::prelude::*; - extern "system" { + unsafe extern "system" { fn GetStdHandle(nStdHandle: u32) -> *mut u8; fn SetStdHandle(nStdHandle: u32, handle: *mut u8) -> i32; } diff --git a/std/tests/sync/rwlock.rs b/std/tests/sync/rwlock.rs index bd4bc7a14bc8e..49f260648c6ac 100644 --- a/std/tests/sync/rwlock.rs +++ b/std/tests/sync/rwlock.rs @@ -59,7 +59,7 @@ fn frob() { thread::spawn(move || { let mut rng = crate::common::test_rng(); for _ in 0..M { - if rng.gen_bool(1.0 / (N as f64)) { + if rng.random_bool(1.0 / (N as f64)) { drop(r.write().unwrap()); } else { drop(r.read().unwrap()); diff --git a/std/tests/win_delete_self.rs b/std/tests/win_delete_self.rs index 1c3ce4d710c38..ce505de69a22d 100644 --- a/std/tests/win_delete_self.rs +++ b/std/tests/win_delete_self.rs @@ -2,6 +2,7 @@ /// Attempting to delete a running binary should return an error on Windows. #[test] +#[cfg_attr(miri, ignore)] // `remove_file` does not work in Miri on Windows fn win_delete_self() { let path = std::env::current_exe().unwrap(); assert!(std::fs::remove_file(path).is_err()); diff --git a/sysroot/Cargo.toml b/sysroot/Cargo.toml index aa6c3dc32e2ba..0f6fa2d291ab3 100644 --- a/sysroot/Cargo.toml +++ b/sysroot/Cargo.toml @@ -1,3 +1,5 @@ +cargo-features = ["public-dependency"] + [package] name = "sysroot" version = "0.0.0" @@ -5,10 +7,10 @@ edition = "2021" # this is a dummy crate to ensure that all required crates appear in the sysroot [dependencies] -proc_macro = { path = "../proc_macro" } +proc_macro = { path = "../proc_macro", public = true } profiler_builtins = { path = "../profiler_builtins", optional = true } -std = { path = "../std" } -test = { path = "../test" } +std = { path = "../std", public = true } +test = { path = "../test", public = true } # Forward features to the `std` crate as necessary [features] @@ -19,11 +21,13 @@ compiler-builtins-mem = ["std/compiler-builtins-mem"] compiler-builtins-no-asm = ["std/compiler-builtins-no-asm"] compiler-builtins-no-f16-f128 = ["std/compiler-builtins-no-f16-f128"] compiler-builtins-mangled-names = ["std/compiler-builtins-mangled-names"] +debug_refcell = ["std/debug_refcell"] +debug_typeid = ["std/debug_typeid"] llvm-libunwind = ["std/llvm-libunwind"] system-llvm-libunwind = ["std/system-llvm-libunwind"] +optimize_for_size = ["std/optimize_for_size"] panic-unwind = ["std/panic_unwind"] panic_immediate_abort = ["std/panic_immediate_abort"] -optimize_for_size = ["std/optimize_for_size"] profiler = ["dep:profiler_builtins"] std_detect_file_io = ["std/std_detect_file_io"] std_detect_dlsym_getauxval = ["std/std_detect_dlsym_getauxval"] diff --git a/test/Cargo.toml b/test/Cargo.toml index 75cc7c00e389c..241ef324b0088 100644 --- a/test/Cargo.toml +++ b/test/Cargo.toml @@ -1,3 +1,5 @@ +cargo-features = ["public-dependency"] + [package] name = "test" version = "0.0.0" @@ -5,8 +7,8 @@ edition = "2021" [dependencies] getopts = { version = "0.2.21", features = ['rustc-dep-of-std'] } -std = { path = "../std" } -core = { path = "../core" } +std = { path = "../std", public = true } +core = { path = "../core", public = true } [target.'cfg(not(all(windows, target_env = "msvc")))'.dependencies] libc = { version = "0.2.150", default-features = false } diff --git a/test/src/console.rs b/test/src/console.rs index 024ef48fc5104..8f29f1dada528 100644 --- a/test/src/console.rs +++ b/test/src/console.rs @@ -314,9 +314,10 @@ pub fn run_tests_console(opts: &TestOpts, tests: Vec) -> io::Resu let mut st = ConsoleTestState::new(opts)?; // Prevent the usage of `Instant` in some cases: - // - It's currently not supported for wasm targets. + // - It's currently not supported for wasm targets without Emscripten nor WASI. + // - It's currently not supported for zkvm targets. let is_instant_unsupported = - (cfg!(target_family = "wasm") && !cfg!(target_os = "wasi")) || cfg!(target_os = "zkvm"); + (cfg!(target_family = "wasm") && cfg!(target_os = "unknown")) || cfg!(target_os = "zkvm"); let start_time = (!is_instant_unsupported).then(Instant::now); run_tests(opts, tests, |x| on_test_event(&x, &mut st, &mut *out))?; diff --git a/test/src/formatters/junit.rs b/test/src/formatters/junit.rs index 57b1b0feceefc..36158b0258a6f 100644 --- a/test/src/formatters/junit.rs +++ b/test/src/formatters/junit.rs @@ -39,15 +39,15 @@ fn str_to_cdata(s: &str) -> String { impl OutputFormatter for JunitFormatter { fn write_discovery_start(&mut self) -> io::Result<()> { - Err(io::Error::new(io::ErrorKind::NotFound, "Not yet implemented!")) + Err(io::const_error!(io::ErrorKind::NotFound, "Not yet implemented!")) } fn write_test_discovered(&mut self, _desc: &TestDesc, _test_type: &str) -> io::Result<()> { - Err(io::Error::new(io::ErrorKind::NotFound, "Not yet implemented!")) + Err(io::const_error!(io::ErrorKind::NotFound, "Not yet implemented!")) } fn write_discovery_finish(&mut self, _state: &ConsoleTestDiscoveryState) -> io::Result<()> { - Err(io::Error::new(io::ErrorKind::NotFound, "Not yet implemented!")) + Err(io::const_error!(io::ErrorKind::NotFound, "Not yet implemented!")) } fn write_run_start( diff --git a/test/src/lib.rs b/test/src/lib.rs index 54f7e4ae79f18..7ada3f269a002 100644 --- a/test/src/lib.rs +++ b/test/src/lib.rs @@ -20,6 +20,7 @@ #![feature(rustdoc_internals)] #![feature(file_buffered)] #![feature(internal_output_capture)] +#![feature(io_const_error)] #![feature(staged_api)] #![feature(process_exitcode_internals)] #![feature(panic_can_unwind)] @@ -184,12 +185,16 @@ pub fn test_main_static_abort(tests: &[&TestDescAndFn]) { // If we're being run in SpawnedSecondary mode, run the test here. run_test // will then exit the process. if let Ok(name) = env::var(SECONDARY_TEST_INVOKER_VAR) { - env::remove_var(SECONDARY_TEST_INVOKER_VAR); + unsafe { + env::remove_var(SECONDARY_TEST_INVOKER_VAR); + } // Convert benchmarks to tests if we're not benchmarking. let mut tests = tests.iter().map(make_owned_test).collect::>(); if env::var(SECONDARY_TEST_BENCH_BENCHMARKS_VAR).is_ok() { - env::remove_var(SECONDARY_TEST_BENCH_BENCHMARKS_VAR); + unsafe { + env::remove_var(SECONDARY_TEST_BENCH_BENCHMARKS_VAR); + } } else { tests = convert_benchmarks_to_tests(tests); }; diff --git a/test/src/term/terminfo/mod.rs b/test/src/term/terminfo/mod.rs index 974b8afd598dd..75fa594908d56 100644 --- a/test/src/term/terminfo/mod.rs +++ b/test/src/term/terminfo/mod.rs @@ -90,7 +90,7 @@ impl TermInfo { get_dbpath_for_term(name) .ok_or_else(|| { - Error::IoError(io::Error::new(io::ErrorKind::NotFound, "terminfo file not found")) + Error::IoError(io::const_error!(io::ErrorKind::NotFound, "terminfo file not found")) }) .and_then(|p| TermInfo::from_path(&(*p))) } diff --git a/test/src/term/terminfo/parser/compiled.rs b/test/src/term/terminfo/parser/compiled.rs index e687b3be41fbf..d1dd0f10d8636 100644 --- a/test/src/term/terminfo/parser/compiled.rs +++ b/test/src/term/terminfo/parser/compiled.rs @@ -173,7 +173,7 @@ fn read_le_u32(r: &mut dyn io::Read) -> io::Result { fn read_byte(r: &mut dyn io::Read) -> io::Result { match r.bytes().next() { Some(s) => s, - None => Err(io::Error::new(io::ErrorKind::Other, "end of file")), + None => Err(io::const_error!(io::ErrorKind::Other, "end of file")), } } diff --git a/test/src/term/terminfo/searcher/tests.rs b/test/src/term/terminfo/searcher/tests.rs index e1edd3b25cf4b..ff532a97d5eb9 100644 --- a/test/src/term/terminfo/searcher/tests.rs +++ b/test/src/term/terminfo/searcher/tests.rs @@ -11,7 +11,11 @@ fn test_get_dbpath_for_term() { } assert_eq!(x("screen"), PathBuf::from("/usr/share/terminfo/s/screen")); assert_eq!(get_dbpath_for_term(""), None); - env::set_var("TERMINFO_DIRS", ":"); + unsafe { + env::set_var("TERMINFO_DIRS", ":"); + } assert_eq!(x("screen"), PathBuf::from("/usr/share/terminfo/s/screen")); - env::remove_var("TERMINFO_DIRS"); + unsafe { + env::remove_var("TERMINFO_DIRS"); + } } diff --git a/test/src/term/win.rs b/test/src/term/win.rs index c77e6aac478bc..62e5c43ea2745 100644 --- a/test/src/term/win.rs +++ b/test/src/term/win.rs @@ -52,7 +52,7 @@ struct CONSOLE_SCREEN_BUFFER_INFO { #[allow(non_snake_case)] #[link(name = "kernel32")] -extern "system" { +unsafe extern "system" { fn SetConsoleTextAttribute(handle: HANDLE, attr: WORD) -> BOOL; fn GetStdHandle(which: DWORD) -> HANDLE; fn GetConsoleScreenBufferInfo(handle: HANDLE, info: *mut CONSOLE_SCREEN_BUFFER_INFO) -> BOOL; diff --git a/unwind/src/lib.rs b/unwind/src/lib.rs index e4ba2bc1ed874..5451a38a674ca 100644 --- a/unwind/src/lib.rs +++ b/unwind/src/lib.rs @@ -1,5 +1,6 @@ #![no_std] #![unstable(feature = "panic_unwind", issue = "32837")] +#![feature(cfg_emscripten_wasm_eh)] #![feature(link_cfg)] #![feature(staged_api)] #![cfg_attr(not(target_env = "msvc"), feature(libc))] @@ -8,7 +9,7 @@ feature(simd_wasm64, wasm_exception_handling_intrinsics) )] #![allow(internal_features)] -#![cfg_attr(not(bootstrap), feature(cfg_emscripten_wasm_eh))] +#![deny(unsafe_op_in_unsafe_fn)] // Force libc to be included even if unused. This is required by many platforms. #[cfg(not(all(windows, target_env = "msvc")))] @@ -56,15 +57,15 @@ cfg_if::cfg_if! { compile_error!("`llvm-libunwind` and `system-llvm-libunwind` cannot be enabled at the same time"); } else if #[cfg(feature = "llvm-libunwind")] { #[link(name = "unwind", kind = "static", modifiers = "-bundle")] - extern "C" {} + unsafe extern "C" {} } else if #[cfg(feature = "system-llvm-libunwind")] { #[link(name = "unwind", kind = "static", modifiers = "-bundle", cfg(target_feature = "crt-static"))] #[link(name = "unwind", cfg(not(target_feature = "crt-static")))] - extern "C" {} + unsafe extern "C" {} } else { #[link(name = "unwind", kind = "static", modifiers = "-bundle", cfg(target_feature = "crt-static"))] #[link(name = "gcc_s", cfg(not(target_feature = "crt-static")))] - extern "C" {} + unsafe extern "C" {} } } @@ -76,11 +77,11 @@ cfg_if::cfg_if! { compile_error!("`llvm-libunwind` and `system-llvm-libunwind` cannot be enabled at the same time"); } else if #[cfg(feature = "llvm-libunwind")] { #[link(name = "unwind", kind = "static", modifiers = "-bundle")] - extern "C" {} + unsafe extern "C" {} } else { #[link(name = "unwind", kind = "static", modifiers = "-bundle", cfg(target_feature = "crt-static"))] #[link(name = "unwind", cfg(not(target_feature = "crt-static")))] - extern "C" {} + unsafe extern "C" {} } } @@ -91,14 +92,14 @@ cfg_if::cfg_if! { } else { #[link(name = "unwind", kind = "static", modifiers = "-bundle", cfg(target_feature = "crt-static"))] #[link(name = "unwind", cfg(not(target_feature = "crt-static")))] - extern "C" {} + unsafe extern "C" {} } } // Android's unwinding library depends on dl_iterate_phdr in `libdl`. #[cfg(target_os = "android")] #[link(name = "dl", kind = "static", modifiers = "-bundle", cfg(target_feature = "crt-static"))] #[link(name = "dl", cfg(not(target_feature = "crt-static")))] -extern "C" {} +unsafe extern "C" {} // When building with crt-static, we get `gcc_eh` from the `libc` crate, since // glibc needs it, and needs it listed later on the linker command line. We @@ -110,7 +111,7 @@ extern "C" {} not(feature = "system-llvm-libunwind") ))] #[link(name = "gcc_s", cfg(not(target_feature = "crt-static")))] -extern "C" {} +unsafe extern "C" {} #[cfg(all( target_os = "linux", @@ -119,67 +120,67 @@ extern "C" {} feature = "system-llvm-libunwind" ))] #[link(name = "unwind", cfg(not(target_feature = "crt-static")))] -extern "C" {} +unsafe extern "C" {} #[cfg(target_os = "redox")] #[link(name = "gcc_eh", kind = "static", modifiers = "-bundle", cfg(target_feature = "crt-static"))] #[link(name = "gcc_s", cfg(not(target_feature = "crt-static")))] -extern "C" {} +unsafe extern "C" {} #[cfg(all(target_vendor = "fortanix", target_env = "sgx"))] #[link(name = "unwind", kind = "static", modifiers = "-bundle")] -extern "C" {} +unsafe extern "C" {} #[cfg(target_os = "netbsd")] #[link(name = "gcc_s")] -extern "C" {} +unsafe extern "C" {} #[cfg(target_os = "freebsd")] #[link(name = "gcc", kind = "static", modifiers = "-bundle", cfg(target_feature = "crt-static"))] #[link(name = "gcc_eh", kind = "static", modifiers = "-bundle", cfg(target_feature = "crt-static"))] #[link(name = "gcc_s", cfg(not(target_feature = "crt-static")))] -extern "C" {} +unsafe extern "C" {} #[cfg(all(target_os = "openbsd", target_arch = "sparc64"))] #[link(name = "gcc")] -extern "C" {} +unsafe extern "C" {} #[cfg(all(target_os = "openbsd", not(target_arch = "sparc64")))] #[link(name = "c++abi")] -extern "C" {} +unsafe extern "C" {} #[cfg(any(target_os = "solaris", target_os = "illumos"))] #[link(name = "gcc_s")] -extern "C" {} +unsafe extern "C" {} #[cfg(target_os = "dragonfly")] #[link(name = "gcc_pic")] -extern "C" {} +unsafe extern "C" {} #[cfg(target_os = "haiku")] #[link(name = "gcc_s")] -extern "C" {} +unsafe extern "C" {} #[cfg(target_os = "aix")] #[link(name = "unwind")] -extern "C" {} +unsafe extern "C" {} #[cfg(target_os = "nto")] cfg_if::cfg_if! { if #[cfg(target_env = "nto70")] { #[link(name = "gcc")] - extern "C" {} + unsafe extern "C" {} } else { #[link(name = "gcc_s")] - extern "C" {} + unsafe extern "C" {} } } #[cfg(target_os = "hurd")] #[link(name = "gcc_s")] -extern "C" {} +unsafe extern "C" {} #[cfg(all(target_os = "windows", target_env = "gnu", target_abi = "llvm"))] #[link(name = "unwind", kind = "static", modifiers = "-bundle", cfg(target_feature = "crt-static"))] #[link(name = "unwind", cfg(not(target_feature = "crt-static")))] -extern "C" {} +unsafe extern "C" {} diff --git a/unwind/src/libunwind.rs b/unwind/src/libunwind.rs index 1fa9e480166b7..1a640bbde71d7 100644 --- a/unwind/src/libunwind.rs +++ b/unwind/src/libunwind.rs @@ -108,10 +108,10 @@ pub type _Unwind_Exception_Cleanup_Fn = ), link(name = "unwind", kind = "static", modifiers = "-bundle") )] -extern "C-unwind" { +unsafe extern "C-unwind" { pub fn _Unwind_Resume(exception: *mut _Unwind_Exception) -> !; } -extern "C" { +unsafe extern "C" { pub fn _Unwind_DeleteException(exception: *mut _Unwind_Exception); pub fn _Unwind_GetLanguageSpecificData(ctx: *mut _Unwind_Context) -> *mut c_void; pub fn _Unwind_GetRegionStart(ctx: *mut _Unwind_Context) -> _Unwind_Ptr; @@ -140,7 +140,7 @@ if #[cfg(any(target_vendor = "apple", target_os = "netbsd", not(target_arch = "a all(feature = "llvm-libunwind", any(target_os = "fuchsia", target_os = "linux", target_os = "xous")), link(name = "unwind", kind = "static", modifiers = "-bundle") )] - extern "C" { + unsafe extern "C" { pub fn _Unwind_GetGR(ctx: *mut _Unwind_Context, reg_index: c_int) -> _Unwind_Word; pub fn _Unwind_SetGR(ctx: *mut _Unwind_Context, reg_index: c_int, value: _Unwind_Word); pub fn _Unwind_GetIP(ctx: *mut _Unwind_Context) -> _Unwind_Word; @@ -198,7 +198,7 @@ if #[cfg(any(target_vendor = "apple", target_os = "netbsd", not(target_arch = "a all(feature = "llvm-libunwind", any(target_os = "fuchsia", target_os = "linux", target_os = "xous")), link(name = "unwind", kind = "static", modifiers = "-bundle") )] - extern "C" { + unsafe extern "C" { fn _Unwind_VRS_Get(ctx: *mut _Unwind_Context, regclass: _Unwind_VRS_RegClass, regno: _Unwind_Word, @@ -218,36 +218,38 @@ if #[cfg(any(target_vendor = "apple", target_os = "netbsd", not(target_arch = "a pub unsafe fn _Unwind_GetGR(ctx: *mut _Unwind_Context, reg_index: c_int) -> _Unwind_Word { let mut val: _Unwind_Word = core::ptr::null(); - _Unwind_VRS_Get(ctx, _UVRSC_CORE, reg_index as _Unwind_Word, _UVRSD_UINT32, - (&raw mut val) as *mut c_void); + unsafe { _Unwind_VRS_Get(ctx, _UVRSC_CORE, reg_index as _Unwind_Word, _UVRSD_UINT32, + (&raw mut val) as *mut c_void); } val } pub unsafe fn _Unwind_SetGR(ctx: *mut _Unwind_Context, reg_index: c_int, value: _Unwind_Word) { let mut value = value; - _Unwind_VRS_Set(ctx, _UVRSC_CORE, reg_index as _Unwind_Word, _UVRSD_UINT32, - (&raw mut value) as *mut c_void); + unsafe { _Unwind_VRS_Set(ctx, _UVRSC_CORE, reg_index as _Unwind_Word, _UVRSD_UINT32, + (&raw mut value) as *mut c_void); } } pub unsafe fn _Unwind_GetIP(ctx: *mut _Unwind_Context) -> _Unwind_Word { - let val = _Unwind_GetGR(ctx, UNWIND_IP_REG); + let val = unsafe { _Unwind_GetGR(ctx, UNWIND_IP_REG) }; val.map_addr(|v| v & !1) } pub unsafe fn _Unwind_SetIP(ctx: *mut _Unwind_Context, value: _Unwind_Word) { // Propagate thumb bit to instruction pointer - let thumb_state = _Unwind_GetGR(ctx, UNWIND_IP_REG).addr() & 1; + let thumb_state = unsafe { _Unwind_GetGR(ctx, UNWIND_IP_REG).addr() & 1 }; let value = value.map_addr(|v| v | thumb_state); - _Unwind_SetGR(ctx, UNWIND_IP_REG, value); + unsafe { _Unwind_SetGR(ctx, UNWIND_IP_REG, value); } } pub unsafe fn _Unwind_GetIPInfo(ctx: *mut _Unwind_Context, ip_before_insn: *mut c_int) -> _Unwind_Word { - *ip_before_insn = 0; - _Unwind_GetIP(ctx) + unsafe { + *ip_before_insn = 0; + _Unwind_GetIP(ctx) + } } // This function also doesn't exist on Android or ARM/Linux, so make it a no-op @@ -261,7 +263,7 @@ cfg_if::cfg_if! { if #[cfg(all(target_vendor = "apple", not(target_os = "watchos"), target_arch = "arm"))] { // 32-bit ARM Apple (except for watchOS armv7k specifically) uses SjLj and // does not provide _Unwind_Backtrace() - extern "C-unwind" { + unsafe extern "C-unwind" { pub fn _Unwind_SjLj_RaiseException(e: *mut _Unwind_Exception) -> _Unwind_Reason_Code; } @@ -271,14 +273,14 @@ if #[cfg(all(target_vendor = "apple", not(target_os = "watchos"), target_arch = all(feature = "llvm-libunwind", any(target_os = "fuchsia", target_os = "linux", target_os = "xous")), link(name = "unwind", kind = "static", modifiers = "-bundle") )] - extern "C-unwind" { + unsafe extern "C-unwind" { pub fn _Unwind_RaiseException(exception: *mut _Unwind_Exception) -> _Unwind_Reason_Code; } #[cfg_attr( all(feature = "llvm-libunwind", any(target_os = "fuchsia", target_os = "linux", target_os = "xous")), link(name = "unwind", kind = "static", modifiers = "-bundle") )] - extern "C" { + unsafe extern "C" { pub fn _Unwind_Backtrace(trace: _Unwind_Trace_Fn, trace_argument: *mut c_void) -> _Unwind_Reason_Code; @@ -302,7 +304,7 @@ if #[cfg(all(windows, any(target_arch = "aarch64", target_arch = "x86_64"), targ context: *mut _Unwind_Context) -> _Unwind_Reason_Code; - extern "C" { + unsafe extern "C" { pub fn _GCC_specific_handler(exceptionRecord: *mut EXCEPTION_RECORD, establisherFrame: LPVOID, contextRecord: *mut CONTEXT, diff --git a/windows_targets/src/lib.rs b/windows_targets/src/lib.rs index 395cd6a4bab55..e89bde8b1abf4 100644 --- a/windows_targets/src/lib.rs +++ b/windows_targets/src/lib.rs @@ -39,4 +39,4 @@ pub macro link { #[link(name = "userenv")] #[link(name = "ws2_32")] #[link(name = "dbghelp")] // required for backtrace-rs symbolization -extern "C" {} +unsafe extern "C" {}