3272 Commits

Author SHA1 Message Date
Jonathan Brouwer ecdcd0e588 Rollup merge of #155779 - Human9000-bit:ssa-range-prop-ref, r=Kivooeo
ssa_range_prop: use `if let` guards

It is a bit cleaner this way

r? @dianqk
2026-04-26 19:06:29 +02:00
human9000 29d58f8b4c Utilize if let guards where aproppriate 2026-04-25 19:42:57 +05:00
Jacob Pratt fa82155e54 Rollup merge of #155680 - Amanieu:call-arg-move-index, r=cjgillot
Handle index projections in call destinations in DSE

Since call destinations are evaluated after call arguments, we can't turn copy arguments into moves if the same local is later used as an index projection in the call destination.

DSE call arg optimization: rust-lang/rust#113758

r? @cjgillot
cc @RalfJung
2026-04-25 01:21:52 -04:00
Jacob Pratt cdba0cea17 Rollup merge of #155379 - ashivaram23:mir-query-cycle, r=saethlin
Avoid query cycles in DataflowConstProp

Fixes rust-lang/rust#155376 by skipping coroutines.
2026-04-24 02:42:50 -04:00
Ben Kimock 4b1f3926de Avoid query cycles in DataflowConstProp
* Avoid query cycles in DataflowConstProp
* Add -Zmir-opt-level=0 to the test
2026-04-24 03:04:03 +00:00
Amanieu d'Antras b15544d52f Handle index projections in call destinations in DSE
Since call destinations are evaluated after call arguments, we can't
turn copy arguments into moves if the same local is later used as an
index projection in the call destination.
2026-04-23 11:17:22 +01:00
Jonathan Brouwer 032b666d6a Rollup merge of #146544 - dianqk:rm-workaround, r=wesleywiser
mir-opt: Remove the workaround in UnreachableEnumBranching

rust-lang/rust#120268 added a workaround due to the compile time of TailDuplicator.

LLVM 20 has resolved this in llvm/llvm-project#114990 and llvm/llvm-project#132536.
2026-04-23 09:38:20 +02:00
aerooneqq 2e6a082513 Use per-parent disambiguators 2026-04-21 18:23:40 +03:00
bors 9ab01ae53c Auto merge of #155491 - ohadravid:faster-storage-in-copyprop-and-gvn, r=saethlin
Fix performance regression introduced in #142531 by excluding `Storage{Live,Dead}` from CGU size estimation



Fix performance regression introduced in rust-lang/rust#142531 ([rust-timer comment](https://github.com/rust-lang/rust/pull/142531#issuecomment-4273712294)) by excluding `Storage{Live,Dead}` from CGU size estimation.

Also, avoid unneeded work for storage removal in non-opt builds in CopyProp and GVN
by allocating local sets for the storage accounting only when `tcx.sess.emit_lifetime_markers()`. 

r? saethlin
2026-04-21 05:35:16 +00:00
Adwin White 6279106e72 fix all errors 2026-04-20 00:18:28 +08: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
Ohad Ravid 2389a3a0fb Avoid unneeded work for storage removal in non-opt builds in CopyProp and GVN 2026-04-18 22:12:59 +03:00
Ohad Ravid 5632001f83 Improve copy_prop and GVN mir-opt passes to remove fewer storage calls 2026-04-17 16:55:43 +03:00
teor dafb6bb801 Refactor FnDecl and FnSig flags into packed structs 2026-04-16 07:08:08 +10:00
bors 338dff3e3a Auto merge of #136006 - oli-obk:push-tzonluoyuwkq, r=wesleywiser
Start using pattern types in libcore



cc rust-lang/rust#135996

Replaces the innards of `NonNull` with `*const T is !null`.

This does affect LLVM's optimizations, as now reading the field preserves the metadata that the field is not null, and transmuting to another type (e.g. just a raw pointer), will also preserve that information for optimizations. This can cause LLVM opts to do more work, but it's not guaranteed to produce better machine code.

Once we also remove all uses of rustc_layout_scalar_range_start from rustc itself, we can remove the support for that attribute entirely and handle all such needs via pattern types
2026-04-13 21:54:46 +00:00
Oli Scherer 834137afd7 Use !null pattern type in libcore 2026-04-13 17:23:03 +02:00
Jacob Pratt bb745253f5 Rollup merge of #155136 - saethlin:intrinsic-cci-comment, r=wesleywiser
Tweak comment about intrinsics in cross-crate-inlinable

@RalfJung pointed out that the previous comment is technically wrong: https://github.com/rust-lang/rust/pull/145910#discussion_r2971285252
2026-04-11 01:49:13 -04:00
Ben Kimock 270ebfcdf5 Tweak comment about intrinsics in cross-crate-inlinable 2026-04-10 22:42:12 -04:00
bors c7c14d4fb0 Auto merge of #155044 - WaffleLapkin:dont-remove-unneeded-drops, r=scottmcm
Don't try to remove `drop_in_place` calls in `RemoveUnneededDrops`



