diff options
Diffstat (limited to 'library/std/src')
| -rw-r--r-- | library/std/src/fs.rs | 5 | ||||
| -rw-r--r-- | library/std/src/io/mod.rs | 40 | ||||
| -rw-r--r-- | library/std/src/lib.rs | 1 | ||||
| -rw-r--r-- | library/std/src/num/f128.rs | 69 | ||||
| -rw-r--r-- | library/std/src/num/f16.rs | 67 | ||||
| -rw-r--r-- | library/std/src/num/f32.rs | 34 | ||||
| -rw-r--r-- | library/std/src/num/f64.rs | 6 | ||||
| -rw-r--r-- | library/std/src/os/android/net.rs | 2 | ||||
| -rw-r--r-- | library/std/src/os/linux/net.rs | 2 | ||||
| -rw-r--r-- | library/std/src/os/net/linux_ext/mod.rs | 2 | ||||
| -rw-r--r-- | library/std/src/os/net/linux_ext/tcp.rs | 12 | ||||
| -rw-r--r-- | library/std/src/os/unix/net/addr.rs | 9 | ||||
| -rw-r--r-- | library/std/src/os/unix/net/tests.rs | 9 | 
13 files changed, 86 insertions, 172 deletions
| diff --git a/library/std/src/fs.rs b/library/std/src/fs.rs index 6cbf8301e01..0cd794fd3ef 100644 --- a/library/std/src/fs.rs +++ b/library/std/src/fs.rs @@ -153,9 +153,8 @@ pub struct Metadata(fs_imp::FileAttr); /// dependent. /// /// # Errors -/// -/// This [`io::Result`] will be an [`Err`] if there's some sort of intermittent -/// IO error during iteration. +/// This [`io::Result`] will be an [`Err`] if an error occurred while fetching +/// the next entry from the OS. #[stable(feature = "rust1", since = "1.0.0")] #[derive(Debug)] pub struct ReadDir(fs_imp::ReadDir); diff --git a/library/std/src/io/mod.rs b/library/std/src/io/mod.rs index 20c82b64bcc..a9a24681e7c 100644 --- a/library/std/src/io/mod.rs +++ b/library/std/src/io/mod.rs @@ -917,6 +917,19 @@ pub trait Read { /// # } /// ``` /// + /// # Usage Notes + /// + /// `read_to_end` attempts to read a source until EOF, but many sources are continuous streams + /// that do not send EOF. In these cases, `read_to_end` will block indefinitely. Standard input + /// is one such stream which may be finite if piped, but is typically continuous. For example, + /// `cat file | my-rust-program` will correctly terminate with an `EOF` upon closure of cat. + /// Reading user input or running programs that remain open indefinitely will never terminate + /// the stream with `EOF` (e.g. `yes | my-rust-program`). + /// + /// Using `.lines()` with a [`BufReader`] or using [`read`] can provide a better solution + /// + ///[`read`]: Read::read + /// /// [`Vec::try_reserve`]: crate::vec::Vec::try_reserve #[stable(feature = "rust1", since = "1.0.0")] fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize> { @@ -960,6 +973,19 @@ pub trait Read { /// (See also the [`std::fs::read_to_string`] convenience function for /// reading from a file.) /// + /// # Usage Notes + /// + /// `read_to_string` attempts to read a source until EOF, but many sources are continuous streams + /// that do not send EOF. In these cases, `read_to_string` will block indefinitely. Standard input + /// is one such stream which may be finite if piped, but is typically continuous. For example, + /// `cat file | my-rust-program` will correctly terminate with an `EOF` upon closure of cat. + /// Reading user input or running programs that remain open indefinitely will never terminate + /// the stream with `EOF` (e.g. `yes | my-rust-program`). + /// + /// Using `.lines()` with a [`BufReader`] or using [`read`] can provide a better solution + /// + ///[`read`]: Read::read + /// /// [`std::fs::read_to_string`]: crate::fs::read_to_string #[stable(feature = "rust1", since = "1.0.0")] fn read_to_string(&mut self, buf: &mut String) -> Result<usize> { @@ -1262,6 +1288,20 @@ pub trait Read { /// Ok(()) /// } /// ``` +/// +/// # Usage Notes +/// +/// `read_to_string` attempts to read a source until EOF, but many sources are continuous streams +/// that do not send EOF. In these cases, `read_to_string` will block indefinitely. Standard input +/// is one such stream which may be finite if piped, but is typically continuous. For example, +/// `cat file | my-rust-program` will correctly terminate with an `EOF` upon closure of cat. +/// Reading user input or running programs that remain open indefinitely will never terminate +/// the stream with `EOF` (e.g. `yes | my-rust-program`). +/// +/// Using `.lines()` with a [`BufReader`] or using [`read`] can provide a better solution +/// +///[`read`]: Read::read +/// #[stable(feature = "io_read_to_string", since = "1.65.0")] pub fn read_to_string<R: Read>(mut reader: R) -> Result<String> { let mut buf = String::new(); diff --git a/library/std/src/lib.rs b/library/std/src/lib.rs index 7c54e731edc..2bb7a63772d 100644 --- a/library/std/src/lib.rs +++ b/library/std/src/lib.rs @@ -351,7 +351,6 @@ #![feature(lazy_get)] #![feature(maybe_uninit_slice)] #![feature(maybe_uninit_write_slice)] -#![feature(nonnull_provenance)] #![feature(panic_can_unwind)] #![feature(panic_internals)] #![feature(pin_coerce_unsized_trait)] diff --git a/library/std/src/num/f128.rs b/library/std/src/num/f128.rs index c0190de089f..64e604e35f7 100644 --- a/library/std/src/num/f128.rs +++ b/library/std/src/num/f128.rs @@ -5,6 +5,7 @@ //! Mathematically significant numbers are provided in the `consts` sub-module. #![unstable(feature = "f128", issue = "116909")] +#![doc(test(attr(feature(cfg_target_has_reliable_f16_f128), expect(internal_features))))] #[unstable(feature = "f128", issue = "116909")] pub use core::f128::consts; @@ -27,8 +28,6 @@ impl f128 { /// /// ``` /// #![feature(f128)] - /// # #![feature(cfg_target_has_reliable_f16_f128)] - /// # #![expect(internal_features)] /// # #[cfg(not(miri))] /// # #[cfg(target_has_reliable_f128_math)] { /// @@ -59,8 +58,6 @@ impl f128 { /// /// ``` /// #![feature(f128)] - /// # #![feature(cfg_target_has_reliable_f16_f128)] - /// # #![expect(internal_features)] /// # #[cfg(not(miri))] /// # #[cfg(target_has_reliable_f128_math)] { /// @@ -93,8 +90,6 @@ impl f128 { /// /// ``` /// #![feature(f128)] - /// # #![feature(cfg_target_has_reliable_f16_f128)] - /// # #![expect(internal_features)] /// # #[cfg(not(miri))] /// # #[cfg(target_has_reliable_f128_math)] { /// @@ -127,8 +122,6 @@ impl f128 { /// /// ``` /// #![feature(f128)] - /// # #![feature(cfg_target_has_reliable_f16_f128)] - /// # #![expect(internal_features)] /// # #[cfg(not(miri))] /// # #[cfg(target_has_reliable_f128_math)] { /// @@ -146,8 +139,6 @@ impl f128 { /// Non-positive values: /// ``` /// #![feature(f128)] - /// # #![feature(cfg_target_has_reliable_f16_f128)] - /// # #![expect(internal_features)] /// # #[cfg(not(miri))] /// # #[cfg(target_has_reliable_f128_math)] { /// @@ -180,8 +171,6 @@ impl f128 { /// /// ``` /// #![feature(f128)] - /// # #![feature(cfg_target_has_reliable_f16_f128)] - /// # #![expect(internal_features)] /// # #[cfg(not(miri))] /// # #[cfg(target_has_reliable_f128_math)] { /// @@ -197,8 +186,6 @@ impl f128 { /// Non-positive values: /// ``` /// #![feature(f128)] - /// # #![feature(cfg_target_has_reliable_f16_f128)] - /// # #![expect(internal_features)] /// # #[cfg(not(miri))] /// # #[cfg(target_has_reliable_f128_math)] { /// @@ -227,8 +214,6 @@ impl f128 { /// /// ``` /// #![feature(f128)] - /// # #![feature(cfg_target_has_reliable_f16_f128)] - /// # #![expect(internal_features)] /// # #[cfg(not(miri))] /// # #[cfg(target_has_reliable_f128_math)] { /// @@ -244,8 +229,6 @@ impl f128 { /// Non-positive values: /// ``` /// #![feature(f128)] - /// # #![feature(cfg_target_has_reliable_f16_f128)] - /// # #![expect(internal_features)] /// # #[cfg(not(miri))] /// # #[cfg(target_has_reliable_f128_math)] { /// @@ -274,8 +257,6 @@ impl f128 { /// /// ``` /// #![feature(f128)] - /// # #![feature(cfg_target_has_reliable_f16_f128)] - /// # #![expect(internal_features)] /// # #[cfg(not(miri))] /// # #[cfg(target_has_reliable_f128_math)] { /// @@ -291,8 +272,6 @@ impl f128 { /// Non-positive values: /// ``` /// #![feature(f128)] - /// # #![feature(cfg_target_has_reliable_f16_f128)] - /// # #![expect(internal_features)] /// # #[cfg(not(miri))] /// # #[cfg(target_has_reliable_f128_math)] { /// @@ -323,8 +302,6 @@ impl f128 { /// /// ``` /// #![feature(f128)] - /// # #![feature(cfg_target_has_reliable_f16_f128)] - /// # #![expect(internal_features)] /// # #[cfg(not(miri))] /// # #[cfg(target_has_reliable_f128_math)] { /// @@ -362,8 +339,6 @@ impl f128 { /// /// ``` /// #![feature(f128)] - /// # #![feature(cfg_target_has_reliable_f16_f128)] - /// # #![expect(internal_features)] /// # #[cfg(not(miri))] /// # #[cfg(target_has_reliable_f128_math)] { /// @@ -395,8 +370,6 @@ impl f128 { /// /// ``` /// #![feature(f128)] - /// # #![feature(cfg_target_has_reliable_f16_f128)] - /// # #![expect(internal_features)] /// # #[cfg(not(miri))] /// # #[cfg(target_has_reliable_f128_math)] { /// @@ -426,8 +399,6 @@ impl f128 { /// /// ``` /// #![feature(f128)] - /// # #![feature(cfg_target_has_reliable_f16_f128)] - /// # #![expect(internal_features)] /// # #[cfg(not(miri))] /// # #[cfg(target_has_reliable_f128_math)] { /// @@ -460,8 +431,6 @@ impl f128 { /// /// ``` /// #![feature(f128)] - /// # #![feature(cfg_target_has_reliable_f16_f128)] - /// # #![expect(internal_features)] /// # #[cfg(not(miri))] /// # #[cfg(target_has_reliable_f128_math)] { /// @@ -495,8 +464,6 @@ impl f128 { /// /// ``` /// #![feature(f128)] - /// # #![feature(cfg_target_has_reliable_f16_f128)] - /// # #![expect(internal_features)] /// # #[cfg(not(miri))] /// # #[cfg(target_has_reliable_f128_math)] { /// @@ -533,8 +500,6 @@ impl f128 { /// /// ``` /// #![feature(f128)] - /// # #![feature(cfg_target_has_reliable_f16_f128)] - /// # #![expect(internal_features)] /// # #[cfg(not(miri))] /// # #[cfg(target_has_reliable_f128_math)] { /// @@ -570,8 +535,6 @@ impl f128 { /// /// ``` /// #![feature(f128)] - /// # #![feature(cfg_target_has_reliable_f16_f128)] - /// # #![expect(internal_features)] /// # #[cfg(not(miri))] /// # #[cfg(target_has_reliable_f128_math)] { /// @@ -611,8 +574,6 @@ impl f128 { /// /// ``` /// #![feature(f128)] - /// # #![feature(cfg_target_has_reliable_f16_f128)] - /// # #![expect(internal_features)] /// # #[cfg(not(miri))] /// # #[cfg(target_has_reliable_f128_math)] { /// @@ -656,8 +617,6 @@ impl f128 { /// /// ``` /// #![feature(f128)] - /// # #![feature(cfg_target_has_reliable_f16_f128)] - /// # #![expect(internal_features)] /// # #[cfg(not(miri))] /// # #[cfg(target_has_reliable_f128_math)] { /// @@ -694,8 +653,6 @@ impl f128 { /// /// ``` /// #![feature(f128)] - /// # #![feature(cfg_target_has_reliable_f16_f128)] - /// # #![expect(internal_features)] /// # #[cfg(not(miri))] /// # #[cfg(target_has_reliable_f128_math)] { /// @@ -733,8 +690,6 @@ impl f128 { /// /// ``` /// #![feature(f128)] - /// # #![feature(cfg_target_has_reliable_f16_f128)] - /// # #![expect(internal_features)] /// # #[cfg(not(miri))] /// # #[cfg(target_has_reliable_f128_math)] { /// @@ -751,8 +706,6 @@ impl f128 { /// Out-of-range values: /// ``` /// #![feature(f128)] - /// # #![feature(cfg_target_has_reliable_f16_f128)] - /// # #![expect(internal_features)] /// # #[cfg(not(miri))] /// # #[cfg(target_has_reliable_f128_math)] { /// @@ -783,8 +736,6 @@ impl f128 { /// /// ``` /// #![feature(f128)] - /// # #![feature(cfg_target_has_reliable_f16_f128)] - /// # #![expect(internal_features)] /// # #[cfg(not(miri))] /// # #[cfg(target_has_reliable_f128_math)] { /// @@ -821,8 +772,6 @@ impl f128 { /// /// ``` /// #![feature(f128)] - /// # #![feature(cfg_target_has_reliable_f16_f128)] - /// # #![expect(internal_features)] /// # #[cfg(not(miri))] /// # #[cfg(target_has_reliable_f128_math)] { /// @@ -859,8 +808,6 @@ impl f128 { /// /// ``` /// #![feature(f128)] - /// # #![feature(cfg_target_has_reliable_f16_f128)] - /// # #![expect(internal_features)] /// # #[cfg(not(miri))] /// # #[cfg(target_has_reliable_f128_math)] { /// @@ -894,8 +841,6 @@ impl f128 { /// /// ``` /// #![feature(f128)] - /// # #![feature(cfg_target_has_reliable_f16_f128)] - /// # #![expect(internal_features)] /// # #[cfg(not(miri))] /// # #[cfg(target_has_reliable_f128_math)] { /// @@ -929,8 +874,6 @@ impl f128 { /// /// ``` /// #![feature(f128)] - /// # #![feature(cfg_target_has_reliable_f16_f128)] - /// # #![expect(internal_features)] /// # #[cfg(not(miri))] /// # #[cfg(target_has_reliable_f128_math)] { /// @@ -966,8 +909,6 @@ impl f128 { /// /// ``` /// #![feature(f128)] - /// # #![feature(cfg_target_has_reliable_f16_f128)] - /// # #![expect(internal_features)] /// # #[cfg(not(miri))] /// # #[cfg(target_has_reliable_f128_math)] { /// @@ -1003,8 +944,6 @@ impl f128 { /// ``` /// #![feature(f128)] /// #![feature(float_gamma)] - /// # #![feature(cfg_target_has_reliable_f16_f128)] - /// # #![expect(internal_features)] /// # #[cfg(not(miri))] /// # #[cfg(target_has_reliable_f128_math)] { /// @@ -1041,8 +980,6 @@ impl f128 { /// ``` /// #![feature(f128)] /// #![feature(float_gamma)] - /// # #![feature(cfg_target_has_reliable_f16_f128)] - /// # #![expect(internal_features)] /// # #[cfg(not(miri))] /// # #[cfg(target_has_reliable_f128_math)] { /// @@ -1079,8 +1016,6 @@ impl f128 { /// ``` /// #![feature(f128)] /// #![feature(float_erf)] - /// # #![feature(cfg_target_has_reliable_f16_f128)] - /// # #![expect(internal_features)] /// # #[cfg(not(miri))] /// # #[cfg(target_has_reliable_f128_math)] { /// /// The error function relates what percent of a normal distribution lies @@ -1121,8 +1056,6 @@ impl f128 { /// ``` /// #![feature(f128)] /// #![feature(float_erf)] - /// # #![feature(cfg_target_has_reliable_f16_f128)] - /// # #![expect(internal_features)] /// # #[cfg(not(miri))] /// # #[cfg(target_has_reliable_f128_math)] { /// let x: f128 = 0.123; diff --git a/library/std/src/num/f16.rs b/library/std/src/num/f16.rs index 4a4a8fd839a..7bdefb05858 100644 --- a/library/std/src/num/f16.rs +++ b/library/std/src/num/f16.rs @@ -5,6 +5,7 @@ //! Mathematically significant numbers are provided in the `consts` sub-module. #![unstable(feature = "f16", issue = "116909")] +#![doc(test(attr(feature(cfg_target_has_reliable_f16_f128), expect(internal_features))))] #[unstable(feature = "f16", issue = "116909")] pub use core::f16::consts; @@ -27,8 +28,6 @@ impl f16 { /// /// ``` /// #![feature(f16)] - /// # #![feature(cfg_target_has_reliable_f16_f128)] - /// # #![expect(internal_features)] /// # #[cfg(not(miri))] /// # #[cfg(target_has_reliable_f16_math)] { /// @@ -59,8 +58,6 @@ impl f16 { /// /// ``` /// #![feature(f16)] - /// # #![feature(cfg_target_has_reliable_f16_f128)] - /// # #![expect(internal_features)] /// # #[cfg(not(miri))] /// # #[cfg(target_has_reliable_f16_math)] { /// @@ -93,8 +90,6 @@ impl f16 { /// /// ``` /// #![feature(f16)] - /// # #![feature(cfg_target_has_reliable_f16_f128)] - /// # #![expect(internal_features)] /// # #[cfg(not(miri))] /// # #[cfg(target_has_reliable_f16_math)] { /// @@ -127,8 +122,6 @@ impl f16 { /// /// ``` /// #![feature(f16)] - /// # #![feature(cfg_target_has_reliable_f16_f128)] - /// # #![expect(internal_features)] /// # #[cfg(not(miri))] /// # #[cfg(target_has_reliable_f16_math)] { /// @@ -146,8 +139,6 @@ impl f16 { /// Non-positive values: /// ``` /// #![feature(f16)] - /// # #![feature(cfg_target_has_reliable_f16_f128)] - /// # #![expect(internal_features)] /// # #[cfg(not(miri))] /// # #[cfg(target_has_reliable_f16_math)] { /// @@ -180,8 +171,6 @@ impl f16 { /// /// ``` /// #![feature(f16)] - /// # #![feature(cfg_target_has_reliable_f16_f128)] - /// # #![expect(internal_features)] /// # #[cfg(not(miri))] /// # #[cfg(target_has_reliable_f16_math)] { /// @@ -197,8 +186,6 @@ impl f16 { /// Non-positive values: /// ``` /// #![feature(f16)] - /// # #![feature(cfg_target_has_reliable_f16_f128)] - /// # #![expect(internal_features)] /// # #[cfg(not(miri))] /// # #[cfg(target_has_reliable_f16_math)] { /// @@ -227,8 +214,6 @@ impl f16 { /// /// ``` /// #![feature(f16)] - /// # #![feature(cfg_target_has_reliable_f16_f128)] - /// # #![expect(internal_features)] /// # #[cfg(not(miri))] /// # #[cfg(target_has_reliable_f16_math)] { /// @@ -244,8 +229,6 @@ impl f16 { /// Non-positive values: /// ``` /// #![feature(f16)] - /// # #![feature(cfg_target_has_reliable_f16_f128)] - /// # #![expect(internal_features)] /// # #[cfg(not(miri))] /// # #[cfg(target_has_reliable_f16_math)] { /// @@ -274,8 +257,6 @@ impl f16 { /// /// ``` /// #![feature(f16)] - /// # #![feature(cfg_target_has_reliable_f16_f128)] - /// # #![expect(internal_features)] /// # #[cfg(not(miri))] /// # #[cfg(target_has_reliable_f16_math)] { /// @@ -291,8 +272,6 @@ impl f16 { /// Non-positive values: /// ``` /// #![feature(f16)] - /// # #![feature(cfg_target_has_reliable_f16_f128)] - /// # #![expect(internal_features)] /// # #[cfg(not(miri))] /// # #[cfg(target_has_reliable_f16_math)] { /// @@ -325,8 +304,6 @@ impl f16 { /// /// ``` /// #![feature(f16)] - /// # #![feature(cfg_target_has_reliable_f16_f128)] - /// # #![expect(internal_features)] /// # #[cfg(not(miri))] /// # #[cfg(target_has_reliable_f16_math)] { /// @@ -358,8 +335,6 @@ impl f16 { /// /// ``` /// #![feature(f16)] - /// # #![feature(cfg_target_has_reliable_f16_f128)] - /// # #![expect(internal_features)] /// # #[cfg(not(miri))] /// # #[cfg(target_has_reliable_f16_math)] { /// @@ -389,8 +364,6 @@ impl f16 { /// /// ``` /// #![feature(f16)] - /// # #![feature(cfg_target_has_reliable_f16_f128)] - /// # #![expect(internal_features)] /// # #[cfg(not(miri))] /// # #[cfg(target_has_reliable_f16_math)] { /// @@ -423,8 +396,6 @@ impl f16 { /// /// ``` /// #![feature(f16)] - /// # #![feature(cfg_target_has_reliable_f16_f128)] - /// # #![expect(internal_features)] /// # #[cfg(not(miri))] /// # #[cfg(target_has_reliable_f16_math)] { /// @@ -458,8 +429,6 @@ impl f16 { /// /// ``` /// #![feature(f16)] - /// # #![feature(cfg_target_has_reliable_f16_f128)] - /// # #![expect(internal_features)] /// # #[cfg(not(miri))] /// # #[cfg(target_has_reliable_f16_math)] { /// @@ -496,8 +465,6 @@ impl f16 { /// /// ``` /// #![feature(f16)] - /// # #![feature(cfg_target_has_reliable_f16_f128)] - /// # #![expect(internal_features)] /// # #[cfg(not(miri))] /// # #[cfg(target_has_reliable_f16_math)] { /// @@ -533,8 +500,6 @@ impl f16 { /// /// ``` /// #![feature(f16)] - /// # #![feature(cfg_target_has_reliable_f16_f128)] - /// # #![expect(internal_features)] /// # #[cfg(not(miri))] /// # #[cfg(target_has_reliable_f16_math)] { /// @@ -574,8 +539,6 @@ impl f16 { /// /// ``` /// #![feature(f16)] - /// # #![feature(cfg_target_has_reliable_f16_f128)] - /// # #![expect(internal_features)] /// # #[cfg(not(miri))] /// # #[cfg(target_has_reliable_f16_math)] { /// @@ -619,8 +582,6 @@ impl f16 { /// /// ``` /// #![feature(f16)] - /// # #![feature(cfg_target_has_reliable_f16_f128)] - /// # #![expect(internal_features)] /// # #[cfg(not(miri))] /// # #[cfg(target_has_reliable_f16_math)] { /// @@ -657,8 +618,6 @@ impl f16 { /// /// ``` /// #![feature(f16)] - /// # #![feature(cfg_target_has_reliable_f16_f128)] - /// # #![expect(internal_features)] /// # #[cfg(not(miri))] /// # #[cfg(target_has_reliable_f16_math)] { /// @@ -696,8 +655,6 @@ impl f16 { /// /// ``` /// #![feature(f16)] - /// # #![feature(cfg_target_has_reliable_f16_f128)] - /// # #![expect(internal_features)] /// # #[cfg(not(miri))] /// # #[cfg(target_has_reliable_f16_math)] { /// @@ -714,8 +671,6 @@ impl f16 { /// Out-of-range values: /// ``` /// #![feature(f16)] - /// # #![feature(cfg_target_has_reliable_f16_f128)] - /// # #![expect(internal_features)] /// # #[cfg(not(miri))] /// # #[cfg(target_has_reliable_f16_math)] { /// @@ -746,8 +701,6 @@ impl f16 { /// /// ``` /// #![feature(f16)] - /// # #![feature(cfg_target_has_reliable_f16_f128)] - /// # #![expect(internal_features)] /// # #[cfg(not(miri))] /// # #[cfg(target_has_reliable_f16_math)] { /// @@ -784,8 +737,6 @@ impl f16 { /// /// ``` /// #![feature(f16)] - /// # #![feature(cfg_target_has_reliable_f16_f128)] - /// # #![expect(internal_features)] /// # #[cfg(not(miri))] /// # #[cfg(target_has_reliable_f16_math)] { /// @@ -822,8 +773,6 @@ impl f16 { /// /// ``` /// #![feature(f16)] - /// # #![feature(cfg_target_has_reliable_f16_f128)] - /// # #![expect(internal_features)] /// # #[cfg(not(miri))] /// # #[cfg(target_has_reliable_f16_math)] { /// @@ -857,8 +806,6 @@ impl f16 { /// /// ``` /// #![feature(f16)] - /// # #![feature(cfg_target_has_reliable_f16_f128)] - /// # #![expect(internal_features)] /// # #[cfg(not(miri))] /// # #[cfg(target_has_reliable_f16_math)] { /// @@ -892,8 +839,6 @@ impl f16 { /// /// ``` /// #![feature(f16)] - /// # #![feature(cfg_target_has_reliable_f16_f128)] - /// # #![expect(internal_features)] /// # #[cfg(not(miri))] /// # #[cfg(target_has_reliable_f16_math)] { /// @@ -929,8 +874,6 @@ impl f16 { /// /// ``` /// #![feature(f16)] - /// # #![feature(cfg_target_has_reliable_f16_f128)] - /// # #![expect(internal_features)] /// # #[cfg(not(miri))] /// # #[cfg(target_has_reliable_f16_math)] { /// @@ -966,8 +909,6 @@ impl f16 { /// ``` /// #![feature(f16)] /// #![feature(float_gamma)] - /// # #![feature(cfg_target_has_reliable_f16_f128)] - /// # #![expect(internal_features)] /// # #[cfg(not(miri))] /// # #[cfg(target_has_reliable_f16_math)] { /// @@ -1004,8 +945,6 @@ impl f16 { /// ``` /// #![feature(f16)] /// #![feature(float_gamma)] - /// # #![feature(cfg_target_has_reliable_f16_f128)] - /// # #![expect(internal_features)] /// # #[cfg(not(miri))] /// # #[cfg(target_has_reliable_f16_math)] { /// @@ -1042,8 +981,6 @@ impl f16 { /// ``` /// #![feature(f16)] /// #![feature(float_erf)] - /// # #![feature(cfg_target_has_reliable_f16_f128)] - /// # #![expect(internal_features)] /// # #[cfg(not(miri))] /// # #[cfg(target_has_reliable_f16_math)] { /// /// The error function relates what percent of a normal distribution lies @@ -1084,8 +1021,6 @@ impl f16 { /// ``` /// #![feature(f16)] /// #![feature(float_erf)] - /// # #![feature(cfg_target_has_reliable_f16_f128)] - /// # #![expect(internal_features)] /// # #[cfg(not(miri))] /// # #[cfg(target_has_reliable_f16_math)] { /// let x: f16 = 0.123; diff --git a/library/std/src/num/f32.rs b/library/std/src/num/f32.rs index b7f6529ac40..e79ec2ae966 100644 --- a/library/std/src/num/f32.rs +++ b/library/std/src/num/f32.rs @@ -304,7 +304,7 @@ impl f32 { /// ``` /// let x = 2.0_f32; /// let abs_difference = (x.powi(2) - (x * x)).abs(); - /// assert!(abs_difference <= f32::EPSILON); + /// assert!(abs_difference <= 1e-5); /// /// assert_eq!(f32::powi(f32::NAN, 0), 1.0); /// ``` @@ -328,7 +328,7 @@ impl f32 { /// ``` /// let x = 2.0_f32; /// let abs_difference = (x.powf(2.0) - (x * x)).abs(); - /// assert!(abs_difference <= f32::EPSILON); + /// assert!(abs_difference <= 1e-5); /// /// assert_eq!(f32::powf(1.0, f32::NAN), 1.0); /// assert_eq!(f32::powf(f32::NAN, 0.0), 1.0); @@ -388,7 +388,7 @@ impl f32 { /// // ln(e) - 1 == 0 /// let abs_difference = (e.ln() - 1.0).abs(); /// - /// assert!(abs_difference <= f32::EPSILON); + /// assert!(abs_difference <= 1e-6); /// ``` #[rustc_allow_incoherent_impl] #[must_use = "method returns a new number and does not mutate the original value"] @@ -413,7 +413,7 @@ impl f32 { /// // 2^2 - 4 == 0 /// let abs_difference = (f.exp2() - 4.0).abs(); /// - /// assert!(abs_difference <= f32::EPSILON); + /// assert!(abs_difference <= 1e-5); /// ``` #[rustc_allow_incoherent_impl] #[must_use = "method returns a new number and does not mutate the original value"] @@ -442,7 +442,7 @@ impl f32 { /// // ln(e) - 1 == 0 /// let abs_difference = (e.ln() - 1.0).abs(); /// - /// assert!(abs_difference <= f32::EPSILON); + /// assert!(abs_difference <= 1e-6); /// ``` /// /// Non-positive values: @@ -479,7 +479,7 @@ impl f32 { /// // log5(5) - 1 == 0 /// let abs_difference = (five.log(5.0) - 1.0).abs(); /// - /// assert!(abs_difference <= f32::EPSILON); + /// assert!(abs_difference <= 1e-6); /// ``` /// /// Non-positive values: @@ -512,7 +512,7 @@ impl f32 { /// // log2(2) - 1 == 0 /// let abs_difference = (two.log2() - 1.0).abs(); /// - /// assert!(abs_difference <= f32::EPSILON); + /// assert!(abs_difference <= 1e-6); /// ``` /// /// Non-positive values: @@ -545,7 +545,7 @@ impl f32 { /// // log10(10) - 1 == 0 /// let abs_difference = (ten.log10() - 1.0).abs(); /// - /// assert!(abs_difference <= f32::EPSILON); + /// assert!(abs_difference <= 1e-6); /// ``` /// /// Non-positive values: @@ -652,7 +652,7 @@ impl f32 { /// // sqrt(x^2 + y^2) /// let abs_difference = (x.hypot(y) - (x.powi(2) + y.powi(2)).sqrt()).abs(); /// - /// assert!(abs_difference <= f32::EPSILON); + /// assert!(abs_difference <= 1e-6); /// ``` #[rustc_allow_incoherent_impl] #[must_use = "method returns a new number and does not mutate the original value"] @@ -676,7 +676,7 @@ impl f32 { /// /// let abs_difference = (x.sin() - 1.0).abs(); /// - /// assert!(abs_difference <= f32::EPSILON); + /// assert!(abs_difference <= 1e-6); /// ``` #[rustc_allow_incoherent_impl] #[must_use = "method returns a new number and does not mutate the original value"] @@ -700,7 +700,7 @@ impl f32 { /// /// let abs_difference = (x.cos() - 1.0).abs(); /// - /// assert!(abs_difference <= f32::EPSILON); + /// assert!(abs_difference <= 1e-6); /// ``` #[rustc_allow_incoherent_impl] #[must_use = "method returns a new number and does not mutate the original value"] @@ -754,7 +754,7 @@ impl f32 { /// // asin(sin(pi/2)) /// let abs_difference = (f.sin().asin() - std::f32::consts::FRAC_PI_2).abs(); /// - /// assert!(abs_difference <= f32::EPSILON); + /// assert!(abs_difference <= 1e-3); /// ``` #[doc(alias = "arcsin")] #[rustc_allow_incoherent_impl] @@ -784,7 +784,7 @@ impl f32 { /// // acos(cos(pi/4)) /// let abs_difference = (f.cos().acos() - std::f32::consts::FRAC_PI_4).abs(); /// - /// assert!(abs_difference <= f32::EPSILON); + /// assert!(abs_difference <= 1e-6); /// ``` #[doc(alias = "arccos")] #[rustc_allow_incoherent_impl] @@ -884,8 +884,8 @@ impl f32 { /// let abs_difference_0 = (f.0 - x.sin()).abs(); /// let abs_difference_1 = (f.1 - x.cos()).abs(); /// - /// assert!(abs_difference_0 <= f32::EPSILON); - /// assert!(abs_difference_1 <= f32::EPSILON); + /// assert!(abs_difference_0 <= 1e-6); + /// assert!(abs_difference_1 <= 1e-6); /// ``` #[doc(alias = "sincos")] #[rustc_allow_incoherent_impl] @@ -1067,7 +1067,7 @@ impl f32 { /// /// let abs_difference = (f - x).abs(); /// - /// assert!(abs_difference <= f32::EPSILON); + /// assert!(abs_difference <= 1e-7); /// ``` #[doc(alias = "arcsinh")] #[rustc_allow_incoherent_impl] @@ -1095,7 +1095,7 @@ impl f32 { /// /// let abs_difference = (f - x).abs(); /// - /// assert!(abs_difference <= f32::EPSILON); + /// assert!(abs_difference <= 1e-6); /// ``` #[doc(alias = "arccosh")] #[rustc_allow_incoherent_impl] diff --git a/library/std/src/num/f64.rs b/library/std/src/num/f64.rs index 75e35a8db33..853417825f9 100644 --- a/library/std/src/num/f64.rs +++ b/library/std/src/num/f64.rs @@ -304,7 +304,7 @@ impl f64 { /// ``` /// let x = 2.0_f64; /// let abs_difference = (x.powi(2) - (x * x)).abs(); - /// assert!(abs_difference <= f64::EPSILON); + /// assert!(abs_difference <= 1e-14); /// /// assert_eq!(f64::powi(f64::NAN, 0), 1.0); /// ``` @@ -328,7 +328,7 @@ impl f64 { /// ``` /// let x = 2.0_f64; /// let abs_difference = (x.powf(2.0) - (x * x)).abs(); - /// assert!(abs_difference <= f64::EPSILON); + /// assert!(abs_difference <= 1e-14); /// /// assert_eq!(f64::powf(1.0, f64::NAN), 1.0); /// assert_eq!(f64::powf(f64::NAN, 0.0), 1.0); @@ -754,7 +754,7 @@ impl f64 { /// // asin(sin(pi/2)) /// let abs_difference = (f.sin().asin() - std::f64::consts::FRAC_PI_2).abs(); /// - /// assert!(abs_difference < 1e-10); + /// assert!(abs_difference < 1e-7); /// ``` #[doc(alias = "arcsin")] #[rustc_allow_incoherent_impl] diff --git a/library/std/src/os/android/net.rs b/library/std/src/os/android/net.rs index 960a304fd0c..3a459ed8aee 100644 --- a/library/std/src/os/android/net.rs +++ b/library/std/src/os/android/net.rs @@ -6,5 +6,5 @@ pub use crate::os::net::linux_ext::addr::SocketAddrExt; #[unstable(feature = "unix_socket_ancillary_data", issue = "76915")] pub use crate::os::net::linux_ext::socket::UnixSocketExt; -#[unstable(feature = "tcp_quickack", issue = "96256")] +#[stable(feature = "tcp_quickack", since = "CURRENT_RUSTC_VERSION")] pub use crate::os::net::linux_ext::tcp::TcpStreamExt; diff --git a/library/std/src/os/linux/net.rs b/library/std/src/os/linux/net.rs index 1de120c8fd3..c14aba13bd1 100644 --- a/library/std/src/os/linux/net.rs +++ b/library/std/src/os/linux/net.rs @@ -6,5 +6,5 @@ pub use crate::os::net::linux_ext::addr::SocketAddrExt; #[unstable(feature = "unix_socket_ancillary_data", issue = "76915")] pub use crate::os::net::linux_ext::socket::UnixSocketExt; -#[unstable(feature = "tcp_quickack", issue = "96256")] +#[stable(feature = "tcp_quickack", since = "CURRENT_RUSTC_VERSION")] pub use crate::os::net::linux_ext::tcp::TcpStreamExt; diff --git a/library/std/src/os/net/linux_ext/mod.rs b/library/std/src/os/net/linux_ext/mod.rs index d0979640c32..bb9dfae2623 100644 --- a/library/std/src/os/net/linux_ext/mod.rs +++ b/library/std/src/os/net/linux_ext/mod.rs @@ -8,7 +8,7 @@ pub(crate) mod addr; #[unstable(feature = "unix_socket_ancillary_data", issue = "76915")] pub(crate) mod socket; -#[unstable(feature = "tcp_quickack", issue = "96256")] +#[stable(feature = "tcp_quickack", since = "CURRENT_RUSTC_VERSION")] pub(crate) mod tcp; #[cfg(test)] diff --git a/library/std/src/os/net/linux_ext/tcp.rs b/library/std/src/os/net/linux_ext/tcp.rs index 95dffb3bc43..167cfa62531 100644 --- a/library/std/src/os/net/linux_ext/tcp.rs +++ b/library/std/src/os/net/linux_ext/tcp.rs @@ -9,7 +9,7 @@ use crate::{io, net}; /// Os-specific extensions for [`TcpStream`] /// /// [`TcpStream`]: net::TcpStream -#[unstable(feature = "tcp_quickack", issue = "96256")] +#[stable(feature = "tcp_quickack", since = "CURRENT_RUSTC_VERSION")] pub trait TcpStreamExt: Sealed { /// Enable or disable `TCP_QUICKACK`. /// @@ -23,7 +23,6 @@ pub trait TcpStreamExt: Sealed { /// # Examples /// /// ```no_run - /// #![feature(tcp_quickack)] /// use std::net::TcpStream; /// #[cfg(target_os = "linux")] /// use std::os::linux::net::TcpStreamExt; @@ -34,7 +33,7 @@ pub trait TcpStreamExt: Sealed { /// .expect("Couldn't connect to the server..."); /// stream.set_quickack(true).expect("set_quickack call failed"); /// ``` - #[unstable(feature = "tcp_quickack", issue = "96256")] + #[stable(feature = "tcp_quickack", since = "CURRENT_RUSTC_VERSION")] fn set_quickack(&self, quickack: bool) -> io::Result<()>; /// Gets the value of the `TCP_QUICKACK` option on this socket. @@ -44,7 +43,6 @@ pub trait TcpStreamExt: Sealed { /// # Examples /// /// ```no_run - /// #![feature(tcp_quickack)] /// use std::net::TcpStream; /// #[cfg(target_os = "linux")] /// use std::os::linux::net::TcpStreamExt; @@ -56,7 +54,7 @@ pub trait TcpStreamExt: Sealed { /// stream.set_quickack(true).expect("set_quickack call failed"); /// assert_eq!(stream.quickack().unwrap_or(false), true); /// ``` - #[unstable(feature = "tcp_quickack", issue = "96256")] + #[stable(feature = "tcp_quickack", since = "CURRENT_RUSTC_VERSION")] fn quickack(&self) -> io::Result<bool>; /// A socket listener will be awakened solely when data arrives. @@ -105,10 +103,10 @@ pub trait TcpStreamExt: Sealed { fn deferaccept(&self) -> io::Result<u32>; } -#[unstable(feature = "tcp_quickack", issue = "96256")] +#[stable(feature = "tcp_quickack", since = "CURRENT_RUSTC_VERSION")] impl Sealed for net::TcpStream {} -#[unstable(feature = "tcp_quickack", issue = "96256")] +#[stable(feature = "tcp_quickack", since = "CURRENT_RUSTC_VERSION")] impl TcpStreamExt for net::TcpStream { fn set_quickack(&self, quickack: bool) -> io::Result<()> { self.as_inner().as_inner().set_quickack(quickack) diff --git a/library/std/src/os/unix/net/addr.rs b/library/std/src/os/unix/net/addr.rs index cb1246db310..fd6fe72dd24 100644 --- a/library/std/src/os/unix/net/addr.rs +++ b/library/std/src/os/unix/net/addr.rs @@ -1,3 +1,4 @@ +use crate::bstr::ByteStr; use crate::ffi::OsStr; #[cfg(any(doc, target_os = "android", target_os = "linux"))] use crate::os::net::linux_ext; @@ -61,7 +62,7 @@ pub(super) fn sockaddr_un(path: &Path) -> io::Result<(libc::sockaddr_un, libc::s enum AddressKind<'a> { Unnamed, Pathname(&'a Path), - Abstract(&'a [u8]), + Abstract(&'a ByteStr), } /// An address associated with a Unix socket. @@ -245,7 +246,7 @@ impl SocketAddr { { AddressKind::Unnamed } else if self.addr.sun_path[0] == 0 { - AddressKind::Abstract(&path[1..len]) + AddressKind::Abstract(ByteStr::from_bytes(&path[1..len])) } else { AddressKind::Pathname(OsStr::from_bytes(&path[..len - 1]).as_ref()) } @@ -260,7 +261,7 @@ impl Sealed for SocketAddr {} #[stable(feature = "unix_socket_abstract", since = "1.70.0")] impl linux_ext::addr::SocketAddrExt for SocketAddr { fn as_abstract_name(&self) -> Option<&[u8]> { - if let AddressKind::Abstract(name) = self.address() { Some(name) } else { None } + if let AddressKind::Abstract(name) = self.address() { Some(name.as_bytes()) } else { None } } fn from_abstract_name<N>(name: N) -> crate::io::Result<Self> @@ -295,7 +296,7 @@ impl fmt::Debug for SocketAddr { fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { match self.address() { AddressKind::Unnamed => write!(fmt, "(unnamed)"), - AddressKind::Abstract(name) => write!(fmt, "\"{}\" (abstract)", name.escape_ascii()), + AddressKind::Abstract(name) => write!(fmt, "{name:?} (abstract)"), AddressKind::Pathname(path) => write!(fmt, "{path:?} (pathname)"), } } diff --git a/library/std/src/os/unix/net/tests.rs b/library/std/src/os/unix/net/tests.rs index 0398a535eb5..9a88687b1df 100644 --- a/library/std/src/os/unix/net/tests.rs +++ b/library/std/src/os/unix/net/tests.rs @@ -411,6 +411,15 @@ fn test_unix_datagram_timeout_zero_duration() { assert_eq!(err.kind(), ErrorKind::InvalidInput); } +#[cfg(any(target_os = "android", target_os = "linux"))] +#[test] +fn abstract_socket_addr_debug() { + assert_eq!( + r#""\0hello world\x01\x02\x03\x04\x05\x06\x07\x08\t\n\x11\x12\r\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f \x7f\x80\x81\xfe\xff" (abstract)"#, + format!("{:?}", SocketAddr::from_abstract_name(b"\0hello world\x01\x02\x03\x04\x05\x06\x07\x08\t\n\x11\x12\r\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f \x7f\x80\x81\xfe\xff").unwrap()), + ); +} + #[test] fn abstract_namespace_not_allowed_connect() { assert!(UnixStream::connect("\0asdf").is_err()); | 
