Commit Graph

54973 Commits

Author SHA1 Message Date
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
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
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
Jacob Pratt 1e2a7dcce4 Rollup merge of #153979 - nnethercote:rename-cycle-things, r=petrochenkov
Rename various query cycle things.

The existing names have bugged me for a while. Changes:

- `CycleError` -> `Cycle`. Because we normally use "error" for a `Diag` with `Level::Error`, and this type is just a precursor to that. Also, many existing locals of this type are already named `cycle`.

- `CycleError::cycle` -> `Cycle::frames`. Because it is a sequence of frames, and we want to avoid `Cycle::cycle` (and `cycle.cycle`).

- `cycle_error` -> `find_and_handle_cycle`. Because that's what it does. The existing name is just a non-descript noun phrase.

- `mk_cycle` -> `handle_cycle`. Because it doesn't make the cycle; the cycle is already made. It handles the cycle, which involves (a) creating the error, and (b) handling the error.

- `report_cycle` -> `create_cycle_error`. Because that's what it does: creates the cycle error (i.e. the `Diag`).

- `value_from_cycle_error` -> `handle_cycle_error_fn`. Because most cases don't produce a value, they just emit an error and quit. And the `_fn` suffix is for consistency with other vtable fns.

- `from_cycle_error` -> `handle_cycle_error`. A similar story for this module.

r? @petrochenkov
2026-03-23 23:42:49 -04:00
Zalathar ee15154817 Remove an unhelpful assertion from try_load_query_value
This assertion makes the method body a lot messier, and seems very unlikely to
ever usefully fail.
2026-03-24 12:56:51 +11:00
Zalathar db19c0c3ee Inline TyCtxt::load_side_effect into its only caller 2026-03-24 12:56:51 +11:00
Zalathar afffa7d6e3 Don't store current-session side effects in OnDiskCache
Every other part of `OnDiskCache` deals with loading information from the
_previous_ session, except for this one field.

Moving it out to `QuerySystem` makes more sense, because that's also where
query return values are stored (inside the caches in their vtables).
2026-03-24 12:56:51 +11:00
Zalathar de15ab0065 Store value/side-effect index lists inside CacheEncoder
These lists can be considered part of the encoder state, and bundling them
inside the encoder is certainly more convenient than passing them around
separately.
2026-03-24 12:56:49 +11:00
bors 212b0d480f Auto merge of #154076 - nnethercote:DepNode-improvements, r=Zalathar
`DepNode` use improvements



We can simplify `DepNode` construction during query execution. Details in individual commits.

r? @Zalathar
2026-03-24 01:37:53 +00:00
bors 6f22f61305 Auto merge of #154273 - JonathanBrouwer:rollup-TJZsnIo, r=JonathanBrouwer
Rollup of 8 pull requests

Successful merges:

 - rust-lang/rust#122668 (Add APIs for dealing with titlecase)
 - rust-lang/rust#153041 (Remove `ATTRIBUTE_ORDER`)
 - rust-lang/rust#153912 (Avoid prematurely choosing a glob import)
 - rust-lang/rust#154093 (const validity checking: do not recurse to references inside MaybeDangling)
 - rust-lang/rust#154257 (Revert eagerly normalize in generalize)
 - rust-lang/rust#154179 (tests/ui/async-await/gat-is-send-across-await.rs: New regression test)
 - rust-lang/rust#154224 (Remove more `BuiltinLintDiag` variants)
 - rust-lang/rust#154245 (Allow applying autodiff macros to trait functions.)
2026-03-23 22:28:18 +00:00
Nicholas Nethercote 3c7ee983eb Compute DepNode for incremental queries.
Prior to #154122 it wasn't used on all paths, so we only computed it
when necessary -- sometimes in `check_if_ensure_can_skip_execution`,
sometimes in one of two places in `execute_job_incr` -- and pass around
`Option<DepNode>` to allow this.

