From 79855bb9ba43060b6718a468ad73094d173d7ce7 Mon Sep 17 00:00:00 2001 From: Samuel Marks <807580+SamuelMarks@users.noreply.github.com> Date: Thu, 11 Jul 2024 20:06:48 -0400 Subject: [PATCH 1/4] [library/std/src/process.rs] `PartialEq` & `Eq` for `ExitCode` --- std/src/process.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/std/src/process.rs b/std/src/process.rs index f351dab78dc1a..727f8f5ceb660 100644 --- a/std/src/process.rs +++ b/std/src/process.rs @@ -1979,7 +1979,7 @@ impl crate::error::Error for ExitStatusError {} /// ExitCode::SUCCESS /// } /// ``` -#[derive(Clone, Copy, Debug)] +#[derive(Clone, Copy, Debug, PartialEq, Eq)] #[stable(feature = "process_exitcode", since = "1.61.0")] pub struct ExitCode(imp::ExitCode); From 9b21aa05574a294e25e24e812ae40e52529d3101 Mon Sep 17 00:00:00 2001 From: Kornel Date: Wed, 17 Jul 2024 22:39:31 +0100 Subject: [PATCH 2/4] Document futility of printing temporary pointers --- core/src/fmt/mod.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/core/src/fmt/mod.rs b/core/src/fmt/mod.rs index 45c2b6a6a0f73..8fc43cb1875e3 100644 --- a/core/src/fmt/mod.rs +++ b/core/src/fmt/mod.rs @@ -975,9 +975,17 @@ pub trait UpperHex { /// `p` formatting. /// /// The `Pointer` trait should format its output as a memory location. This is commonly presented -/// as hexadecimal. +/// as hexadecimal. For more information on formatters, see [the module-level documentation][module]. /// -/// For more information on formatters, see [the module-level documentation][module]. +/// Printing of pointers is not a reliable way to discover how Rust programs are implemented. +/// The act of reading an address changes the program itself, and may change how the data is represented +/// in memory, and may affect which optimizations are applied to the code. +/// +/// The printed pointer values are not guaranteed to be stable nor unique identifiers of objects. +/// Rust allows moving values to different memory locations, and may reuse the same memory locations +/// for different purposes. +/// +/// There is no guarantee that the printed value can be converted back to a pointer. /// /// [module]: ../../std/fmt/index.html /// From 355445b026172e79f6f899d0154eb79738fc3a6e Mon Sep 17 00:00:00 2001 From: Samuel Marks <807580+SamuelMarks@users.noreply.github.com> Date: Thu, 5 Sep 2024 11:37:05 -0500 Subject: [PATCH 3/4] [library/std/src/process.rs] Update docstring with @joshtriplett's replacement text --- std/src/process.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/std/src/process.rs b/std/src/process.rs index 727f8f5ceb660..c25383405c43b 100644 --- a/std/src/process.rs +++ b/std/src/process.rs @@ -1937,10 +1937,14 @@ impl crate::error::Error for ExitStatusError {} /// to its parent under normal termination. /// /// `ExitCode` is intended to be consumed only by the standard library (via -/// [`Termination::report()`]), and intentionally does not provide accessors like -/// `PartialEq`, `Eq`, or `Hash`. Instead the standard library provides the -/// canonical `SUCCESS` and `FAILURE` exit codes as well as `From for -/// ExitCode` for constructing other arbitrary exit codes. +/// [`Termination::report()`]). For forwards compatibility with potentially +/// unusual targets, this type currently does not provide `Eq`, `Hash`, or +/// access to the raw value. This type does provide `PartialEq` for +/// comparison, but note that there may potentially be multiple failure +/// codes, some of which will _not_ compare equal to `ExitCode::FAILURE`. +/// The standard library provides the canonical `SUCCESS` and `FAILURE` +/// exit codes as well as `From for ExitCode` for constructing other +/// arbitrary exit codes. /// /// # Portability /// From b2d6fdd4d856a462f1f16eab7dcfe6a7b4099b86 Mon Sep 17 00:00:00 2001 From: Samuel Marks <807580+SamuelMarks@users.noreply.github.com> Date: Fri, 6 Sep 2024 12:32:00 -0500 Subject: [PATCH 4/4] [library/std/src/process.rs] Remove `Eq` `derive` --- std/src/process.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/std/src/process.rs b/std/src/process.rs index c25383405c43b..2c964648f0c2e 100644 --- a/std/src/process.rs +++ b/std/src/process.rs @@ -1983,7 +1983,7 @@ impl crate::error::Error for ExitStatusError {} /// ExitCode::SUCCESS /// } /// ``` -#[derive(Clone, Copy, Debug, PartialEq, Eq)] +#[derive(Clone, Copy, Debug, PartialEq)] #[stable(feature = "process_exitcode", since = "1.61.0")] pub struct ExitCode(imp::ExitCode);