Commit graph

9833 commits

Author SHA1 Message Date
Matthias Krüger
119eea2b79
Rollup merge of #151577 - Zalathar:dep-kind-vtable, r=Kivooeo
Rename `DepKindStruct` to `DepKindVTable`

This type is used by dependency-tracking code in the query system, for looking up function pointers and other metadata associated with a particular `DepKind`.

Calling it “struct” is not particularly helpful, whereas calling it a “vtable” at least gives some basic intuition for what it is and how it is used.

Some associated identifiers have also drifted a bit over time, and this PR adjusts those as well.

There should be no change to compiler behaviour.

r? nnethercote (or compiler)
2026-01-25 07:43:01 +01:00
bors
75963ce795 Auto merge of #151065 - nagisa:add-preserve-none-abi, r=petrochenkov
abi: add a rust-preserve-none calling convention

This is the conceptual opposite of the rust-cold calling convention and is particularly useful in combination with the new `explicit_tail_calls` feature.

For relatively tight loops implemented with tail calling (`become`) each of the function with the regular calling convention is still responsible for restoring the initial value of the preserved registers. So it is not unusual to end up with a situation where each step in the tail call loop is spilling and reloading registers, along the lines of:

    foo:
        push r12
        ; do things
        pop r12
        jmp next_step

This adds up quickly, especially when most of the clobberable registers are already used to pass arguments or other uses.

I was thinking of making the name of this ABI a little less LLVM-derived and more like a conceptual inverse of `rust-cold`, but could not come with a great name (`rust-cold` is itself not a great name: cold in what context? from which perspective? is it supposed to mean that the function is rarely called?)
2026-01-25 02:49:32 +00:00
Simonas Kazlauskas
6db94dbc25 abi: add a rust-preserve-none calling convention
This is the conceptual opposite of the rust-cold calling convention and
is particularly useful in combination with the new `explicit_tail_calls`
feature.

For relatively tight loops implemented with tail calling (`become`) each
of the function with the regular calling convention is still responsible
for restoring the initial value of the preserved registers. So it is not
unusual to end up with a situation where each step in the tail call loop
is spilling and reloading registers, along the lines of:

    foo:
        push r12
        ; do things
        pop r12
        jmp next_step

This adds up quickly, especially when most of the clobberable registers
are already used to pass arguments or other uses.

I was thinking of making the name of this ABI a little less LLVM-derived
and more like a conceptual inverse of `rust-cold`, but could not come
with a great name (`rust-cold` is itself not a great name: cold in what
context? from which perspective? is it supposed to mean that the
function is rarely called?)
2026-01-24 19:23:17 +02:00
Matthias Krüger
a7249d87d8
Rollup merge of #151282 - Zalathar:pin-pat, r=Nadrieril
THIR patterns: Explicitly distinguish `&pin` from plain `&`/`&mut`

Currently, `thir::PatKind::Deref` is used for ordinary `&`/`&mut` patterns, and also for `&pin const` and `&pin mut` patterns under `feature(pin_ergonomics)`. The only way to distinguish between them is by inspecting the `Ty` attached to the pattern node.

That's non-obvious, making it easy to miss, and is also a bit confusing to read when it does occur.

This PR therefore adds an explicit `pin: hir::Pinnedness` field to `thir::PatKind::Deref`, to explicitly distinguish pin-deref nodes from ordinary builtin-deref nodes.

(I'm not deeply familiar with the future of pin-patterns, so I'm not sure whether that information is best carried as a field or as a separate `PatKind`, but I think this approach is at least an improvement over the status quo.)

r? Nadrieril (or compiler)
2026-01-24 15:35:09 +01:00
Zalathar
4b25ccdb91 Rename DepKindStruct to DepKindVTable 2026-01-24 18:22:14 +11:00
Zalathar
ff331d2cc8 Rename HandleCycleError to CycleErrorHandling 2026-01-23 13:58:17 +11:00
Jonathan Brouwer
96a40e9ac3
Rollup merge of #151296 - Human9000-bit:const-array-mir-dump-fix, r=BoxyUwU
MGCA: Fix incorrect pretty printing of valtree arrays