But now it's always used, so this commit makes us compute it earlier,
which simplifies things.
- `check_if_ensure_can_skip_execution` can be made simpler, returning a
  bool and eliminating the need for `EnsureCanSkip`.
- `execute_job_incr` no longer uses two slightly different methods to
  create a `DepNode` (`get_or_insert_with` vs `unwrap_or_else`).
2026-03-24 08:54:10 +11:00
Nicholas Nethercote 1e4b453670 Remove some dep-graph assertions.
The call chain for a non-incremental query includes the following
functions:

- execute_query_non_incr_inner (assert!)
- try_execute_query (assert!)
- execute_job_non_incr (assert!)

And likewise for an incremental query:

- execute_query_incr_inner (assert!)
- try_execute_query (assert!)
- execute_job_incr (expect)

That is five distinct functions. Every one of them has an `assert!` or
`expect` call that checks that the dep-graph is/is not enabled as
expected. Three cheers for defensive programming but this feels like
overkill, particularly when `execute_job{,_non_incr,_incr}` each have a
single call site.

This commit removes the assertions in `execute_query_*` and
`try_execute_query`, leaving a check in each of the `execute_job_*`
functions.
2026-03-24 08:48:50 +11:00
Nicholas Nethercote 90ea993083 Rename various query cycle things.
The existing names have bugged me for a while. Changes:

- `CycleError` -> `Cycle`. Because we normally use "error" for a `Diag`
  with `Level::Error`, and this type is just a precursor to that. Also,
  many existing locals of this type are already named `cycle`.

- `CycleError::cycle` -> `Cycle::frames`. Because it is a sequence of
  frames, and we want to avoid `Cycle::cycle` (and `cycle.cycle`).

- `cycle_error` -> `find_and_handle_cycle`. Because that's what it does.
  The existing name is just a non-descript noun phrase.

- `mk_cycle` -> `handle_cycle`. Because it doesn't make the cycle; the
  cycle is already made. It handles the cycle, which involves (a)
  creating the error, and (b) handling the error.

- `report_cycle` -> `create_cycle_error`. Because that's what it does:
  creates the cycle error (i.e. the `Diag`).

- `value_from_cycle_error` -> `handle_cycle_error_fn`. Because most
  cases don't produce a value, they just emit an error and quit.
  And the `_fn` suffix is for consistency with other vtable fns.

- `from_cycle_error` -> `handle_cycle_error`. A similar story for this
  module.
2026-03-24 08:47:34 +11:00
Jonathan Brouwer a9b484936c Rollup merge of #154245 - ZuseZ4:autodiff-trait-support, r=JonathanBrouwer,jdonszelmann
Allow applying autodiff macros to trait functions.

It will use enzyme to generate a default derivative implementation, which can be overwritten by the user.

closes: https://github.com/rust-lang/rust/issues/153329

r? @JonathanBrouwer
2026-03-23 20:18:36 +01:00
Jonathan Brouwer d7beee5f18 Rollup merge of #154224 - GuillaumeGomez:migrate-diag, r=JonathanBrouwer
Remove more `BuiltinLintDiag` variants

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

r? @JonathanBrouwer
2026-03-23 20:18:35 +01:00
Jonathan Brouwer 7f8f600807 Rollup merge of #154257 - jdonszelmann:revert-eagerly-normalize-in-generalize, r=lcnr
Revert eagerly normalize in generalize

r? @lcnr

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

We'll likely pull eager normalization out of generalization

Fixes rust-lang/rust#154173
Fixes rust-lang/rust#154244
2026-03-23 20:18:34 +01:00
Jonathan Brouwer 62a3eab283 Rollup merge of #154093 - RalfJung:validity-maybedangling, r=WaffleLapkin
const validity checking: do not recurse to references inside MaybeDangling

This arguably should be allowed, but we currently reject it:
```rust
#![feature(maybe_dangling)]
use std::mem::MaybeDangling;

const X: MaybeDangling<&bool> = unsafe { std::mem::transmute(&5u8) };
```