As per my justification in https://github.com/rust-lang/rust/pull/154327#discussion_r3056946688

r? scottmcm
2026-04-11 00:55:22 +00:00
Jana Dönszelmann 63c212e62b make typing_mode getter 2026-04-10 11:42:02 +02:00
Jana Dönszelmann 0e0d12ccb3 introduce TypingModeEqWrapper and make TypingMode !Eq 2026-04-10 11:40:01 +02:00
Waffle Lapkin fa73f032b8 don't try to remove drop_in_place calls in RemoveUnneededDrops 2026-04-10 09:32:35 +02:00
Nicholas Nethercote 6352e8298f Move maybe_loop_headers out of rustc_middle.
`rustc_middle` is enormous and it's always good to move things out of it
where possible. `maybe_loop_headers` is easy to move because it has a
single use in `jump_threading.rs`.
2026-04-09 11:09:52 +10:00
Waffle Lapkin 0f767084b8 ty::Alias refactor: fixup all the compiler code 2026-04-07 10:08:12 +02:00
yukang 86796ddaa0 Label overwritten assignments for never read assignments 2026-03-31 20:44:11 +08:00
Ralf Jung 1dfbb8998c use Allocation::write_scalar instead of manual endianess logic 2026-03-28 11:43:58 +01:00
Daria Sukhonina 1b68d921a7 Add typeck_root_def_id_local 2026-03-27 15:36:28 +03:00
Ralf Jung 298c251f91 large_enums mir pass: fix is_enabled logic 2026-03-26 08:23:07 +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
Jonathan Brouwer a00aa4c5fb Rollup merge of #153660 - dianqk:dbg-single-use-const, r=mati865
mir-opt: Drop invalid debuginfos after SingleUseConsts.

Fixes https://github.com/rust-lang/rust/issues/153601.
2026-03-11 22:05:45 +01:00
Jonathan Brouwer 77134bd3e2 Rollup merge of #153611 - RalfJung:interp-error-strings, r=oli-obk
interpret: go back to regular string interpolation for error messages

Using the translatable diagnostic infrastructure adds a whole lot of boilerplate which isn't actually useful for const-eval errors, so let's get rid of it. This effectively reverts https://github.com/rust-lang/rust/pull/111677. That PR effectively added 1000 lines and this PR only removes around 600 -- the difference is caused by (a) keeping some of the types around for validation, where we can use them to share error strings and to trigger the extra help for pointer byte shenanigans during CTFE, and (b) this not being a full revert of rust-lang/rust#111677; I am not touching diagnostics outside the interpreter such as all the const-checking code which also got converted to fluent in the same PR.

The last commit does something similar for `LayoutError`, which also helps deduplicate a bunch of error strings. I can make that into a separate PR if you prefer.

r? @oli-obk
Fixes https://github.com/rust-lang/rust/issues/113117
Fixes https://github.com/rust-lang/rust/issues/116764
Fixes https://github.com/rust-lang/rust/issues/112618
2026-03-11 22:05:44 +01:00
Jonathan Brouwer 707bf0961a Rollup merge of #152569 - oli-obk:rustc_layout_scalar_valid_range_end_end, r=davidtwco
Stop using rustc_layout_scalar_valid_range_* in rustc

