Commit Graph

24583 Commits

Author SHA1 Message Date
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
Jacob Pratt e97324a04f Rollup merge of #154548 - jeanibarz:fix/add-test-150457, r=jieyouxu
Add regression test for TransmuteFrom ICE with min_generic_const_args

Regression test for rust-lang/rust#150457.

The wfcheck ICE with TransmuteFrom + min_generic_const_args was fixed by rust-lang/rust#150707 but didn't get a test.

Closes rust-lang/rust#150457
2026-03-30 05:13:17 -04: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 59e6f0d826 Rollup merge of #154549 - jeanibarz:fix/add-test-152633, r=chenyukang
Add regression test for recursive lazy type alias normalization ICE

Regression test for rust-lang/rust#152633.

The normalization ICE with recursive lazy_type_alias + min_generic_const_args was fixed by rust-lang/rust#152040 but didn't get a test. Compiler now reports E0275 instead of crashing.

Closes rust-lang/rust#152633
2026-03-29 21:39:28 +02: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 880c9e01ed Rollup merge of #154328 - scrabsha:push-tkozopuzoorz, r=lolbinarycat
rustdoc: add missing {os,target,target_env} values for cfg pretty printer
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
Sasha Pourcelot 9f0944832b rustdoc: add missing target_{os,arch,env} values for cfg pretty printer 2026-03-29 16:02:23 +00:00
Sasha Pourcelot c67380d6fe rustdoc: add test showing cfg pretty-printing of all targets 2026-03-29 15:56:39 +00:00
Jean IBARZ 9fd2c9ef01 Add regression test for recursive lazy type alias normalization ICE
Exercises a self-referencing type alias with lazy_type_alias and
min_generic_const_args, which previously caused an ICE during
normalization.
2026-03-29 15:40:18 +02:00
Jean IBARZ 5e698662cd Add regression test for TransmuteFrom ICE with min_generic_const_args
Exercises TransmuteFrom with min_generic_const_args, which previously
caused an ICE in well-formedness checking.
2026-03-29 15:40:15 +02:00
dianne 51816efcc0 don't drop arguments' temporaries in dbg! 2026-03-29 06:38:38 -07:00
yukang 69b6d26d05 fix invalid type suggestion for item nested in function 2026-03-29 16:23:14 +08:00
Trevor Gross 0bb3fe315e core: Move {RangeIter, RangeFromIter}::remainder to new_range_remainder
Split the remainder functions from the rest of `std::range`.
2026-03-29 02:11:32 -05:00
Trevor Gross cbc94349d0 core: Destabilize beta-stable RangeInclusiveIter::remainder
As discussed, make this portion of the range API unstable again. This
will now be tracked under `new_range_remainder`.

Discussion: https://rust-lang.zulipchat.com/#narrow/channel/327149-t-libs-api.2Fapi-changes/topic/.60RangeFrom.3A.3Aremainder.60.20possible.20panic/with/582108913
2026-03-29 01:58:50 -05:00
Guillaume Gomez c2fc360b96 Rollup merge of #154504 - cyrgani:structenum, r=Kivooeo
move many tests from `structs-enums` to `structs` or `enum`

This PR moves most of the tests in `ui/structs-enums` that are only about structs or only about enums to their respective directory, as a step towards removing `ui/structs-enums`.
Followup to rust-lang/rust#154131.
r? @Kivooeo
2026-03-29 00:06:53 +01:00
Guillaume Gomez 0ba684b705 Rollup merge of #154453 - chenyukang:yukang-fix-154383, r=notriddle
Fix ice in rustdoc of private reexport

Fixes rust-lang/rust#154383

The root cause is rustdoc could still try to resolve links for source docs that resolver did not cache in `ResolveDocLinks::Exported` mode. The test case will not crash with `--document-private-items` option, which will use `ResolveDocLinks::All`.

The fix makes rustdoc skip link resolution based on the source `DefId` of each doc fragment, so its behavior stays aligned with resolver's logic here: https://github.com/chenyukang/rust/blob/dc5cb1719eed6ac9275fe93d914d32141606b2ac/compiler/rustc_resolve/src/late.rs#L685
2026-03-29 00:06:52 +01: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
Guillaume Gomez aad3710227 Rollup merge of #153380 - pitaj:stabilize-new_range_from_api, r=tgross35
stabilize new RangeFrom type and iterator

```rust
// in core and std
pub mod range;

// in core::range

pub struct RangeFrom<Idx> {
    pub start: Idx,
}

impl<Idx: fmt::Debug> fmt::Debug for RangeFrom<Idx> { /* ... */ }

impl<Idx: PartialOrd<Idx>> RangeFrom<Idx> {
    pub const fn contains<U>(&self, item: &U) -> bool
    where
        Idx: [const] PartialOrd<U>,
        U: ?Sized + [const] PartialOrd<Idx>;
}

impl<Idx: Step> RangeFrom<Idx> {
    pub fn iter(&self) -> RangeFromIter<Idx>;
}

impl<T> const RangeBounds<T> for RangeFrom<T> { /* ... */ }
impl<T> const RangeBounds<T> for RangeFrom<&T> { /* ... */ }

impl<T> const From<RangeFrom<T>> for legacy::RangeFrom<T> { /* ... */ }
impl<T> const From<legacy::RangeFrom<T>> for RangeFrom<T> { /* ... */ }

pub struct RangeFromIter<A>(/* ... */);

// `RangeFromIter::remainder` left unstable

impl<A: Step> Iterator for RangeFromIter<A> {
    type Item = A;
    /* ... */
}

impl<A: Step> FusedIterator for RangeFromIter<A> { }
impl<A: Step> IntoIterator for RangeFrom<A> {
    type Item = A;
    type IntoIter = RangeFromIter<A>;
    /* ... */
}

unsafe impl<T> const SliceIndex<[T]> for range::RangeFrom<usize> {
    type Output = [T];
    /* ... */
}
unsafe impl const SliceIndex<str> for range::RangeFrom<usize> {
    type Output = str;
    /* ... */
}

impl ops::Index<range::RangeFrom<usize>> for CStr {
    type Output = CStr;
    /* ... */
}
```

