Skip to content

Rustc pull update #2479

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

Merged
merged 54 commits into from
Jun 26, 2025
Merged

Rustc pull update #2479

merged 54 commits into from
Jun 26, 2025

Conversation

github-actions[bot]
Copy link

Latest update from rustc.

Veykril and others added 30 commits June 17, 2025 08:19
feat: Add the quickfix for increasing visibility of a private field to the private-field diagnostic (previously it was only on no-such-field)
feat: In "Fill match arms", allow users to prefer `Self` to the enum name when possible
Enable automatic cross-compilation in run-make tests

Supersedes rust-lang/rust#138066.

Blocker for rust-lang/rust#141856.

Based on rust-lang/rust#138066 plus `rustdoc()` cross-compile changes.

### Summary

This PR automatically specifies `--target` to `rustc()` and `rustdoc()` to have `rustc`/`rustdoc` produce cross-compiled artifacts in run-make tests by default, unless:

- `//@ ignore-cross-compile` is used, or
- `bare_{rustc,rustdoc}` are used, or
- Explicit `.target()` is specified, which overrides the default cross-compile target.

Some tests are necessarily modified:

- Tests that have `.target(target())` have that incantation removed (since this is now automatically the default).
- Some tests have `//@ needs-target-std`, but are a necessary-but-insufficient condition, and are changed to `//@ ignore-cross-compile` instead as host-only tests.
    - A few tests received `//@ ignore-musl` that fail against `x86_64-unknown-linux-musl` because of inability to find `-lunwind`. AFAICT, they don't *need* to test cross-compiled artifacts.
    - Some tests are constrained to host-only for now, because the effort to make them pass on cross-compile does not seem worth the complexity, and it's not really *meaningfully* improving test coverage.

try-job: dist-various-1
ci: split x86_64-gnu-tools job

try-job: x86_64-gnu-tools
try-job: x86_64-gnu-miri
try-job: aarch64-gnu
Handle win32 separator for cygwin paths

This PR handles a issue that cygwin actually supports Win32 path, so we need to handle the Win32 prefix and separaters.

r? `@mati865`

cc `@jeremyd2019`

~~Not sure if I should handle the prefix like the windows target... Cygwin *does* support win32 paths directly going through the APIs, but I think it's not the recommended way.~~

Here I just use `cygwin_conv_path` because it handles both cygwin and win32 paths correctly and convert them into absolute POSIX paths.

UPDATE: Windows path prefix is handled.
 Allow storing `format_args!()` in variable

Fixes rust-lang/rust#92698

Tracking issue for super let: rust-lang/rust#139076

Tracking issue for format_args: rust-lang/rust#99012

This change allows:

```rust
let name = "world";
let f = format_args!("hello {name}!"); // New: Store format_args!() for later!

println!("{f}");
```

This will need an FCP.

