Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 21079f5

Browse files
committed
Auto merge of rust-lang#140378 - ChrisDenton:rollup-3mj0wp9, r=ChrisDenton
Rollup of 8 pull requests Successful merges: - rust-lang#138395 (Download GCC from CI on test builders) - rust-lang#138737 (uefi: Update r-efi) - rust-lang#138939 (Add `Arc::is_unique`) - rust-lang#139224 (fix(test): Expose '--no-capture' in favor of `--nocapture`) - rust-lang#139546 (std(docs): clarify how std::fs::set_permisions works with symlinks) - rust-lang#140345 (Avoid re-interning in `LateContext::get_def_path`) - rust-lang#140351 (docs: fix incorrect stability markers on `std::{todo, matches}`) - rust-lang#140359 (specify explicit safety guidance for from_utf8_unchecked) r? `@ghost` `@rustbot` modify labels: rollup
2 parents deb9479 + 0ae362b commit 21079f5

File tree

14 files changed

+118
-33
lines changed

14 files changed

+118
-33
lines changed

bootstrap.example.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@
180180
# Note that this will attempt to download GCC even if there are local
181181
# modifications to the `src/gcc` submodule.
182182
# Currently, this is only supported for the `x86_64-unknown-linux-gnu` target.
183-
# download-ci-gcc = false
183+
#download-ci-gcc = false
184184

185185
# =============================================================================
186186
# General build configuration options

compiler/rustc_lint/src/context.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -812,7 +812,10 @@ impl<'tcx> LateContext<'tcx> {
812812
return Ok(());
813813
}
814814

815-
self.path.push(Symbol::intern(&disambiguated_data.data.to_string()));
815+
self.path.push(match disambiguated_data.data.get_opt_name() {
816+
Some(sym) => sym,
817+
None => Symbol::intern(&disambiguated_data.data.to_string()),
818+
});
816819
Ok(())
817820
}
818821