Tracking issue: https://github.com/rust-lang/rust/issues/125687
2026-03-29 00:06:49 +01:00
Peter Jaszkowiak 085dff4944 stabilize new RangeFrom type and iterator
stabilizes `core::range::RangeFrom`
stabilizes `core::range::RangeFromIter`

add examples for `remainder` method on range iterators
`RangeFromIter::remainder` was not stabilized (see issue 154458)
2026-03-28 12:00:10 -06: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
bors 0d4eb09831 Auto merge of #154503 - RalfJung:rollup-DkU2JXL, r=RalfJung
Rollup of 11 pull requests

Successful merges:

 - rust-lang/rust#152880 (Tweak incorrect assoc item note)
 - rust-lang/rust#153526 (Fix LegacyKeyValueFormat report from docker build: i686)
 - rust-lang/rust#153613 (interpreter error reporting: remove arguments that are always the same)
 - rust-lang/rust#154029 (Replace `truncate(0)` with `clear()`)
 - rust-lang/rust#154125 (Inline and remove `DepGraphData::try_mark_parent_green`.)
 - rust-lang/rust#154185 (Prevent no_threads RwLock's write() impl from setting mode to -1 when it is locked for reading)
 - rust-lang/rust#154394 (Normalize rustc path prefix when testing `-Z track-diagnostics`)
 - rust-lang/rust#154450 (Use the normal arg-parsing machinery for `-Zassert-incr-state`)
 - rust-lang/rust#154475 (Emit a pre-expansion feature gate warning for `box`'ed struct field patterns)
 - rust-lang/rust#154500 (EnumSizeOpt: use Allocation::write_scalar instead of manual endianess logic)
 - rust-lang/rust#154502 (interpret: ensure that untupled arguments are actually tuples)
2026-03-28 13:54:29 +00:00
cyrgani 5bdde380cc move many tests from structs-enums to structs or enum 2026-03-28 12:38:35 +00: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 d400f17222 Rollup merge of #154394 - aDotInTheVoid:in-one-word-he-told-me-secret-of-success-in-testing-normalize, r=fmease
Normalize rustc path prefix when testing `-Z track-diagnostics`

Fixes https://github.com/rust-lang/rust/issues/154392
2026-03-28 13:15:52 +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
Alona Enraght-Moony d10baae9ce Normalize rustc path prefix when testing -Z track-diagnostics
Fixes https://www.github.com/rust-lang/rust/issues/154392
2026-03-28 12:01:38 +00:00
bors 7e28c7438a Auto merge of #153821 - Lars-Schumann:const-step, r=Mark-Simulacrum
constify `Step` trait and all of its `impl`ementations

constifying [Step](https://github.com/rust-lang/rust/issues/42168) trait and all of its implementations, with some friendly help from [const_cmp](https://github.com/rust-lang/rust/issues/143800)
2026-03-28 10:44:18 +00:00
Ralf Jung 767d71fcb2 EnumSizeOpt test: show actual bytes of new allocation 2026-03-28 11:41:55 +01:00
Daria Sukhonina 1792232d01 fix tests/incremental/hashes 2026-03-28 12:38:49 +03:00
Daria Sukhonina 5cf7376aac Rename typeck into typeck_root in tests/incremental 2026-03-28 12:38:49 +03:00
Daria Sukhonina 26c75dfccf Rename typeck into typeck_root in tests/ui 2026-03-28 12:38:49 +03:00
Yuki Okushi 531631c7ad Make messages more generic 2026-03-28 16:18:11 +09: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
León Orell Valerian Liehr a7ad9acc4a Clearly exercise all soft feature gates 2026-03-27 20:50:36 +01: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
Aleksey Kliger 0c05f6c478 Add ignore-cross-compile to incremental-finalize-fail
The test needs proc-macros to function
2026-03-27 10:44:41 -04:00
León Orell Valerian Liehr 20f9361b76 Rollup merge of #154421 - chenyukang:yukang-fix-154395-rustdoc-json-emit-conflict, r=aDotInTheVoid
Rustdoc rejects html emits with json output

Fixes rust-lang/rust#154395
2026-03-27 15:11:57 +01:00
León Orell Valerian Liehr 84ecc09f66 Rollup merge of #154246 - JumpiiX:fix-101532-dead-code-warnings, r=fmease
Add test for issue #101532: dead code warnings in const _

Closes rust-lang/rust#101532

Adds a test for dead code warnings in `const _`.

This was already fixed, just adding coverage to avoid regressions.
2026-03-27 15:11:56 +01: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
Yuki Okushi 1af153cdb9 Tweak incorrect assoc item note 2026-03-27 21:19:40 +09:00