Commit graph

51805 commits

Author SHA1 Message Date
Kivooeo
3f4f07f0b9 add check for uninhabited types along side never
(cherry picked from commit 2a2da782d3)
2025-12-20 13:54:03 -08:00
Boxy Uwu
3c55c98ec8 replace version placeholder 2025-12-08 10:08:32 +00:00
Matthias Krüger
a43b30c113
Rollup merge of #149671 - RalfJung:interpret-float-min-max, r=mati865
interpret: test SNaN handling of float min/max and update comments

Also see https://github.com/rust-lang/rust/pull/149563.

I also renamed these enum variants so they are not almost identical.
2025-12-05 16:17:13 +01:00
Matthias Krüger
8e46521d0e
Rollup merge of #149666 - Zalathar:backend-has-zstd, r=jieyouxu
Add perma-unstable `--print=backend-has-zstd` for use by compiletest

Tests for `-Zdebuginfo-compression=zstd` need to be skipped if LLVM was built without support for zstd compression.

Currently, compiletest relies on messy and fragile heuristics to detect whether the compiler's LLVM was built with zstd support. But the compiler itself already knows whether LLVM has zstd or not, so it's easier for compiletest to just ask the compiler.

---

Originally I was intending for this to be a `--print=debuginfo-compression` flag that would print out a list of values supported by `-Zdebuginfo-compression=`. I got that working locally, but it was more complex than I was happy with (in both rustc and compiletest), so I decided to cut scope and instead add a very narrow perma-unstable print request instead.

There is always a circularity hazard whenever we ask the compiler-under-test for information about how to test it. But in this case, the underlying compiler code is fairly simple, whereas the previous heuristics were inherently messy and unreliable anyway.
2025-12-05 16:17:12 +01:00
Matthias Krüger
93249823c2
Rollup merge of #149661 - alinas:llvm-22-runtimelibraryinfo-fix, r=cuviper
Fix for LLVM22 making lowering decisions dependent on RuntimeLibraryInfo.

LLVM added codegen decision making based on RuntimeLibraryInfo. Mirror the change in Rust's codegen.

LLVM reference commit:
04c81a9973.
2025-12-05 16:17:11 +01:00
Matthias Krüger
0c05bb5606
Rollup merge of #149630 - wafarm:fix-149604, r=JonathanBrouwer
Check identifiers defined in macros when suggesting identifiers hidden by hygiene

Fix rust-lang/rust#149604

r? `@JonathanBrouwer` (Since you reviewed the other one related to this)
2025-12-05 16:17:10 +01:00
Matthias Krüger
c42ce16c7b
Rollup merge of #149548 - aerooneqq:ice-issue-144594, r=petrochenkov
Generate delegation error body when delegation is not resolved

This PR relates to the delegation feature rust-lang/rust#118212, it fixes rust-lang/rust#144594 ICE.
r? `@petrochenkov`
2025-12-05 16:17:10 +01:00
Matthias Krüger
7850fc4b13
Rollup merge of #149101 - reddevilmidzy:mutable, r=eholk
Improve mutable-binding suggestion to include name

resolve: rust-lang/rust#148467
2025-12-05 16:17:07 +01:00
aerooneqq
3e717121a1 Generate error delegation body when delegation is not resolved 2025-12-05 15:22:26 +03:00
bors
97b131c900 Auto merge of #148602 - BoxyUwU:coercion_cleanup_uncontroversial, r=lcnr
misc coercion cleanups and handle safety correctly

r? lcnr

### "remove normalize call"

Fixes rust-lang/rust#132765

If the normalization fails we would sometimes get a `TypeError` containing inference variables created inside of the probe used by coercion. These would then get leaked out causing ICEs in diagnostics logic

### "leak check and lub for closure<->closure coerce-lubs of same defids"