library/Cargo.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -257,19 +257,19 @@ dependencies = [
257257

258258
[[package]]
259259
name = "r-efi"
260-
version = "4.5.0"
260+
version = "5.2.0"
261261
source = "registry+https://github.com/rust-lang/crates.io-index"
262-
checksum = "e9e935efc5854715dfc0a4c9ef18dc69dee0ec3bf9cc3ab740db831c0fdd86a3"
262+
checksum = "74765f6d916ee2faa39bc8e68e4f3ed8949b48cccdac59983d287a7cb71ce9c5"
263263
dependencies = [
264264
"compiler_builtins",
265265
"rustc-std-workspace-core",
266266
]
267267

268268
[[package]]
269269
name = "r-efi-alloc"
270-
version = "1.0.0"
270+
version = "2.0.0"
271271
source = "registry+https://github.com/rust-lang/crates.io-index"
272-
checksum = "31d6f09fe2b6ad044bc3d2c34ce4979796581afd2f1ebc185837e02421e02fd7"
272+
checksum = "e43c53ff1a01d423d1cb762fd991de07d32965ff0ca2e4f80444ac7804198203"
273273
dependencies = [
274274
"compiler_builtins",
275275
"r-efi",

library/alloc/src/sync.rs

Lines changed: 61 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2446,7 +2446,7 @@ impl<T: ?Sized, A: Allocator> Arc<T, A> {
24462446
#[inline]
24472447
#[stable(feature = "arc_unique", since = "1.4.0")]
24482448
pub fn get_mut(this: &mut Self) -> Option<&mut T> {
2449-
if this.is_unique() {
2449+
if Self::is_unique(this) {
24502450
// This unsafety is ok because we're guaranteed that the pointer
24512451
// returned is the *only* pointer that will ever be returned to T. Our
24522452
// reference count is guaranteed to be 1 at this point, and we required
@@ -2526,28 +2526,81 @@ impl<T: ?Sized, A: Allocator> Arc<T, A> {
25262526
unsafe { &mut (*this.ptr.as_ptr()).data }
25272527
}
25282528

2529-
/// Determine whether this is the unique reference (including weak refs) to
2530-
/// the underlying data.
2529+
/// Determine whether this is the unique reference to the underlying data.
25312530
///
2532-
/// Note that this requires locking the weak ref count.
2533-
fn is_unique(&mut self) -> bool {
2531+
/// Returns `true` if there are no other `Arc` or [`Weak`] pointers to the same allocation;
2532+
/// returns `false` otherwise.
2533+
///
2534+
/// If this function returns `true`, then is guaranteed to be safe to call [`get_mut_unchecked`]
2535+
/// on this `Arc`, so long as no clones occur in between.
2536+
///
2537+
/// # Examples
2538+
///
2539+
/// ```
2540+
/// #![feature(arc_is_unique)]
2541+
///
2542+
/// use std::sync::Arc;
2543+
///
2544+
/// let x = Arc::new(3);
2545+
/// assert!(Arc::is_unique(&x));
2546+
///
2547+
/// let y = Arc::clone(&x);
2548+
/// assert!(!Arc::is_unique(&x));
2549+
/// drop(y);
2550+
///
2551+
/// // Weak references also count, because they could be upgraded at any time.
2552+
/// let z = Arc::downgrade(&x);
2553+
/// assert!(!Arc::is_unique(&x));
2554+
/// ```
2555+
///
2556+
/// # Pointer invalidation
2557+
///
2558+
/// This function will always return the same value as `Arc::get_mut(arc).is_some()`. However,
2559+
/// unlike that operation it does not produce any mutable references to the underlying data,
2560+
/// meaning no pointers to the data inside the `Arc` are invalidated by the call. Thus, the
2561+
/// following code is valid, even though it would be UB if it used `Arc::get_mut`:
2562+
///
2563+
/// ```
2564+
/// #![feature(arc_is_unique)]
2565+
///
2566+
/// use std::sync::Arc;
2567+
///
2568+
/// let arc = Arc::new(5);
2569+
/// let pointer: *const i32 = &*arc;
2570+
/// assert!(Arc::is_unique(&arc));
2571+
/// assert_eq!(unsafe { *pointer }, 5);
2572+
/// ```
2573+
///
2574+
/// # Atomic orderings
2575+
///
2576+
/// Concurrent drops to other `Arc` pointers to the same allocation will synchronize with this
2577+
/// call - that is, this call performs an `Acquire` operation on the underlying strong and weak
2578+
/// ref counts. This ensures that calling `get_mut_unchecked` is safe.
2579+
///
2580+
/// Note that this operation requires locking the weak ref count, so concurrent calls to
2581+
/// `downgrade` may spin-loop for a short period of time.
2582+
///
2583+
/// [`get_mut_unchecked`]: Self::get_mut_unchecked
2584+
#[inline]
2585+
#[unstable(feature = "arc_is_unique", issue = "138938")]
2586+
pub fn is_unique(this: &Self) -> bool {
25342587
// lock the weak pointer count if we appear to be the sole weak pointer
25352588
// holder.
25362589
//
25372590
// The acquire label here ensures a happens-before relationship with any
25382591
// writes to `strong` (in particular in `Weak::upgrade`) prior to decrements
25392592
// of the `weak` count (via `Weak::drop`, which uses release). If the upgraded
25402593
// weak ref was never dropped, the CAS here will fail so we do not care to synchronize.
2541-
if self.inner().weak.compare_exchange(1, usize::MAX, Acquire, Relaxed).is_ok() {
2594+
if this.inner().weak.compare_exchange(1, usize::MAX, Acquire, Relaxed).is_ok() {
25422595
// This needs to be an `Acquire` to synchronize with the decrement of the `strong`
25432596
// counter in `drop` -- the only access that happens when any but the last reference
25442597
// is being dropped.
2545-
let unique = self.inner().strong.load(Acquire) == 1;
2598+
let unique = this.inner().strong.load(Acquire) == 1;
25462599

25472600
// The release write here synchronizes with a read in `downgrade`,
25482601
// effectively preventing the above read of `strong` from happening
25492602
// after the write.
2550-
self.inner().weak.store(1, Release); // release the lock
2603+
this.inner().weak.store(1, Release); // release the lock
25512604
unique
25522605
} else {
25532606
false

library/core/src/str/converts.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ pub const unsafe fn from_utf8_unchecked(v: &[u8]) -> &str {
178178
/// Converts a slice of bytes to a string slice without checking
179179
/// that the string contains valid UTF-8; mutable version.
180180
///
181-
/// See the immutable version, [`from_utf8_unchecked()`] for more information.
181+
/// See the immutable version, [`from_utf8_unchecked()`] for documentation and safety requirements.
182182
///
183183
/// # Examples
184184
///

library/core/src/str/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ impl str {
306306
/// Converts a slice of bytes to a string slice without checking
307307
/// that the string contains valid UTF-8; mutable version.
308308
///
309-
/// See the immutable version, [`from_utf8_unchecked()`] for more information.
309+
/// See the immutable version, [`from_utf8_unchecked()`] for documentation and safety requirements.
310310
///
311311
/// # Examples
312312
///

library/std/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ wasi = { version = "0.11.0", features = [
8383
], default-features = false }
8484

8585
[target.'cfg(target_os = "uefi")'.dependencies]
86-
r-efi = { version = "4.5.0", features = ['rustc-dep-of-std'] }
87-
r-efi-alloc = { version = "1.0.0", features = ['rustc-dep-of-std'] }
86+
r-efi = { version = "5.2.0", features = ['rustc-dep-of-std'] }
87+
r-efi-alloc = { version = "2.0.0", features = ['rustc-dep-of-std'] }
8888

8989
[features]
9090
backtrace = [

library/std/src/fs.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2980,6 +2980,21 @@ pub fn read_dir<P: AsRef<Path>>(path: P) -> io::Result<ReadDir> {
29802980
///
29812981
/// [changes]: io#platform-specific-behavior
29822982
///
2983+
/// ## Symlinks
2984+
/// On UNIX-like systems, this function will update the permission bits
2985+
/// of the file pointed to by the symlink.
2986+
///
2987+
/// Note that this behavior can lead to privalage escalation vulnerabilites,
2988+
/// where the ability to create a symlink in one directory allows you to
2989+
/// cause the permissions of another file or directory to be modified.
2990+
///
2991+
/// For this reason, using this function with symlinks should be avoided.
2992+
/// When possible, permissions should be set at creation time instead.
2993+
///
2994+
/// # Rationale
2995+
/// POSIX does not specify an `lchown` function,
2996+
/// and symlinks can be followed regardless of what permission bits are set.
2997+
///
29832998
/// # Errors
29842999
///
29853000
/// This function will return an error in the following situations, but is not

library/std/src/lib.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -703,8 +703,14 @@ pub use core::cfg_match;
703703
reason = "`concat_bytes` is not stable enough for use and is subject to change"
704704
)]
705705
pub use core::concat_bytes;
706+
#[stable(feature = "matches_macro", since = "1.42.0")]
707+
#[allow(deprecated, deprecated_in_future)]
708+
pub use core::matches;
706709
#[stable(feature = "core_primitive", since = "1.43.0")]
707710
pub use core::primitive;
711+
#[stable(feature = "todo_macro", since = "1.40.0")]
712+
#[allow(deprecated, deprecated_in_future)]
713+
pub use core::todo;
708714
// Re-export built-in macros defined through core.
709715
#[stable(feature = "builtin_macro_prelude", since = "1.38.0")]
710716
#[allow(deprecated)]
@@ -718,8 +724,8 @@ pub use core::{
718724
#[stable(feature = "rust1", since = "1.0.0")]
719725
#[allow(deprecated, deprecated_in_future)]
720726
pub use core::{
721-
assert_eq, assert_ne, debug_assert, debug_assert_eq, debug_assert_ne, matches, todo, r#try,
722-
unimplemented, unreachable, write, writeln,
727+
assert_eq, assert_ne, debug_assert, debug_assert_eq, debug_assert_ne, r#try, unimplemented,
728+
unreachable, write, writeln,
723729
};
724730

725731
// Include a number of private modules that exist solely to provide

library/test/src/cli.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ fn optgroups() -> getopts::Options {
6161
.optopt("", "logfile", "Write logs to the specified file (deprecated)", "PATH")
6262
.optflag(
6363
"",
64-
"nocapture",
64+
"no-capture",
6565
"don't capture stdout/stderr of each \
6666
task, allow printing directly",
6767
)
@@ -172,7 +172,7 @@ tests in the same order again. Note that --shuffle and --shuffle-seed do not
172172
affect whether the tests are run in parallel.
173173
174174
All tests have their standard output and standard error captured by default.
175-
This can be overridden with the --nocapture flag or setting RUST_TEST_NOCAPTURE
175+
This can be overridden with the --no-capture flag or setting RUST_TEST_NOCAPTURE
176176
environment variable to a value other than "0". Logging is not captured by default.
177177
178178
Test Attributes:
@@ -199,7 +199,10 @@ Test Attributes:
199199
/// otherwise creates a `TestOpts` object and returns it.
200200
pub fn parse_opts(args: &[String]) -> Option<OptRes> {
201201
// Parse matches.
202-
let opts = optgroups();
202+
let mut opts = optgroups();
203+
// Flags hidden from `usage`
204+
opts.optflag("", "nocapture", "Deprecated, use `--no-capture`");
205+
203206
let binary = args.first().map(|c| &**c).unwrap_or("...");
204207
let args = args.get(1..).unwrap_or(args);
205208
let matches = match opts.parse(args) {
@@ -210,7 +213,7 @@ pub fn parse_opts(args: &[String]) -> Option<OptRes> {
210213
// Check if help was requested.
211214
if matches.opt_present("h") {
212215
// Show help and do nothing more.
213-
usage(binary, &opts);
216+
usage(binary, &optgroups());
214217
return None;
215218
}
216219

@@ -447,7 +450,7 @@ fn get_color_config(matches: &getopts::Matches) -> OptPartRes<ColorConfig> {
447450
}
448451

449452
fn get_nocapture(matches: &getopts::Matches) -> OptPartRes<bool> {
450-
let mut nocapture = matches.opt_present("nocapture");
453+
let mut nocapture = matches.opt_present("nocapture") || matches.opt_present("no-capture");
451454
if !nocapture {
452455
nocapture = match env::var("RUST_TEST_NOCAPTURE") {
453456
Ok(val) => &val != "0",

0 commit comments

Comments
 (0)