Commit Graph

320818 Commits

Author SHA1 Message Date
Jonathan Brouwer 20ef8d1b13 Rollup merge of #153750 - tshepang:rdg-sync, r=tshepang
rustc-dev-guide subtree update

Subtree update of `rustc-dev-guide` to https://github.com/rust-lang/rustc-dev-guide/commit/f6cc6f634e282fa4cfe25310ed80a14bbc88ee48.

Created using https://github.com/rust-lang/josh-sync.

r? @ghost
2026-03-12 12:31:43 +01:00
Jonathan Brouwer 32143e9676 Rollup merge of #153748 - lolbinarycat:editorconfig-css, r=jieyouxu
editorconfig: css uses tabs

Tidy enforces the fact that css files use tabs, but currently `.editorconfig` says everything that isn't llvm or a Makefile should always use spaces.  This PR makes it so all editors that honor `.editorconfig` will use the correct indentation for css files.
2026-03-12 12:31:43 +01:00
Jonathan Brouwer 82017d9f5c Rollup merge of #153736 - cyrgani:incomplete-2, r=fmease
add test that an incomplete feature emits a warning

Related to https://github.com/rust-lang/compiler-team/issues/974, this PR adds a new test to specifically check that a dummy incomplete feature triggers the `incomplete_features` lint. (since this seemed to be the favored approach on Zulip)

Alternative to https://github.com/rust-lang/rust/pull/153706.

r? fmease
2026-03-12 12:31:42 +01:00
Jonathan Brouwer 9488c30b6c Rollup merge of #153717 - ralpha:unused_macro_rules-lint-correction, r=TaKO8Ki
unused_macro_rules switched used and unused comments

Incorrect swapping of "used" and "unused".

The lint example:
```rust
#[warn(unused_macro_rules)]
macro_rules! unused_empty {
    (hello) => { println!("Hello, world!") }; // This rule is unused
    () => { println!("empty") }; // This rule is used
}

fn main() {
    unused_empty!(hello);
}
```

It is clearly using the `(hello)` case. Yet it is labeled as "unused".
This PR fixed that small issue and corrects the mistake.
2026-03-12 12:31:42 +01:00
Jonathan Brouwer 04cf7532ea Rollup merge of #153694 - TKanX:bugfix/153391-cycle-error-key-param, r=nnethercote
fix(query): Pass Query Key to `value_from_cycle_error`

### Summary:

Pass the query key directly to `value_from_cycle_error` so that `FromCycleError` impls (notably `FnSig`) can use the recovered query's `DefId` instead of relying on `cycle[0]`, which is arbitrarily rotated by the parallel deadlock handler.

As suggested in [#153644 (comment)](https://github.com/rust-lang/rust/pull/153644#issuecomment-4030645331).

Closes rust-lang/rust#153391

r? @nnethercote
cc @zetanumbers
2026-03-12 12:31:41 +01:00
Jonathan Brouwer 8aea29b091 Rollup merge of #153529 - homersimpsons:chore/fix-LegacyKeyValueFormat-pr, r=marcoieni
Fix LegacyKeyValueFormat report from docker build: pr

Part of https://github.com/rust-lang/rust/pull/152305

r? @marcoieni
2026-03-12 12:31:40 +01:00
Jonathan Brouwer 5d17f08215 Rollup merge of #153432 - nnethercote:dataflow-comments, r=cjgillot
Fix some comments about dataflow analysis.

Mostly in the examples in `initialized.rs`. In particular, the `EverInitializedPlaces` example currently doesn't cover how it's initialization sites that are tracked, rather than local variables (that's the `b_0`/`b_1` distinction in the example.)

r? @cjgillot
2026-03-12 12:31:40 +01:00
Jonathan Brouwer 0102e918fd Rollup merge of #153763 - nikic:target-cpu-native-fix, r=lqd
Don't add empty target features for target-cpu=native on macOS

LLVM does not support host feature detection (only host cpu detection) on apple platforms. As such, the returned feature string will be empty. Adding this empty string to the target-features attribute results in a verifier error on LLVM 22.

Fix this by not adding the empty string to the target features. The reason why this was not caught by the target-cpu-native test is that it requires a function that adds *some* target features, otherwise the attribute is omitted entirely. We achieve this with a somewhat peculiar construction that enables `neon` if it's already enabled. (This is to avoid enabling it on softfloat targets.)

Fixes https://github.com/rust-lang/rust/issues/153397.
2026-03-12 12:31:40 +01:00
Jonathan Brouwer 305778ca68 Rollup merge of #153726 - Kobzol:parallel-frontend-tests-optional, r=jieyouxu
Add optional CI job to build the compiler with the parallel frontend

Discussed on [Zulip](https://rust-lang.zulipchat.com/#narrow/channel/187679-t-compiler.2Fparallel-rustc/topic/Add.20the.20parallel.20front-end.20test.20suite/with/578684794).

Note: this only builds the compiler, stdlib, etc. with 2 threads. UI tests are still compiled serially. I'd add that in a follow-up PR if we see that this new job works well (and if optional auto jobs work well in the first place).

r? @jieyouxu
2026-03-12 12:31:39 +01:00
Nikita Popov 0670491950 Don't add empty target features for target-cpu=native on macOS
LLVM does not support host feature detection (only host cpu
detection) on apple platforms. As such, the returned feature
string will be empty. Adding this empty string to the target-features
attribute results in a verifier error on LLVM 22.

Fix this by not adding the empty string to the target features.
The reason why this was not caught by the target-cpu-native test
is that it requires a function that adds *some* target features,
otherwise the attribute is omitted entirely. We achieve this with
a somewhat peculiar construction that enables `neon` if it's
already enabled. (This is to avoid enabling it on softfloat targets.)
2026-03-12 10:00:21 +01:00
Jakub Beránek b3333b3aaf Document optional auto jobs in the rustc-dev-guide 2026-03-12 09:35:56 +01:00
Jakub Beránek 96e4833bea Add new CI job that runs tests with a toolchain built with multiple threads 2026-03-12 09:08:51 +01:00
Jakub Beránek ac062fd223 Allow auto jobs to be non-blocking 2026-03-12 09:05:44 +01:00
Tony Kan 3464048bc4 test(parallel): Add regression test for #153391
Co-authored-by: Daria Sukhonina <zetanumbers@users.noreply.github.com>
2026-03-11 19:19:31 -07:00
Tony Kan cfcbcb715c fix(query): Pass query key to value_from_cycle_error
Co-authored-by: Daria Sukhonina <zetanumbers@users.noreply.github.com>
Co-authored-by: Nicholas Nethercote <nnethercote@users.noreply.github.com>
2026-03-11 19:19:24 -07:00
Tshepang Mbambo da4f9a7e65 Merge pull request #2795 from rust-lang/tshepang/sembr
sembr a few files
2026-03-12 02:14:38 +01:00
Tshepang Mbambo 751562faf5 sembr src/tracing.md 2026-03-12 02:10:03 +01:00
Tshepang Mbambo 7963b55d9a sembr src/git.md 2026-03-12 02:09:02 +01:00
Tshepang Mbambo 5de87cd04a sembr src/diagnostics/translation.md 2026-03-12 02:08:20 +01:00
Tshepang Mbambo 5e305ab74d sembr src/backend/updating-llvm.md 2026-03-12 02:05:08 +01:00
binarycat db26b5b8e0 editorconfig: css uses tabs 2026-03-11 18:07:27 -05:00
bors d1ee5e59a9 Auto merge of #153741 - JonathanBrouwer:rollup-xwr7mEB, r=JonathanBrouwer
Rollup of 12 pull requests

Successful merges:

 - rust-lang/rust#152569 (Stop using rustc_layout_scalar_valid_range_* in rustc)
 - rust-lang/rust#153421 (Fix ICE in fn_delegation when child segment resolves to a trait)
 - rust-lang/rust#153571 (Avoid ICE when an EII declaration conflicts with a constructor)
 - rust-lang/rust#153581 (Simplify `type_of_opaque`.)
 - rust-lang/rust#153611 (interpret: go back to regular string interpolation for error messages)
 - rust-lang/rust#153635 (Unify same-span labels in move error diagnostics)
 - rust-lang/rust#153660 (mir-opt: Drop invalid debuginfos after SingleUseConsts.)
 - rust-lang/rust#153685 (Introduce `for_each_query_vtable!` to move more code out of query macros)
 - rust-lang/rust#153722 (miri-test-libstd: use --tests and update some comments)
 - rust-lang/rust#153671 (Make Enzyme has dependent on LLVM hash)
 - rust-lang/rust#153710 (remove `.ftl` checks from tidy)
 - rust-lang/rust#153720 (doc/rustc: clarify how to contact arm-maintainers)
2026-03-11 21:06:42 +00:00
Jonathan Brouwer f3dfb442a7 Rollup merge of #153720 - davidtwco:contact-arm-maintainers, r=RalfJung
doc/rustc: clarify how to contact arm-maintainers

Addresses feedback from https://github.com/rust-lang/rust/pull/147268#discussion_r2838223188
2026-03-11 22:05:48 +01:00
Jonathan Brouwer 69d352f10c Rollup merge of #153710 - cyrgani:tidy-ftl, r=bjorn3
remove `.ftl` checks from tidy

These files have been removed following https://github.com/rust-lang/compiler-team/issues/959.
Part of https://github.com/rust-lang/rust/issues/151366.
2026-03-11 22:05:48 +01:00
Jonathan Brouwer 23b1e6a8c4 Rollup merge of #153671 - ZuseZ4:make-enzyme-bootstrap-robust, r=Kobzol
Make Enzyme has dependent on LLVM hash

This issue was encountered a few times by autodiff contributors.
Closes https://github.com/rust-lang/rust/issues/152969

Just adding the llvm hash here triggered a rebuild of Enzyme locally, but I'll admit I didn't try it with a real llvm submodule update.

r? @Kobzol
2026-03-11 22:05:47 +01:00
Jonathan Brouwer ad0e037d39 Rollup merge of #153722 - RalfJung:miri-test-benches, r=Kobzol
miri-test-libstd: use --tests and update some comments

rust-lang/rust#153143 added `./x test --tests` matching `cargo --tests`, which is exactly what Miri wants when testing the standard library. So let's use it for that. We can then also remove a hack in `library/alloctests/benches/vec_deque_append.rs`.

Also update the comment for why the other benchmarks still need to be disabled in Miri, and remove some `cfg_attr` that seem unnecessary since the entire crate that contains them is already disabled in Miri. Those were copied over in https://github.com/rust-lang/rust/commit/b8fa843a1a60146b93ca5b1d11bbe23c1b1076f3 -- they used to be needed since benches and tests were in the same crate, but they aren't any more.
2026-03-11 22:05:46 +01:00
Jonathan Brouwer 844950343e Rollup merge of #153685 - Zalathar:for-each-query, r=nnethercote
Introduce `for_each_query_vtable!` to move more code out of query macros

After https://github.com/rust-lang/rust/pull/153114 moved a few for-each-query functions into the big `rustc_query_impl::plumbing` macro, I have found that those functions became much harder to navigate and modify, because they no longer have access to ordinary IDE features in rust-analyzer. Even *finding* the functions is considerably harder, because a plain go-to-definition no longer works smoothly.

This PR therefore tries to move as much of that code back out of the macro as possible, with the aid of a smaller `for_each_query_vtable!` helper macro. A typical use of that macro looks like this:

```rust
for_each_query_vtable!(ALL, tcx, |query| {
    query_key_hash_verify(query, tcx);
});
```

The result is an outer function consisting almost entirely of plain Rust code, with all of the usual IDE affordances expected of normal Rust code. Because it uses plain Rust syntax, it can also be formatted automatically by rustfmt.

Adding another layer of macro-defined macros is not something I propose lightly, but in this case I think the improvement is well worth it:
- The outer functions can once again be defined as “normal” Rust functions, right next to their corresponding inner functions, making navigation and modification much easier.
- The closure expression is ordinary Rust code that simply gets repeated ~300 times in the expansion, once for each query, in order to account for the variety of key/value/cache types used by different queries. Even within the closure expression, IDE features still *mostly* work, which is an improvement over the status quo.
- For future maintainers looking at the call site, the macro's effect should hopefully be pretty obvious and intuitive, reducing the need to even look at the helper macro. And the helper macro itself is largely straightforward, with its biggest complication being that it necessarily uses the `$name` metavar from the outer macro.

There should be no change to compiler behaviour.

r? nnethercote (or compiler)
2026-03-11 22:05:46 +01:00
Jonathan Brouwer a00aa4c5fb Rollup merge of #153660 - dianqk:dbg-single-use-const, r=mati865
mir-opt: Drop invalid debuginfos after SingleUseConsts.

Fixes https://github.com/rust-lang/rust/issues/153601.
2026-03-11 22:05:45 +01:00
Jonathan Brouwer ce0374c6ae Rollup merge of #153635 - arferreira:unify-move-error-span-labels, r=estebank
Unify same-span labels in move error diagnostics

Fixes rust-lang/rust#153506.

When there's a single binding in a move error, we emit "data moved here" and "move occurs because ... does not implement the Copy trait" as two separate labels on the same span. This combines them into one label via a new `TypeNoCopy::LabelMovedHere` variant.

The multi-binding case still uses separate labels + a note since they point at different spans.

cc @estebank
2026-03-11 22:05:45 +01:00
Jonathan Brouwer 77134bd3e2 Rollup merge of #153611 - RalfJung:interp-error-strings, r=oli-obk
interpret: go back to regular string interpolation for error messages

Using the translatable diagnostic infrastructure adds a whole lot of boilerplate which isn't actually useful for const-eval errors, so let's get rid of it. This effectively reverts https://github.com/rust-lang/rust/pull/111677. That PR effectively added 1000 lines and this PR only removes around 600 -- the difference is caused by (a) keeping some of the types around for validation, where we can use them to share error strings and to trigger the extra help for pointer byte shenanigans during CTFE, and (b) this not being a full revert of rust-lang/rust#111677; I am not touching diagnostics outside the interpreter such as all the const-checking code which also got converted to fluent in the same PR.

The last commit does something similar for `LayoutError`, which also helps deduplicate a bunch of error strings. I can make that into a separate PR if you prefer.

r? @oli-obk
Fixes https://github.com/rust-lang/rust/issues/113117
Fixes https://github.com/rust-lang/rust/issues/116764
Fixes https://github.com/rust-lang/rust/issues/112618
2026-03-11 22:05:44 +01:00
Jonathan Brouwer 4e64a8b568 Rollup merge of #153581 - nnethercote:rm-cycle_stash, r=oli-obk
Simplify `type_of_opaque`.

There is a bunch of complexity supporting the "cannot check whether the hidden type of opaque type satisfies auto traits" error that shows up in `tests/ui/impl-trait/auto-trait-leak.rs`. This is an obscure error that shows up in a single test. If we are willing to downgrade that error message to a cycle error, we can do the following.

- Simplify the `type_of_opaque` return value.
- Remove the `cycle_stash` query modifier.
- Remove the `CyclePlaceholder` type.
- Remove the `SelectionError::OpaqueTypeAutoTraitLeakageUnknown` variant.
- Remove a `FromCycleError` impl.
- Remove `report_opaque_type_auto_trait_leakage`.
- Remove the `StashKey::Cycle` variant.
- Remove the `CycleErrorHandling::Stash` variant.

That's a lot! I think this is a worthwhile trade-off.

r? @oli-obk
2026-03-11 22:05:43 +01:00
Jonathan Brouwer 627a150072 Rollup merge of #153571 - TaKO8Ki:eii-ice-153502, r=jdonszelmann
Avoid ICE when an EII declaration conflicts with a constructor

Fixes rust-lang/rust#153502

When an `#[eii]` declaration conflicts with a tuple-struct constructor of the same name, error recovery can resolve
the EII target to the constructor instead of the generated foreign item. `compare_eii_function_types` then assumes
that target is a foreign function and later ICEs while building diagnostics.

This pull request adds an early guard in `compare_eii_function_types` to skip EII signature comparison unless the resolved target is actually a foreign function.
2026-03-11 22:05:43 +01:00
Jonathan Brouwer 0b15b91dff Rollup merge of #153421 - GokhanKabar:fix-delegation-ice, r=petrochenkov
Fix ICE in fn_delegation when child segment resolves to a trait

Fixes rust-lang/rust#153420

When a delegation path like `reuse Trait::<> as bar4` has only one segment resolving to a trait (not a function), the child args processing in `get_delegation_user_specified_args` called `lower_generic_args_of_path` with `self_ty = None`. Since the trait's generics have `has_self = true`, this triggered
`assert!(self_ty.is_some())`.

Fix by computing and providing `self_ty` when the child segment's `def_id` has `has_self`. In valid delegation code the child segment always resolves to a function, so this only affects error recovery.
2026-03-11 22:05:42 +01:00
Jonathan Brouwer 707bf0961a Rollup merge of #152569 - oli-obk:rustc_layout_scalar_valid_range_end_end, r=davidtwco
Stop using rustc_layout_scalar_valid_range_* in rustc

*[View all comments](https://triagebot.infra.rust-lang.org/gh-comments/rust-lang/rust/pull/152569)*

Another step towards rust-lang/rust#135996

Required some manual impls, but we already do many manual impls for the newtype_index types, so it's not really a new maintenance burden.
2026-03-11 22:05:41 +01:00
cyrgani c909ae5a35 add test that an incomplete feature emits a warning 2026-03-11 18:26:49 +00:00
GokhanKabar 86880c90c2 Fix ICE in fn_delegation when child segment resolves to a trait
When a delegation path like `reuse Trait::<> as bar4` has a child segment
that resolves to a trait instead of a function, the compiler would ICE
because `lower_generic_args_of_path` asserts that `self_ty` is `Some`
when `has_self` is true and `parent` is `None`.

Fix this by filtering out non-function child segments early using
`.filter()` in the method chain, so that when the child segment resolves
to a trait (error recovery for E0423), we skip generic args computation
entirely and return an empty list via `unwrap_or_default()`.

Also make `get_segment` return `Option` by using `opt_def_id()` instead
of `def_id()` to gracefully handle unresolved segments.
2026-03-11 16:40:54 +01:00
Ralf Jung bc4dfa5e33 miri-test-libstd: use --tests and update some comments 2026-03-11 15:17:23 +01:00
Ralf Jung fe1f92af4b de-duplicate LayoutError formatting 2026-03-11 13:55:03 +01:00
Ralf Jung 90f7d7e074 clean up some unused leftovers 2026-03-11 13:53:40 +01:00
Ralf Jung 94361fba3e interpret: go back to regular string interpolation for error messages 2026-03-11 13:53:40 +01:00
ralpha 9fcec027de unused_macro_rules switched used and unused comments 2026-03-11 13:28:59 +01:00
bors 3b1b0ef4d8 Auto merge of #153704 - JonathanBrouwer:rollup-f0S4ki3, r=JonathanBrouwer
Rollup of 4 pull requests

Successful merges:

 - rust-lang/rust#153072 (Allow merging all libcore/alloc doctests into a single binary)
 - rust-lang/rust#153408 (miri: make read_discriminant UB when the tag is not in the validity range of the tag field)
 - rust-lang/rust#153674 (Detect inherent method behind deref being shadowed by trait method)
 - rust-lang/rust#153689 (Eliminate `QueryLatchInfo`.)
2026-03-11 11:49:55 +00:00
Zalathar d066ff7263 Pass the vtable to alloc_self_profile_query_strings_for_query_cache
This simplifies the inner function's signature, and makes it more consistent
with other uses of `for_each_query_vtable!`.
2026-03-11 22:18:02 +11:00
Zalathar 0059012ab2 Introduce for_each_query_vtable! to move more code out of query macros 2026-03-11 22:18:00 +11:00
cyrgani 59733c61e8 remove .ftl checks from tidy 2026-03-11 11:09:43 +00:00
Nicholas Nethercote 3399ed3c9a Simplify type_of_opaque.
There is a bunch of complexity supporting the "cannot check whether the
hidden type of opaque type satisfies auto traits" error that shows up in
`tests/ui/impl-trait/auto-trait-leak.rs`. This is an obscure error that
shows up in a single test. If we are willing to downgrade that error
message to a cycle error, we can do the following.

- Simplify the `type_of_opaque` return value.
- Remove the `cycle_stash` query modifier.
- Remove the `CyclePlaceholder` type.
- Remove the `SelectionError::OpaqueTypeAutoTraitLeakageUnknown`
  variant.
- Remove a `FromCycleError` impl.
- Remove `report_opaque_type_auto_trait_leakage`.
- Remove the `StashKey::Cycle` variant.
- Remove the `CycleErrorHandling::Stash` variant.

That's a lot! I think this is a worthwhile trade-off.
2026-03-11 21:54:42 +11:00
Takayuki Maeda be78a0d629 avoid ICE when EII target resolves to a constructor
remove span_delayed_bug
2026-03-11 19:04:46 +09:00
Jonathan Brouwer 53e67f248d Rollup merge of #153689 - nnethercote:rm-QueryLatchInfo, r=petrochenkov
Eliminate `QueryLatchInfo`.

The boolean `complete` flag indicates whether the `waiters` vec is still in use, which means the `waiters` vec must be empty when `complete` is true. This is achieved by using `drain` on the waiters just after `complete` is set.

We can do better by using the type system to make invalid combinations impossible. This commit removes `complete` and puts the waiters inside an `Option`. `Some` means the query job is still active, and `None` once it is complete. And `QueryLatchInfo` is eliminated.

(The `Arc<Mutex<Option<Vec<Arc<QueryWaiter<'tcx>>>>>>` type is a mouthful, but when it's all in one place I find it easier to understand than when it's split across two types. And we can use `Option` methods like `as_ref`, `as_mut`, and `take`, which is nice.)

r? @petrochenkov
2026-03-11 10:58:52 +01:00
Jonathan Brouwer 3679ba7fb0 Rollup merge of #153674 - estebank:issue-41906, r=petrochenkov
Detect inherent method behind deref being shadowed by trait method

```
error[E0277]: the trait bound `Rc<RefCell<S>>: Borrow<S>` is not satisfied
  --> $DIR/shadowed-intrinsic-method-deref.rs:16:22
   |
LL |     let sb : &S = &s.borrow();
   |                      ^^^^^^ the trait `Borrow<S>` is not implemented for `Rc<RefCell<S>>`
   |
help: the trait `Borrow<S>` is not implemented for `Rc<RefCell<S>>`
      but trait `Borrow<RefCell<S>>` is implemented for it
  --> $SRC_DIR/alloc/src/rc.rs:LL:COL
   = help: for that trait implementation, expected `RefCell<S>`, found `S`
   = note: there's an inherent method on `RefCell<S>` of the same name, which can be auto-dereferenced from `&RefCell<T>`
help: to access the inherent method on `RefCell<S>`, use the fully-qualified path
   |
LL -     let sb : &S = &s.borrow();
LL +     let sb : &S = &RefCell::borrow(&s);
   |
```

In the example above, method `borrow` is available both on `<RefCell<S> as Borrow<S>>` *and* on `RefCell<S>`. Adding the import `use std::borrow::Borrow;` causes `s.borrow()` to find the former instead of the latter. We now point out that the other exists, and provide a suggestion on how to call it.

Fix rust-lang/rust#41906. CC rust-lang/rust#153662.
2026-03-11 10:58:52 +01:00
Jonathan Brouwer 5999ec3328 Rollup merge of #153408 - RalfJung:tag-read-must-be-valid, r=oli-obk
miri: make read_discriminant UB when the tag is not in the validity range of the tag field

Arguably, reading an enum discriminant is an operation that uses the "type" of the discriminant field -- and therefore it should fail when the value in that field isn't valid at that type. Therefore, code like this should be UB:
```rust
fn main() {
    unsafe {
        let x = 12u8;
        let x_ptr: *const u8 = &x;
        let cast_ptr = x_ptr as *const Option<bool>;
        // Reading the discriminant should fail since the tag value is not in the valid
        // range for the tag field.
        let _val = matches!(*cast_ptr, None);
        //~^ ERROR: invalid tag
    }
}
```
However, Miri currently sees no UB here. (MiniRust does see UB.) This is because we never actually check whether the tag we read is in the validity range for its field. So let's add such a check, and a corresponding test.

In fact, we have to do this check, since the codegen backend adds range metadata on the discriminant load, as can be seen in [this example](https://play.rust-lang.org/?version=stable&mode=release&edition=2024&gist=02ef5e80fdfe61540e44198dd827b630). In other words, the above code has UB in LLVM IR but not in Miri, which is a critical Miri bug.
2026-03-11 10:58:51 +01:00