Fixes https://github.com/rust-lang/trait-system-refactor-initiative/issues/233
```rust
fn peculiar() -> impl Fn(u8) -> u8 {
    return |x| x + 1
}
```
the `|x| x + 1` expr has a type of `Closure(?31t)` which we wind up inferring the RPIT to. The `CoerceMany` `ret_coercion` for the whole `peculiar` typeck has an expected type of `RPIT` (unnormalized). When we type check the `return |x| x + 1` expr we go from the never type to `Closure(?31t)` which then participates in the `ret_coercion` giving us a `coerce-lub(RPIT, Closure(?31t))`.

Normalizing `RPIT` gives us some `Closure(?50t)` where `?31t` and `?50t` have been unified with `?31t` as the root var. `resolve_vars_if_possible` doesn't resolve infer vars to their roots so these wind up with different structural identities so the fast path doesn't apply and we fall back to coercing to a `fn` ptr. cc rust-lang/rust#147193 which also fixes this

New solver probably just gets more inference variables here because canonicalization + generally different approach to normalization of opaques. Idk :3

### FCP worthy stuffy

there are some other FCP worthy things but they're in my FCP comment which also contains some analysis of the breaking nature of the previously listed changes in this PR: https://github.com/rust-lang/rust/pull/148602#issuecomment-3503497467
2025-12-05 11:46:41 +00:00
Ralf Jung
f040a1a915 interpret: test SNaN handling of float min/max and update comments 2025-12-05 08:53:42 +01:00
Zalathar
84ff44c749 Add perma-unstable --print=backend-has-zstd for use by compiletest
Tests for `-Zdebuginfo-compression=zstd` need to be skipped if LLVM was built
without support for zstd compression.

Currently, compiletest relies on messy and fragile heuristics to detect whether
the compiler's LLVM was built with zstd support. But the compiler itself
already knows whether LLVM has zstd or not, so it's easier for compiletest to
just ask the compiler.
2025-12-05 14:27:52 +11:00
bors
3e2dbcdd3a Auto merge of #149646 - matthiaskrgr:rollup-jbfeow8, r=matthiaskrgr
Rollup of 9 pull requests

Successful merges:

 - rust-lang/rust#147224 (Emscripten: Turn wasm-eh on by default)
 - rust-lang/rust#149405 (Recover on misspelled item keyword)
 - rust-lang/rust#149443 (Tidying up UI tests [6/N])
 - rust-lang/rust#149524 (Move attribute safety checking to attribute parsing)
 - rust-lang/rust#149593 (powf, powi: point out SNaN non-determinism)
 - rust-lang/rust#149605 (Use branch name instead of HEAD when unshallowing)
 - rust-lang/rust#149612 (Apply the `bors` environment also to the `outcome` job)
 - rust-lang/rust#149623 (Don't require a normal tool build of clippy/rustfmt when running their test steps)
 - rust-lang/rust#149627 (Point to the item that is incorrectly annotated with `#[diagnostic::on_const]`)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-12-04 22:04:03 +00:00
Alina Sbirlea
ad73972e99 Fix for LLVM22 making lowering decisions dependent on RuntimeLibraryInfo.
LLVM reference commit:
04c81a9973.
2025-12-04 20:23:00 +00:00
bors
b33119ffdd Auto merge of #149642 - GuillaumeGomez:subtree-update_cg_gcc_2025-12-04, r=GuillaumeGomez
cg_gcc subtree update

cc `@antoyo`

r? ghost
2025-12-04 17:48:32 +00:00
Matthias Krüger
69f8a5ca67
Rollup merge of #149627 - lapla-cogito:diag_onconst, r=jdonszelmann
Point to the item that is incorrectly annotated with `#[diagnostic::on_const]`

close rust-lang/rust#149606

r? estebank
2025-12-04 16:07:57 +01:00
Matthias Krüger
0c95abb979
Rollup merge of #149524 - JonathanBrouwer:move_attr_safety, r=jdonszelmann
Move attribute safety checking to attribute parsing

