Commit Graph

55024 Commits

Author SHA1 Message Date
Jonathan Brouwer 997493114f Rollup merge of #151148 - Jarcho:gbit_set, r=davidtwco
Add functions to `GrowableBitSet`

Only really need `insert_range` for clippy, but may as well add the others. Using `Range` instead of `RangeBounds` since an end bound is needed for this to make sense and there aren't any traits to enforce that.
2026-03-25 19:52:56 +01:00
Jonathan Brouwer c13e9ec32b Rollup merge of #154364 - aerooneqq:delegation-generics-small-fixes, r=petrochenkov
delegation: don't propagate synthetic params, remove lifetime hacks

Some small fixes after new delegation lowering was merged: remove lifetime hacks as now we get only early-bound lifetimes from generics, don't propagate synthetic generic params as now we know that they are synthetic. Fixes rust-lang/rust#143498. Part of rust-lang/rust#118212.

r? @petrochenkov
2026-03-25 19:52:56 +01:00
Jonathan Brouwer 145917253d Rollup merge of #154363 - aerooneqq:nested-delegations, r=petrochenkov
delegation: fix zero-args nested delegation ICE

This PR fixes an ICE when during lowering of nested delegation we need to access information about its parent, who is also inside body of another delegation. As a fix we lower delegation body even if there are no arguments in signature function, in this case we will see an error `this function takes 0 arguments but 1 argument was supplied`. Fixes rust-lang/rust#154332. Part of rust-lang/rust#118212.

r? @petrochenkov
2026-03-25 19:52:55 +01:00
Jonathan Brouwer 8dfc5edc38 Rollup merge of #154351 - nnethercote:overhaul-Erasable-impls, r=petrochenkov
Overhaul `Erasable` impls

This PR removes many unused `Erasable` impls, converts many of the hand-written impls to macro-generated impls, and sorts the macro's inputs. This cuts over 200 lines of code and fixes three FIXME comments.

r? @petrochenkov
2026-03-25 19:52:55 +01:00
Jonathan Brouwer 85ddb8e414 Rollup merge of #154313 - mu001999-contrib:fix/154295, r=petrochenkov
Init `self_decl` with a correct visibility

Fixes rust-lang/rust#154295

r? petrochenkov
2026-03-25 19:52:52 +01:00
Jonathan Brouwer b5e4b4ca79 Rollup merge of #154269 - RalfJung:miri-recursive-shallow, r=saethlin
miri recursive validation: only check one layer deep

As has been proposed in https://github.com/rust-lang/unsafe-code-guidelines/issues/414, let's see what happens if we make recursive checking in Miri shallow: we treat whatever is behind a reference as if it was inside `MaybeDangling`, which means nested references do not have to be dereferenceable.

This changes the meaning of the original flag -- I don't think it is worth supporting multiple variants of recursive checking (it'd require a bunch of new plumbing), and this seems to be the strictest variant that still has any traction in the discussion.
2026-03-25 19:52:52 +01:00
Jonathan Brouwer 27f9b7ca59 Rollup merge of #154263 - RalfJung:interpret-arg-passing-spans, r=oli-obk
interpret: when passing an argument fails, point at that argument

