Commit Graph

55123 Commits

Author SHA1 Message Date
Jacob Pratt 89eb3298db Rollup merge of #154566 - heiher:loong-mcount-sym, r=chenyukang
loongarch: use "_mcount" as the default mcount symbol

Set the `mcount` field to "_mcount" for all LoongArch targets to match Clang/GCC behavior [1]. This fixes linking failures when using `-Z instrument-mcount`, where the runtime expects "_mcount" instead of "mcount".

[1] https://github.com/llvm/llvm-project/blob/main/clang/lib/Basic/Targets/LoongArch.h#L60
2026-03-30 05:13:18 -04:00
Jacob Pratt 7275f7e2e3 Rollup merge of #154564 - estebank:tweak-wf-errors, r=Kivooeo
Tweak wording of E0275 WF errors

Modify the main error message to read better:

```
error[E0275]: overflow evaluating whether `&'a mut Bar` is well-formed
```
2026-03-30 05:13:18 -04:00
Jacob Pratt a2cc7a9f0a Rollup merge of #154563 - estebank:multiline-binop, r=TaKO8Ki
Point at binop lhs and rhs when expression is multiline

```
error[E0277]: cannot add `()` to `u32`
  --> $DIR/multiline-span-simple.rs:13:18
   |
LL |       foo(1 as u32 +
   |           -------- ^ no implementation for `u32 + ()`
LL |
LL | /         bar(x,
LL | |
LL | |             y),
   | |______________-
```
2026-03-30 05:13:17 -04:00
WANG Rui 6e984cd4bf loongarch: use "_mcount" as the default mcount symbol
Set the `mcount` field to "_mcount" for all LoongArch targets to match
Clang/GCC behavior [1]. This fixes linking failures when using
`-Z instrument-mcount`, where the runtime expects "_mcount" instead of
"mcount".

[1] https://github.com/llvm/llvm-project/blob/main/clang/lib/Basic/Targets/LoongArch.h#L60
2026-03-30 07:53:20 +08:00
bors 80ad55752e Auto merge of #154559 - JonathanBrouwer:rollup-Iut0qjN, r=JonathanBrouwer
Rollup of 11 pull requests

Successful merges:

 - rust-lang/rust#154074 (don't drop arguments' temporaries in `dbg!`)
 - rust-lang/rust#154328 (rustdoc: add missing {os,target,target_env} values for cfg pretty printer)
 - rust-lang/rust#154540 (Fix invalid type suggestion for item nested in function)
 - rust-lang/rust#154549 (Add regression test for recursive lazy type alias normalization ICE)
 - rust-lang/rust#153373 (Fix LegacyKeyValueFormat report from docker build: powerpc)
 - rust-lang/rust#154322 (feat: reimplement `hash_map!` macro)
 - rust-lang/rust#154416 (Add `IoSplit` diagnostic item for `std::io::Split`)
 - rust-lang/rust#154486 (std_detect on AArch64 Darwin: Detect FEAT_SVE_B16B16)
 - rust-lang/rust#154508 (Fix ambiguous parsing in bootstrap.py)
 - rust-lang/rust#154518 (Panic in Hermit clock_gettime)
 - rust-lang/rust#154530 (update zulip link in `std` documentation)
2026-03-29 22:49:44 +00:00
Esteban Küber 0740609ea3 Point at binop lhs and rhs when expression is multiline
```
error[E0277]: cannot add `()` to `u32`
  --> $DIR/multiline-span-simple.rs:13:18
   |
LL |       foo(1 as u32 +
   |           -------- ^ no implementation for `u32 + ()`
LL |
LL | /         bar(x,
LL | |
LL | |             y),
   | |______________-
```
2026-03-29 21:07:54 +00:00
Jonathan Brouwer 883eda3a72 Rollup merge of #154540 - chenyukang:yukang-fix-146786-unusable-path-suggestion, r=estebank
Fix invalid type suggestion for item nested in function

Fixes rust-lang/rust#146786

I also tried to add the `omit_parent` logic in pretty formatter here:
https://github.com/chenyukang/rust/blob/69b6d26d05006dca7556abc555fb0e029ecf1f4e/compiler/rustc_middle/src/ty/print/pretty.rs#L2240-L2295
so that we don't need to add `should_omit_parent_def_path` and `reset_path`.

but seems there will be duplicate print code with `default_print_def_path`.

maybe r? @estebank
2026-03-29 21:39:27 +02:00
Jonathan Brouwer 2a18b885ce Rollup merge of #154074 - dianne:dbg-temp-scopes, r=Mark-Simulacrum
don't drop arguments' temporaries in `dbg!`

Fixes rust-lang/rust#153850

Credit to @theemathas for help with macro engineering ^^

r? libs
2026-03-29 21:39:26 +02:00
bors a25435bcf7 Auto merge of #154304 - zetanumbers:typeck_root, r=petrochenkov
Make typeck a tcx method which calls typeck_root query



Currently typeck query itself calls `tcx.typeck(tcx.typeck_root_def_id(key))` if its key isn't a type-check root. I thought this might be an overhead and made typeck a tcx method which calls typeck_root query instead.

This is a step to simplify `cache_on_disk_if` query modifier.

@petrochenkov please run perf
2026-03-29 19:37:29 +00:00
Esteban Küber dae0c01108 Tweak wording of E0275 WF errors
Modify the main error message to read better:

```
error[E0275]: overflow evaluating whether `&'a mut Bar` is well-formed
```
2026-03-29 18:25:55 +00:00
dianne 7d1b41cbb3 update diagnostic for variables moved by dbg! 2026-03-29 09:48:41 -07:00
yukang 69b6d26d05 fix invalid type suggestion for item nested in function 2026-03-29 16:23:14 +08:00
bors 148adf223e Auto merge of #154525 - GuillaumeGomez:rollup-hLPbuqn, r=GuillaumeGomez
Rollup of 9 pull requests

Successful merges:

 - rust-lang/rust#153380 (stabilize new RangeFrom type and iterator)
 - rust-lang/rust#153834 (Merge `fabsf16/32/64/128` into `fabs::<F>`)
 - rust-lang/rust#154043 (simd_fmin/fmax: make semantics and name consistent with scalar intrinsics)
 - rust-lang/rust#154494 (triagebot: add reminder for bumping CI LLVM stamp)
 - rust-lang/rust#153374 (Fix LegacyKeyValueFormat report from docker build: dist-x86_64)
 - rust-lang/rust#154320 (`trim_prefix` for paths)
 - rust-lang/rust#154453 (Fix ice in rustdoc of private reexport)
 - rust-lang/rust#154504 (move many tests from `structs-enums` to `structs` or `enum`)
 - rust-lang/rust#154515 (Notify stdarch maintainers on changes in std_detect)
2026-03-29 01:57:54 +00:00
Guillaume Gomez 67ab3ac423 Rollup merge of #154043 - RalfJung:simd-min-max, r=Amanieu,calebzulawski,antoyo
simd_fmin/fmax: make semantics and name consistent with scalar intrinsics

This is the SIMD version of https://github.com/rust-lang/rust/pull/153343: change the documented semantics of the SIMD float min/max intrinsics to that of the scalar intrinsics, and also make the name consistent. The overall semantic change this amounts to is that we restrict the non-determinism: the old semantics effectively mean "when one input is an SNaN, the result non-deterministically is a NaN or the other input"; the new semantics say that in this case the other input must be returned. For all other cases, old and new semantics are equivalent. This means all users of these intrinsics that were correct with the old semantics are still correct: the overall set of possible behaviors has become smaller, no new possible behaviors are being added.

In terms of providers of this API:
- Miri, GCC, and cranelift already implement the new semantics, so no changes are needed.
- LLVM is adjusted to use `minimumnum nsz` instead of `minnum`, thus giving us the new semantics.

In terms of consumers of this API:
- Portable SIMD almost certainly wants to match the scalar behavior, so this is strictly a bugfix here.
- Stdarch mostly stopped using the intrinsic, except on nvptx, where arguably the new semantics are closer to what we actually want than the old semantics (https://github.com/rust-lang/stdarch/issues/2056).

Q: Should there be an `f` in the intrinsic name to indicate that it is for floats? E.g., `simd_fminimum_number_nsz`?

Also see https://github.com/rust-lang/rust/issues/153395.
2026-03-29 00:06:50 +01:00
Guillaume Gomez e6f17e4bbb Rollup merge of #153834 - N1ark:generic-float-intrinsics, r=tgross35,RalfJung
Merge `fabsf16/32/64/128` into `fabs::<F>`

Following [a small conversation on Zulip](https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/Float.20intrinsics/with/521501401) (and because I'd be interested in starting to contribute on Rust), I thought I'd give a try at merging the float intrinsics :)

This PR just merges `fabsf16`, `fabsf32`, `fabsf64`, `fabsf128`, as it felt like an easy first target.

Notes:
- I'm opening the PR for one intrinsic as it's probably easier if the shift is done one intrinsic at a time, but let me know if you'd rather I do several at a time to reduce the number of PRs.
- Currently this PR increases LOCs, despite being an attempt at simplifying the intrinsics/compilers. I believe this increase is a one time thing as I had to define new functions and move some things around, and hopefully future PRs/commits will reduce overall LoCs
- `fabsf32` and `fabsf64` are `#[rustc_intrinsic_const_stable_indirect]`, while `fabsf16` and `fabsf128` aren't; because `f32`/`f64` expect the function to be const, the generic version must be made indirectly stable too. We'd need to check with T-lang this change is ok; the only other intrinsics where there is such a mismatch is `minnum`, `maxnum` and `copysign`.
- I haven't touched libm because I'm not familiar with how it works; any guidance would be welcome!
2026-03-29 00:06:50 +01:00
bors 3f3c6f45dc Auto merge of #154472 - petrochenkov:fastglob2, r=mati865
resolve: Never lookup glob names in modules from other crates

This is basically rust-lang/rust#151211, but with the check moved one level above and slightly more work skipped.
rust-lang/rust#151211 showed small, but very consistent perf improvements (see "Show non-relevant results"), but I didn't notice back then.

(This change logically falls into my current work on splitting local and external name resolution modules in type system https://github.com/petrochenkov/rust/tree/modmodmod)
2026-03-28 22:43:53 +00:00
bors fb27476aaf Auto merge of #154468 - Kobzol:revert-154200, r=dingxiangfei2009
Revert "Rollup merge of #154200 - resrever:enable-dwarf-call-sites, r=dingxiangfei2009"

This reverts commit 2f1603077b, reversing
changes made to 6e3c17424d.

Debugging perf. hit from https://github.com/rust-lang/rust/pull/154384.

The binary size hits from https://github.com/rust-lang/rust/pull/154468#issuecomment-4144557076 were due to this PR, not all of the copmile-time hits though.
2026-03-28 16:59:18 +00:00
Ralf Jung c47e0e1d72 Rollup merge of #154502 - RalfJung:interpret-untuple-check, r=oli-obk
interpret: ensure that untupled arguments are actually tuples

Something seems very wrong if they are not. ;)
2026-03-28 13:15:54 +01:00
Ralf Jung 2645f0d02b Rollup merge of #154500 - RalfJung:enum-opt-endianess, r=oli-obk
EnumSizeOpt: use Allocation::write_scalar instead of manual endianess logic

The first commits makes the test actually show the bytes of the newly generated allocation, so we'd notice if something goes wrong.

The 2nd commit replaces manual endianess handling with use of proper `Allocation` methods.

r? @oli-obk
2026-03-28 13:15:54 +01:00
Ralf Jung 7ee19eb038 Rollup merge of #154475 - fmease:soft-gate-box-struct-field-pat, r=Kivooeo
Emit a pre-expansion feature gate warning for `box`'ed struct field patterns

While the following code triggers a feature gate *warning*:

```rs
fn f() {
    #[cfg(false)]
    let box x; //~ WARN box pattern syntax is experimental
}
```

the code below does not (on stable & main):

```rs
fn f() {
    #[cfg(false)]
    let Struct { box x };
}
```

This is an oversight as both are part of the unstable feature `box_patterns` (that isn't properly gated pre expansion for historical reasons). Of course, both forms lead to a feature gate error *post expansion*.

This is a bug fix and doesn't need any input from T-compiler or T-lang. For context, emitting warnings in these cases is legitimized by [MCP 535](https://github.com/rust-lang/compiler-team/issues/535)[^1].

Part of rust-lang/rust#154045.

[^1]: In case you're wondering why the MCP talks about a *lint* even though the feature gate warnings as seen today don't reference any lint by name, read https://github.com/rust-lang/rust/issues/154045#issuecomment-4144034419.
2026-03-28 13:15:53 +01:00
Ralf Jung effcc70c7c Rollup merge of #154450 - Zalathar:assert-incr-state, r=fmease
Use the normal arg-parsing machinery for `-Zassert-incr-state`

The flag parser for `-Zassert-incr-state` currently extracts an `Option<String>`, and then performs an ad-hoc parsing step slightly later. From looking at https://github.com/rust-lang/rust/pull/90386, I can't see any reason why it doesn't just use the normal flag-parsing machinery.

A second commit also extracts the underlying implementation to a separate helper function, so that it isn't cluttering up the main control flow.

I found this while working on larger cleanups to incremental-file loading.
2026-03-28 13:15:53 +01:00
Ralf Jung b3196a0427 Rollup merge of #154125 - nnethercote:rm-try_mark_parent_green, r=oli-obk
Inline and remove `DepGraphData::try_mark_parent_green`.

It has a single call site. And also remove all the `debug!` calls that clutter up the code. The end result is much easier to read, with `try_mark_previous_green` now recursively calling itself directly, instead of indirectly via `try_mark_parent_green`.

r? @oli-obk
2026-03-28 13:15:51 +01:00
Ralf Jung d289cc4a38 Rollup merge of #154029 - xtqqczze:clear, r=joboet
Replace `truncate(0)` with `clear()`
2026-03-28 13:15:50 +01:00
Ralf Jung f50103eed2 Rollup merge of #153613 - RalfJung:interpret-report, r=oli-obk
interpreter error reporting: remove arguments that are always the same

This `report` function is called twice and both callers use the same `span` and `get_span_and_frames`... so let's just fix those arguments inside the function, no need to be more generic than this.
2026-03-28 13:15:49 +01:00
Ralf Jung 7881a31ccf Rollup merge of #152880 - JohnTitor:tweak-assoc-item-note, r=fmease
Tweak incorrect assoc item note

Fix rust-lang/rust#142797
r? @fmease
2026-03-28 13:15:48 +01:00
Ralf Jung ad298d5a81 interpret: ensure that untupled arguments are actually tuples 2026-03-28 12:07:49 +01:00
Zalathar 10d29ee606 Extract -Zassert-incr-state into a separate helper function
This code is only needed by an obscure `-Z` flag, so pulling it out of the main
path makes the normal logic easier to follow.
2026-03-28 21:52:55 +11:00
Zalathar 29be0590f4 Use the normal arg-parsing machinery for -Zassert-incr-state 2026-03-28 21:52:55 +11:00
Ralf Jung 1dfbb8998c use Allocation::write_scalar instead of manual endianess logic 2026-03-28 11:43:58 +01:00
Daria Sukhonina 94ed03acb5 Make typeck a tcx method which calls typeck_root query 2026-03-28 12:38:44 +03:00
bors 79531c53de Auto merge of #154489 - Zalathar:rollup-wBQK8Wt, r=Zalathar
Rollup of 9 pull requests

Successful merges:

 - rust-lang/rust#154357 (uefi: extend comment for TcpStream Send impl)
 - rust-lang/rust#154410 (Clean up the API for opening/checking incremental-compilation files )
 - rust-lang/rust#154081 (format safety doc of Rc/Arc::from_raw/from_raw_in)
 - rust-lang/rust#154110 (Change "error finalizing incremental compilation" text and emit it as a note, not a warning)
 - rust-lang/rust#154196 (Make `Ipv6Addr::multicast_scope()` exhaustive)
 - rust-lang/rust#154221 (`vec::as_mut_slice()`: use lowercase "isize" in safety comment)
 - rust-lang/rust#154234 (Use common Timestamp impl in Hermit (attempt 2))
 - rust-lang/rust#154396 (chore(deps): update rust crate tar to v0.4.45)
 - rust-lang/rust#154488 (Revert "Unstable book options parser")
2026-03-28 07:35:44 +00:00
Yuki Okushi 531631c7ad Make messages more generic 2026-03-28 16:18:11 +09:00
Manuel Drehwald a3261a2307 Revert "Link LLVM dynamically on aarch64-apple-darwin"
This reverts commit e7c268f883.
2026-03-28 05:11:48 +01:00
Stuart Cook e0a0ad188d Rollup merge of #154488 - Zalathar:unstable, r=jieyouxu
Revert "Unstable book options parser"

- Reverts https://github.com/rust-lang/rust/pull/154070

This reverts commit 6fd8466768, reversing changes made to fda6d37bb8.

---

The changes in https://github.com/rust-lang/rust/pull/154070 are well-intentioned, but in their current form they place an unreasonable maintenance burden on the affected part of the compiler, out of proportion to the benefit gained.

- Moving the unstable options to a separate `include!` file is marginally more convenient for the unstable-book-gen tool, but a big hassle for compiler contributors looking to read or modify the list of unstable options. It breaks normal file layout conventions, interferes with navigation, and interferes with IDE features, all without ever being truly necessary.

- The extra `syn`-based parser in unstable-book-gen is quite complicated, almost entirely undocumented, and seemingly buggy. That makes it extremely difficult to understand or modify, which in turn makes it effectively impossible to ever change the `options!` macro on the compiler side.

- The new tests in unstable-book-gen don't appear to be hooked up to run in CI.

- The compiler changes don't appear to have been approved by a T-compiler reviewer.

Before contemplating a revert, I tried to put together a fix-forward to resolve or mitigate some of these issues. But unstable-book-gen in its current state makes that impractical, so unfortunately I believe that the only way forward is to revert the original changes.

---

I do think the reverted functionality is potentially useful, and I'm not fundamentally opposed to a revised version of it landing in the future, if the relevant concerns are addressed.

But I feel strongly that the current version does not justify the real and troublesome maintenance burden that it imposes on compiler contributors.
2026-03-28 15:01:40 +11:00
Stuart Cook ee64422ffa Rollup merge of #154110 - lambdageek:fix/incr-compile-note, r=wesleywiser
Change "error finalizing incremental compilation" text and emit it as a note, not a warning

As mentioned in https://github.com/rust-lang/rust/issues/151181#issuecomment-3762036971 and https://github.com/rust-lang/rust/issues/151181#issuecomment-4068842260 the current message could be improved:

1. Right now it displays as "warning: error ..." which is confusing (is it an error or a warning)
2. It doesn't give the user a clear indication of what the consequences are
3. The _current_ build is successful. The _next_ build might be slower

The new message is now

```text
note: did not finalize incremental compilation session directory ...
  |
  = help: the next build will not be able to reuse work from this compilation
```

I started a zulip thread [#t-compiler/incremental > Ergonomics of "error finalizing incremental session"](https://rust-lang.zulipchat.com/#narrow/channel/241847-t-compiler.2Fincremental/topic/Ergonomics.20of.20.22error.20finalizing.20incremental.20session.22/with/580191447)
2026-03-28 15:01:38 +11:00
Stuart Cook 7b5fe9efa2 Rollup merge of #154410 - Zalathar:open-incremental-file, r=wesleywiser
Clean up the API for opening/checking incremental-compilation files

Returning dedicated structs and enums makes the meaning of each return value more obvious, and provides a more natural home for documentation.

This part of the codebase is fairly crufty, and I doubt anyone feels fully confident about reviewing changes to it, but hopefully these particular cleanups should be fairly straightforward.

I have more changes planned in this area (e.g. cleaning up `LoadResult`), but I stopped here to make review a bit easier.
2026-03-28 15:01:37 +11:00
Zalathar d470684a43 Revert "Unstable book options parser"
This reverts commit 6fd8466768, reversing
changes made to fda6d37bb8.
2026-03-28 14:18:26 +11:00
León Orell Valerian Liehr a1d397e113 Emit pre-expansion feature gate warning for box'ed struct field pats 2026-03-27 20:50:36 +01:00
Jakub Beránek 8b44562bc8 Revert "Rollup merge of #154200 - resrever:enable-dwarf-call-sites, r=dingxiangfei2009"
This reverts commit 2f1603077b, reversing
changes made to 6e3c17424d.
2026-03-27 20:08:24 +01:00
Vadim Petrochenkov 3ee74ae580 resolve: Never lookup glob names in modules from other crates 2026-03-27 19:23:37 +03:00
León Orell Valerian Liehr 4f6837edbd Rollup merge of #154431 - TaKO8Ki:fix-explicit-reference-cast-unrelated-leaf, r=JohnTitor
Avoid ICE in explicit reference cast suggestion for unrelated leaf pr…

Fixes rust-lang/rust#154403

The explicit reference cast suggestion in was enabled based on `main_trait_predicate` being `From`/`TryFrom`, but it then extracted the source type from `leaf_trait_predicate`.

That is only valid when the leaf obligation is also part of the `From`/`TryFrom` conversion family.
2026-03-27 15:11:55 +01:00
León Orell Valerian Liehr da5a1d7684 Rollup merge of #154405 - chenyukang:yukang-fix-153096-doc-comment-bidi-help, r=JohnTitor
Improve doc comment unicode guidance

Fixes rust-lang/rust#153096

This PR does not suggest HTML bidi markup, because doc comments are still Rust source first, not only rendered rustdoc output. HTML only helps in the rendered documentation rather than making them explicit in source.
2026-03-27 15:11:54 +01:00
León Orell Valerian Liehr 9ba9194d1e Rollup merge of #154371 - zetanumbers:typeck_root_def_id_local, r=petrochenkov
Use LocalDefId for more tcx method calls

r? @petrochenkov

Might bring perf improvements
2026-03-27 15:11:54 +01:00
León Orell Valerian Liehr 6fd8466768 Rollup merge of #154070 - mehdiakiki:unstable-book-options-parser, r=clubby789
Unstable book options parser

Parses the `options!` macro in `compiler/rustc_session/src/options.rs` directly to extract the unstable (-Z) compiler flag names and descriptions to generate documentation for the unstable book.

I took notice from the previous attempt which ran `rustc -Zhelp` and parsed the output and used this approach that reads the source directly.

Used claude for the tedious char by char parsing parts but verified the code, I hope that's ok!
2026-03-27 15:11:53 +01:00
Daria Sukhonina 62ec331a84 Use tcx.local_parent() more often 2026-03-27 15:36:29 +03:00
Daria Sukhonina 2bb9d70b1e Use stable_crate_id more often 2026-03-27 15:36:28 +03:00
Daria Sukhonina 1b68d921a7 Add typeck_root_def_id_local 2026-03-27 15:36:28 +03:00
Daria Sukhonina 08bb61bb88 Use tcx.is_typeck_child() more often 2026-03-27 15:36:28 +03:00
Yuki Okushi 1af153cdb9 Tweak incorrect assoc item note 2026-03-27 21:19:40 +09:00
bors fda6d37bb8 Auto merge of #154455 - jhpratt:rollup-I3JcUWU, r=jhpratt
Rollup of 6 pull requests

Successful merges:

 - rust-lang/rust#152457 (Pass -pg to linker when using -Zinstrument-mcount)
 - rust-lang/rust#154031 (Remove divergence check from check_expr_array)
 - rust-lang/rust#154418 (move many tests out of `ui/unsafe`)
 - rust-lang/rust#154441 (bootstrap: force a CI LLVM stamp bump)
 - rust-lang/rust#153675 (simd_add/sub/mul/neg: document overflow behavior)
 - rust-lang/rust#154430 (Create GPU target notification group)
2026-03-27 09:03:50 +00:00