From 8808d5a2b20e45f9947a3362a20383d8f5d29ef6 Mon Sep 17 00:00:00 2001 From: binarycat Date: Tue, 8 Apr 2025 12:27:33 -0500 Subject: [PATCH 01/12] std(docs): clarify how std::fs::set_permisions works with symlinks fixes https://github.com/rust-lang/rust/issues/75942 fixes https://github.com/rust-lang/rust/issues/124201 --- library/std/src/fs.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/library/std/src/fs.rs b/library/std/src/fs.rs index 801baf3d99072..1fe180066cea0 100644 --- a/library/std/src/fs.rs +++ b/library/std/src/fs.rs @@ -2980,6 +2980,19 @@ pub fn read_dir>(path: P) -> io::Result { /// /// [changes]: io#platform-specific-behavior /// +/// # Symlinks +/// On UNIX systems, it is impossible to manipulate the permission bits of a symlink itself[^1]. +/// Because of this, on those systems, this function will update the permission bits +/// of the file pointed to by the symlink. +/// +/// Note that this behavior can lead to privalage escalation vulnerabilites, +/// where the ability to write a symlink in one directory allows you to +/// cause the permissions of another directory to be modified. +/// +/// For this reason, using this function with symlinks should be avoided. +/// When possible, permissions should be set at creation time instead. +/// +/// [^1]: even if it were possible, the permissions on a symlink are ignored. /// # Errors /// /// This function will return an error in the following situations, but is not From 37c4a37ca2d94047b984aa16a95800b48255d327 Mon Sep 17 00:00:00 2001 From: binarycat Date: Tue, 8 Apr 2025 15:07:08 -0500 Subject: [PATCH 02/12] clarify std::fs::set_permissions symlink behavior nest under platform-specific behavior, factor rationale into its own section, and tweak language. --- library/std/src/fs.rs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/library/std/src/fs.rs b/library/std/src/fs.rs index 1fe180066cea0..3340a5dc23daa 100644 --- a/library/std/src/fs.rs +++ b/library/std/src/fs.rs @@ -2980,19 +2980,21 @@ pub fn read_dir>(path: P) -> io::Result { /// /// [changes]: io#platform-specific-behavior /// -/// # Symlinks -/// On UNIX systems, it is impossible to manipulate the permission bits of a symlink itself[^1]. -/// Because of this, on those systems, this function will update the permission bits +/// ## Symlinks +/// On UNIX-like systems, this function will update the permission bits /// of the file pointed to by the symlink. /// /// Note that this behavior can lead to privalage escalation vulnerabilites, -/// where the ability to write a symlink in one directory allows you to -/// cause the permissions of another directory to be modified. +/// where the ability to create a symlink in one directory allows you to +/// cause the permissions of another file or directory to be modified. /// /// For this reason, using this function with symlinks should be avoided. /// When possible, permissions should be set at creation time instead. /// -/// [^1]: even if it were possible, the permissions on a symlink are ignored. +/// # Rationale +/// POSIX does not specify an `lchown` function, +/// and symlinks can be followed regardless of what permission bits are set. +/// /// # Errors /// /// This function will return an error in the following situations, but is not From 11f7290c9f9122c5f2c47802c1883b2a0a04aed9 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Mon, 27 Jan 2025 13:49:28 -0600 Subject: [PATCH 03/12] refactor(test): Decouple parsing from help generation This will help with hiding some options in `--help` --- library/test/src/cli.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/test/src/cli.rs b/library/test/src/cli.rs index ef6786f431670..b532bfbea4d7c 100644 --- a/library/test/src/cli.rs +++ b/library/test/src/cli.rs @@ -210,7 +210,7 @@ pub fn parse_opts(args: &[String]) -> Option { // Check if help was requested. if matches.opt_present("h") { // Show help and do nothing more. - usage(binary, &opts); + usage(binary, &optgroups()); return None; } From aa8670f6f81dac097d24277e7559ce5abf5d5183 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Mon, 27 Jan 2025 14:04:49 -0600 Subject: [PATCH 04/12] fix(test): Expose '--no-capture', deprecating '--nocapture' This improves consistency with commonly expected CLI conventions, avoiding a common stutter people make when running tests (trying what they expect and then having to check the docs to then user whats accepted). An alternative could have been to take a value, like `--capture ` (e.g. `pytest` does this). Overall, we're shifting focus for features to custom test harnesses (see #134283). Most of `pytest`s modes will likely be irrelevant in that situation. As for the rest, its too early to tell which, if any, may be relevant, so we're sticking with this small, quality of life improvement. By deprecating `--nocapture`, we intend that custom test harnesses do not need to support it for reasons outside of their own compatibility requirements, much like the deprecation in #134283 I'm punting for now on the naming of `RUST_TEST_NOCAPTURE`. I feel like T-testing-devex should do a wider look at environment variables role in lib`test` before evaluating whether to - Deprecate it in favor of the user passing CLI flags or the test runner providing its own config - Deprecate in favor of `RUST_TEST_NO_CAPTURE` - Deprecate in favor of `RUST_TEST_CAPTURE` Other CLI flags were evaluated for casing consistency: - `--logfile` has the same problem but was deprecated in #134283 Fixes #133073 --- library/test/src/cli.rs | 11 +++++++---- src/doc/rustc/src/tests/index.md | 10 ++++++---- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/library/test/src/cli.rs b/library/test/src/cli.rs index b532bfbea4d7c..8840714a66238 100644 --- a/library/test/src/cli.rs +++ b/library/test/src/cli.rs @@ -61,7 +61,7 @@ fn optgroups() -> getopts::Options { .optopt("", "logfile", "Write logs to the specified file (deprecated)", "PATH") .optflag( "", - "nocapture", + "no-capture", "don't capture stdout/stderr of each \ task, allow printing directly", ) @@ -172,7 +172,7 @@ tests in the same order again. Note that --shuffle and --shuffle-seed do not affect whether the tests are run in parallel. All tests have their standard output and standard error captured by default. -This can be overridden with the --nocapture flag or setting RUST_TEST_NOCAPTURE +This can be overridden with the --no-capture flag or setting RUST_TEST_NOCAPTURE environment variable to a value other than "0". Logging is not captured by default. Test Attributes: @@ -199,7 +199,10 @@ Test Attributes: /// otherwise creates a `TestOpts` object and returns it. pub fn parse_opts(args: &[String]) -> Option { // Parse matches. - let opts = optgroups(); + let mut opts = optgroups(); + // Flags hidden from `usage` + opts.optflag("", "nocapture", "Deprecated, use `--no-capture`"); + let binary = args.first().map(|c| &**c).unwrap_or("..."); let args = args.get(1..).unwrap_or(args); let matches = match opts.parse(args) { @@ -447,7 +450,7 @@ fn get_color_config(matches: &getopts::Matches) -> OptPartRes { } fn get_nocapture(matches: &getopts::Matches) -> OptPartRes { - let mut nocapture = matches.opt_present("nocapture"); + let mut nocapture = matches.opt_present("nocapture") || matches.opt_present("no-capture"); if !nocapture { nocapture = match env::var("RUST_TEST_NOCAPTURE") { Ok(val) => &val != "0", diff --git a/src/doc/rustc/src/tests/index.md b/src/doc/rustc/src/tests/index.md index d2026513d2f0d..12de69a4c9eec 100644 --- a/src/doc/rustc/src/tests/index.md +++ b/src/doc/rustc/src/tests/index.md @@ -81,7 +81,7 @@ behavior. > Note: When running with [`cargo test`], the libtest CLI arguments must be > passed after the `--` argument to differentiate between flags for Cargo and -> those for the harness. For example: `cargo test -- --nocapture` +> those for the harness. For example: `cargo test -- --no-capture` ### Filters @@ -225,7 +225,7 @@ The following options affect the output behavior. Displays one character per test instead of one line per test. This is an alias for [`--format=terse`](#--format-format). -#### `--nocapture` +#### `--no-capture` Does not capture the stdout and stderr of the test, and allows tests to print to the console. Usually the output is captured, and only displayed if the test @@ -234,11 +234,13 @@ fails. This may also be specified by setting the `RUST_TEST_NOCAPTURE` environment variable to anything but `0`. +`--nocapture` is a deprecated alias for `--no-capture`. + #### `--show-output` Displays the stdout and stderr of successful tests after all tests have run. -Contrast this with [`--nocapture`](#--nocapture) which allows tests to print +Contrast this with [`--no-capture`](#--no-capture) which allows tests to print *while they are running*, which can cause interleaved output if there are multiple tests running in parallel, `--show-output` ensures the output is contiguous, but requires waiting for all tests to finish. @@ -247,7 +249,7 @@ contiguous, but requires waiting for all tests to finish. Control when colored terminal output is used. Valid options: -* `auto`: Colorize if stdout is a tty and [`--nocapture`](#--nocapture) is not +* `auto`: Colorize if stdout is a tty and [`--no-capture`](#--no-capture) is not used. This is the default. * `always`: Always colorize the output. * `never`: Never colorize the output. From 3d29e842a7036e40d4b1912fab2ab4d2036015c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Ber=C3=A1nek?= Date: Wed, 23 Apr 2025 11:04:39 +0200 Subject: [PATCH 05/12] Fix `download-ci-gcc key` in `bootstrap.example.toml` --- bootstrap.example.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bootstrap.example.toml b/bootstrap.example.toml index 72c4492d465d8..70b0cac3bfb83 100644 --- a/bootstrap.example.toml +++ b/bootstrap.example.toml @@ -180,7 +180,7 @@ # Note that this will attempt to download GCC even if there are local # modifications to the `src/gcc` submodule. # Currently, this is only supported for the `x86_64-unknown-linux-gnu` target. -# download-ci-gcc = false +#download-ci-gcc = false # ============================================================================= # General build configuration options From d4011ae04372e3b0fb77e28487002c2f05f1b65a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Ber=C3=A1nek?= Date: Wed, 23 Apr 2025 11:04:56 +0200 Subject: [PATCH 06/12] Download GCC from CI on test builders --- src/ci/run.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/ci/run.sh b/src/ci/run.sh index 6980d8220e574..b6143af632ddc 100755 --- a/src/ci/run.sh +++ b/src/ci/run.sh @@ -183,6 +183,9 @@ else RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --set llvm.static-libstdcpp" fi + # Download GCC from CI on test builders + RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --set gcc.download-ci-gcc=true" + if [ "$NO_DOWNLOAD_CI_RUSTC" = "" ]; then RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --set rust.download-rustc=if-unchanged" fi From 59b6cf5332e837b328193ba4f27f98e1f794a24d Mon Sep 17 00:00:00 2001 From: Ayush Singh Date: Thu, 20 Mar 2025 12:04:07 +0530 Subject: [PATCH 07/12] uefi: Update r-efi - Bump up the version to 5.2.0 Signed-off-by: Ayush Singh --- library/Cargo.lock | 8 ++++---- library/std/Cargo.toml | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/library/Cargo.lock b/library/Cargo.lock index f7f09a11f3ac9..c21dec14986fa 100644 --- a/library/Cargo.lock +++ b/library/Cargo.lock @@ -257,9 +257,9 @@ dependencies = [ [[package]] name = "r-efi" -version = "4.5.0" +version = "5.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9e935efc5854715dfc0a4c9ef18dc69dee0ec3bf9cc3ab740db831c0fdd86a3" +checksum = "74765f6d916ee2faa39bc8e68e4f3ed8949b48cccdac59983d287a7cb71ce9c5" dependencies = [ "compiler_builtins", "rustc-std-workspace-core", @@ -267,9 +267,9 @@ dependencies = [ [[package]] name = "r-efi-alloc" -version = "1.0.0" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31d6f09fe2b6ad044bc3d2c34ce4979796581afd2f1ebc185837e02421e02fd7" +checksum = "e43c53ff1a01d423d1cb762fd991de07d32965ff0ca2e4f80444ac7804198203" dependencies = [ "compiler_builtins", "r-efi", diff --git a/library/std/Cargo.toml b/library/std/Cargo.toml index 3536e84d58bed..602af4a0447ee 100644 --- a/library/std/Cargo.toml +++ b/library/std/Cargo.toml @@ -83,8 +83,8 @@ wasi = { version = "0.11.0", features = [ ], default-features = false } [target.'cfg(target_os = "uefi")'.dependencies] -r-efi = { version = "4.5.0", features = ['rustc-dep-of-std'] } -r-efi-alloc = { version = "1.0.0", features = ['rustc-dep-of-std'] } +r-efi = { version = "5.2.0", features = ['rustc-dep-of-std'] } +r-efi-alloc = { version = "2.0.0", features = ['rustc-dep-of-std'] } [features] backtrace = [ From 6f5698c3683f0b158399c0c22c88234dfb695c29 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Sat, 26 Apr 2025 22:06:42 +0200 Subject: [PATCH 08/12] Avoid re-interning in `LateContext::get_def_path` The def path printer in `get_def_path` essentially calls `Symbol::intern(&symbol.to_string())` for simple symbols in a path. This accounts for ~30% of the runtime of get_def_path. We can avoid this by simply appending the symbol directly when available. --- compiler/rustc_lint/src/context.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/compiler/rustc_lint/src/context.rs b/compiler/rustc_lint/src/context.rs index 3660bb3f780ab..5679d4566dcd4 100644 --- a/compiler/rustc_lint/src/context.rs +++ b/compiler/rustc_lint/src/context.rs @@ -812,7 +812,10 @@ impl<'tcx> LateContext<'tcx> { return Ok(()); } - self.path.push(Symbol::intern(&disambiguated_data.data.to_string())); + self.path.push(match disambiguated_data.data.get_opt_name() { + Some(sym) => sym, + None => Symbol::intern(&disambiguated_data.data.to_string()), + }); Ok(()) } From 9fed91fde0c72ef60c3c7931d34a9e841e0b00e7 Mon Sep 17 00:00:00 2001 From: Michael Howell Date: Sat, 26 Apr 2025 14:56:17 -0700 Subject: [PATCH 09/12] docs: fix incorrect stability markers on `std::{todo, matches}` This regression appeared in 916cfbcd3ed95a737b5a62103bbc4118ffe1eb2b. The change is behaving as expected (a non-glob re-export uses the stability marker on the `use` item, not the original one), but this part of the standard library didn't follow it. --- library/std/src/lib.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/library/std/src/lib.rs b/library/std/src/lib.rs index f77bf92a806e3..ee745426b5296 100644 --- a/library/std/src/lib.rs +++ b/library/std/src/lib.rs @@ -704,8 +704,14 @@ pub use core::cfg_match; reason = "`concat_bytes` is not stable enough for use and is subject to change" )] pub use core::concat_bytes; +#[stable(feature = "matches_macro", since = "1.42.0")] +#[allow(deprecated, deprecated_in_future)] +pub use core::matches; #[stable(feature = "core_primitive", since = "1.43.0")] pub use core::primitive; +#[stable(feature = "todo_macro", since = "1.40.0")] +#[allow(deprecated, deprecated_in_future)] +pub use core::todo; // Re-export built-in macros defined through core. #[stable(feature = "builtin_macro_prelude", since = "1.38.0")] #[allow(deprecated)] @@ -719,8 +725,8 @@ pub use core::{ #[stable(feature = "rust1", since = "1.0.0")] #[allow(deprecated, deprecated_in_future)] pub use core::{ - assert_eq, assert_ne, debug_assert, debug_assert_eq, debug_assert_ne, matches, todo, r#try, - unimplemented, unreachable, write, writeln, + assert_eq, assert_ne, debug_assert, debug_assert_eq, debug_assert_ne, r#try, unimplemented, + unreachable, write, writeln, }; // Include a number of private modules that exist solely to provide From d40d424d43e4e4138fd8be2e042f5c1dc20048fe Mon Sep 17 00:00:00 2001 From: Ayush Singh Date: Sun, 27 Apr 2025 14:07:33 +0530 Subject: [PATCH 10/12] CI: docker: host-x86_64: test-various: uefi_qemu_test: Update r-efi - Update r-efi to 5.2.0 Signed-off-by: Ayush Singh --- .../host-x86_64/test-various/uefi_qemu_test/Cargo.lock | 6 +++--- .../host-x86_64/test-various/uefi_qemu_test/Cargo.toml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/ci/docker/host-x86_64/test-various/uefi_qemu_test/Cargo.lock b/src/ci/docker/host-x86_64/test-various/uefi_qemu_test/Cargo.lock index dacf531e4048d..8b6a664ad9397 100644 --- a/src/ci/docker/host-x86_64/test-various/uefi_qemu_test/Cargo.lock +++ b/src/ci/docker/host-x86_64/test-various/uefi_qemu_test/Cargo.lock @@ -1,12 +1,12 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "r-efi" -version = "4.5.0" +version = "5.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9e935efc5854715dfc0a4c9ef18dc69dee0ec3bf9cc3ab740db831c0fdd86a3" +checksum = "74765f6d916ee2faa39bc8e68e4f3ed8949b48cccdac59983d287a7cb71ce9c5" [[package]] name = "uefi_qemu_test" diff --git a/src/ci/docker/host-x86_64/test-various/uefi_qemu_test/Cargo.toml b/src/ci/docker/host-x86_64/test-various/uefi_qemu_test/Cargo.toml index 976245f5bdd06..1a8d0d94368f6 100644 --- a/src/ci/docker/host-x86_64/test-various/uefi_qemu_test/Cargo.toml +++ b/src/ci/docker/host-x86_64/test-various/uefi_qemu_test/Cargo.toml @@ -7,4 +7,4 @@ edition = "2021" resolver = "2" [dependencies] -r-efi = "4.1.0" +r-efi = "5.2.0" From 0795b2d646aa6dbaae2f12c50b60ac7e38e0a91d Mon Sep 17 00:00:00 2001 From: LemonJ <1632798336@qq.com> Date: Sun, 27 Apr 2025 16:56:31 +0800 Subject: [PATCH 11/12] specify explicit safety guidance for from_utf8_unchecked --- library/core/src/str/converts.rs | 2 +- library/core/src/str/mod.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/library/core/src/str/converts.rs b/library/core/src/str/converts.rs index 37854a4da64ce..058628797ea85 100644 --- a/library/core/src/str/converts.rs +++ b/library/core/src/str/converts.rs @@ -178,7 +178,7 @@ pub const unsafe fn from_utf8_unchecked(v: &[u8]) -> &str { /// Converts a slice of bytes to a string slice without checking /// that the string contains valid UTF-8; mutable version. /// -/// See the immutable version, [`from_utf8_unchecked()`] for more information. +/// See the immutable version, [`from_utf8_unchecked()`] for documentation and safety requirements. /// /// # Examples /// diff --git a/library/core/src/str/mod.rs b/library/core/src/str/mod.rs index 79b4953fcc11a..9a70541adaddd 100644 --- a/library/core/src/str/mod.rs +++ b/library/core/src/str/mod.rs @@ -306,7 +306,7 @@ impl str { /// Converts a slice of bytes to a string slice without checking /// that the string contains valid UTF-8; mutable version. /// - /// See the immutable version, [`from_utf8_unchecked()`] for more information. + /// See the immutable version, [`from_utf8_unchecked()`] for documentation and safety requirements. /// /// # Examples /// From 2ab403441f9740cb371cd1d5121daffb88f08a2d Mon Sep 17 00:00:00 2001 From: SabrinaJewson Date: Tue, 25 Mar 2025 18:05:12 +0000 Subject: [PATCH 12/12] Add `Arc::is_unique` --- library/alloc/src/sync.rs | 69 ++++++++++++++++++++++++++++++++++----- 1 file changed, 61 insertions(+), 8 deletions(-) diff --git a/library/alloc/src/sync.rs b/library/alloc/src/sync.rs index c62f8e5b70f4d..dd7eeef769525 100644 --- a/library/alloc/src/sync.rs +++ b/library/alloc/src/sync.rs @@ -2446,7 +2446,7 @@ impl Arc { #[inline] #[stable(feature = "arc_unique", since = "1.4.0")] pub fn get_mut(this: &mut Self) -> Option<&mut T> { - if this.is_unique() { + if Self::is_unique(this) { // This unsafety is ok because we're guaranteed that the pointer // returned is the *only* pointer that will ever be returned to T. Our // reference count is guaranteed to be 1 at this point, and we required @@ -2526,11 +2526,64 @@ impl Arc { unsafe { &mut (*this.ptr.as_ptr()).data } } - /// Determine whether this is the unique reference (including weak refs) to - /// the underlying data. + /// Determine whether this is the unique reference to the underlying data. /// - /// Note that this requires locking the weak ref count. - fn is_unique(&mut self) -> bool { + /// Returns `true` if there are no other `Arc` or [`Weak`] pointers to the same allocation; + /// returns `false` otherwise. + /// + /// If this function returns `true`, then is guaranteed to be safe to call [`get_mut_unchecked`] + /// on this `Arc`, so long as no clones occur in between. + /// + /// # Examples + /// + /// ``` + /// #![feature(arc_is_unique)] + /// + /// use std::sync::Arc; + /// + /// let x = Arc::new(3); + /// assert!(Arc::is_unique(&x)); + /// + /// let y = Arc::clone(&x); + /// assert!(!Arc::is_unique(&x)); + /// drop(y); + /// + /// // Weak references also count, because they could be upgraded at any time. + /// let z = Arc::downgrade(&x); + /// assert!(!Arc::is_unique(&x)); + /// ``` + /// + /// # Pointer invalidation + /// + /// This function will always return the same value as `Arc::get_mut(arc).is_some()`. However, + /// unlike that operation it does not produce any mutable references to the underlying data, + /// meaning no pointers to the data inside the `Arc` are invalidated by the call. Thus, the + /// following code is valid, even though it would be UB if it used `Arc::get_mut`: + /// + /// ``` + /// #![feature(arc_is_unique)] + /// + /// use std::sync::Arc; + /// + /// let arc = Arc::new(5); + /// let pointer: *const i32 = &*arc; + /// assert!(Arc::is_unique(&arc)); + /// assert_eq!(unsafe { *pointer }, 5); + /// ``` + /// + /// # Atomic orderings + /// + /// Concurrent drops to other `Arc` pointers to the same allocation will synchronize with this + /// call - that is, this call performs an `Acquire` operation on the underlying strong and weak + /// ref counts. This ensures that calling `get_mut_unchecked` is safe. + /// + /// Note that this operation requires locking the weak ref count, so concurrent calls to + /// `downgrade` may spin-loop for a short period of time. + /// + /// [`get_mut_unchecked`]: Self::get_mut_unchecked + #[inline] + #[unstable(feature = "arc_is_unique", issue = "138938")] + pub fn is_unique(this: &Self) -> bool { // lock the weak pointer count if we appear to be the sole weak pointer // holder. // @@ -2538,16 +2591,16 @@ impl Arc { // writes to `strong` (in particular in `Weak::upgrade`) prior to decrements // of the `weak` count (via `Weak::drop`, which uses release). If the upgraded // weak ref was never dropped, the CAS here will fail so we do not care to synchronize. - if self.inner().weak.compare_exchange(1, usize::MAX, Acquire, Relaxed).is_ok() { + if this.inner().weak.compare_exchange(1, usize::MAX, Acquire, Relaxed).is_ok() { // This needs to be an `Acquire` to synchronize with the decrement of the `strong` // counter in `drop` -- the only access that happens when any but the last reference // is being dropped. - let unique = self.inner().strong.load(Acquire) == 1; + let unique = this.inner().strong.load(Acquire) == 1; // The release write here synchronizes with a read in `downgrade`, // effectively preventing the above read of `strong` from happening // after the write. - self.inner().weak.store(1, Release); // release the lock + this.inner().weak.store(1, Release); // release the lock unique } else { false