r? @WaffleLapkin
2026-03-23 20:18:34 +01:00
Jonathan Brouwer 924b91147b Rollup merge of #153912 - mu001999-contrib:fix-153842, r=petrochenkov
Avoid prematurely choosing a glob import

Fixes rust-lang/rust#153842

Use the following without introducing trait to explain:
```rust
mod a {
    pub use crate::x::y as x; // single import #1
}

mod b {
    pub mod x {
        pub mod y {}
    }
}

use a::x; // single import #2
use b::*; // glob import #3

fn main() {}
```

In current implementation, when `#1` is first resolved, `crate::x` is temporarily taken from glob import `#3` as `crate::b::x`. This happens because `single_import_can_define_name` will see that `#2` cannot define `x` (because it depends on `#1` and `#1` is ignored) and then return `false`. Later, during finalization, `crate::x` in `#1` resolves through single import `#2` instead, which no longer matches the initially cached module `crate::b::x` and triggers the ICE.

I think the resolver should keep this unresolved because `#2` may still define `x` to avoid prematurely choosing a glob import.

r? petrochenkov
2026-03-23 20:18:33 +01:00
Jonathan Brouwer 7011667a9f Rollup merge of #153041 - JonathanBrouwer:attribute_order, r=jdonszelmann
Remove `ATTRIBUTE_ORDER`

r? @jdonszelmann

There's only a few attributes that use `KeepInnermost` and I think I like the consistency of just making them all `KeepOutermost`
2026-03-23 20:18:33 +01:00
bors f66622c7ec Auto merge of #152931 - khyperia:always-check-constarghastype, r=BoxyUwU
Always check `ConstArgHasType` even when otherwise ignoring



fixes https://github.com/rust-lang/rust/issues/149774

helping @BoxyUwU finish up https://github.com/rust-lang/rust/pull/150322, this is a simple tweak/finishing-up of that PR.

this is a breaking change that crater detected has some issues with in Boxy's PR, and hence needs a t-types FCP. I can go and help fix those crates if/once the break is signed off on.
2026-03-23 19:06:58 +00:00
bors eb9d3caf05 Auto merge of #154253 - JonathanBrouwer:rollup-LLZUsz2, r=JonathanBrouwer
Rollup of 13 pull requests

Successful merges:

 - rust-lang/rust#154241 (`rust-analyzer` subtree update)
 - rust-lang/rust#153686 (`std`: include `dlmalloc` for all non-wasi Wasm targets)
 - rust-lang/rust#154105 (bootstrap: Pass `--features=rustc` to rustc_transmute)
 - rust-lang/rust#153069 ([BPF] add target feature allows-misaligned-mem-access)
 - rust-lang/rust#154085 (Parenthesize or-patterns in prefix pattern positions in pretty printer)
 - rust-lang/rust#154191 (refactor RangeFromIter overflow-checks impl)
 - rust-lang/rust#154207 (Refactor query loading)
 - rust-lang/rust#153540 (drop derive helpers during attribute parsing)
 - rust-lang/rust#154140 (Document consteval behavior of ub_checks, overflow_checks, is_val_statically_known.)
 - rust-lang/rust#154161 (On E0277 tweak help when single type impls traits)
 - rust-lang/rust#154218 (interpret/validity: remove unreachable error kind)
 - rust-lang/rust#154225 (diagnostics: avoid ICE in confusable_method_name for associated functions)
 - rust-lang/rust#154228 (Improve inline assembly error messages)
2026-03-23 15:46:13 +00:00
Jonathan Brouwer 34ef9a6146 Remove ATTRIBUTE_ORDER 2026-03-23 13:57:23 +01:00
Jonathan Brouwer baffc5e9bc Rollup merge of #154201 - Zalathar:try-set-color, r=nnethercote
Use enums to clarify `DepNodeColorMap` color marking

When a function's documentation has to explain the meaning of nested results and options, then it is often a good candidate for using a custom result enum instead.

