Auto merge of #140378 - ChrisDenton:rollup-3mj0wp9, r=ChrisDenton
Rollup of 8 pull requests Successful merges: - #138395 (Download GCC from CI on test builders) - #138737 (uefi: Update r-efi) - #138939 (Add `Arc::is_unique`) - #139224 (fix(test): Expose '--no-capture' in favor of `--nocapture`) - #139546 (std(docs): clarify how std::fs::set_permisions works with symlinks) - #140345 (Avoid re-interning in `LateContext::get_def_path`) - #140351 (docs: fix incorrect stability markers on `std::{todo, matches}`) - #140359 (specify explicit safety guidance for from_utf8_unchecked) r? `@ghost` `@rustbot` modify labels: rollup
This commit is contained in:
commit
21079f53a3
14 changed files with 118 additions and 33 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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(())
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -2446,7 +2446,7 @@ impl<T: ?Sized, A: Allocator> Arc<T, A> {
|
|||
#[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<T: ?Sized, A: Allocator> Arc<T, A> {
|
|||
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<T: ?Sized, A: Allocator> Arc<T, A> {
|
|||
// 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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
///
|
||||
|
|
|
|||
|
|
@ -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
|
||||
///
|
||||
|
|
|
|||
|
|
@ -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 = [
|
||||
|
|
|
|||
|
|
@ -2980,6 +2980,21 @@ pub fn read_dir<P: AsRef<Path>>(path: P) -> io::Result<ReadDir> {
|
|||
///
|
||||
/// [changes]: io#platform-specific-behavior
|
||||
///
|
||||
/// ## 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 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.
|
||||
///
|
||||
/// # 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
|
||||
|
|
|
|||
|
|
@ -703,8 +703,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)]
|
||||
|
|
@ -718,8 +724,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
|
||||
|
|
|
|||
|
|
@ -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<OptRes> {
|
||||
// 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) {
|
||||
|
|
@ -210,7 +213,7 @@ pub fn parse_opts(args: &[String]) -> Option<OptRes> {
|
|||
// Check if help was requested.
|
||||
if matches.opt_present("h") {
|
||||
// Show help and do nothing more.
|
||||
usage(binary, &opts);
|
||||
usage(binary, &optgroups());
|
||||
return None;
|
||||
}
|
||||
|
||||
|
|
@ -447,7 +450,7 @@ fn get_color_config(matches: &getopts::Matches) -> OptPartRes<ColorConfig> {
|
|||
}
|
||||
|
||||
fn get_nocapture(matches: &getopts::Matches) -> OptPartRes<bool> {
|
||||
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",
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -7,4 +7,4 @@ edition = "2021"
|
|||
resolver = "2"
|
||||
|
||||
[dependencies]
|
||||
r-efi = "4.1.0"
|
||||
r-efi = "5.2.0"
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue