Commit graph

301854 commits

Author SHA1 Message Date
Stuart Cook
017586c93a
Rollup merge of #144713 - nnethercote:rustc_middle-ty-cleanups, r=lcnr
`rustc_middle::ty` cleanups

r? `@davidtwco`
2025-07-31 18:52:11 +10:00
Stuart Cook
8cca6bce4e
Rollup merge of #144665 - scottmcm:restore-sroa-simd-check, r=compiler-errors
Re-block SRoA on SIMD types

Fixes rust-lang/rust#144621
2025-07-31 18:52:10 +10:00
Stuart Cook
880113eff9
Rollup merge of #144657 - Muscraft:fix-unicode-close-window, r=fee1-dead
fix: Only "close the window" when its the last annotated file

While comparing the Unicode theme output of `rustc` and `annotate-snippets`, I found that `rustc` would ["close the window"](686bc1c5f9/compiler/rustc_errors/src/emitter.rs (L1025-L1027)) (draw a `╰╴`), even though there were other annotated files that followed the current one. This PR makes it so the emitter will only "close the window" on the last annotated file.

Before:
```
error[E0624]: method `method` is private
   ╭▸ $DIR/close_window.rs:9:7
   │
LL │     s.method();
   ╰╴      ━━━━━━ private method
   │
   ⸬ $DIR/auxiliary/close_window.rs:3:5
   │
LL │     fn method(&self) {}
   ╰╴    ──────────────── private method defined here
```

After:
```
error[E0624]: method `method` is private
   ╭▸ $DIR/close_window.rs:9:7
   │
LL │     s.method();
   │       ━━━━━━ private method
   │
   ⸬ $DIR/auxiliary/close_window.rs:3:5
   │
LL │     fn method(&self) {}
   ╰╴    ──────────────── private method defined here
```
2025-07-31 18:52:10 +10:00
Guillaume Gomez
bee5fbf36e Fix CI build failure when using new libtest public constant 2025-07-31 10:45:18 +02:00
Guillaume Gomez
227abb70ab Make libtest::ERROR_EXIT_CODE const public to not redefine it in rustdoc 2025-07-31 10:44:50 +02:00
Flakebi
7a127fba65
Fix linker-plugin-lto only doing thin lto
When rust provides LLVM bitcode files to lld and the bitcode contains
function summaries as used for thin lto, lld defaults to using thin lto.
This prevents some optimizations that are only applied for fat lto.

We solve this by not creating function summaries when fat lto is
enabled. The bitcode for the module is just directly written out.

An alternative solution would be to set the `ThinLTO=0` module flag to
signal lld to do fat lto.
The code in clang that sets this flag is here:
560149b5e3/clang/lib/CodeGen/BackendUtil.cpp (L1150)
The code in LLVM that queries the flag and defaults to thin lto if not
set is here:
e258bca950/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp (L4441-L4446)
2025-07-31 10:38:34 +02:00
Tsukasa OI
c51e5ce452 std_detect: Linux 6.16 support for RISC-V
It adds feature detection of 1 extension (new in std_detect).

New RISC-V Extension:

1.  "Zabha"
2025-07-31 07:39:10 +00:00
Scott Schafer
761c4e308c
fix: Only "close the window" when its the last annotated file 2025-07-31 00:25:09 -06:00
xizheyin
7b667e7811
Extend is_case_difference to handle digit-letter confusables
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-07-31 13:55:59 +08:00
bors
cc0a5b7305 Auto merge of #144718 - Zalathar:rollup-76lrtf2, r=Zalathar
Rollup of 6 pull requests

Successful merges:

 - rust-lang/rust#135975 (Implement `push_mut`)
 - rust-lang/rust#143672 (Fix Box allocator drop elaboration)
 - rust-lang/rust#144232 (Implement support for `become` and explicit tail call codegen for the LLVM backend)
 - rust-lang/rust#144663 (coverage: Re-land "Enlarge empty spans during MIR instrumentation")
 - rust-lang/rust#144685 (Only extract lang items once in codegen_fn_attrs)
 - rust-lang/rust#144717 (Move `rustc_middle::parameterized`)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-07-31 05:43:55 +00:00
Stuart Cook
9c6a618a7b
Rollup merge of #144717 - nnethercote:mv-rustc_middle-parameterized, r=compiler-errors
Move `rustc_middle::parameterized`

It doesn't need to be in `rustc_middle`.

r? `@compiler-errors`
2025-07-31 15:42:02 +10:00
Stuart Cook
45169cbf38
Rollup merge of #144685 - jdonszelmann:lang-items-once, r=wafflelapkin
Only extract lang items once in codegen_fn_attrs

This one should be obvious. These two extraction points used to be far apart but now that they're refactored to be close it was rather obvious we're just doing double work....

r? ``@WaffleLapkin``

Buils on rust-lang/rust#144655
2025-07-31 15:42:01 +10:00
Stuart Cook
5c123c25e3
Rollup merge of #144663 - Zalathar:empty-span, r=petrochenkov
coverage: Re-land "Enlarge empty spans during MIR instrumentation"

This allows us to assume that coverage spans will only be discarded during codegen in very unusual situations.

---

This seemingly-simple change has a rather messy history:
- rust-lang/rust#140847
- rust-lang/rust#141650
- rust-lang/rust#144298
- rust-lang/rust#144480

Since then, a number of related changes have landed that should make it reasonable to try again:
- rust-lang/rust#144530
- rust-lang/rust#144560
- rust-lang/rust#144616

In particular, we have multiple fixes/mitigations, and a confirmed regression test for the original bug that is not triggered by re-landing the changes in this PR.
2025-07-31 15:42:00 +10:00
Stuart Cook
8628b78f24
Rollup merge of #144232 - xacrimon:explicit-tail-call, r=WaffleLapkin
Implement support for `become` and explicit tail call codegen for the LLVM backend

This PR implements codegen of explicit tail calls via `become` in `rustc_codegen_ssa` and support within the LLVM backend. Completes a task on (https://github.com/rust-lang/rust/issues/112788). This PR implements all the necessary bits to make explicit tail calls usable, other backends have received stubs for now and will ICE if you use `become` on them. I suspect there is some bikeshedding to be done on how we should go about implementing this for other backends, but it should be relatively straightforward for GCC after this is merged.

During development I also put together a POC bytecode VM based on tail call dispatch to test these changes out and analyze the codegen to make sure it generates expected assembly. That is available [here](https://github.com/xacrimon/tcvm).
2025-07-31 15:42:00 +10:00
Stuart Cook
f478bec907
Rollup merge of #143672 - beepster4096:box_drop_flags_again, r=oli-obk
Fix Box allocator drop elaboration

New version of rust-lang/rust#131146.

Clearing Box's drop flag after running its destructor can cause it to skip dropping its allocator, so just don't. Its cleared by the drop ladder code afterwards already.

Unlike the last PR this also handles other types with destructors properly, in the event that we can have open drops on them in the future (by partial initialization or DerefMove or something).

Finally, I also added tests for the interaction with async drop here but I discovered rust-lang/rust#143658, so one of the tests has a `knownbug` annotation. Not sure if it should be in this PR at all though.

Fixes rust-lang/rust#131082

r? wesleywiser - prev. reviewer
2025-07-31 15:41:59 +10:00
Stuart Cook
dc8aec4cf2
Rollup merge of #135975 - balt-dev:master, r=tgross35
Implement `push_mut`

Implementation of rust-lang/rust#135974.
2025-07-31 15:41:58 +10:00
Nicholas Nethercote
7aec38b6d9 Fix up size asserts.
- Put them in the module that defines the type.
- Add some `WithCachedTypeInfo<T>` asserts for consistency.
2025-07-31 15:17:21 +10:00
Nicholas Nethercote
cf95e45ec6 Move InferVarInfo out of rustc_middle.
It's only used in `rustc_hir_typeck`.
2025-07-31 15:17:20 +10:00
Nicholas Nethercote
0b3c980c24 Remove TyCtxt::get_attrs_unchecked.
It's identical to `TyCtxt::get_all_attrs` except it takes `DefId`
instead of `impl Into<DefIf>`.
2025-07-31 15:17:20 +10:00
Nicholas Nethercote
a949c47f0d Remove ParamEnvAnd::into_parts.
The fields are public, so this doesn't need a method, normal
deconstruction and/or field access is good enough.
2025-07-31 15:17:20 +10:00
Nicholas Nethercote
c4e3cc0228 Move TermVid out of rustc_middle.
It's only used in `rustc_infer`.
2025-07-31 15:17:08 +10:00
Nicholas Nethercote
66fd421208 Move rustc_middle::parameterized to rustc_metadata.
It's only used there.
2025-07-31 15:14:34 +10:00
Nicholas Nethercote
0a3eb2f88e Remove unused ParameterizedOverTcx impls. 2025-07-31 15:04:22 +10:00
Michael Goulet
51cd9b564f Consider operator's span when computing binop expr span 2025-07-31 02:28:11 +00:00
Nicholas Nethercote
b44eb11bdf Move ParamTerm out of rustc_middle.
It's only used in `rustc_hir_typeck`.
2025-07-31 11:50:45 +10:00
Nicholas Nethercote
3a1f2d5cc2 Move an EarlyParamRegion impl block.
Next to all the other `EarlyParamRegion` pieces.
2025-07-31 11:50:43 +10:00
Nicholas Nethercote
790ab94798 Move ImplHeader out of rustc_middle.
It's not used in `rustc_middle`, and `rustc_trait_selection` is a better
place for it.
2025-07-31 11:50:36 +10:00
Nicholas Nethercote
e83c8cb26c Move ResolverOutputs out of rustc_middle.
It's not used in `rustc_middle`, and `rustc_resolve` is a better place
for it.
2025-07-31 11:50:23 +10:00
Nicholas Nethercote
2bf10de494 Remove unused impl_decodable_via_ref! entries. 2025-07-31 11:48:53 +10:00
bors
32e7a4b92b Auto merge of #144405 - lcnr:hir-typeck-uniquify, r=BoxyUwU
uniquify root goals during HIR typeck

We need to rely on region identity to deal with hangs such as https://github.com/rust-lang/trait-system-refactor-initiative/issues/210 and to keep the current behavior of `fn try_merge_responses`.

This is a problem as borrowck starts by replacing each *occurrence* of a region with a unique inference variable. This frequently splits a single region during HIR typeck into multiple distinct regions. As we assume goals to always succeed during borrowck, relying on two occurances of a region being identical during HIR typeck causes ICE. See the now fixed examples in https://github.com/rust-lang/trait-system-refactor-initiative/issues/27 and rust-lang/rust#139409.

We've previously tried to avoid this issue by always *uniquifying* regions when canonicalizing goals. This prevents caching subtrees during canonicalization which resulted in hangs for very large types. People rely on such types in practice, which caused us to revert our attempt to reinstate `#[type_length_limit]` in https://github.com/rust-lang/rust/pull/127670. The complete list of changes here:
- rust-lang/rust#107981
- rust-lang/rust#110180
- rust-lang/rust#114117
- rust-lang/rust#130821

After more consideration, all occurrences of such large types need to happen outside of typeck/borrowck. We know this as we already walk over all types in the MIR body when replacing their regions with nll vars.

This PR therefore enables us to rely on region identity inside of the trait solver by exclusively **uniquifying root goals during HIR typeck**. These are the only goals we assume to hold during borrowck. This is insufficient as type inference variables may "hide" regions we later uniquify. Because of this, we now stash proven goals which depend on inference variables in HIR typeck and reprove them after writeback. This closes https://github.com/rust-lang/trait-system-refactor-initiative/issues/127.

This was originally part of rust-lang/rust#144258 but I've moved it into a separate PR. While I believe we need to rely on region identity to fix the performance issues in some way, I don't know whether rust-lang/rust#144258 is the best approach to actually do so. Regardless of how we deal with the hangs however, this change is necessary and desirable regardless.

r? `@compiler-errors` or `@BoxyUwU`
2025-07-31 00:32:55 +00:00
Stypox
e1f674cfa9
Use specific name for "frame" span field
Otherwise the field would be named "message" by default
2025-07-31 00:40:00 +02:00
Stypox
3b5fec08f1
Use new enter_trace_span! syntax for layout_of & friends 2025-07-31 00:40:00 +02:00
Stypox
8e786169e8
Uniform enter_trace_span! and add documentation
The macro was uniformed between rustc_const_eval and miri
2025-07-31 00:40:00 +02:00
Scott Schafer
4643d9ad6d
test: Check close window rendering 2025-07-30 16:25:24 -06:00
bors
606dcc0d2e Auto merge of #116316 - cjgillot:incr-privacy, r=petrochenkov
Remove eval_always from check_private_in_public.

This PR attempts to avoid re-computing `check_private_in_public` query. First by marking the query as non-`eval_always`, and by reducing the amount of accesses to HIR as much as possible.

Latest perf https://github.com/rust-lang/rust/pull/116316#issuecomment-3094672105 shows that we manage it. The cost is extra dep-graph bookkeeping.
2025-07-30 21:29:47 +00:00
Michael Goulet
585eac88c8 stall ConstArgHasType in compute_goal_fast_path 2025-07-30 20:30:17 +00:00
Alona Enraght-Moony
a33e084afe rustdoc-json: Move #[macro_export] from Other to it's own variant 2025-07-30 19:57:32 +00:00
Alona Enraght-Moony
1a515e6949 rustdoc-json: Add test for #[macro_use] attribute 2025-07-30 19:54:23 +00:00
bors
3048886e59 Auto merge of #144692 - samueltardieu:rollup-0j1y08x, r=samueltardieu
Rollup of 4 pull requests

Successful merges:

 - rust-lang/rust#143465 (Support multiple crate versions in --extern-html-root-url)
 - rust-lang/rust#144308 ([rustdoc] Display total time and compilation time of merged doctests)
 - rust-lang/rust#144655 (clean up codegen fn attrs)
 - rust-lang/rust#144675 (Reject running `compiletest` self-tests against stage 0 rustc unless explicitly allowed)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-07-30 18:16:17 +00:00
Samuel Tardieu
202d1f5bf4
Rollup merge of #144675 - jieyouxu:compiletest-staging, r=Kobzol
Reject running `compiletest` self-tests against stage 0 rustc unless explicitly allowed

Currently, in `pr-check-1`, we run `python3 ../x.py test --stage 0 src/tools/compiletest`, which is `compiletest` self-tests against stage 0 rustc. This makes it very annoying for PRs wanting to change target spec JSON format, which `compiletest` depends on for target information, as otherwise `compiletest` would have to know how to handle 2 different target spec JSON formats and know when to pick which.

Instead of doing that, we change `compiletest` self-tests to reject running against stage 0 `rustc` *unless* explicitly allowed with `build.compiletest-allow-stage0=true`. `build.compiletest-allow-stage0` is a proper bootstrap config option in favor of the ad-hoc `COMPILETEST_FORCE_STAGE0` env var. This means that:

- `./x test src/tools/compiletest --stage=0` is not allowed, unless `build.compiletest-allow-stage0=true` is set. In this scenario, `compiletest` self-tests should be expected to fail unless the stage 0 `rustc` as provided is like codegen_cranelift where it's *actually* built from in-tree `rustc` sources.
- In CI, we change `./x test src/tools/compiletest --stage=0` to `./x test src/tools/compiletest --stage=1`, and move it to `pr-check-2`. Yes, this involves building the stage 1 compiler, but `pr-check-2` already has to build stage 1 compiler to test stage 1 library crates.
- Crucially, this means that **`compiletest` is only intended to support one target spec JSON format**, namely the one corresponding to the in-tree `rustc`.
- This should preserve the `compiletest-use-stage0-libtest` UX optimization where changing `compiler/` tree should still not require rebuilding `compiletest` as long as `build.compiletest-use-stage0-libtest=true`, as that should remain orthogonal. This is completely unlike my previous attempt at https://github.com/rust-lang/rust/pull/144563 that tries to do a way more invasive change which would cause the rebuild problem.

Best reviewed commit-by-commit.

---

r? `@Kobzol`
2025-07-30 19:49:03 +02:00
Samuel Tardieu
175121903a
Rollup merge of #144655 - jdonszelmann:cleanup-codegen-fn-attrs, r=WaffleLapkin
clean up codegen fn attrs

This honestly had become a mess over time and needed some love. No behavior should've changed, and I effectively just moved code around. Though, I can't promise there weren't any bugs in the original code with how randomly it was organised.....

r? `@WaffleLapkin`
2025-07-30 19:49:02 +02:00
Samuel Tardieu
61760fbda4
Rollup merge of #144308 - GuillaumeGomez:merged-doctest-times, r=lolbinarycat
[rustdoc] Display total time and compilation time of merged doctests

Fixes rust-lang/rust#144270.

Does it look good to you `@kpreid?`

<img width="908" height="263" alt="image" src="https://github.com/user-attachments/assets/cd5d082d-c4e0-42ed-91dd-bd263b413dcd" />
2025-07-30 19:49:02 +02:00
Samuel Tardieu
b38ece9021
Rollup merge of #143465 - kornelski:extern-name, r=petrochenkov
Support multiple crate versions in --extern-html-root-url

Rustdoc's `--extern-html-root-url` used to use `tcx.crate_name()` to identify crates, but that used crates' internal names from their metadata, instead of names given to them in `--extern`. That was confusing, because both `--extern…` arguments seem related and use similar syntax. Crucially, this didn't work correctly with Cargo's package aliases or multiple versions of crates.

`sess.opts.externs` lacks `CrateNum`, and `Resolver.extern_prelude` gets destroyed before `rustdoc` has a chance to see it, so I've had to save this mapping in `CStore`.

Just in case, I've kept the previous mapping by crate name as a fallback for crates that weren't matched by their extern name.

Fixes rust-lang/rust#76296
2025-07-30 19:49:01 +02:00
Balt
3ccfa14e48 Implement push_mut 2025-07-30 12:26:16 -05:00
Jana Dönszelmann
3fe0e24356
only extract lang items once 2025-07-30 16:44:16 +02:00
Jana Dönszelmann
1d589c87be
clean up codegen fn attrs 2025-07-30 16:39:16 +02:00
lcnr
2b065e7c0b extend comment 2025-07-30 14:30:57 +02:00
lcnr
df2e54376c add comment and opaque type fixme 2025-07-30 14:01:37 +02:00
lcnr
b6cbe33aeb handle region dependent goals due to infer vars 2025-07-30 14:01:37 +02:00
Jieyou Xu
e954253d43
Add change tracker entry 2025-07-30 19:55:17 +08:00