Rollup of 13 pull requests#157616
Open
JonathanBrouwer wants to merge 38 commits into
Open
Conversation
…nce Option calling `.cloned()` or `.copied()` on `Option<T>` where `T` is an owned type emitted "`Option<T>` is not an iterator" with a suggestion to prepend `.into_iter()`. the suggested code still did not compile: `Option<T>::into_iter()` yields `T` by value not `&T`, so `.cloned()`/`.copied()` failed again for the same reason. `Option<T>` implements `IntoIterator`, which is why the `impl_into_iterator_should_be_iterator` branch fires. added a guard before it: when the method is `cloned`/`copied`, the receiver is `Option<T>`, and `T` is a concrete non-reference type, emit a targeted label pointing at the correct form (`Option<&T>`) and suggest removing the call instead.
…y 'unused' size_of calls
Inconsistency happens when subdiagnostic pads the main diagnostic with an empty source line (aka "|"). Meanwhile the parallel frontend might bunch subdiagnostics on a single primary diagnostic, removing padding from some other one. Revert "Update reproducibly failing tests when parallel frontend is enabled" This reverts commit f582193. Apply a test directive format suggested by a reviewer Bless thine tests
…d in comptime fn
…rgetted at what it does
Co-authored-by: Taiki Endo <te316e89@gmail.com> Co-authored-by: Kerry Jones <kerry@iodrive.co.za>
BPF does not support C variadics.
Seemingly on XFS only, the `AlreadyExists` variant is returned.
Reproducible on Linux hosts:
```rust
use clap::Parser;
struct Args {
/// Destination to try
#[arg()]
path: std::path::PathBuf,
}
fn main() {
let args = Args::parse();
// Renaming a directory over a non-empty existing directory should fail.
let tmpdir = std::path::Path::new(&args.path);
std::fs::create_dir_all(tmpdir).unwrap();
let source_path = tmpdir.join("source_directory");
let target_path = tmpdir.join("target_directory");
std::fs::create_dir(&source_path).unwrap();
std::fs::create_dir(&target_path).unwrap();
let target_path_file = target_path.join("target_file.txt");
std::fs::write(target_path.join("target_file.txt"), b"target hello world").unwrap();
println!("wrote {target_path_file:?}");
println!("{source_path:?} -> {target_path:?}");
let err = std::fs::rename(source_path, target_path).unwrap_err();
assert_eq!(err.kind(), std::io::ErrorKind::DirectoryNotEmpty);
}
```
```bash
XFS_BLOCK=image-xfs
truncate -s 512M image-xfs
mkfs.xfs -q image-xfs
mkdir mnt-xfs
sudo mount -o loop image-xfs mnt-xfs
sudo chmod 777 mnt-xfs
cargo run -- mnt-xfs/
```
Output:
```
wrote "mnt-xfs/target_directory/target_file.txt"
"mnt-xfs/source_directory" -> "mnt-xfs/target_directory"
thread 'main' (267220) panicked at src/main.rs:30:5:
assertion `left == right` failed
left: AlreadyExists
right: DirectoryNotEmpty
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
```
asm! support for the Xtensa architecture This implements the asm! support for Xtensa. We've been using this code for a few years in [our fork](https://github.com/esp-rs/rust) and it's been working well. I finally found some time to clean it up a bit and start the upstreaming process. This should be one of the final PRs for Xtensa support on the Rust side (minus bug fixes of course). After this, we're mostly just waiting on the LLVM upstreaming which is going well. This PR doesn't cover all possible asm options for Xtensa, but the base ISA plus a few extras that are used in Espressif chips. r? Amanieu
Add very basic "comptime" fn implementation Implements functions that cannot be called at runtime (and thus also not from normal const functions, as those could be called from runtime). This is done via the internal attribute `rustc_comptime` that can be added to normal functions, turning them into compile-time-only functions. Because @fee1-dead and @compiler-errors did amazing work, we even get trait bounds that work inside comptime fns: via unconditionally-const `const Trait` bounds. Use cases are * rust-lang#146923 * const heap intrinsics * and the other various intrinsics (e.g. size_of 😆) that will just ICE in codegen or panic at runtime if they actually end up in runtime code project goal issue: rust-lang/rust-project-goals#406 no tracking issue until we have a feature gate and some sort of syntax cc @scottmcm as the T-lang goal champion
…cs-in-tests, r=petrochenkov Fix unstable diagnostics in tests The main inconsistency in changed tests happens when subdiagnostic pads the main diagnostic with an empty source line (aka "|"). Meanwhile the parallel frontend might bunch subdiagnostics on a single primary diagnostic, removing padding from some other one. So we can just ignore "|" lines. Updates rust-lang#154314 Reverts rust-lang#157103
Improve TLS codegen by marking the panic/init path as cold This is an extension of the performance improvements seen from <rust-lang#141685>. I noticed that the non-`const` TLS still didn't have the `#[cold]` attribute for the uninit/panic path, and I also realized that neither implementation should have the initialization or panic path inlined, ever. These paths are taken either only once per thread (`init`) or never (`panic`, in a well-behaving Rust program), thus they don't deserve to litter the code generated each time you access a thread-local variable. So in addition to `#[cold]` I added the more aggressive `#[inline(never)]` to both cold paths as well.
…acro_API, r=Mark-Simulacrum Add `_value` API for number literals in proc-macro Part of rust-lang#136652. This PR adds the `*_value` for numbers (integers and floats). However, `f16` and `f128` are voluntarily left out as they're still unstable. Adding support for them is just a matter of uncommenting two lines, so should be fine. Setting same reviewer as last time. r? @Urgau
…r=Mark-Simulacrum xfs support in `test_rename_directory_to_non_empty_directory` While running Ferrocene's test suite we use a variety of filesystems, including XFS. Those systems caught a failing test in [a recent upstream pull](ferrocene/ferrocene#2375). The test failing: https://github.com/rust-lang/rust/blob/1ea1171c1e537f295225be1c7b67dba46794e6ad/library/std/src/fs/tests.rs#L2141-L2157 It was recently removed from being Windows-only in: rust-lang@a0298aa#diff-0ec4075fea7f5f4cc82c306e975ae7638b1fc500d30c11a83f337a69ef1dfd65L2177 Seemingly on XFS only, the `AlreadyExists` variant is returned instead. This workaround allows both possible errors. I am unsure at this time if it is a signal of incorrectness in Rust somewhere, but on Python a similar failure can be noted: ```bash ana@autonoma ~/git/ferrocene/scratch ❯ mkdir blap flap ana@autonoma ~/git/ferrocene/scratch ❯ touch flap/zap ana@autonoma ~/git/ferrocene/scratch ❯ python Python 3.13.13 (main, May 15 2026, 12:38:54) [GCC 15.2.1 20260214] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import os >>> os.rename("blap", "flap") Traceback (most recent call last): File "<python-input-3>", line 1, in <module> os.rename("blap", "flap") ~~~~~~~~~^^^^^^^^^^^^^^^^ FileExistsError: [Errno 17] File exists: 'blap' -> 'flap' ana@autonoma ~/git/ferrocene/scratch ❯ cd /tmp/ ana@autonoma /tmp ❯ mkdir blap flap ana@autonoma /tmp ❯ touch flap/zap ana@autonoma /tmp ❯ python Python 3.13.13 (main, May 15 2026, 12:38:54) [GCC 15.2.1 20260214] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import os >>> os.rename("blap", "flap") Traceback (most recent call last): File "<python-input-1>", line 1, in <module> os.rename("blap", "flap") ~~~~~~~~~^^^^^^^^^^^^^^^^ OSError: [Errno 39] Directory not empty: 'blap' -> 'flap' ``` I tested on `ext4`, `tmpfs`, `overlayfs`, `btrfs`, and `xfs`. Only XFS seems to display this error. ## Reproduction On Linux hosts: ```rust use clap::Parser; struct Args { /// Destination to try #[arg()] path: std::path::PathBuf, } fn main() { let args = Args::parse(); // Renaming a directory over a non-empty existing directory should fail. let tmpdir = std::path::Path::new(&args.path); std::fs::create_dir_all(tmpdir).unwrap(); let source_path = tmpdir.join("source_directory"); let target_path = tmpdir.join("target_directory"); std::fs::create_dir(&source_path).unwrap(); std::fs::create_dir(&target_path).unwrap(); let target_path_file = target_path.join("target_file.txt"); std::fs::write(target_path.join("target_file.txt"), b"target hello world").unwrap(); println!("wrote {target_path_file:?}"); println!("{source_path:?} -> {target_path:?}"); let err = std::fs::rename(source_path, target_path).unwrap_err(); assert_eq!(err.kind(), std::io::ErrorKind::DirectoryNotEmpty); } ``` ```bash XFS_BLOCK=image-xfs truncate -s 512M image-xfs mkfs.xfs -q image-xfs mkdir mnt-xfs sudo mount -o loop image-xfs mnt-xfs sudo chmod 777 mnt-xfs cargo run -- mnt-xfs/ ``` Output: ``` wrote "mnt-xfs/target_directory/target_file.txt" "mnt-xfs/source_directory" -> "mnt-xfs/target_directory" thread 'main' (267220) panicked at src/main.rs:30:5: assertion `left == right` failed left: AlreadyExists right: DirectoryNotEmpty note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace ``` You can run this test directly: ```bash ./x.py --stage 2 test library/std --target x86_64-unknown-linux-gnu -- fs::tests::test_rename_directory_to_non_empty_directory --nocapture ```
…line-tests, r=petrochenkov Relax test requirements for consistency That note occurring under the first emitted warning. Test `tests/ui/lint/rfc-2383-lint-reason/force_warn_expected_lints_fulfilled.rs` fails for parallel frontend due to its inconsistent order of diagnostics, which is fine on its own. As such this PR removes these note requirements and they are now only covered by `force_warn_expected_lints_fulfilled.stderr`, which is almost the same thing. Updates rust-lang#154314 r? @nnethercote
…adic-ignore-bpf, r=folkertdev tests: codegen-llvm: Ignore BPF targets in c-variadic-opt BPF does not support C variadics. r? @nagisa
…diagnostic, r=folkertdev fix: don't suggest .into_iter() for .cloned()/.copied() on non-reference Option calling `.cloned()` or `.copied()` on `Option<T>` where `T` is an owned type emitted "`Option<T>` is not an iterator" with a suggestion to prepend `.into_iter()`. the suggested code still did not compile: `Option<T>::into_iter()` yields `T` by value not `&T` so `.cloned()`/`.copied()` failed again for the same reason. `Option<T>` implements `IntoIterator` which is why the `impl_into_iterator_should_be_iterator` branch fires. added a guard before it: when the method is `cloned`/`copied`, the receiver is `Option<T>` and `T` is a concrete non-reference type. emit a targeted label pointing at the correct form (`Option<&T>`) and suggest removing the call instead. closes rust-lang#151147
…=Nadrieril Fix diagnostics for non-exhaustive destructuring assignments (rust-lang#157553) Assigning to a refutable pattern (e.g. `Foo::One = Foo::One;`) is a destructuring assignment, which is lowered to a `let` binding. When the pattern was refutable, the refutability check reported it as a `let` binding. This detects the `AssignDesugar` origin during match checking and reports it as an assignment instead, dropping the `let`-specific note and suggestion. Fixes rust-lang#157553.
explain that the size_of constant also serves to avoid optimizing away 'unused' size_of calls
During a discussion at the all-hands I got worried that we might do uncanny optimizations on code like this which would lead to that code actually compiling
```rust
#![crate_type = "lib"]
#[unsafe(no_mangle)] // ensure this gets monomorphized
pub fn f() {
assert_valid_type::<[u32; 1 << 62]>();
}
pub fn assert_valid_type<T>() {
std::mem::size_of::<T>();
}
```
We do something like that for [even more cursed similar code](https://play.rust-lang.org/?version=nightly&mode=release&edition=2021&gist=41b84c5e705c9d86a05a919e2135e2d3).
But turns out that for `size_of`, we are good! Ever since that was made a constant, the required_consts system ensures that we do indeed evaluate the constant even if we do not use its results.
r? @oli-obk
…st, r=JonathanBrouwer test: remove ineffective link-extern-crate-with-drop-type test Closes rust-lang#157477 Removed `tests/ui/cross-crate/link-extern-crate-with-drop-type.rs` and its auxiliary file. As discussed in the issue, this test was meant for language-level "resources" which were removed from Rust long ago, making the current test ineffective. Verified locally that the remaining tests in `tests/ui/cross-crate` pass successfully.
…-path, r=mu001999 rustdoc: Remove unnecessary fast path I added this "fast path" prematurely in PR rust-lang#116882. It's not actually necessary as this perf run shows: rust-lang#146483 (comment) (https://perf.rust-lang.org/compare.html?start=40ace17fc3891155bad26a50d60a9ab07b83bf8e&end=a77816d56c8fdadab64ae3f9fe1a653bfdb975a8&stat=instructions:u). Let's remove it since makes it slightly more annoying to add new reprs (one would need to update two places).
Contributor
Author
Contributor
This comment has been minimized.
This comment has been minimized.
rust-bors Bot
pushed a commit
that referenced
this pull request
Jun 8, 2026
Rollup of 13 pull requests try-job: dist-various-1 try-job: test-various try-job: x86_64-gnu-aux try-job: x86_64-gnu-llvm-21-3 try-job: x86_64-msvc-1 try-job: aarch64-apple try-job: x86_64-mingw-1 try-job: i686-msvc-2
Contributor
|
⌛ Testing commit eb90e0a with merge cb46fbb... Workflow: https://github.com/rust-lang/rust/actions/runs/27152763492 |
rust-bors Bot
pushed a commit
that referenced
this pull request
Jun 8, 2026
…uwer Rollup of 13 pull requests Successful merges: - #147302 (asm! support for the Xtensa architecture) - #148820 (Add very basic "comptime" fn implementation) - #157299 (Fix unstable diagnostics in tests) - #143511 (Improve TLS codegen by marking the panic/init path as cold) - #154608 (Add `_value` API for number literals in proc-macro) - #156762 (xfs support in `test_rename_directory_to_non_empty_directory`) - #157300 (Relax test requirements for consistency) - #157383 (tests: codegen-llvm: Ignore BPF targets in c-variadic-opt) - #157413 (fix: don't suggest .into_iter() for .cloned()/.copied() on non-reference Option) - #157578 (Fix diagnostics for non-exhaustive destructuring assignments (#157553)) - #157587 (explain that the size_of constant also serves to avoid optimizing away 'unused' size_of calls) - #157596 (test: remove ineffective link-extern-crate-with-drop-type test) - #157602 (rustdoc: Remove unnecessary fast path)
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Successful merges:
_valueAPI for number literals in proc-macro #154608 (Add_valueAPI for number literals in proc-macro)test_rename_directory_to_non_empty_directory#156762 (xfs support intest_rename_directory_to_non_empty_directory)r? @ghost
Create a similar rollup