For a long time now, we did some contortions so that when something goes wrong while initializing the arguments for a function, we point at the call site rather than the callee. Historically, this had to be done because the "current location" in the callee pointed at the first instruction, which would obviously be nonsense. A while ago we gained the ability in the interpreter for the "current location" to be just a span that we point at for errors, but we never reevaluated the decision for how spans are handled during function calls. (We did use this "just a span" location for [errors during the initial stack frame setup](https://github.com/rust-lang/rust/commit/d21e0118d0eefc8b0073fa47fa16699d37047abf), but not for argument initialization.)

There's no always-great choice for pointing at the caller vs the callee: when they disagree about the type of an argument, either side could be wrong. If We do *two* typed copies in that case, one at the caller type and one at the callee type. Arguably we should point at the one that goes wrong, but we don't have a good way to expose that.

What ultimately pushed me over the edge towards pointing at the callee are two points:
- This provides strictly more information. if we point at the callee, the caller is available in the stacktrace. But if we point at the caller, then it might be impossible to figure out the actual callee if a function pointer or dyn call is involved.
- As part of resolving some long-standing questions around retags I am moving retagging to become part of validation, which means the retag and protector initialization of function arguments will happen during argument initialization. These currently point at the argument inside the callee, which I think is strictly preferable for these errors.

The diff will be much smaller with whitespace changes hidden.
2026-03-25 19:52:51 +01:00
Jonathan Brouwer 2f1603077b Rollup merge of #154200 - resrever:enable-dwarf-call-sites, r=dingxiangfei2009
debuginfo: emit DW_TAG_call_site entries

Set `FlagAllCallsDescribed` on function definition DIEs so LLVM emits DW_TAG_call_site entries, letting debuggers and analysis tools track tail calls.
2026-03-25 19:52:50 +01:00
Jonathan Brouwer 6e3c17424d Rollup merge of #153702 - SpriteOvO:guard-matcher, r=davidtwco
Add macro matcher for `guard` fragment specifier

Tracking issue #153104

This PR implements a new `guard` macro matcher to match `if-let` guards (specifically [`MatchArmGuard`](https://github.com/rust-lang/reference/blob/50a1075e879be75aeec436252c84eef0fad489f4/src/expressions/match-expr.md#match-guards)). In the upcoming PR, we can use this new matcher in the `matches!` and `assert_matches!` macros to support their use with `if-let` guards. (see #152313)

The original `Expr` used to represent a guard has been wrapped in a new `Guard` type, allowing us to carry the span information of the leading `if` keyword. However, it might be even better to include the `if` keyword in the `Guard` type as well? I've left a FIXME comment in the code.
2026-03-25 19:52:50 +01:00
Jonathan Brouwer 0cd8de3843 Rollup merge of #153049 - Darksonn:kasan-sw-tags, r=fmease
Add `-Zsanitize=kernel-hwaddress`

The Linux kernel has a config option called `CONFIG_KASAN_SW_TAGS`  that enables `-fsanitize=kernel-hwaddress`. This is not supported by Rust.

One slightly awkward detail is that `#[sanitize(address = "off")]` applies to both `-Zsanitize=address` and `-Zsanitize=kernel-address`. Probably it was done this way because both are the same LLVM pass. I replicated this logic here for hwaddress, but it might be undesirable.

Note that `#[sanitize(kernel_hwaddress = "off")]` could be supported as an annotation on statics, but since it's also missing for `#[sanitize(hwaddress = "off")]`, I did not add it.

MCP: https://github.com/rust-lang/compiler-team/issues/975
Tracking issue: https://github.com/rust-lang/rust/issues/154171

cc @rcvalle @maurer @ojeda
2026-03-25 19:52:49 +01:00
mu001999 01795c3eab Init self_decl with a correct vis 2026-03-25 21:41:33 +08:00
aerooneqq c2383b53a2 Don't propagate synthetic params, remove lifetime hacks 2026-03-25 13:04:03 +03:00
aerooneqq 11a338deb6 Fix nested zero-args delegation ICE 2026-03-25 12:08:31 +03:00
Nicholas Nethercote 4f03262c8a Use impl_erasable_for_types_with_no_type_params! even more.
Some of the hand-written `Erasable` impls only match a single type in
practice. It's easier to just list the concrete types in
`impl_erasable_for_types_with_no_type_params!`.
2026-03-25 16:11:24 +11:00
Nicholas Nethercote dce1805599 Use impl_erasable_for_simple_types! more, and rename it.
Now that 'static lifetimes aren't used, a lot of the hand-written
`Erasable` impls can now be done with the macro. (The only ones that
can't are those with a generic type parameter, because `size_of`
doesn't work in that case.)

Also, `impl_erasable_for_single_lifetime_types!` isn't needed at all.
2026-03-25 16:08:00 +11:00
Nicholas Nethercote efd36a4897 Avoid 'static in Erasable impls.
Using '_ removes unnecessary differences between the impl type and the
associated `Storage` type.
2026-03-25 14:29:10 +11:00
Nicholas Nethercote 2fde4f4210 Adjust some Erasable impls.
A few can be done with the `impl_erasable_for_single_lifetime_types!`
macro instead of being hand-written.
2026-03-25 14:27:45 +11:00
Nicholas Nethercote 289932194a Avoid unnecessary qualification of ErrorGuaranteed.
It's imported and can be used directly within this file, and already is
in a few places.
2026-03-25 14:27:45 +11:00
Nicholas Nethercote 833bf3c375 Sort impl_erasable_* macro calls. 2026-03-25 14:27:45 +11:00
Nicholas Nethercote 8ab0c4cbf3 Remove unused Erasable impls.
There are many!
2026-03-25 14:27:43 +11:00
bors 8a703520e8 Auto merge of #154339 - JonathanBrouwer:rollup-FPeeGxJ, r=JonathanBrouwer
Rollup of 3 pull requests

Successful merges:

 - rust-lang/rust#154311 ([libcore] Disable `doc(auto_cfg)` for integers trait impls)
 - rust-lang/rust#154331 (allow `incomplete_features` in all ui tests)
 - rust-lang/rust#154336 (Remove more BuiltinLintDiag variants - part 3)
2026-03-24 22:00:08 +00:00
Jonathan Brouwer d54a564510 Rollup merge of #154336 - GuillaumeGomez:migrate-diag, r=JonathanBrouwer
Remove more BuiltinLintDiag variants - part 3

Part of https://github.com/rust-lang/rust/issues/153099.

Last part of the "easy" migration.

r? @JonathanBrouwer
2026-03-24 22:36:57 +01:00
Guillaume Gomez c17dec615d Remove BuiltinLintDiag usage in rustc_metadata 2026-03-24 19:45:17 +01:00
bors 362211dc29 Auto merge of #154326 - JonathanBrouwer:rollup-MflIdQW, r=JonathanBrouwer
Rollup of 5 pull requests

Successful merges:

 - rust-lang/rust#152710 (Unalign `PackedFingerprint` on all hosts, not just x86 and x86-64)
 - rust-lang/rust#153874 (constify const Fn*: Destruct)
 - rust-lang/rust#154097 (improve validation error messages: show surrounding type)
 - rust-lang/rust#154277 (use `minicore` more in testing inline assembly)
 - rust-lang/rust#154293 (Use verbose span suggestion for type const)
2026-03-24 18:37:19 +00:00
Alice Ryhl 422906d57e Do not check for LEAK & KERNELHWADDRESS because they are incompatible 2026-03-24 17:39:46 +00:00
Jonathan Brouwer 9396ab225e Rollup merge of #154293 - reddevilmidzy:type-diag, r=fmease
Use verbose span suggestion for type const

close: https://github.com/rust-lang/rust/issues/154214

r? fmease
2026-03-24 18:14:18 +01:00
Jonathan Brouwer ab6401749a Rollup merge of #154097 - RalfJung:validity-error, r=oli-obk
improve validation error messages: show surrounding type

Also, for dyn-downcast show the type we're downcasting to.

r? @oli-obk
2026-03-24 18:14:15 +01:00
Jonathan Brouwer 1e3d3bdb24 Rollup merge of #153874 - bend-n:constify-const-fn-destruct, r=oli-obk
constify const Fn*: Destruct

makes closures const destruct where their upvars are. i think this makes sense
and is how this should be implemented.

r? @oli-obk
2026-03-24 18:14:15 +01:00
Jonathan Brouwer 65097900fd Rollup merge of #152710 - Zalathar:unalign-fingerprint, r=fmease
Unalign `PackedFingerprint` on all hosts, not just x86 and x86-64

Back in https://github.com/rust-lang/rust/pull/78646, `DepNode` was modified to store an unaligned `PackedFingerprint` instead of an 8-byte-aligned `Fingerprint`. That reduced the size of DepNode from 24 bytes to 17 bytes (nowadays 18 bytes), resulting in considerable memory savings in incremental builds.

See https://github.com/rust-lang/rust/pull/152695#issuecomment-3907091509 for a benchmark demonstrating the impact of *removing* that optimization.

At the time (and today), the unaligning was only performed on x86 and x86-64 hosts, because those CPUs are known to generally have low overhead for unaligned memory accesses. Hosts with other CPU architectures would continue to use an 8-byte-aligned fingerprint and a 24-byte DepNode.

Given the subsequent rise of aarch64 (especially on macOS) and other architectures, it's a shame that some commonly-used builds of rustc don't get those memory-size benefits, based on a decision made several years ago under different circumstances.

We don't have benchmarks to show the actual effect of unaligning DepNode fingerprints on various non-x86 hosts, but it seems very likely to be a good idea on Apple chips, and I have no particular reason to think that it will be catastrophically bad on other hosts. And we don't typically perform this kind of speculative pessimization in other parts of the compiler.
2026-03-24 18:14:14 +01:00
Jonathan Brouwer a5327061eb Rollup merge of #154303 - GuillaumeGomez:migrate-diag2, r=JonathanBrouwer
Remove more `BuiltinLintDiag` variants - part 2

Part of https://github.com/rust-lang/rust/issues/153099.

r? @JonathanBrouwer
2026-03-24 16:22:52 +01:00
Jonathan Brouwer 1cfbc509e6 Rollup merge of #154142 - aerooneqq:dont-create-ast-generics-2, r=petrochenkov
Delegation: eliminate usage of AST from generics creation

This PR eliminates all interaction with AST during creation of generics, then it supports proper const param types propagation. Fixes rust-lang/rust#153433. Fixes rust-lang/rust#153499. Part of rust-lang/rust#118212.

r? @petrochenkov
2026-03-24 16:22:49 +01:00
Redddy e03983878f Use verbose span suggestion for type const 2026-03-24 15:02:10 +00:00
aerooneqq 1d325ce436 Eliminate usage of AST from generics creation 2026-03-24 14:16:36 +03:00
bors 0312931d8c Auto merge of #154300 - JonathanBrouwer:rollup-MkFxTPv, r=JonathanBrouwer
Rollup of 4 pull requests

Successful merges:

 - rust-lang/rust#153434 (Use a safe `BucketIndex` abstraction in `VecCache`)
 - rust-lang/rust#154133 (Defer codegen for the VaList Drop impl to actual uses)
 - rust-lang/rust#154297 (fix/extend some mir-opt comments)
 - rust-lang/rust#154299 (document some functions on AttributeExt)
2026-03-24 11:14:58 +00:00
Guillaume Gomez 5d7f89417c Remove more BuiltinLintDiag in rustc_resolve 2026-03-24 11:47:03 +01:00
Guillaume Gomez 45027f1788 Remove more BuiltinLintDiag in rustc_middle 2026-03-24 11:47:03 +01:00
Guillaume Gomez eba0efd9aa Remove more BuiltinLintDiag in rustc_attr_parsing 2026-03-24 11:47:03 +01:00
Jonathan Brouwer 6f67067c6f Rollup merge of #154299 - jdonszelmann:document-attribute-ext, r=JonathanBrouwer
document some functions on AttributeExt

r? @jyn514
2026-03-24 10:54:05 +01:00
Jonathan Brouwer a5a286df89 Rollup merge of #154297 - RalfJung:mir-opt-comments, r=dianqk
fix/extend some mir-opt comments

Looks like CopyProp was refactored without updating that comment.

And for GVN, I think this is what you had in mind @cjgillot but would be great if you could have a look.
2026-03-24 10:54:04 +01:00
Jonathan Brouwer fad2a35ebf Rollup merge of #154133 - bjorn3:va_list_drop_defer_codegen, r=nnethercote
Defer codegen for the VaList Drop impl to actual uses

This allows compiling libcore with codegen backends that don't actually implement VaList like cg_clif.
2026-03-24 10:54:04 +01:00
Jonathan Brouwer f02eaf6ea5 Rollup merge of #153434 - Zalathar:bucket-index, r=nnethercote
Use a safe `BucketIndex` abstraction in `VecCache`

The current code for indexing into bucket arrays is quite tricky and unsafe, partly because it has to keep manually assuring the compiler that a bucket index is always less than 21.

By encapsulating that knowledge in a 21-value enum, we can make the code clearer and safer, without giving up performance.

Having a dedicated `BucketIndex` type could also help with further cleanups of `VecCache` indexing.
2026-03-24 10:54:03 +01:00
Jana Dönszelmann c87cd68568 document some functions on AttributeExt 2026-03-24 09:29:26 +01:00
bors cde9cf08d7 Auto merge of #151063 - sgasho:aarch64-dist-enzyme, r=ZuseZ4
Link LLVM dynamically on aarch64-apple-darwin



Follow-up to rust-lang/rust#152768.

* Link LLVM dynamically on MacOS
* Fix a macOS LLVM dylib name mismatch
2026-03-24 08:05:38 +00:00
Ralf Jung fb2b0031d0 GVN: add clarifying example to reference comment 2026-03-24 08:59:29 +01:00
Ralf Jung bd16cd4fb5 CopyProp: fix outdated comment 2026-03-24 08:12:17 +01:00
Ralf Jung 5f68044357 miri recursive checking: only check one layer deep 2026-03-24 07:59:37 +01:00
Zalathar fd3b22a836 Use a safe BucketIndex abstraction in VecCache
The current code for indexing into bucket arrays is quite tricky and unsafe,
partly because it has to keep manually assuring the compiler that a bucket
index is always less than 21.

By encapsulating that knowledge in a 21-value enum, we can make the code
clearer and safer, without giving up performance.

Having a dedicated `BucketIndex` type could also help with further cleanups of
`VecCache` indexing.
2026-03-24 17:52:09 +11:00
bors 9df83179a4 Auto merge of #154289 - jhpratt:rollup-JFDweJT, r=jhpratt
Rollup of 10 pull requests

Successful merges:

 - rust-lang/rust#153964 (Fix `doc_cfg` not working as expected on trait impls)
 - rust-lang/rust#153979 (Rename various query cycle things.)
 - rust-lang/rust#154132 (Add missing num_internals feature gate to coretests/benches)
 - rust-lang/rust#154153 (core: Implement `unchecked_funnel_{shl,shr}`)
 - rust-lang/rust#154236 (Clean up query-forcing functions)
 - rust-lang/rust#154252 (Don't store current-session side effects in `OnDiskCache`)
 - rust-lang/rust#154017 ( Fix invalid add of duplicated call locations for the rustdoc scraped examples feature)
 - rust-lang/rust#154163 (enzyme submodule update)
 - rust-lang/rust#154264 (Update books)
 - rust-lang/rust#154282 (rustc-dev-guide subtree update)
2026-03-24 04:54:28 +00:00
Jacob Pratt 39343f53fd Rollup merge of #154252 - Zalathar:on-disk-cache, r=nnethercote
Don't store current-session side effects in `OnDiskCache`

This PR is a series of related cleanups to `OnDiskCache`, which is responsible for loading query return values (and side effects) that were serialized during the previous incremental-compilation session.

The primary change is to move the `current_side_effects` field out of OnDiskCache and into QuerySystem. That field was awkward because it was the only part of OnDiskCache state related to serializing the *current* compilation session, rather than loading values from the previous session.

The other commits should hopefully be straightforward.

r? nnethercote (or compiler)
2026-03-23 23:42:51 -04:00
Jacob Pratt efa7a5ea4a Rollup merge of #154236 - Zalathar:force-query, r=nnethercote
Clean up query-forcing functions

This PR takes the `force_query` function, inlines it into its only caller `force_from_dep_node_inner`, and renames the resulting function to `force_query_dep_node`. Combining the functions became possible after the removal of `rustc_query_system`, because they are now in the same crate.

There are two other notable cleanups along the way:

- Removing an unhelpful assertion and its verbose comment
  - The removed comment was originally added in https://github.com/rust-lang/rust/commit/0454a41, but is too verbose to be worth preserving inline.
- Removing a redundant cache lookup while forcing, as it is useless in the serial compiler and unnecessary (and probably unhelpful) in the parallel compiler

r? nnethercote
2026-03-23 23:42:51 -04:00