From 17234dbb3db8f4715fc0c96c0e5c5444a5980eb9 Mon Sep 17 00:00:00 2001 From: Jubilee Young Date: Sun, 11 Apr 2021 21:37:46 -0700 Subject: [PATCH 1/7] Pretend Duration::MAX was part of duration_saturating_ops --- library/core/src/time.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/core/src/time.rs b/library/core/src/time.rs index 2219353b055ad..7db03367fd534 100644 --- a/library/core/src/time.rs +++ b/library/core/src/time.rs @@ -146,7 +146,7 @@ impl Duration { /// /// assert_eq!(Duration::MAX, Duration::new(u64::MAX, 1_000_000_000 - 1)); /// ``` - #[unstable(feature = "duration_constants", issue = "57391")] + #[stable(feature = "duration_saturating_ops", since = "1.53.0")] pub const MAX: Duration = Duration::new(u64::MAX, NANOS_PER_SEC - 1); /// Creates a new `Duration` from the specified number of whole seconds and From d86835281b2fe9d04c006e0a0f5e24f363a420db Mon Sep 17 00:00:00 2001 From: Mara Bos Date: Sat, 24 Apr 2021 18:45:20 +0200 Subject: [PATCH 2/7] Stabilize ordering_helpers. --- library/core/src/cmp.rs | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/library/core/src/cmp.rs b/library/core/src/cmp.rs index 67dd1d83415bd..cdb6006b1b354 100644 --- a/library/core/src/cmp.rs +++ b/library/core/src/cmp.rs @@ -334,7 +334,6 @@ impl Ordering { /// # Examples /// /// ``` - /// #![feature(ordering_helpers)] /// use std::cmp::Ordering; /// /// assert_eq!(Ordering::Less.is_eq(), false); @@ -343,7 +342,8 @@ impl Ordering { /// ``` #[inline] #[must_use] - #[unstable(feature = "ordering_helpers", issue = "79885")] + #[rustc_const_stable(feature = "ordering_helpers", since = "1.53.0")] + #[stable(feature = "ordering_helpers", since = "1.53.0")] pub const fn is_eq(self) -> bool { matches!(self, Equal) } @@ -353,7 +353,6 @@ impl Ordering { /// # Examples /// /// ``` - /// #![feature(ordering_helpers)] /// use std::cmp::Ordering; /// /// assert_eq!(Ordering::Less.is_ne(), true); @@ -362,7 +361,8 @@ impl Ordering { /// ``` #[inline] #[must_use] - #[unstable(feature = "ordering_helpers", issue = "79885")] + #[rustc_const_stable(feature = "ordering_helpers", since = "1.53.0")] + #[stable(feature = "ordering_helpers", since = "1.53.0")] pub const fn is_ne(self) -> bool { !matches!(self, Equal) } @@ -372,7 +372,6 @@ impl Ordering { /// # Examples /// /// ``` - /// #![feature(ordering_helpers)] /// use std::cmp::Ordering; /// /// assert_eq!(Ordering::Less.is_lt(), true); @@ -381,7 +380,8 @@ impl Ordering { /// ``` #[inline] #[must_use] - #[unstable(feature = "ordering_helpers", issue = "79885")] + #[rustc_const_stable(feature = "ordering_helpers", since = "1.53.0")] + #[stable(feature = "ordering_helpers", since = "1.53.0")] pub const fn is_lt(self) -> bool { matches!(self, Less) } @@ -391,7 +391,6 @@ impl Ordering { /// # Examples /// /// ``` - /// #![feature(ordering_helpers)] /// use std::cmp::Ordering; /// /// assert_eq!(Ordering::Less.is_gt(), false); @@ -400,7 +399,8 @@ impl Ordering { /// ``` #[inline] #[must_use] - #[unstable(feature = "ordering_helpers", issue = "79885")] + #[rustc_const_stable(feature = "ordering_helpers", since = "1.53.0")] + #[stable(feature = "ordering_helpers", since = "1.53.0")] pub const fn is_gt(self) -> bool { matches!(self, Greater) } @@ -410,7 +410,6 @@ impl Ordering { /// # Examples /// /// ``` - /// #![feature(ordering_helpers)] /// use std::cmp::Ordering; /// /// assert_eq!(Ordering::Less.is_le(), true); @@ -419,7 +418,8 @@ impl Ordering { /// ``` #[inline] #[must_use] - #[unstable(feature = "ordering_helpers", issue = "79885")] + #[rustc_const_stable(feature = "ordering_helpers", since = "1.53.0")] + #[stable(feature = "ordering_helpers", since = "1.53.0")] pub const fn is_le(self) -> bool { !matches!(self, Greater) } @@ -429,7 +429,6 @@ impl Ordering { /// # Examples /// /// ``` - /// #![feature(ordering_helpers)] /// use std::cmp::Ordering; /// /// assert_eq!(Ordering::Less.is_ge(), false); @@ -438,7 +437,8 @@ impl Ordering { /// ``` #[inline] #[must_use] - #[unstable(feature = "ordering_helpers", issue = "79885")] + #[rustc_const_stable(feature = "ordering_helpers", since = "1.53.0")] + #[stable(feature = "ordering_helpers", since = "1.53.0")] pub const fn is_ge(self) -> bool { !matches!(self, Less) } From a80dbea918d6dd0516439f399a62512753276da5 Mon Sep 17 00:00:00 2001 From: Jubilee Young Date: Mon, 19 Apr 2021 16:31:30 -0700 Subject: [PATCH 3/7] Clarify Duration::MAX depends on Instant Duration is used in std to represent a difference between two Instants. As such, it has to at least contain that span of time in it. However, Instant can vary by platform. Thus, we should explain the impl of Duration::MAX is sensitive to these vagaries of the platform. --- library/core/src/time.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/library/core/src/time.rs b/library/core/src/time.rs index 7db03367fd534..d7fa5f9bf0a75 100644 --- a/library/core/src/time.rs +++ b/library/core/src/time.rs @@ -136,16 +136,18 @@ impl Duration { /// The maximum duration. /// - /// It is roughly equal to a duration of 584,942,417,355 years. + /// May vary by platform. At least equal to the number of seconds + /// difference between the minimum and maximum [`std::time::Instant`]. + /// On many platforms this is roughly 584,942,417,355 years. /// /// # Examples /// /// ``` - /// #![feature(duration_constants)] /// use std::time::Duration; /// /// assert_eq!(Duration::MAX, Duration::new(u64::MAX, 1_000_000_000 - 1)); /// ``` + /// [`std::time::Instant`]: ../../std/time/struct.Instant.html #[stable(feature = "duration_saturating_ops", since = "1.53.0")] pub const MAX: Duration = Duration::new(u64::MAX, NANOS_PER_SEC - 1); From 22ec96135d1928b5fa9ea5ee565ad8f1efd76152 Mon Sep 17 00:00:00 2001 From: r00ster Date: Sun, 25 Apr 2021 14:45:48 +0200 Subject: [PATCH 4/7] Unify the docs of std::env::{args_os, args} more --- library/std/src/env.rs | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/library/std/src/env.rs b/library/std/src/env.rs index 5fa092af1da02..513d9caa157ad 100644 --- a/library/std/src/env.rs +++ b/library/std/src/env.rs @@ -710,14 +710,14 @@ pub struct ArgsOs { /// passed as-is. /// /// On glibc Linux systems, arguments are retrieved by placing a function in `.init_array`. -/// Glibc passes `argc`, `argv`, and `envp` to functions in `.init_array`, as a non-standard +/// glibc passes `argc`, `argv`, and `envp` to functions in `.init_array`, as a non-standard /// extension. This allows `std::env::args` to work even in a `cdylib` or `staticlib`, as it /// does on macOS and Windows. /// /// # Panics /// /// The returned iterator will panic during iteration if any argument to the -/// process is not valid unicode. If this is not desired, +/// process is not valid Unicode. If this is not desired, /// use the [`args_os`] function instead. /// /// # Examples @@ -735,17 +735,25 @@ pub fn args() -> Args { Args { inner: args_os() } } -/// Returns the arguments which this program was started with (normally passed +/// Returns the arguments that this program was started with (normally passed /// via the command line). /// /// The first element is traditionally the path of the executable, but it can be -/// set to arbitrary text, and it may not even exist, so this property should +/// set to arbitrary text, and may not even exist. This means this property should /// not be relied upon for security purposes. /// -/// On glibc Linux systems, arguments are retrieved by placing a function in ".init_array". -/// Glibc passes argc, argv, and envp to functions in ".init_array", as a non-standard extension. -/// This allows `std::env::args` to work even in a `cdylib` or `staticlib`, as it does on macOS -/// and Windows. +/// On Unix systems the shell usually expands unquoted arguments with glob patterns +/// (such as `*` and `?`). On Windows this is not done, and such arguments are +/// passed as-is. +/// +/// On glibc Linux systems, arguments are retrieved by placing a function in `.init_array`. +/// glibc passes `argc`, `argv`, and `envp` to functions in `.init_array`, as a non-standard +/// extension. This allows `std::env::args_os` to work even in a `cdylib` or `staticlib`, as it +/// does on macOS and Windows. +/// +/// Note that the returned iterator will not panic during iteration if any argument to the +/// process is not valid Unicode. For more safety, +/// use the [`args`] function instead. /// /// # Examples /// From 82b6983acabb61e9e720ec362440fc556fd069c2 Mon Sep 17 00:00:00 2001 From: r00ster Date: Sun, 25 Apr 2021 15:48:24 +0200 Subject: [PATCH 5/7] Change wording --- library/std/src/env.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library/std/src/env.rs b/library/std/src/env.rs index 513d9caa157ad..116a37249e392 100644 --- a/library/std/src/env.rs +++ b/library/std/src/env.rs @@ -751,8 +751,8 @@ pub fn args() -> Args { /// extension. This allows `std::env::args_os` to work even in a `cdylib` or `staticlib`, as it /// does on macOS and Windows. /// -/// Note that the returned iterator will not panic during iteration if any argument to the -/// process is not valid Unicode. For more safety, +/// Note that the returned iterator will not check if the arguments to the +/// process are valid Unicode. To ensure UTF-8 validity, /// use the [`args`] function instead. /// /// # Examples From 8278380047c05539daf404adc17018de4570ddde Mon Sep 17 00:00:00 2001 From: Jubilee Young Date: Sun, 25 Apr 2021 10:28:23 -0700 Subject: [PATCH 6/7] Update to reflect feedback on the constraints --- library/core/src/time.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/library/core/src/time.rs b/library/core/src/time.rs index d7fa5f9bf0a75..5af4f11bb7857 100644 --- a/library/core/src/time.rs +++ b/library/core/src/time.rs @@ -136,9 +136,10 @@ impl Duration { /// The maximum duration. /// - /// May vary by platform. At least equal to the number of seconds - /// difference between the minimum and maximum [`std::time::Instant`]. - /// On many platforms this is roughly 584,942,417,355 years. + /// May vary by platform as necessary. Must be able to contain the difference between + /// two instances of [`Instant`] or two instances of [`SystemTime`]. + /// This constraint gives it a value of about 584,942,417,355 years in practice, + /// which is currently used on all platforms. /// /// # Examples /// @@ -147,7 +148,8 @@ impl Duration { /// /// assert_eq!(Duration::MAX, Duration::new(u64::MAX, 1_000_000_000 - 1)); /// ``` - /// [`std::time::Instant`]: ../../std/time/struct.Instant.html + /// [`Instant`]: ../../std/time/struct.Instant.html + /// [`SystemTime`]: ../../std/time/struct.SystemTime.html #[stable(feature = "duration_saturating_ops", since = "1.53.0")] pub const MAX: Duration = Duration::new(u64::MAX, NANOS_PER_SEC - 1); From 0d9a1c6762e28261b9aed18f37151483d0fbbc6b Mon Sep 17 00:00:00 2001 From: hi-rustin Date: Mon, 26 Apr 2021 13:43:30 +0800 Subject: [PATCH 7/7] rustdoc: Fix typo for maybe_inline_local fn --- src/librustdoc/visit_ast.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/librustdoc/visit_ast.rs b/src/librustdoc/visit_ast.rs index 3538182427a93..c9071eea78b79 100644 --- a/src/librustdoc/visit_ast.rs +++ b/src/librustdoc/visit_ast.rs @@ -150,7 +150,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> { om } - /// Tries to resolve the target of a `crate use` statement and inlines the + /// Tries to resolve the target of a `pub use` statement and inlines the /// target if it is defined locally and would not be documented otherwise, /// or when it is specifically requested with `please_inline`. /// (the latter is the case when the import is marked `doc(inline)`) @@ -183,7 +183,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> { || use_attrs.lists(sym::doc).has_word(sym::hidden); // For cross-crate impl inlining we need to know whether items are - // reachable in documentation -- a previously nonreachable item can be + // reachable in documentation -- a previously unreachable item can be // made reachable by cross-crate inlining which we're checking here. // (this is done here because we need to know this upfront). if !res_did.is_local() && !is_no_inline {