This PR also renames `DepNodeColorMap::try_mark` to `try_set_color`, to make it more distinct from the similarly-named `DepGraph::try_mark_green`.

The difference is that `try_mark_green` is a higher-level operation that tries to determine whether a node _can_ be marked green, whereas `try_set_color` is a lower-level operation that actually records a colour for the node.

The updated docs for `try_set_color` also fix a typo: *atomicaly* → *atomically*.

r? nnethercote (or compiler)
2026-03-23 12:15:01 +01:00
Jonathan Brouwer 20612ce827 Rollup merge of #154188 - rperier:diagnostic_on_move_point_to_the_tracking_issue, r=JonathanBrouwer
Update the tracking issue for #[diagnostic::on_move]

PR rust-lang/rust#150935 has been merged and then I have opened the tracking issue (whoops ?). So this update `compiler/rustc_feature/src/unstable.rs` to point to the right tracking issue.

This is related to the tracking issue rust-lang/rust#154181
2026-03-23 12:15:01 +01:00
Jonathan Brouwer 64716caf69 Rollup merge of #154182 - Unique-Usman:ua/constnotype2, r=estebank
diagnostics: avoid ICE for undeclared generic parameter in impl

Avoid an ICE for:

    struct A;
    impl A<B> {}

The compiler no longer panics and can proceed to emit existing diagnostics.

Adds `tests/ui/missing/undeclared-generic-parameter.rs`.

Fixes rust-lang/rust#154165 and introduced by rust-lang/rust#152913
2026-03-23 12:15:00 +01:00
Jonathan Brouwer 49e2983d6d Rollup merge of #153582 - mehdiakiki:simplify-find-attr-hir-id, r=JonathanBrouwer
Simplify find_attr! for HirId usage

Add a `HasAttrs<'tcx, Tcx>` trait to `rustc_hir` that allows `find_attr!` to accept `DefId`, `LocalDefId`, `OwnerId`, and `HirId` directly, instead of requiring callers to manually fetch the attribute slice first.

Before:
  `find_attr!(tcx.hir_attrs(hir_id), SomeAttr)`

After:
  `find_attr!(tcx, hir_id, SomeAttr)`

The trait is defined in `rustc_hir` with a generic `Tcx` parameter to avoid a dependency cycle (`rustc_hir` cannot depend on `rustc_middle`). The four concrete impls for `TyCtxt` are in `rustc_middle`.

Fixes https://github.com/rust-lang/rust/issues/153103
2026-03-23 12:14:56 +01:00
Jonathan Brouwer a87d694af2 Rollup merge of #150630 - Mark-Simulacrum:rephrase-compression-warn, r=JonathanBrouwer
Unknown -> Unsupported compression algorithm

Both zstd and zlib are *known* compression algorithms, they just may not be supported by the backend. We shouldn't mislead users into e.g. thinking they made a typo.

cc https://github.com/rust-lang/rust/issues/120953
2026-03-23 12:14:55 +01:00
Jonathan Brouwer 699e1b395e Rollup merge of #153931 - cyrgani:old-consts, r=Mark-Simulacrum
remove usages of to-be-deprecated numeric constants

Split out from rust-lang/rust#146882.
2026-03-23 12:14:55 +01:00
Jonathan Brouwer 6e6e266520 Rollup merge of #153857 - RalfJung:cfg-abi, r=Mark-Simulacrum
Rename `target.abi` to `target.cfg_abi` and enum-ify llvm_abiname

See [Zulip](https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/De-spaghettifying.20ABI.20controls/with/578893542) for more context. Discussed a bit in https://github.com/rust-lang/rust/pull/153769#discussion_r2934399038 too.

This renames `target.abi` to `target.cfg_abi` to make it less likely that someone will use it to determine things about the actual ccABI, i.e. the calling convention used on the target. `target.abi` does not control that calling convention, it just *sometimes* informs the user about that calling convention (and also about other aspects of the ABI).