This implementation makes use of `super let`, which is unstable and might not exist in the future in its current form. However, it is entirely reasonable to assume future Rust will always have _a_ way of expressing temporary lifetimes like this, since the (stable) `pin!()` macro needs this too. (This was also the motivation for merging rust-lang/rust#139114.)

(This is a second version of rust-lang/rust#139135)
Add --color=always to test explorer command
…egers, r=tgross35

Use a distinct `ToString` implementation for `u128` and `i128`

Part of rust-lang/rust#135543.

Follow-up of rust-lang/rust#136264.

When working on rust-lang/rust#142098, I realized that `i128` and `u128` could also benefit from a distinct `ToString` implementation so here it.

The last commit is just me realizing that I forgot to add the format tests for `usize` and `isize`.

Here is the bench comparison:

| bench name | last nightly | with this PR | diff |
|-|-|-|-|
| bench_i128 | 29.25 ns/iter (+/- 0.66) | 17.52 ns/iter (+/- 0.7) | -40.1% |
| bench_u128 | 34.06 ns/iter (+/- 0.21) | 16.1 ns/iter (+/- 0.6) | -52.7% |

I used this code to test:

```rust
#![feature(test)]

extern crate test;

use test::{Bencher, black_box};

#[inline(always)]
fn convert_to_string<T: ToString>(n: T) -> String {
    n.to_string()
}

macro_rules! decl_benches {
    ($($name:ident: $ty:ident,)+) => {
        $(
	    #[bench]
            fn $name(c: &mut Bencher) {
                c.iter(|| convert_to_string(black_box({ let nb: $ty = 20; nb })));
            }
	)+
    }
}

decl_benches! {
    bench_u128: u128,
    bench_i128: i128,
}
```
Use jemalloc for Clippy

The tool macros are annoying, we should IMO just get rid of them, create separate steps for each tool and (re)use some builders in them to share the build code.

r? `@ghost`
Add `trim_prefix` and `trim_suffix` methods for both `slice` and `str` types.

Implements `trim_prefix` and `trim_suffix` methods for both `slice` and `str` types, which remove at most one occurrence of a prefix/suffix while always returning a string/slice (rather than Option), enabling easy method chaining.

## Tracking issue
rust-lang/rust#142312

## API
```rust
impl str {
    pub fn trim_prefix<P: Pattern>(&self, prefix: P) -> &str;
    pub fn trim_suffix<P: Pattern>(&self, suffix: P) -> &str
    where
        for<'a> P::Searcher<'a>: ReverseSearcher<'a>;
}

impl<T> [T] {
    pub fn trim_prefix<P: SlicePattern<Item = T> + ?Sized>(&self, prefix: &P) -> &[T]
    where
        T: PartialEq;
    pub fn trim_suffix<P: SlicePattern<Item = T> + ?Sized>(&self, suffix: &P) -> &[T]
    where
        T: PartialEq;
}
```

## Examples
```rust
// Method chaining
assert_eq!(" <https://example.com/> ".trim().trim_prefix('<').trim_suffix('>').trim(), "https://example.com/");

// Slices
let v = &[10, 40, 30];
assert_eq!(v.trim_prefix(&[10]), &[40, 30][..]);
```

## ACP
Originally proposed in rust-lang/libs-team#597
…li-obk

Fix missing docs in `rustc_attr_parsing`
…=lolbinarycat

Fix random failure when JS code is executed when the whole file was not read yet

Very randomly (and rarely), when I arrived on a page with `?search=something` in the URL, I got this error:

![Screenshot From 2025-06-14 11-27-46](https://github.com/user-attachments/assets/4b61b067-4e80-49c1-9a45-cff1509bf86a)

Moving the `initSearch` function at the bottom to ensure everything has been loaded fixes the issue.

PS: Sorry for the noise. Pushed to the wrong branch and rust-lang/rust#142496 closed. ><
…laumeGomez,fmease

add issue template for rustdoc

~~This also expands the scope of the "diagnostic
issue" template to include rustdoc lints,
meaning diagnostic issues will need triaging again. I think this is preferable to the alternative of
cramming even more cases under a single issue template.~~

r? t-rustdoc
rustc-dev-guide subtree update

r? ``@ghost``
Make sure to rebuild rustdoc if `src/rustdoc-json-types` is changed

I think `rustdoc-json-types` was more recently split out, so this download-rustc logic became outdated as it wasn't tracked. This PR adds `src/rustdoc-json-types` to be tracked for difference versus upstream, so that we properly rebuild rustdoc if it has changes versus upstream.

Fixes rust-lang/rust#142738.

### Local testing

This is not so easy to test locally because it requires download-rustc. To test this, you need to:

1. Disable `download-rustc` inhibition from bootstrap changes versus upstream, by including `:!src/bootstrap` in https://github.com/rust-lang/rust/blob/255aa220821c05c3eac7605fce4ea1c9ab2cbdb4/src/bootstrap/src/core/config/config.rs#L67-L74.
2. Then, use a config like `profile = "tools"` which by default uses `download-rustc = "if-unchanged"`.
3. Run `./x test tests/rustdoc-json` one time, to "prime" initial build caches.
4. Change the `FORMAT_VERSION` in `src/rustdoc-json-types`, i.e.
	```diff
	diff --git a/src/rustdoc-json-types/lib.rs b/src/rustdoc-json-types/lib.rs
	index 1f93895ae07..72a3720c7b4 100644
	--- a/src/rustdoc-json-types/lib.rs
	+++ b/src/rustdoc-json-types/lib.rs
	``@@`` -38,7 +38,7 ``@@``
	 // are deliberately not in a doc comment, because they need not be in public docs.)
	 //
	 // Latest feature: Pretty printing of inline attributes changed
	-pub const FORMAT_VERSION: u32 = 48;
	+pub const FORMAT_VERSION: u32 = 666;
	```
5. Observe that without this patch, `rustdoc-json` tests fail because `FORMAT_VERSION` mismatch. Observe that with this patch, rustdoc gets properly rebuilt and `rustdoc-json` tests pass.

cc ``@aDotInTheVoid``

r? Kobzol
Convert `ilog(10)` to `ilog10()`

Except in tests, convert `integer.ilog(10)` to `integer.ilog10()` for better speed and to provide better examples of code that efficiently counts decimal digits. I couldn't find any instances of `integer.ilog(2)`.
Some symbol and PathRoot cleanups

I'm looking into unifying how we join and print paths. Here are some preliminary cleanups.

r? ``@petrochenkov``
…gross35

remove equivalent new method on context

Noticed the two had converged so much they literally became equivalent. So one could go hehe
Rollup of 10 pull requests

Successful merges:

 - rust-lang/rust#142629 (Add config builder for bootstrap tests)
 - rust-lang/rust#142715 (correct template for `#[align]` attribute)
 - rust-lang/rust#142720 (De-dup common code from `ExternalCrate` methods)
 - rust-lang/rust#142736 (add issue template for rustdoc)
 - rust-lang/rust#142743 (rustc-dev-guide subtree update)
 - rust-lang/rust#142744 (Add a mailmap entry for y21)
 - rust-lang/rust#142758 (Make sure to rebuild rustdoc if `src/rustdoc-json-types` is changed)
 - rust-lang/rust#142764 (Convert `ilog(10)` to `ilog10()`)
 - rust-lang/rust#142767 (Some symbol and PathRoot cleanups)
 - rust-lang/rust#142769 (remove equivalent new method on context)

r? `@ghost`
`@rustbot` modify labels: rollup
Rollup of 9 pull requests

Successful merges:

 - rust-lang/rust#142331 (Add `trim_prefix` and `trim_suffix` methods for both `slice` and `str` types.)
 - rust-lang/rust#142491 (Rework #[cold] attribute parser)
 - rust-lang/rust#142494 (Fix missing docs in `rustc_attr_parsing`)
 - rust-lang/rust#142495 (Better template for `#[repr]` attributes)
 - rust-lang/rust#142497 (Fix random failure when JS code is executed when the whole file was not read yet)
 - rust-lang/rust#142575 (Ensure copy* intrinsics also perform the static self-init checks)
 - rust-lang/rust#142650 (Refactor Translator)
 - rust-lang/rust#142713 (mbe: Refactor transcription)
 - rust-lang/rust#142755 (rustdoc: Remove `FormatRenderer::cache`)

r? `@ghost`
`@rustbot` modify labels: rollup
Only traverse reachable blocks in JumpThreading.

Fixes rust-lang/rust#131451

We only compute loop headers for reachable blocks. We shouldn't try to perform an opt on unreachable blocks anyway.
…r=nnethercote

Avoid a few more allocations in `write_shared.rs`

Inspired by rust-lang/rust#141421 , avoids a few `Vec`, `PathBuf` and `String` allocations in `write_shared.rs`. I don't think these will show up on benchmarks, but are still worthwhile IMHO.
Also includes a few small cleanups.
r? nnethercote - if you'd like :)
Preserve caches in a call to shrink_to_fit

A small follow up to rust-lang/rust#142542.
completely deduplicate `Visitor` and `MutVisitor`

r? oli-obk

This closes rust-lang/rust#127615.

### Discussion

> * Give every `MutVisitor::visit_*` method a corresponding `flat_map_*` method.

Not every AST node exists in a location where they can be mapped to multiple instances of themselves. Not every AST node exists in a location where they can be removed from existence (e.g. `filter_map_expr`). I don't think this is doable.

> * Give every `MutVisitor::visit_*` method a corresponding `Visitor` method and vice versa

The only three remaining method-level asymmetries after this PR are `visit_stmt` and `visit_nested_use_tree` (only on `Visitor`) and `visit_span` (only on `MutVisitor`).

`visit_stmt` doesn't seem applicable to `MutVisitor` because `walk_flat_map_stmt_kind` will ask `flat_map_item` / `filter_map_expr` to potentially turn a single `Stmt` to multiple based on what a visitor wants. So only using `flat_map_stmt` seems appropriate.

`visit_nested_use_tree` is used for `rustc_resolve` to track stuff. Not useful for `MutVisitor` for now.

`visit_span` is currently not used for `MutVisitor` already, it was just kept in case we want to revive rust-lang/rust#127241. cc `@cjgillot` maybe we could remove for now and re-insert later if we find a use-case? It does involve some extra effort to maintain.

* Remaining FIXMEs

`visit_lifetime` has an extra param for `Visitor` that's not in `MutVisitor`. This is again something only used by `rustc_resolve`. I think we can keep that symmetry for now.
bors and others added 24 commits June 22, 2025 23:30
Let String pass #[track_caller] to its Vec calls

I've added `#[track_caller]` to `String` methods that delegate to `Vec` methods that already have `#[track_caller]`.

I've also added `#[track_caller]` to methods that have `assert!` or `panic!` due to invalid inputs.
…youxu

Document subdirectories of UI tests with README files

Part of rust-lang/rust#133895 and the [2025 Google Summer of Code](https://blog.rust-lang.org/2025/05/08/gsoc-2025-selected-projects/) associated project.

When adding a new UI test, one is faced with hundreds of subdirectories in `tests/ui` reflecting various categories. Knowing where to put the new test is not trivial, as many of the categories have slightly misleading names. For example, `moves` does not only refer to the `move` keyword but to functions taking ownership in general, whereas `allocator` does not refer to allocation in general but rather to the very specific `allocator_api` and `global_allocator` features.

Many contributors will therefore place their test at the top level of ̀`tests/ui` where it will be mixed with hundreds of unrelated tests.

This PR is a tentative move towards more clearly defined tag/categories, with a SUMMARY.md file documenting the true purpose of each subdirectory, placed inside `tests/ui`.

r? ``@jieyouxu``
…lmann

Port `#[no_mangle]` to new attribute parsing infrastructure

Ports `no_mangle` to the new attribute parsing infrastructure for rust-lang/rust#131229 (comment)

r? ``@jdonszelmann``
…t, r=workingjubilee

centralize `-Zmin-function-alignment` logic

tracking issue: rust-lang/rust#82232
discussed in: rust-lang/rust#142824 (comment)

Apply the `-Zmin-function-alignment` value to the alignment field of the function attributes when those are created, so that individual backends don't need to consider it.

The one exception right now is cranelift, because it can't yet set the alignment for individual functions, but it can (and does) set the global minimum function alignment.

cc ``@RalfJung`` I think this is an improvement regardless, is there anything else that should be done for miri?
…pdate, r=Kobzol

Check rustdoc-json-types FORMAT_VERSION is correctly updated

Follow-up of rust-lang/rust#142677.

``@nnethercote`` suggested that we should also ensure that the `FORMAT_VERSION` was only increased by 1 and we should check for it, this PR does it.

cc ``@aDotInTheVoid``
r? ghost
Rollup of 5 pull requests

Successful merges:

 - rust-lang/rust#141597 (Document subdirectories of UI tests with README files)
 - rust-lang/rust#142823 (Port `#[no_mangle]` to new attribute parsing infrastructure)
 - rust-lang/rust#142828 (1.88.0 release notes)
 - rust-lang/rust#142854 (centralize `-Zmin-function-alignment` logic)
 - rust-lang/rust#142875 (Check rustdoc-json-types FORMAT_VERSION is correctly updated)

r? `@ghost`
`@rustbot` modify labels: rollup
Bump the version number to 1.90.0

Part of the release process. This PR must not be rolled up.

r? cuviper
Subtree update of `rust-analyzer`

r? `@ghost`
update to literal-escaper 0.0.4 for better API without `unreachable` and faster string parsing

This is the replacement for just the part of rust-lang/rust#138163 dealing with the changed API of unescape functionality, since that got moved into its own crate.

<del>This uses an unpublished version of literal-escaper (https://github.com/rust-lang/literal-escaper/pull/8).</del>

r? `@nnethercote`
Apply `impl_super_outlives` optimization to new trait solver

I never did rust-lang/rust#128746 for the new solver.

r? lcnr
Leave from CopyProp early when there are no replacements

r? cjgillot
Remove dead instructions in terminate blocks

Terminate blocks look pretty in the IR I've looked at, so no actual perf delta from this. But it seems reasonable to note produce unused IR.
`tests/ui`: A New Order [8/N]

Some `tests/ui/` housekeeping, to trim down number of tests directly under `tests/ui/`. Part of rust-lang/rust#133895.
Add runtime check to avoid overwrite arg in `Diag`

## Origin PR description
At first, I set up a `debug_assert` check for the arg method to make sure that `args` in `Diag` aren't easily overwritten, and I added the `remove_arg()` method, so that if you do need to overwrite an arg, then you can explicitly call `remove_arg()` to remove it first, then call `arg()` to overwrite it.

For the code before the rust-lang/rust#142015 change, it won't compile because it will report an error
```
arg `instance`already exists.
```

This PR also modifies all diagnostics that fail the check to pass the check. There are two cases of check failure:

1. ~~Between *the parent diagnostic and the subdiagnostic*, or *between the subdiagnostics* have the same field between them. In this case, I renamed the conflicting fields.~~
2. ~~For subdiagnostics stored in `Vec`, the rendering may iteratively write the same arg over and over again. In this case, I changed the auto-generation with `derive(SubDiagnostic)` to manually implementing `SubDiagnostic` and manually rendered it with `eagerly_translate()`, similar to rust-lang/rust#142031 (comment), and after rendering it I manually deleted useless arg with the newly added `remove_arg` method.~~

## Final Decision

After trying and discussing, we made a final decision.

For `#[derive(Subdiagnostic)]`, This PR made two changes:

1. After the subdiagnostic is rendered, remove all args of this subdiagnostic, which allows for usage like `Vec<Subdiag>`.
2. Store `diag.args` before setting arguments, so that you can restore the contents of the main diagnostic after deleting the arguments after subdiagnostic is rendered, to avoid deleting the main diagnostic's arg when they have the same name args.
Add PrintTAFn flag for targeted type analysis printing

## Summary
This PR adds a new `PrintTAFn` flag to the `-Z autodiff` option that allows printing type analysis information for a specific function, rather than all functions.

## Changes

### New Flag
- Added `PrintTAFn=<function_name>` option to `-Z autodiff`
- Usage: `-Z autodiff=Enable,PrintTAFn=my_function_name`

### Implementation Details
- **Rust side**: Added `PrintTAFn(String)` variant to `AutoDiff` enum
- **Parser**: Updated `parse_autodiff` to handle `PrintTAFn=<function_name>` syntax with proper error handling
- **FFI**: Added `set_print_type_fun` function to interface with Enzyme's `FunctionToAnalyze` command line option
- **Documentation**: Updated help text and documentation for the new flag

### Files Modified
- `compiler/rustc_session/src/config.rs`: Added `PrintTAFn(String)` variant
- `compiler/rustc_session/src/options.rs`: Updated parser and help text (now shows `PrintTAFn` in the list)
- `compiler/rustc_codegen_llvm/src/llvm/enzyme_ffi.rs`: Added FFI function and static variable
- `compiler/rustc_codegen_llvm/src/back/lto.rs`: Added handling for new flag
- `src/doc/rustc-dev-guide/src/autodiff/flags.md`: Updated documentation
- `src/doc/unstable-book/src/compiler-flags/autodiff.md`: Updated documentation

## Testing
The flag can be tested with:
```bash
rustc +enzyme -Z autodiff=Enable,PrintTAFn=square test.rs
```

This will print type analysis information only for the function named "square" instead of all functions.

## Error Handling
The parser includes proper error handling:
- Missing argument: `PrintTAFn` without `=<function_name>` will show an error
- Unknown options: Invalid autodiff options will be reported

r? ```@ZuseZ4```
Check CoerceUnsized impl validity before coercing

Self-explanatory from the title.

Fixes rust-lang/rust#126982
Fixes rust-lang/rust#131048
Fixes rust-lang/rust#134217
Fixes rust-lang/rust#126269
Fixes rust-lang/rust#138265
…r=jieyouxu

Convert some ABI tests to use `extern "rust-invalid"`
Make `Sub`, `Mul`, `Div` and `Rem`  `const_traits`

Generally useful for implementation, like Add.
Rollup of 7 pull requests

Successful merges:

 - rust-lang/rust#142146 (Withdraw the claim `extern "C-cmse-nonsecure-*"` always matches `extern "C"`)
 - rust-lang/rust#142200 (`tests/ui`: A New Order [8/N])
 - rust-lang/rust#142724 (Add runtime check to avoid overwrite arg in `Diag`)
 - rust-lang/rust#142809 (Add PrintTAFn flag for targeted type analysis printing)
 - rust-lang/rust#142976 (Check CoerceUnsized impl validity before coercing)
 - rust-lang/rust#142992 (Convert some ABI tests to use `extern "rust-invalid"`)
 - rust-lang/rust#143000 (Make `Sub`, `Mul`, `Div` and `Rem`  `const_traits`)

r? `@ghost`
`@rustbot` modify labels: rollup
@rustbot
Copy link
Collaborator

rustbot commented Jun 26, 2025

Thanks for the PR. If you have write access, feel free to merge this PR if it does not need reviews. You can request a review using r? rustc-dev-guide or r? <username>.

@rustbot rustbot added the S-waiting-on-review Status: this PR is waiting for a reviewer to verify its content label Jun 26, 2025
@rustbot rustbot closed this Jun 26, 2025
@rustbot rustbot reopened this Jun 26, 2025
@tshepang tshepang merged commit 3008550 into master Jun 26, 2025
1 check passed
@tshepang tshepang deleted the rustc-pull branch June 26, 2025 04:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: this PR is waiting for a reviewer to verify its content
Projects
None yet
Development

Successfully merging this pull request may close these issues.