Skip to content

Rollup of 10 pull requests #140376

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 24 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
afb78f0
Remove backticks from `ShouldPanic::YesWithMessage`'s `TrFailedMsg`
ShE3py Jan 27, 2025
8808d5a
std(docs): clarify how std::fs::set_permisions works with symlinks
lolbinarycat Apr 8, 2025
37c4a37
clarify std::fs::set_permissions symlink behavior
lolbinarycat Apr 8, 2025
f2534de
crashes: more tests
matthiaskrgr Apr 15, 2025
11f7290
refactor(test): Decouple parsing from help generation
epage Jan 27, 2025
aa8670f
fix(test): Expose '--no-capture', deprecating '--nocapture'
epage Jan 27, 2025
3d29e84
Fix `download-ci-gcc key` in `bootstrap.example.toml`
Kobzol Apr 23, 2025
d4011ae
Download GCC from CI on test builders
Kobzol Apr 23, 2025
59b6cf5
uefi: Update r-efi
Ayush1325 Mar 20, 2025
6f5698c
Avoid re-interning in `LateContext::get_def_path`
DaniPopes Apr 26, 2025
9fed91f
docs: fix incorrect stability markers on `std::{todo, matches}`
notriddle Apr 26, 2025
d40d424
CI: docker: host-x86_64: test-various: uefi_qemu_test: Update r-efi
Ayush1325 Apr 27, 2025
0795b2d
specify explicit safety guidance for from_utf8_unchecked
DiuDiu777 Apr 27, 2025
2ab4034
Add `Arc::is_unique`
SabrinaJewson Mar 25, 2025
de05c64
Rollup merge of #136160 - ShE3py:should-panic-backticks, r=thomcc
ChrisDenton Apr 28, 2025
f383650
Rollup merge of #138395 - Kobzol:ci-download-gcc, r=Mark-Simulacrum
ChrisDenton Apr 28, 2025
0fc8b2a
Rollup merge of #138737 - Ayush1325:r-efi-update, r=tgross35
ChrisDenton Apr 28, 2025
84e92b1
Rollup merge of #138939 - SabrinaJewson:arc-is-unique, r=tgross35
ChrisDenton Apr 28, 2025
cc56d40
Rollup merge of #139224 - epage:nocapture, r=thomcc
ChrisDenton Apr 28, 2025
a5d3110
Rollup merge of #139546 - lolbinarycat:std-set_permissions-75942, r=t…
ChrisDenton Apr 28, 2025
137e5d9
Rollup merge of #139883 - matthiaskrgr:crashesapr15, r=Mark-Simulacrum
ChrisDenton Apr 28, 2025
9ff7370
Rollup merge of #140345 - DaniPopes:get-def-path, r=Urgau
ChrisDenton Apr 28, 2025
caa49b8
Rollup merge of #140351 - rust-lang:notriddle/stability-use, r=thomcc
ChrisDenton Apr 28, 2025
6114a5e
Rollup merge of #140359 - DiuDiu777:str-fix, r=Noratrieb
ChrisDenton Apr 28, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bootstrap.example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion compiler/rustc_lint/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
}

Expand Down
8 changes: 4 additions & 4 deletions library/Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -257,19 +257,19 @@ 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",
]

[[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",
Expand Down
69 changes: 61 additions & 8 deletions library/alloc/src/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -2526,28 +2526,81 @@ 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.
//
// The acquire label here ensures a happens-before relationship with any
// 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
Expand Down
2 changes: 1 addition & 1 deletion library/core/src/str/converts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
///
Expand Down
2 changes: 1 addition & 1 deletion library/core/src/str/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
///
Expand Down
4 changes: 2 additions & 2 deletions library/std/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down
15 changes: 15 additions & 0 deletions library/std/src/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 8 additions & 2 deletions library/std/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand All @@ -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
Expand Down
13 changes: 8 additions & 5 deletions library/test/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
)
Expand Down Expand Up @@ -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:
Expand All @@ -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) {
Expand All @@ -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;
}

Expand Down Expand Up @@ -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",
Expand Down
9 changes: 4 additions & 5 deletions library/test/src/test_result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,15 @@ pub(crate) fn calc_result(
} else if let Some(panic_str) = maybe_panic_str {
TestResult::TrFailedMsg(format!(
r#"panic did not contain expected string
panic message: `{panic_str:?}`,
expected substring: `{msg:?}`"#
panic message: {panic_str:?}
expected substring: {msg:?}"#
))
} else {
TestResult::TrFailedMsg(format!(
r#"expected panic with string value,
found non-string value: `{:?}`
expected substring: `{:?}`"#,
(*err).type_id(),
msg
expected substring: {msg:?}"#,
(*err).type_id()
))
}
}
Expand Down
6 changes: 3 additions & 3 deletions library/test/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,8 @@ fn test_should_panic_bad_message() {
}
let expected = "foobar";
let failed_msg = r#"panic did not contain expected string
panic message: `"an error message"`,
expected substring: `"foobar"`"#;
panic message: "an error message"
expected substring: "foobar""#;
let desc = TestDescAndFn {
desc: TestDesc {
name: StaticTestName("whatever"),
Expand Down Expand Up @@ -238,7 +238,7 @@ fn test_should_panic_non_string_message_type() {
let failed_msg = format!(
r#"expected panic with string value,
found non-string value: `{:?}`
expected substring: `"foobar"`"#,
expected substring: "foobar""#,
TypeId::of::<i32>()
);
let desc = TestDescAndFn {
Expand Down
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ edition = "2021"
resolver = "2"

[dependencies]
r-efi = "4.1.0"
r-efi = "5.2.0"
3 changes: 3 additions & 0 deletions src/ci/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 6 additions & 4 deletions src/doc/rustc/src/tests/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand All @@ -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.
Expand All @@ -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.
Expand Down
Loading
Loading