diff options
Diffstat (limited to 'library/std/src')
| -rw-r--r-- | library/std/src/error.rs | 8 | ||||
| -rw-r--r-- | library/std/src/macros.rs | 12 | ||||
| -rw-r--r-- | library/std/src/net/ip.rs | 10 | ||||
| -rw-r--r-- | library/std/src/panicking.rs | 2 | ||||
| -rw-r--r-- | library/std/src/primitive_docs.rs | 13 | ||||
| -rw-r--r-- | library/std/src/process.rs | 2 | ||||
| -rw-r--r-- | library/std/src/sys/unix/locks/futex_rwlock.rs | 5 | ||||
| -rw-r--r-- | library/std/src/time.rs | 4 |
8 files changed, 34 insertions, 22 deletions
diff --git a/library/std/src/error.rs b/library/std/src/error.rs index 361163d1970..438304e1664 100644 --- a/library/std/src/error.rs +++ b/library/std/src/error.rs @@ -863,12 +863,12 @@ impl dyn Error + Send + Sync { } } -/// An error reporter that print's an error and its sources. +/// An error reporter that prints an error and its sources. /// /// Report also exposes configuration options for formatting the error chain, either entirely on a /// single line, or in multi-line format with each cause in the error chain on a new line. /// -/// `Report` only requires that the wrapped error implements `Error`. It doesn't require that the +/// `Report` only requires that the wrapped error implement `Error`. It doesn't require that the /// wrapped error be `Send`, `Sync`, or `'static`. /// /// # Examples @@ -972,7 +972,7 @@ impl dyn Error + Send + Sync { /// /// ## Return from `main` /// -/// `Report` also implements `From` for all types that implement [`Error`], this when combined with +/// `Report` also implements `From` for all types that implement [`Error`]; this when combined with /// the `Debug` output means `Report` is an ideal starting place for formatting errors returned /// from `main`. /// @@ -1020,7 +1020,7 @@ impl dyn Error + Send + Sync { /// ``` /// /// **Note**: `Report`s constructed via `?` and `From` will be configured to use the single line -/// output format, if you want to make sure your `Report`s are pretty printed and include backtrace +/// output format. If you want to make sure your `Report`s are pretty printed and include backtrace /// you will need to manually convert and enable those flags. /// /// ```should_panic diff --git a/library/std/src/macros.rs b/library/std/src/macros.rs index c7348951511..0cb21ef53b1 100644 --- a/library/std/src/macros.rs +++ b/library/std/src/macros.rs @@ -62,9 +62,9 @@ macro_rules! panic { #[cfg_attr(not(test), rustc_diagnostic_item = "print_macro")] #[allow_internal_unstable(print_internals)] macro_rules! print { - ($($arg:tt)*) => { - $crate::io::_print($crate::format_args!($($arg)*)) - }; + ($($arg:tt)*) => {{ + $crate::io::_print($crate::format_args!($($arg)*)); + }}; } /// Prints to the standard output, with a newline. @@ -133,9 +133,9 @@ macro_rules! println { #[cfg_attr(not(test), rustc_diagnostic_item = "eprint_macro")] #[allow_internal_unstable(print_internals)] macro_rules! eprint { - ($($arg:tt)*) => { - $crate::io::_eprint($crate::format_args!($($arg)*)) - }; + ($($arg:tt)*) => {{ + $crate::io::_eprint($crate::format_args!($($arg)*)); + }}; } /// Prints to the standard error, with a newline. diff --git a/library/std/src/net/ip.rs b/library/std/src/net/ip.rs index f629a1a0f99..438bae01b60 100644 --- a/library/std/src/net/ip.rs +++ b/library/std/src/net/ip.rs @@ -138,7 +138,8 @@ pub struct Ipv4Addr { /// /// To convert from an IPv4 address to an IPv4-mapped IPv6 address, use [`Ipv4Addr::to_ipv6_mapped`]. /// Use [`Ipv6Addr::to_ipv4`] to convert an IPv4-mapped IPv6 address to the canonical IPv4 address. -/// Note that this will also convert the IPv6 loopback address `::1` to `0.0.0.1`. +/// Note that this will also convert the IPv6 loopback address `::1` to `0.0.0.1`. Use +/// [`Ipv6Addr::to_ipv4_mapped`] to avoid this. /// /// [IETF RFC 4291 Section 2.5.5.2]: https://datatracker.ietf.org/doc/html/rfc4291#section-2.5.5.2 /// @@ -1646,8 +1647,6 @@ impl Ipv6Addr { /// # Examples /// /// ``` - /// #![feature(ip)] - /// /// use std::net::{Ipv4Addr, Ipv6Addr}; /// /// assert_eq!(Ipv6Addr::new(0xff00, 0, 0, 0, 0, 0, 0, 0).to_ipv4_mapped(), None); @@ -1656,7 +1655,7 @@ impl Ipv6Addr { /// assert_eq!(Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 1).to_ipv4_mapped(), None); /// ``` #[rustc_const_unstable(feature = "const_ipv6", issue = "76205")] - #[unstable(feature = "ip", issue = "27709")] + #[stable(feature = "ipv6_to_ipv4_mapped", since = "1.63.0")] #[must_use = "this returns the result of the operation, \ without modifying the original"] #[inline] @@ -1674,7 +1673,8 @@ impl Ipv6Addr { /// or an [IPv4-mapped] address as defined in [IETF RFC 4291 section 2.5.5.2], /// otherwise returns [`None`]. /// - /// Note that this will return an [`IPv4` address] for the IPv6 loopback address `::1`. + /// Note that this will return an [`IPv4` address] for the IPv6 loopback address `::1`. Use + /// [`Ipv6Addr::to_ipv4_mapped`] to avoid this. /// /// `::a.b.c.d` and `::ffff:a.b.c.d` become `a.b.c.d`. `::1` becomes `0.0.0.1`. /// All addresses *not* starting with either all zeroes or `::ffff` will return `None`. diff --git a/library/std/src/panicking.rs b/library/std/src/panicking.rs index 9b045980d45..25c9201f2ed 100644 --- a/library/std/src/panicking.rs +++ b/library/std/src/panicking.rs @@ -325,7 +325,7 @@ pub mod panic_count { pub const ALWAYS_ABORT_FLAG: usize = 1 << (usize::BITS - 1); // Panic count for the current thread. - thread_local! { static LOCAL_PANIC_COUNT: Cell<usize> = Cell::new(0) } + thread_local! { static LOCAL_PANIC_COUNT: Cell<usize> = const { Cell::new(0) } } // Sum of panic counts from all threads. The purpose of this is to have // a fast path in `is_zero` (which is used by `panicking`). In any particular diff --git a/library/std/src/primitive_docs.rs b/library/std/src/primitive_docs.rs index 147312b9720..688ab63bf13 100644 --- a/library/std/src/primitive_docs.rs +++ b/library/std/src/primitive_docs.rs @@ -994,6 +994,19 @@ mod prim_tuple {} /// surprising results upon inspecting the bit patterns, /// as the same calculations might produce NaNs with different bit patterns. /// +/// When the number resulting from a primitive operation (addition, +/// subtraction, multiplication, or division) on this type is not exactly +/// representable as `f32`, it is rounded according to the roundTiesToEven +/// direction defined in IEEE 754-2008. That means: +/// +/// - The result is the representable value closest to the true value, if there +/// is a unique closest representable value. +/// - If the true value is exactly half-way between two representable values, +/// the result is the one with an even least-significant binary digit. +/// - If the true value's magnitude is ≥ `f32::MAX` + 2<sup>(`f32::MAX_EXP` − +/// `f32::MANTISSA_DIGITS` − 1)</sup>, the result is ∞ or −∞ (preserving the +/// true value's sign). +/// /// For more information on floating point numbers, see [Wikipedia][wikipedia]. /// /// *[See also the `std::f32::consts` module](crate::f32::consts).* diff --git a/library/std/src/process.rs b/library/std/src/process.rs index 28e802d07e1..1def9fe0972 100644 --- a/library/std/src/process.rs +++ b/library/std/src/process.rs @@ -2108,7 +2108,7 @@ pub fn id() -> u32 { /// A trait for implementing arbitrary return types in the `main` function. /// -/// The C-main function only supports to return integers as return type. +/// The C-main function only supports returning integers. /// So, every type implementing the `Termination` trait has to be converted /// to an integer. /// diff --git a/library/std/src/sys/unix/locks/futex_rwlock.rs b/library/std/src/sys/unix/locks/futex_rwlock.rs index 57f6d58840d..5ff1aba7974 100644 --- a/library/std/src/sys/unix/locks/futex_rwlock.rs +++ b/library/std/src/sys/unix/locks/futex_rwlock.rs @@ -208,9 +208,8 @@ impl RwLock { // Don't go to sleep if the lock has become available, // or if the writers waiting bit is no longer set. - let s = self.state.load(Relaxed); - if is_unlocked(state) || !has_writers_waiting(s) { - state = s; + state = self.state.load(Relaxed); + if is_unlocked(state) || !has_writers_waiting(state) { continue; } diff --git a/library/std/src/time.rs b/library/std/src/time.rs index 708e4064e06..b2014f462bd 100644 --- a/library/std/src/time.rs +++ b/library/std/src/time.rs @@ -95,8 +95,8 @@ pub use core::time::FromFloatSecsError; /// use std::time::{Instant, Duration}; /// /// let now = Instant::now(); -/// let max_nanoseconds = u64::MAX / 1_000_000_000; -/// let duration = Duration::new(max_nanoseconds, 0); +/// let max_seconds = u64::MAX / 1_000_000_000; +/// let duration = Duration::new(max_seconds, 0); /// println!("{:?}", now + duration); /// ``` /// |
