10295 Commits

Author SHA1 Message Date
Rust timing bot 19b70ac34d Unrolled build for #155772
Rollup merge of #155772 - oli-obk:const-closures-everywhere, r=fee1-dead

Check closure's constness validity in the constness query

fixes rust-lang/rust#155584

instead of checking during ast lowering, where it's not easily possible to obtain all the right information in time. While lowering an assoc item we don't know if the parent was a const trait or a const impl. Tracing this information is quite annoying, and complicates a lot of code, which checking here after the fact is trivial.
2026-04-27 13:12:48 +02:00
Oli Scherer 8e1c34f5cc Check closure's constness validity in the constness query
instead of during ast lowering, where it's not easily possible to obtain all the right information in time
2026-04-27 07:44:19 +02:00
Jacob Pratt bd2d1a8443 Rollup merge of #155835 - jyn514:jyn/verify-ich-diagnostics, r=wesleywiser
couple of `crate_name` cleanups

Split out from https://github.com/rust-lang/rust/pull/153924; these changes should be uncontroversial.
2026-04-26 21:56:46 -04:00
Jacob Pratt c20a92efd9 Rollup merge of #155778 - kevinheavey:perf-mk-place-elem-avoid-vec-alloc, r=cjgillot,JohnTitor
Avoid Vec allocation in TyCtxt::mk_place_elem

`mk_place_elem` appends a single `PlaceElem` to an existing (interned) projection. The current implementation copies the projection into a fresh `Vec`, pushes the new element, and re-interns the slice, which allocates on every call.

Feed the elements through `mk_place_elems_from_iter` so that `CollectAndApply`'s hand-unrolled stack fast path (up to 9 elements, in `rustc_type_ir::interner`) kicks in for the common case of short projections and the `Vec` allocation is skipped entirely. The behavior is identical for longer projections (the fast path falls back to a `Vec` internally).
2026-04-26 21:56:42 -04:00
jyn d9e227e98a Fix broken logic in incremental_verify_ich_failed 2026-04-26 16:18:45 +00:00
bors 9838411cb7 Auto merge of #155257 - petrochenkov:visatleast, r=adwinwhite
privacy: Assert that compared visibilities are (usually) ordered



And make "greater than" (`>`) the new primary operation for comparing visibilities instead of "is at least" (`>=`).
2026-04-25 16:15:55 +00:00
Kevin Heavey 5cd9d929a9 Avoid Vec allocation in TyCtxt::mk_place_elem
`mk_place_elem` appends a single `PlaceElem` to an existing (interned)
projection. The current implementation copies the projection into a
fresh `Vec`, pushes the new element, and re-interns the slice, which
allocates on the heap on every call.

Feed the elements through `mk_place_elems_from_iter` so that
`CollectAndApply`'s hand-unrolled stack fast path (up to 9 elements,
in `rustc_type_ir::interner`) kicks in for the common case of short
projections and the `Vec` allocation is skipped entirely. The behavior
is identical for longer projections (the fast path falls back to a
`Vec` internally).
2026-04-25 15:05:59 +01:00
Camille Gillot 0705bbac94 Do not modify resolver outputs during lowering
Co-authored-by: Camille Gillot <gillot.camille@gmail.com>
2026-04-24 23:58:52 +00:00
Vadim Petrochenkov 714df2bf00 privacy: Assert that compared visibilities are (usually) ordered
Also use `greater_than` instead of `is_at_least` for comparing visibilities, which we can do because visibilities are asserted to be ordered now.
2026-04-23 18:22:48 +03:00
Guillaume Gomez abce9f98d7 Rollup merge of #155442 - CoCo-Japan-pan:impl-restriction-reorder, r=Urgau,fmease,jhpratt
Change keyword order for `impl` restrictions

Based on rust-lang/rust#155222, this PR reorders keywords in trait definitions to group restrictions with visibility. It changes the order from `pub(...) const unsafe auto impl(...) trait Foo {...}`  to `pub(...) impl(...) const unsafe auto trait Foo {...}`.

Tracking issue for restrictions: rust-lang/rust#105077

r? @Urgau
cc @jhpratt
2026-04-23 14:42:47 +02:00
Guillaume Gomez 0595fcd195 Rollup merge of #154957 - lapla-cogito:issue_153891, r=oli-obk
Fix ICE when const closure appears inside a non-const trait method