Also turn llvm_abiname into an enum to make it more natural to match on.
Cc @workingjubilee @madsmtm
2026-03-23 12:14:54 +01:00
Jonathan Brouwer 7d43ebc519 Rollup merge of #153312 - b-naber:namespaced-crate-names-pt1, r=petrochenkov
Packages as namespaces part 1

Part 1 of https://github.com/rust-lang/rust/pull/152299

r? @petrochenkov
2026-03-23 12:14:52 +01:00
Jonathan Brouwer b20e49f5e6 Rollup merge of #152543 - petrochenkov:rprivtit2, r=fmease
privacy: Fix type privacy holes in RPITITs

A subset of https://github.com/rust-lang/rust/pull/146470.

Private types in RPITITs now report hard errors.
Private types in bounds of associated types still only report the `private_bounds` lint due to unacceptable amount of breakage (https://github.com/rust-lang/rust/pull/146470#issuecomment-3682850214).

Closes https://github.com/rust-lang/rust/issues/144139
2026-03-23 12:14:51 +01:00
Jana Dönszelmann 632ed10838 Revert "eagerly normalize during generalization"
This reverts commit 5d0863b147.
2026-03-23 12:09:34 +01:00
Jana Dönszelmann 4af62bdbac Revert "implement eager normalization in a fresh context during typeck"
This reverts commit 04f2c0191e.
2026-03-23 12:09:34 +01:00
Jana Dönszelmann e190973e4f Revert "merge generalizer state and structurally relate aliases"
This reverts commit 917713b4db.
2026-03-23 12:09:34 +01:00
Jana Dönszelmann df0f627bfc Revert "explicitly provide type in transmute"
This reverts commit 7a123e87b2.
2026-03-23 12:09:34 +01:00
Jana Dönszelmann c838deca23 Revert "normalize at the start of generalize if we can"
This reverts commit f50591fc10.
2026-03-23 12:09:34 +01:00
Jana Dönszelmann 38cb40091c Revert "try generalizing if normalization isn't a tyvar"
This reverts commit e8e3544a71.
2026-03-23 12:09:34 +01:00
Jana Dönszelmann 304a197ba5 Revert "fixup span in obligation cause"
This reverts commit 2d411a0faa.
2026-03-23 12:09:34 +01:00
Jana Dönszelmann bd781549f2 Revert "inline into"
This reverts commit 9aa065bc49.
2026-03-23 12:09:34 +01:00
Jana Dönszelmann 1fa1611e9f Revert "address review"
This reverts commit d665c0b371.
2026-03-23 12:09:34 +01:00
Jonathan Brouwer 1448ab91d2 Rollup merge of #154228 - folkertdev:mention-invalid-template-modifier, r=nnethercote
Improve inline assembly error messages

by

- using `DiagSymbolList` to get nicely formatted lists
- mentioning the `modifier` when an invalid modifier is used. This is useful in case the span cannot be resolved (which I ran into).
2026-03-23 12:01:03 +01:00
Jonathan Brouwer 50018abcdb Rollup merge of #154225 - Unique-Usman:ua/rustc_confusable, r=Kivooeo
diagnostics: avoid ICE in confusable_method_name for associated functions

Avoid unconditionally slicing `inputs()[1..]`, which assumes a `self` parameter. Use `is_method()` to conditionally skip the receiver, preventing out-of-bounds access and fixing suggestions for associated functions.
2026-03-23 12:01:02 +01:00
Jonathan Brouwer b828ed9e66 Rollup merge of #154218 - RalfJung:validity-init-scalar, r=nnethercote
interpret/validity: remove unreachable error kind

See the comments in the code for why this is unreachable.
2026-03-23 12:01:02 +01:00
Jonathan Brouwer 773db3e325 Rollup merge of #154161 - estebank:e0277-ty-impls, r=Kivooeo
On E0277 tweak help when single type impls traits

When encountering an unmet predicate, when we point at the trait impls that do exist, if they are all for the same self type, tweak the wording to make it less verbose.
2026-03-23 12:01:01 +01:00