Fixes rust-lang/rust#151126

- **add failing test**
- **fix: additional check whether const array could be printed as raw bytes**

As I figured out, the problem was in `pretty_print_const_valtree`, where it tried to print unevaluated consts as if they were evaluated, which resulted in ICE.
2026-01-22 13:35:41 +01:00
human9000
ff97a6a7f4 fix: allow to print const array as raw bytes only if possible to do so 2026-01-22 15:06:22 +05:00
Jacob Pratt
512cc8d785
Rollup merge of #151442 - clubby789:crate-type-port, r=JonathanBrouwer
Port `#![crate_type]` to the attribute parser

Tracking issue: https://github.com/rust-lang/rust/issues/131229

~~Note that the actual parsing that is used in the compiler session is unchanged, as it must happen very early on; this just ports the validation logic.~~

Also added `// tidy-alphabetical-start` to `check_attr.rs` to make it a bit less conflict-prone
2026-01-22 00:37:43 -05:00
Jacob Pratt
4a983e0900
Rollup merge of #151439 - Mark-Simulacrum:bootstrap-bump, r=nnethercote
Bump bootstrap compiler to 1.94

https://forge.rust-lang.org/release/process.html#default-branch-bootstrap-update-tuesday
2026-01-22 00:37:43 -05:00
Jamie Hill-Daniel
66b78b700b Port crate_type to attribute parser 2026-01-22 02:34:28 +00:00
bors
b765963267 Auto merge of #150843 - fmease:dyn-ace, r=BoxyUwU
mGCA: Make trait object types with type-level associated consts dyn compatible