This PR moves attribute safety checking to be done during attribute parsing. The `cfg` and `cfg_attr` attribute no longer need special-cased safety checking, yay!

This PR is a part 1 of 2, in the second part I'd like to define attribute safety in the attribute parsers rather than getting the information from BUILTIN_ATTRIBUTE_MAP, but to keep PRs reviewable lets do that separately.

Fixes https://github.com/rust-lang/rust/issues/148453 by reordering the diagnostics. The "cannot find attribute" diagnostic now appears first, but both diagnostics still appear.

r? `@jdonszelmann`
2025-12-04 16:07:53 +01:00
Matthias Krüger
55fa9f74db
Rollup merge of #149405 - scrabsha:push-tzonpluy, r=jdonszelmann
Recover on misspelled item keyword

the title says everything. first commit adds a test that shows how current `main` behaves on misspelled item keyword. second commit adds the recovery, which allows to emit many more errors.
2025-12-04 16:07:52 +01:00
Matthias Krüger
c80ac0f21a
Rollup merge of #147224 - hoodmane:wasm-eh-default-on, r=bjorn3
Emscripten: Turn wasm-eh on by default

As specified by [MCP](https://github.com/rust-lang/compiler-team/issues/920)
Resolves https://github.com/rust-lang/rust/issues/148309
Resolves https://github.com/rust-lang/rust/issues/112195
2025-12-04 16:07:51 +01:00
bors
29e035e172 Auto merge of #149632 - matthiaskrgr:rollup-c5iqgtn, r=matthiaskrgr
Rollup of 10 pull requests

Successful merges:

 - rust-lang/rust#149521 (Improve `io::Error::downcast`)
 - rust-lang/rust#149544 (Only apply `no_mangle_const_items`'s suggestion to plain const items)
 - rust-lang/rust#149545 (fix the check for which expressions read never type)
 - rust-lang/rust#149570 (rename cortex-ar references to unified aarch32)
 - rust-lang/rust#149574 (Batched compiletest Config fixups)
 - rust-lang/rust#149579 (Motor OS: fix compile error)
 - rust-lang/rust#149595 (Tidying up `tests/ui/issues` tests [2/N])
 - rust-lang/rust#149597 (Revert "implement and test `Iterator::{exactly_one, collect_array}`")
 - rust-lang/rust#149608 (Allow PowerPC spe_acc as clobber-only register)
 - rust-lang/rust#149610 (Implement benchmarks for uN::{gather,scatter}_bits)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-12-04 14:38:19 +00:00
Guillaume Gomez
94f1bfe1fc Merge commit 'dab6863ce8' into subtree-update_cg_gcc_2025-12-04 2025-12-04 14:53:08 +01:00
Matthias Krüger
5c4915734d
Rollup merge of #149608 - pmur:murp/ppc-clobber-speacc, r=Amanieu
Allow PowerPC spe_acc as clobber-only register

This register is only supported on the *powerpc*spe targets. It is only recognized by LLVM. gcc does not accept this as a clobber, nor does it support these targets.

This is a volatile register, thus it is included with clobber_abi.

r? `@Amanieu`
r? `@antoyo`
2025-12-04 09:22:15 +01:00
Matthias Krüger
c598b4e300
Rollup merge of #149597 - jdonszelmann:revert-iterator-exactly-one, r=wafflelapkin
Revert "implement and test `Iterator::{exactly_one, collect_array}`"

This reverts https://github.com/rust-lang/rust/pull/149270

I was quite excited it merged, and immediately realized with ``@WaffleLapkin`` that this is a breaking change on nightly! Despite still being marked as unstable, the name conflicts with the name on itertools as was discussed on the PR itself: https://github.com/rust-lang/rust/pull/149270#issuecomment-3573812447.

I'll reopen the PR though, and mark it as blocked on https://github.com/rust-lang/rust/pull/148605
2025-12-04 09:22:14 +01:00
Matthias Krüger
a411fe8f8d
Rollup merge of #149545 - WaffleLapkin:type_ascribe2, r=jackh726
fix the check for which expressions read never type

Fixes rust-lang/rust#149542
Fixes rust-lang/rust#149431

First commit is a drive-by needed for the refactor of the unreachable code lint, see https://github.com/rust-lang/rust/issues/148303
2025-12-04 09:22:11 +01:00
Matthias Krüger
5c9a4eed87
Rollup merge of #149544 - reddevilmidzy:where, r=fmease
Only apply `no_mangle_const_items`'s suggestion to plain const items

resolve: rust-lang/rust#149511
2025-12-04 09:22:11 +01:00
Matthias Krüger
62a42e8a31
Rollup merge of #149557 - folkertdev:c-variadic-not-supported, r=workingjubilee
c-variadic: bpf and spirv do not support c-variadic definitions

tracking issue: https://github.com/rust-lang/rust/issues/44930

Emit a nice error message on bpf and spirv targets when a c-variadic function is defined. Spirv also does not support c-variadic calls, bpf appears to allow them.

r? ```@workingjubilee```
2025-12-04 08:46:24 +01:00
Matthias Krüger
420ef95cd7
Rollup merge of #149528 - fee1-dead-contrib:rangeboundreword, r=jieyouxu
reword error for invalid range patterns

For half-open ranges, specifies that the upper bound cannot be the minimum.

Also specify that this only applies to range patterns and not also expressions.

Fixes rust-lang/rust#149165
2025-12-04 08:46:21 +01:00
Matthias Krüger
40c97a9279
Rollup merge of #149501 - lcnr:no-hard-error-on-norm-failure, r=lqd,oli-obk
CTFE: avoid emitting a hard error on generic normalization failures

Fixes rust-lang/rust#149081.

The fix is quite unsatisfying and should not be necessary, cc rust-lang/rust#149283. That change is significantly more involved. This temporary fix introduces some unnecessary complexity and may hide other type system bugs.

cc ````@rust-lang/types```` I think we should try to fix issue rust-lang/rust#149283 in the near future and then remove this hack again.

I originally intended a more targeted fix. I wanted to skip evaluating constants in MIR opts if their body was polymorphic and the current generic arguments still reference generic parameters. Notes from looking into this:
- we only fetch the MIR in the `eval_to_allocation_raw` query
- figuring out which MIR to use is hard
	- dealing with trivial consts is annoying
	- need to resolve instances for associated consts
	- implementing this by hand is hard
- inlining handles this issue by bailing on literally all normalization failures, even the ones that imply an unsoundness
	- `try_normalize_after_erasing_regions` generally does two things
		- deal with ambiguity after inlining
		- deal with error tainting issues (please don't, we should stop doing that)
- CTFE could be changed to always silently ignore normalization failures if we're in a generic body
	- hides actual bugs <- went with this option

r? types
2025-12-04 08:46:20 +01:00
Matthias Krüger
bea2f89de6
Rollup merge of #149183 - tiif:typing_env_fix, r=BoxyUwU
Use `TypingMode::PostAnalysis` in `try_evaluate_const`

As mentioned in https://github.com/rust-lang/rust/pull/148698#discussion_r2541882341, we should use ``TypingMode::PostAnalysis`` for that path.

````@BoxyUwU```` prefer the match in ``try_evaluate_const`` to be exhaustive, so I also included that in this PR :3
2025-12-04 08:46:19 +01:00
Matthias Krüger
82a17b30d8
Rollup merge of #149147 - chenyukang:yukang-fix-unused_assignments-macro-gen-147648, r=JonathanBrouwer
Fix unused_assignments false positives from macros

Fixes rust-lang/rust#147648
2025-12-04 08:46:18 +01:00
Matthias Krüger
5019bdaefe
Rollup merge of #147841 - jdonszelmann:test-macro-ice, r=wafflelapkin
Fix ICE when applying test macro to crate root

This PR does a couple of things. First of all, I found [an ICE](https://play.rust-lang.org/?version=stable&mode=debug&edition=2024&gist=a733a7f3d223e1a9712e44b571f3e5cf) that happens when applying `#![core::prelude::v1::test]` to the crate root. This is caused by the test macro not expanding to an item when `--test` isn't applied. For the crate root, that means it deletes the crate....

The fix now first does target checking, and only if the target is valid discards the item when `--test` isn't applied. The discarding is, I think, important for perf.

The problem with this PR is that it means that `#[test]` applied to structs previously would give no errors unless `--test` is applied! That sounds like a bug to me, but maybe we should crater run it just in case, since technically that's a breaking change. Errors in such items wouldn't be reported previously.

 Also fixed a smol diagnostics bug with `#[bench]`'s error messages refering to `#[test]` accidentally.

r? noratrieb (since I already explained you a bunch, feel free to re-assign)

Fixes https://github.com/rust-lang/rust/issues/114920
2025-12-04 08:46:17 +01:00
Wafarm
e513ce3fb4
Check identifiers defined in macros when suggesting identifiers hidden by hygiene 2025-12-04 14:58:46 +08:00
reddevilmidzy
d49075f083 Suppress ref mut suggestion for for-loop bindings 2025-12-04 15:13:40 +09:00
reddevilmidzy
f30eced2e3 Wrap binding name in parentheses in for-loop mut suggestion 2025-12-04 15:07:33 +09:00
lapla
2db3c95f72
Point to the item that is incorrectly annotated with #[diagnostic::on_const] 2025-12-04 11:59:19 +09:00
reddevilmidzy
2951d72219 Simplify and robustly compute suggestion span using
`vis_span.to(ident.span.shrink_to_lo())`
2025-12-04 11:01:40 +09:00
reddevilmidzy
6ce0f0ff91 Only apply no_mangle_const_items's suggestion to plain const items 2025-12-04 11:01:10 +09:00
Hood Chatham
f07a84fde8
Emscripten: Turn wasm-eh on by default
As specified by MCP:
https://github.com/rust-lang/compiler-team/issues/920
Resolves https://github.com/rust-lang/rust/issues/148309
2025-12-03 14:34:07 -08:00
Paul Murphy
b54b288518 Allow PowerPC spe_acc as clobber-only register
This register is only supported on the *powerpc*spe targets. It is
only recognized by LLVM. gcc does not accept this as a clobber, nor
does it support these targets.

This is a volatile register, thus it is included with clobber_abi.
2025-12-03 12:37:22 -06:00
Sasha Pourcelot
9ffde14aa4 Recover on misspelled item keyword 2025-12-03 18:09:40 +00:00
Boxy Uwu
2f95ecfdd6 reviews 2025-12-03 16:36:32 +00:00
Jonathan Brouwer
31d289c9bc
Lower spans in AttrPath correctly 2025-12-03 17:00:20 +01:00
Jonathan Brouwer
884fb5aef2
Move attribute safety checking to rustc_attr_parsing 2025-12-03 17:00:06 +01:00
Jana Dönszelmann
97d4d2154f
fixup name in diagnostics 2025-12-03 16:38:24 +01:00
Jana Dönszelmann
9dd3caeebe
only discard items with #[test] on it when target is valid 2025-12-03 16:38:24 +01:00
Jana Dönszelmann
c3407323ad
Revert "fixup warnings around the compiler"
This reverts commit f20175293a.
2025-12-03 16:34:32 +01:00
Waffle Lapkin
e4f02e40b6
fix guard patterns interaction with never type 2025-12-03 16:01:38 +01:00
tiif
af66b68f63 refactor: make the match exhaustive 2025-12-03 15:01:30 +00:00
tiif
46d8adeb61 Use TypingEnv::fully_monomorphized for evaluating const without generic param path 2025-12-03 15:01:16 +00:00
Boxy Uwu
24a3f58ade remove redundant lub 2025-12-03 14:55:44 +00:00