*[View all comments](https://triagebot.infra.rust-lang.org/gh-comments/rust-lang/rust/pull/152569)*

Another step towards rust-lang/rust#135996

Required some manual impls, but we already do many manual impls for the newtype_index types, so it's not really a new maintenance burden.
2026-03-11 22:05:41 +01:00
Ralf Jung 94361fba3e interpret: go back to regular string interpolation for error messages 2026-03-11 13:53:40 +01:00
bors b2fabe39bd Auto merge of #153673 - JonathanBrouwer:rollup-cGOKonI, r=JonathanBrouwer
Rollup of 7 pull requests

Successful merges:

 - rust-lang/rust#153560 (Introduce granular tidy_ctx's check in extra_checks)
 - rust-lang/rust#153666 (Add a regression test for rust-lang/rust#153599)
 - rust-lang/rust#153493 (Remove `FromCycleError` trait)
 - rust-lang/rust#153549 (tests/ui/binop: add annotations for reference rules)
 - rust-lang/rust#153641 (Move `Spanned`.)
 - rust-lang/rust#153663 (Remove `TyCtxt::node_lint` method and `rustc_middle::lint_level` function)
 - rust-lang/rust#153664 (Add test for rust-lang/rust#109804)
2026-03-11 05:12:10 +00:00
bors d1c79458b5 Auto merge of #153379 - TKanX:refactor/149164-simplify-autodiff-rlib, r=ZuseZ4
refactor(autodiff): Simplify Autodiff Handling of `rlib` Dependencies

### Summary:

Resolves the two FIXMEs left in rust-lang/rust#149033, per @bjorn3 guidance in [the discussion](https://github.com/rust-lang/rust/pull/149033#discussion_r2535465880).

Closes rust-lang/rust#149164 

r? @ZuseZ4
cc @bjorn3
2026-03-11 02:03:25 +00:00
Jonathan Brouwer 4af0d1551a Rollup merge of #153641 - nnethercote:mv-Spanned, r=JonathanBrouwer
Move `Spanned`.

It's defined in `rustc_span::source_map` which doesn't make any sense because it has nothing to do with source maps. This commit moves it to the crate root, a more sensible spot for something this basic.

r? @JonathanBrouwer
2026-03-10 22:46:56 +01:00
dianqk 86da9312dc mir-opt: Drop invalid debuginfos after SingleUseConsts. 2026-03-11 05:40:44 +08:00
Nicholas Nethercote c12ab08c14 Move Spanned.
It's defined in `rustc_span::source_map` which doesn't make any sense
because it has nothing to do with source maps. This commit moves it to
the crate root, a more sensible spot for something this basic.
2026-03-11 06:25:23 +11:00
David Wood db5e2dc248 abi: s/ScalableVector/SimdScalableVector
Renaming to remove any ambiguity as to what "vector" refers to in this
context
2026-03-10 11:52:22 +00:00
Guillaume Gomez 3a64713bd5 Remove TyCtxt::node_span_lint usage from rustc_mir_transform 2026-03-09 11:35:33 +01:00
Zalathar 985b41d387 Remove the rustc_data_structures::assert_matches! re-exports 2026-03-08 22:02:23 +11:00
bors c7b206bba4 Auto merge of #153383 - nnethercote:overhaul-ensure_ok, r=Zalathar
Overhaul `ensure_ok`

The interaction of `ensure_ok` and the `return_result_from_ensure_ok` query modifier is weird and hacky. This PR cleans it up. Details in the individual commits.

r? @Zalathar
2026-03-08 07:03:35 +00:00
Nicholas Nethercote d4503b017e Overhaul ensure_ok.
`ensure_ok` provides a special, more efficient way of calling a query
when its return value isn't needed. But there is a complication: if the
query is marked with the `return_result_from_ensure_ok` modifier, then
it will return `Result<(), ErrorGuaranteed`. This is clunky and feels
tacked on. It's annoying to have to add a modifier to a query to declare
information present in its return type, and it's confusing that queries
called via `ensure_ok` have different return types depending on the
modifier.

This commit:

- Eliminates the `return_result_from_ensure_ok` modifier. The proc macro
  now looks at the return type and detects if it matches `Result<_,
  ErrorGuarantee>`. If so, it adds the modifier
  `returns_error_guaranteed`. (Aside: We need better terminology to
  distinguish modifiers written by the user in a `query` declaration
  (e.g. `cycle_delayed_bug`) from modifiers added by the proc macro
  (e.g. `cycle_error_handling`.))

- Introduces `ensure_result`, which replaces the use of `ensure_ok` for
  queries that return `Result<_, ErrorGuarantee>`. As a result,
  `ensure_ok` can now only be used for the "ignore the return value"
  case.
2026-03-08 09:39:39 +11:00
Josh Stone 32bae1353e Update cfg(bootstrap) 2026-03-07 10:42:02 -08:00
Oli Scherer ff7e604154 Stop using rustc_layout_scalar_valid_range_* in rustc 2026-03-07 15:36:56 +00:00
Jonathan Brouwer 828c0c0668 Remove remove_arg from diagnostics 2026-03-06 18:52:11 +01:00
Jonathan Brouwer d8092147fe Rename translation -> formatting 2026-03-04 17:47:24 +01:00
Tony Kan dd9922151f refactor(autodiff): Simplify rlib dep handling; use fn_ptr_ty in adjust_activity_to_abi, drop mono-collection & cross-crate-inline workarounds 2026-03-04 03:53:52 -08:00
Matthias Krüger 5bd6a0c2f9 Rollup merge of #153274 - ValorZard:async-drop-multi-crate-crash, r=oli-obk
Fix async drop multi crate crash

fixes rust-lang/rust#142572
Again, I've been talking in the Zulip about this: [#wg-async > is there a way I can help with Async Drop? @ 💬](https://rust-lang.zulipchat.com/#narrow/channel/187312-wg-async/topic/is.20there.20a.20way.20I.20can.20help.20with.20Async.20Drop.3F/near/575627286)

TL;DR: This is going to be a bit of a refactor, hold your horses

Also, I might end up splitting this into two PRs, so I can first merge my elaborate_drop.rs refactor, and then my fix for the crash later, but IDK yet
2026-03-04 09:49:02 +01:00