Under feature `min_generic_const_args` (mGCA) (rust-lang/rust#132980), render traits with non-parametrized type-level associated constants (i.e., `#[type_const]` ones) dyn compatible but force the user to specify all type-level associated consts in the trait object type via bindings (either directly, via supertrait bounds and/or behind trait aliases) just like associated types, their sibling.

Fixes rust-lang/rust#130300 (feature request).
Fixes rust-lang/rust#136063 (bug).
Fixes rust-lang/rust#137260 (bug).
Fixes rust-lang/rust#137514 (bug).

While I'm accounting for most illegal `Self` references via const projections & params, I'm intentionally ignoring RUST-123140 (and duplicates) in this PR which is to be tackled some other time.

Additional context: Crate `rustc-demangle` had to be updated to fix v0 demangling. I've patched it in PR https://github.com/rust-lang/rustc-demangle/pull/87 which was was released in version 0.1.27 via PR https://github.com/rust-lang/rustc-demangle/pull/88.
2026-01-22 01:56:41 +00:00
Mark Rousskov
3dc7a1f33b Bump stage0 2026-01-21 20:03:56 -05:00
Oscar Bray
1143cb2bb2 Port two panic attrs to the attr parser.
Ports #![panic_runtime] and #![needs_panic_runtime]
2026-01-21 21:07:19 +00:00
Oscar Bray
8c4e48e9b5 Port #![compiler_builtins] to the attribute parser. 2026-01-21 21:06:39 +00:00
Jonathan Brouwer
f87b84ce3d
Rollup merge of #151445 - Zalathar:arenas-default, r=mati865
Derive `Default` for `QueryArenas`

There's no need to manually implement Default for this struct, because the fields are all `TypeArena<_>` or `()`, which both implement Default already.

This lets us avoid one occurrence of the `query_if_arena!` macro.
2026-01-21 16:39:42 +01:00
León Orell Valerian Liehr
7f5819317b
mGCA: Render traits dyn incompatible if the ty of an assoc const refs Self (barring Self projections) 2026-01-21 12:53:48 +01:00
León Orell Valerian Liehr
baba337869
Introduce AssocTag::descr & refactor in the vicinity 2026-01-21 12:53:46 +01:00
León Orell Valerian Liehr
9b861ace46
Generalize diag for missing assoc types to account for assoc consts 2026-01-21 12:53:46 +01:00
León Orell Valerian Liehr
8d524f096d
mGCA: Make traits with type assoc consts dyn compatible...
...but require all assoc consts to be specified via bindings.
2026-01-21 12:53:44 +01:00
Zalathar
2495e5834b Add some comments to QueryArenas 2026-01-21 18:10:53 +11:00
Zalathar
91a0e09d3e Derive Default for QueryArenas 2026-01-21 18:09:51 +11:00
Jacob Pratt
980547529a
Rollup merge of #151402 - dep-kind-name, r=petrochenkov
Simplify lookup of `DepKind` names in duplicate dep node check

This PR simplifies parts of the query system, by removing the `make_dep_kind_name_array!` macro, and removing much of the associated plumbing added by 68fd771bc1.

Instead, we now create a `DEP_KIND_NAMES` constant in `define_dep_nodes!`, and look up names in that instead.
2026-01-21 02:04:02 -05:00
Zalathar
395ca3be21 Remove #[derive(Clone)] from DepsType 2026-01-21 12:02:26 +11:00
Zalathar
154255698a Make Deps::name lookup a non-self associated function
The dep names needed here are statically available from `rustc_middle`.
2026-01-21 12:02:26 +11:00
Zalathar
17c5b7a4b5 Replace make_dep_kind_name_array! with a slice constant 2026-01-21 12:02:26 +11:00
Zachary S
c3205f98dd Replace #[rustc_do_not_implement_via_object] with #[rustc_dyn_incompatible_trait], which makes the marked trait dyn-incompatible.
Removes the attribute from `MetaSized` and `PointeeSized`, with a special case in the trait solvers for `MetaSized`.

`dyn MetaSized` is a perfectly cromulent type, and seems to only have had #[rustc_do_not_implement_via_object] so the builtin object
candidate does not overlap with the builtin MetaSized impl that all `dyn` types get.
Resolves this with a special case by checking `is_sizedness_trait` where the trait solvers previously checked `implement_via_object`.

`dyn PointeeSized` alone is rejected for other reasons (since `dyn PointeeSized` is considered to have no principal trait because `PointeeSized`
is removed at an earlier stage of the compiler), but `(dyn PointeeSized + Send)` is valid and equivalent to `dyn Send`.

Add suggestions from code review

Update compiler/rustc_trait_selection/src/traits/dyn_compatibility.rs and tests

Co-authored-by: lcnr <rust@lcnr.de>
2026-01-20 12:54:40 -06:00
Stuart Cook
1262ff906b
Rollup merge of #150288 - offload-bench-fix, r=ZuseZ4
Add scalar support for offload

This PR adds scalar support to the offload feature. The scalar management has two main parts:

On the host side, each scalar arg is casted to `ix` type, zero extended to `i64` and passed to the kernel like that.
On the device, the each scalar arg (`i64` at that point), is truncated to `ix` and then casted to the original type.

r? @ZuseZ4
2026-01-20 18:00:08 +11:00
Zalathar
566c23de41 THIR patterns: Explicitly distinguish &pin from plain &/&mut 2026-01-20 13:41:32 +11:00
Marcelo Domínguez
307a4fcdf8 Add scalar support for both host and device 2026-01-19 22:28:42 +01:00
Jonathan Brouwer
958d1f907b
Rollup merge of #150879 - remove_diag_lints, r=Kivooeo
Remove the diagnostic lints

Removes the `untranslatable_diagnostic` and `diagnostic_outside_of_impl` lints
These lints are allowed for a while already. Per https://github.com/rust-lang/compiler-team/issues/959, we no longer want to enforce struct diagnostics for all usecases, so this is no longer useful.

r? @Kivooeo
I recommend reviewing commit by commit (also feel free to wait with reviewing until the MCP is accepted)

@rustbot +S-blocked
Blocked by https://github.com/rust-lang/compiler-team/issues/959
2026-01-19 20:53:20 +01:00
Jonathan Brouwer
a66a2e31eb
Rollup merge of #150550 - borrowck_cleanup_2, r=lcnr
Miscellaneous cleanups to borrowck related code

r? lcnr
2026-01-19 20:53:20 +01:00
Jonathan Brouwer
619f1378ed
Rollup merge of #148623 - trimmed-paths, r=davidtwco
Ignore `#[doc(hidden)]` items when computing trimmed paths for printing

The `trimmed_def_paths` query examines all items in the current crate, and all pub items in immediate-dependency crates (including the standard library), to see which item names are unique and can therefore be printed unambiguously as a bare name without a module path.

Currently that query has no special handling for `#[doc(hidden)]` items, which has two consequences:
- Hidden names can be considered unique, and will therefore be printed without a path, making it hard to find where that name is defined (since it normally isn't listed in documentation).
- Hidden names can conflict with visible names that would otherwise be considered unique, causing diagnostics to mysteriously become more verbose based on internal details of other crates.

This PR therefore makes the `trimmed_def_paths` query ignore external-crate items that are `#[doc(hidden)]`, along with their descendants.

As a result, hidden item names are never considered unique for trimming, and no longer interfere with visible item names being considered unique.

---
- Fixes https://github.com/rust-lang/rust/issues/148387.
2026-01-19 20:53:19 +01:00
Jonathan Brouwer
f50f5dc494
Remove all usages of #[rustc_lint_diagnostics] 2026-01-19 17:39:54 +01:00
Jonathan Brouwer
0ee7d96253
Remove all allows for diagnostic_outside_of_impl and untranslatable_diagnostic throughout the codebase
This PR was mostly made by search&replacing
2026-01-19 17:39:49 +01:00
Boxy Uwu
169dadcbbe two phase borrow handling cleanups 2026-01-19 16:08:54 +00:00
Zalathar
7ec34defe9 Temporarily re-export assert_matches! to reduce stabilization churn 2026-01-19 18:26:53 +11:00
Zalathar
2df2c72d7a Ignore #[doc(hidden)] items when computing trimmed paths 2026-01-19 12:27:27 +11:00
Matthias Krüger
57e950bc98
Rollup merge of #151203 - revert-QueryStackFrame-split, r=oli-obk
Revert `QueryStackFrame` split

PR rust-lang/rust#138672 fixed a query cycle OOM reported in rust-lang/rust#124901. The fix involved delaying computation of some query stack frame elements and was very complex. It involved the addition of two new types, the addition of a generic `I` parameter to eleven(!) other types, a `PhantomData` field, and even required an unsafe transmute of a closure. [This comment](https://github.com/rust-lang/rust/issues/124901#issuecomment-2104852065) had suggested a much simpler fix, but it was ignored. The PR also failed to add a test case.

This PR adds a test case, reverts the complex fix, applies the simpler fix, and does a few other minor cleanups.

r? @oli-obk
2026-01-16 13:57:47 +01:00
Matthias Krüger
81cc29a425
Rollup merge of #145354 - cache-proc-derive-macros, r=petrochenkov
Cache derive proc macro expansion with incremental query

This is a revival of https://github.com/rust-lang/rust/pull/129102, originally implemented by @futile. Since it looks like they are not active currently, I'd like to push this work forward.

The first commit is squashed and rebased work from the original PR, with author attribution to futile. The rest of the commits are some additional comments that I created mostly for myself to understand what happens here. I also did some cleanups based on Vadim's review comments on the original PR, plus I refactored the TLS access a bit using `scoped_tls`.

The biggest issue, as usually, are tests... I tried using `#[rustc_clean(..., loaded_from_disk = "derive_macro_expansion")]`, but the problem is that since this query cannot recover the original key from its hash, and thus its fingerprintstyle is `FingerprintStyle::Opaque`, [this](2fef0a30ae/compiler/rustc_incremental/src/persist/dirty_clean.rs (L388)) crashes when I try to use `loaded_from_disk`. Any suggestions from someone who actually understands the query system would be welcome 😅

TODO: document the new unstable flag

On a no-op change re-check of `octocrab 0.49` (which has a ton of `serde` derive proc macro invocations), this saves ~0.6s out of ~6s (so a ~10% win) on my PC.

r? @petrochenkov
2026-01-16 13:57:45 +01:00
Nicholas Nethercote
48bcaf7ed1 Revert the QueryStackFrameExtra/QueryStackDeferred split.
PR #138672 introduced a complex and invasive split of `QueryStackFrame`
to avoid a query cycle. This commit reverts that change because there is
a much simpler change that fixes the problem, which will be in the next
commit.
2026-01-16 19:18:42 +11:00
Felix Rath
8fa2f693bb
Implement incremental caching for derive macro expansions 2026-01-16 07:36:36 +01:00
Nicholas Nethercote
4c2e447027 Rename fatal_cycle as cycle_fatal.
To be consistent with the closely related `cycle_stash` and
`cycle_delay_bug`.
2026-01-16 14:55:03 +11:00
Nicholas Nethercote
9f6e7473d6 Fix a typo. 2026-01-16 14:54:20 +11:00
bors
18ae990755 Auto merge of #150925 - dianqk:if-cmp, r=saethlin
Only use SSA locals in SimplifyComparisonIntegral

Fixes https://github.com/rust-lang/rust/issues/150904.

The place may be modified from the comparison statement to the switchInt terminator.

Best reviewed commit by commit.
2026-01-15 23:54:21 +00:00
bors
22c74ba918 Auto merge of #151056 - mejrs:do_not_recommend, r=JonathanBrouwer
Port `diagnostic::do_not_recommend` to new attr parsing

r? @jdonszelmann
2026-01-15 19:35:19 +00:00
Stuart Cook
69f0a498ba
Rollup merge of #151103 - array-pat-len, r=Nadrieril,petrochenkov
mir_build: Simplify length-determination and indexing for array/slice patterns

The existing length-determination code in `prefix_slice_suffix` has ended up overly complicated, partly because it doesn't know in advance whether the pattern is supposed to be an array pattern or a slice pattern.

Pulling most of that step out into the `PatKind::Array` arm makes the whole thing a bit nicer overall.

There should (hopefully) be no change to compiler output. The biggest “functional” change is that we now discard the subpatterns of an array pattern of unknowable length, instead of treating it as a slice pattern. I'm not aware of any way for this to make an observable difference, and it can only occur when compilation is already doomed to fail.
2026-01-15 21:39:03 +11:00
Stuart Cook
eafe40e05c
Rollup merge of #150846 - thir-hir-id, r=lcnr
include `HirId`s directly in the THIR, not wrapped in `LintLevel`s

Occurrences of `LintLevel` in the THIR were always `LintLevel::Explicit`, containing a `HirId`, so we don't need to make it possible to put `LintLevel::Inherited` there. Removing the unused case where `HirId`s aren't present in the THIR slightly simplifies diagnostics/lints/tools that want to map from the THIR back to the HIR, e.g. rust-lang/rust#145569.

Since `LintLevel` is no longer present in the THIR, I've moved it in the second commit to live in `rustc_mir_build`; that's where it's actually used. I'm not sure exactly where exactly it should live there, but I put it in the `builder::scope` module since it's used by `Builder::in_scope` for determining when to introduce source scopes.

r? lcnr as the reviewer of rust-lang/rust#145569, since this was discussed there
2026-01-15 21:39:02 +11:00
dianne
8868b479a8 move LintLevel to rustc_mir_build 2026-01-14 14:25:21 -08:00
dianne
36d37fd11b THIR: directly contain HirIds, not LintLevels 2026-01-14 14:25:21 -08:00