Fixes rust-lang/rust#153891

`hir_body_const_context()` unconditionally delegated to the parent's const context for const closures, returning `None` when the parent had no const context. This caused `mir_const_qualif()` to hit a `span_bug!`, since `mir_promoted()` had already decided to call it based on the closure's own syntactic constness. Fall back to `ConstContext::ConstFn` when the parent's const context is `None`, so that the const closure body is still properly const-checked rather than triggering an ICE.

Examining [another attempt](https://github.com/rust-lang/rust/pull/153900/changes) at this issue (which has already been closed), I thought that its approach represents a workaround fix to avoid inconsistencies in the caller of `mir_promoted()`, whereas I think the correct behavior is for `hir_body_const_context()` itself to return the proper value.
2026-04-23 14:42:47 +02:00
bors 30837cb66d Auto merge of #155550 - zetanumbers:cache_insert_unique, r=oli-obk
Replace `ShardedHashMap` method `insert` with debug-checked `insert_unique`

Currently every use of `ShardedHashMap::insert` checks that it won't evict an old value due to unique key. I haven't found any issue related to that faulty condition, so I thought of replacing it with `ShardedHashMap::insert_unique` which doesn't check for this condition unless `debug_assertions` are enabled. This might improve the performance.

r? @petrochenkov
2026-04-22 22:28:22 +00:00
Jonathan Brouwer 5e48418496 Rollup merge of #155587 - oli-obk:feed-visibility-no-hash, r=petrochenkov
Immediately feed visibility on DefId creation

This system was originally introduced in rust-lang/rust#121089

This PR was enabled by refactorings in rust-lang/rust#154945, because after that, the visibility feeding happens directly after the `DefId` creation, so we don't need to go through the intermediate hash table anymore

Should unblock rust-lang/rust#138995
2026-04-22 19:18:29 +02:00
Jonathan Brouwer 8bade0362d Rollup merge of #154283 - Zoxc:rem-nodes_in_current_session, r=nnethercote
Remove `nodes_in_current_session` field and related assertions

This removes the `nodes_in_current_session` field and related assertions. These are enabled if `-Z incremental-verify-ich` is passed or `debug_assertions` is on. Historically these have been useful to catch query keys with improper `HashStable` impls which lead to collisions.

We currently also check for duplicate nodes when loading the dep graph. This check is more complete as it covers the entire dep graph and is enabled by default. It doesn't provide a query key for a collision however. This check is also delayed to the next incremental session.

We also have the `verify_query_key_hashes` which is also enabled if `-Z incremental-verify-ich` is passed or `debug_assertions` is on. This checks for dep node conflicts in each query cache and provides 2 conflicting keys if present.

I think these remaining checks are sufficient and so we can remove `nodes_in_current_session`.
2026-04-22 19:18:28 +02:00
lapla 9be8fca54e Fix ICE when const closure appears inside a non-const trait method 2026-04-22 15:41:31 +09:00
bors 1bfcb284f7 Auto merge of #155392 - WaffleLapkin:alias-termmm, r=BoxyUwU
`AliasTerm` refactor

follow up to https://github.com/rust-lang/rust/pull/154758
tracking issue: https://github.com/rust-lang/rust/issues/154941
2026-04-22 02:57:46 +00:00
Oli Scherer 3070ce9d1b Immediately feed visibility on DefId creation 2026-04-21 22:45:34 +02:00
Jonathan Brouwer aa3335484f Rollup merge of #155547 - aerooneqq:better-disambiguators, r=oli-obk
Use per-parent disambiguators everywhere

This PR addressing the following concerns about per-parent disambiguators (rust-lang/rust#153955):

- DisambiguatorState is removed, PerParentDisambiguatorState is now used everywhere,
- Steals were removed from every per-parent disambiguator in resolver,
- It adds `parent` field in `PerParentDisambiguatorState` in `#[cfg(debug_assertions)]` for asserting that per-parent disambiguator corresponds to the same `LocalDefId` which is passed into `create_def`,
- ~Removes `Disambiguator` trait replacing it with `Disambiguator` enum, with this change we no longer expose `next` method (as trait should be public otherwise the warning will be emitted). It may affect perf in a negative way though.~

~Those changes should not fix perf issues that were [reported](https://github.com/rust-lang/rust/pull/153955#issuecomment-4269223191), perf run that was attempted [before](https://github.com/rust-lang/rust/pull/153955#issuecomment-4214516698) showed much better results. Performance can be probably fixed by removing per-parent disambiguators replacing them with a single one as it was before, then it will be passed to AST -> HIR lowering and modified. For delayed owners we can store ~followup disambiguators as it was in the beginning of the rust-lang/rust#153955~ per-parent disambiguators. This solution should save achievements from rust-lang/rust#153955 (removed `DefPathData` variants).
However, I would prefer to keep per-parent disambiguators as it seems a better architectural solution for me.~

r? @petrochenkov
cc @oli-obk
2026-04-21 20:42:52 +02:00
Jonathan Brouwer 63b6bd933e Rollup merge of #155425 - nnethercote:rm-dup-Flags-methods, r=nikomatsakis
Remove duplicated `Flags` methods.

The `Flags` trait has two methods: `flags` and `outer_exclusive_binder`. Multiple types impl this trait and then also have duplicate inherent methods with the same names; these are all marked with "Think about removing this" comments. This is left over from things being moved into `rustc_type_ir`.

This commit removes those inherent methods. This requires adding `use Flags` to a number of files.

r? @lcnr
2026-04-21 20:42:51 +02:00
aerooneqq 2e6a082513 Use per-parent disambiguators 2026-04-21 18:23:40 +03:00
Waffle Lapkin 54abf6d683 remove unused parameter from opt_alias_variances 2026-04-21 12:28:26 +02:00
Waffle Lapkin e8b6c9737e fix ty::UnevaluatedConst<I>>->AliasTerm<I> conversion 2026-04-21 12:28:25 +02:00
Waffle Lapkin d7986943e4 AliasTermTy refactor: fixup compiler 2026-04-21 12:28:22 +02:00
Oli Scherer b1c7595965 Ensure we don't feed owners from ast lowering if we ever make that query tracked 2026-04-21 08:56:02 +02:00
John Kåre Alsaker 0add85cbe6 Remove nodes_in_current_session field and related assertions 2026-04-21 05:05:44 +02:00
Jacob Pratt 4c7e6565ef Rollup merge of #153411 - Sa4dUs:offload-slices, r=ZuseZ4
Offload slice support

This PR allows offload to support slice type arguments.

~NOTE: this is built on top of https://github.com/rust-lang/rust/pull/152283~

r? @ZuseZ4
2026-04-20 20:50:20 -04:00
Marcelo Domínguez af839a8a96 Add offload slice support 2026-04-20 19:15:52 +02:00
bors c28e303778 Auto merge of #155552 - JonathanBrouwer:rollup-JKIpTuW, r=JonathanBrouwer
Rollup of 11 pull requests

Successful merges:

 - rust-lang/rust#154654 (Move `std::io::ErrorKind` to `core::io`)
 - rust-lang/rust#145270 (Fix an ICE observed with an explicit tail-call in a default trait method)
 - rust-lang/rust#154895 (borrowck: Apply `user_arg_index` nomenclature more broadly)
 - rust-lang/rust#155213 (resolve: Make sure visibilities of import declarations make sense)
 - rust-lang/rust#155346 (`single_use_lifetimes`: respect `anonymous_lifetime_in_impl_trait`)
 - rust-lang/rust#155517 (Add a test for Mach-O `#[link_section]` API inherited from LLVM)
 - rust-lang/rust#155549 (Remove some unnecessary lifetimes.)
 - rust-lang/rust#154248 (resolve :  mark repr_simd as internal)
 - rust-lang/rust#154772 (slightly optimize the `non-camel-case-types` lint)
 - rust-lang/rust#155541 (Add `#[rust_analyzer::prefer_underscore_import]` to the traits in `rustc_type_ir::inherent`)
 - rust-lang/rust#155544 (bootstrap: Make "detected modifications" for download-rustc less verbose)
2026-04-20 16:15:13 +00:00
bors 91367b0f73 Auto merge of #154924 - nnethercote:rm-impl-HashStable-for-Attr-slice, r=JonathanBrouwer
Remove `HashStable` impl for `[hir::Attribute]`.



This impl skips:
- All doc comments
- A handful of other attributes, mostly `rustc_*` ones related to incremental compilation testing.
    
This skipping originated in rust-lang/rust#36025 and was extended a couple of times, e.g. in rust-lang/rust#36370. Those PRs don't have any explanation of why the skipping exists. Perhaps the reasoning was that doc comments should only affect rustdoc and rustdoc doesn't use incremental compilation? But doc comments end up in metadata, and there is a query `attrs_for_def` that returns a `&'tcx [hir::Attribute]`. So skipping some attributes just seems plainly wrong.
    
This commit removes the impl, which means `[hir::Attribute]` hashing falls back to the default impl for `[T]`. This has no noticeable effect on the test suite. It does slightly hurt performance, because of the doc comments. This perf regression seems worth it for the correctness benefits.
2026-04-20 12:55:41 +00:00
Daria Sukhonina 72f25eea33 Replace ShardedHashMap method insert with debug-checked insert_unique 2026-04-20 13:22:22 +03:00
Nicholas Nethercote 5e00b8e7d5 Remove some unnecessary lifetimes.
We have a number of structs with more lifetimes than necessary. This
commit removes them.

LLM disclosure: I asked Claude Code to check for unnecessary lifetimes
in all types with three or more lifetimes, and it produced a list of
candidates (half of which were invalid). I did the modifications for the
valid cases myself, and found a couple more cases along the way.
2026-04-20 19:25:51 +10:00
Nicholas Nethercote e192eec395 Remove duplicated Flags methods.
The `Flags` trait has two methods: `flags` and `outer_exclusive_binder`.
Multiple types impl this trait and then also have duplicate inherent
methods with the same names; these are all marked with "Think about
removing this" comments. This is left over from things being moved into
`rustc_type_ir`.

This commit removes those inherent methods. This requires adding `use
Flags` to a number of files.
2026-04-20 10:13:53 +10:00
Adwin White 6279106e72 fix all errors 2026-04-20 00:18:28 +08:00
Adwin White 3e1e35b5d1 make common normalization routines take Unnormalized 2026-04-20 00:08:14 +08:00
Adwin White 5c12b9283e introduce Unnormalized wrapper and make instantiation use it 2026-04-20 00:08:14 +08:00
CoCo-Japan-pan 614994fb8b Update HIR pretty printing 2026-04-19 15:58:02 +09:00
bors 6f109d8a2d Auto merge of #155223 - teor2345:fndef-refactor, r=mati865
Refactor FnDecl and FnSig non-type fields into a new wrapper type





#### Why this Refactor?

This PR is part of an initial cleanup for the [arg splat experiment](https://github.com/rust-lang/rust/issues/153629), but it's a useful refactor by itself.

It refactors the non-type fields of `FnDecl`, `FnSig`, and `FnHeader` into a new packed wrapper types, based on this comment in the `splat` experiment PR:
https://github.com/rust-lang/rust/pull/153697#discussion_r3004637413

It also refactors some common `FnSig` creation settings into their own methods. I did this instead of creating a struct with defaults.

#### Relationship to `splat` Experiment

I don't think we can use functional struct updates (`..default()`) to create `FnDecl` and `FnSig`, because we need the bit-packing for the `splat` experiment.

Bit-packing will avoid breaking "type is small" assertions for commonly used types when `splat` is added.
This PR packs these types:
- ExternAbi: enum + `unwind` variants (38) -> 6 bits
- ImplicitSelfKind: enum variants (5) -> 3 bits
- lifetime_elision_allowed, safety, c_variadic: bool -> 1 bit

#### Minor Changes

Fixes some typos, and applies rustfmt to clippy files that got skipped somehow.
2026-04-18 23:46:37 +00:00
bors 0febdbab27 Auto merge of #155494 - JonathanBrouwer:rollup-UvJjCP5, r=JonathanBrouwer
Rollup of 10 pull requests

Successful merges:

 - rust-lang/rust#150230 (spec next chunk for trustedlen)
 - rust-lang/rust#155284 (net::tcp/udp: fix docs about how set_nonblocking is implemented)
 - rust-lang/rust#146870 (fix: add aliasing rules for Box)
 - rust-lang/rust#154003 (Make std::fs::File Send on UEFI)
 - rust-lang/rust#155187 (std: fix HashMap RNG docs wording)
 - rust-lang/rust#155255 (Document why `layout.align() + layout.size()` doesn't overflow)
 - rust-lang/rust#155351 (Reorganize tests from `tests/ui/issues/`)
 - rust-lang/rust#155406 (std: Update dependency on `wasi` crate)
 - rust-lang/rust#155447 (Simplify `parse_limited`)
 - rust-lang/rust#155481 (Delete `SizeSkeleton::Generic`)
2026-04-18 19:16:28 +00:00
Shoyu Vanilla ace3aa319c Make region equality emits Eq constraints 2026-04-18 22:02:01 +09:00
Theemathas Chirananthavat 1a27916756 Delete SizeSkeleton::Generic
This variant was never constructed anywhere.
2026-04-18 16:00:28 +07:00
bors f29256dd14 Auto merge of #155248 - JonathanBrouwer:no_hash_delayed_lints, r=GuillaumeGomez
Don't hash `DelayedLints`

This PR unblocks https://github.com/rust-lang/rust/pull/154432, and was also a minor perf win locally
2026-04-17 16:05:32 +00:00
Jonathan Brouwer d14311c4a1 Don't hash DelayedLints 2026-04-17 16:08:45 +02:00
bors 4dbafc340b Auto merge of #153955 - aerooneqq:def-path-hash-collision, r=petrochenkov
delegation: fix def path hash collision, add per parent disambiguators



This PR addresses the following delegation issues:
- It fixes rust-lang/rust#153410 when generating new `DefId`s for generic parameters by ~saving `DisambiguatorState`s from resolve stage and using them at AST -> HIR lowering~ introducing per owner disambiguators and transferring them to AST -> HIR lowering stage
- ~Next it fixes the ICE which is connected to using `DUMMY_SP` in delegation code, which was found during previous fix~
- ~Finally, after those fixes the rust-lang/rust#143498 is also fixed, only bugs with propagating synthetic generic params are left.~

Fixes rust-lang/rust#153410. Part of rust-lang/rust#118212.

r? @petrochenkov
2026-04-17 11:13:11 +00:00
aerooneqq 699eb29443 Fix delegation def path hash collision, add per-parent disambiguators 2026-04-17 09:46:54 +03:00
Stuart Cook 7e43cdf977 Rollup merge of #155391 - zetanumbers:query_latch_oneliner, r=petrochenkov
Small refactor of `QueryJob::latch` method

We can use `Option::get_or_insert_with` to avoid unwrapping there.
2026-04-17 16:17:59 +10:00
Stuart Cook 6951f83914 Rollup merge of #155335 - Mark-Simulacrum:bootstrap-bump, r=jieyouxu
Bump bootstrap to 1.96 beta

See https://forge.rust-lang.org/release/process.html#default-branch-bootstrap-update-tuesday

I think this will wind up needing another PR in a week or so when we pick up assert_matches getting destabilized in beta? But that seems like it can be split into its own PR.
2026-04-17 16:17:52 +10:00
Mark Rousskov a64c420c70 Bump stage0 to 1.96 beta 2026-04-16 19:30:56 -04:00
Daria Sukhonina d0f5b5caa8 Replace redundant unwrap with get_or_insert_with 2026-04-16 15:19:42 +03:00
Jacob Pratt 92f640115a Rollup merge of #155364 - nnethercote:reduce-err-struct-visibilities, r=Kivooeo
Reduce diagnostic type visibilities.

Most diagnostic types are only used within their own crate, and so have a `pub(crate)` visibility. We have some diagnostic types that are unnecessarily `pub`. This is bad because (a) information hiding, and (b) if a `pub(crate)` type becomes unused the compiler will warn but it won't warn for a `pub` type.

This commit eliminates unnecessary `pub` visibilities for some diagnostic types, and also some related things due to knock-on effects. (I found these types with some ad hoc use of `grep`.)

r? @Kivooeo
2026-04-16 01:54:15 -04:00
Jacob Pratt a5f590a1d6 Rollup merge of #155340 - oli-obk:size-skeleton-pat-tys, r=mati865
Handle nonnull pattern types in size skeleton

The original comment was correct, the size is always the same, but we have more information now. In theory there was an additional bug that would have allowed transmuting things of different sizes, but I don't see how that would have been actually doable as the `tail` types would always have differed.

fixes rust-lang/rust#155330
2026-04-16 01:54:13 -04:00