Commit Graph

323684 Commits

Author SHA1 Message Date
Daniel Scherzer bd712bd224 CValue::zst() - add missing "ZST" in docs 2026-04-14 13:22:50 -07:00
bors 12f35ad39e Auto merge of #155209 - JonathanBrouwer:attr_cleanup2, r=jdonszelmann
Post-attribute ports cleanup pt. 1 (again)

This is a re-implementation of most (but not all) of https://github.com/rust-lang/rust/pull/154808

The code is the same as in that PR, other than a few changes, I'll leave comments where I changed things.
I did re-implement most of the commits rather than cherry-picking, so it's probably good to check the entire diff regardless

r? @jdonszelmann
2026-04-14 08:59:40 +00:00
bors 7db0ab43a7 Auto merge of #155270 - jhpratt:rollup-Djg7HpJ, r=jhpratt
Rollup of 3 pull requests

Successful merges:

 - rust-lang/rust#152530 (Use the term struct-like variant instead of anonymous structs for data of struct-like enum variants)
 - rust-lang/rust#155005 (preserve SIMD element type information)
 - rust-lang/rust#155230 (Avoid linting `doc_cfg` as unused in rustc)
2026-04-14 04:56:46 +00:00
Jacob Pratt ec3a6b407f Rollup merge of #155230 - TaKO8Ki:fix-unused-features-doc-cfg, r=Kivooeo
Avoid linting `doc_cfg` as unused in rustc

Fixes rust-lang/rust#154487

https://github.com/rust-lang/rust/blob/af80b0f2cd0505bcc86eaa675d1ab403110d373a/src/librustdoc/passes/propagate_doc_cfg.rs#L19-L26
2026-04-14 00:37:25 -04:00
Jacob Pratt 803a7227fb Rollup merge of #155005 - folkertdev:simd-element-type-llvm, r=nnethercote
preserve SIMD element type information

Preserve the SIMD element type and provide it to LLVM for better optimization.

This is relevant for AArch64 types like `int16x4x2_t`, see also https://github.com/llvm/llvm-project/issues/181514. Such types are defined like so:

```rust
#[repr(simd)]
struct int16x4_t([i16; 4]);

#[repr(C)]
struct int16x4x2_t(pub int16x4_t, pub int16x4_t);
```

Previously this would be translated to the opaque `[2 x <8 x i8>]`, with this PR it is instead `[2 x <4 x i16>]`. That change is not relevant for the ABI, but using the correct type prevents bitcasts that can (indeed, do) confuse the LLVM pattern matcher.

This change will make it possible to implement the deinterleaving loads on AArch64 in a portable way (without neon-specific intrinsics), which means that e.g. Miri or the cranelift backend can run them without additional support.

discussion at [#t-compiler > loss of vector element type information](https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/loss.20of.20vector.20element.20type.20information/with/584483611)
2026-04-14 00:37:24 -04:00
Jacob Pratt 47d991a1aa Rollup merge of #152530 - orzechow:struct_like_enum_variants_docs, r=ChrisDenton
Use the term struct-like variant instead of anonymous structs for data of struct-like enum variants

The current term in the docs `anonymous structs` seems to be outdated.
I'd suggest `struct-like data` or rephrasing the whole sentence to use `struct-like variant`.

The terminology used in the [Rust Book on enums](https://doc.rust-lang.org/stable/book/ch06-01-defining-an-enum.html#listing-6-2) is
> named fields, like a struct

The [Reference on enums](https://doc.rust-lang.org/stable/reference/items/enumerations.html#r-items.enum.constructor) uses
> struct-like enum variant

The term `anonymous struct` on the other hand is neither mentioned in the Rust book on [structs](https://doc.rust-lang.org/stable/book/ch05-01-defining-structs.html) or [enums](https://doc.rust-lang.org/stable/book/ch06-01-defining-an-enum.html#listing-6-2), nor the references on [structs](https://doc.rust-lang.org/stable/reference/items/structs.html) or [enums](https://doc.rust-lang.org/stable/reference/items/enumerations.html#r-items.enum.constructor).
2026-04-14 00:37:23 -04:00
bors 0006519783 Auto merge of #155267 - jhpratt:rollup-fgQZJCS, r=jhpratt
Rollup of 5 pull requests

Successful merges:

 - rust-lang/rust#149357 (Implement `-Z allow-partial-mitigations` (RFC 3855))
 - rust-lang/rust#154939 (Refactor: simplify report_selection_error)
 - rust-lang/rust#152688 (Trait aliases: Also imply default trait bounds on type params other than `Self`)
 - rust-lang/rust#154352 (rustdoc: dep-info for standalone markdown inputs)
 - rust-lang/rust#155195 (tidy: handle `#[cfg_attr(bootstrap, doc = "...")]` in `compiler/` comments)
2026-04-14 01:06:31 +00:00
Jacob Pratt 30d2f5aca6 Rollup merge of #155195 - jieyouxu:tidy-compiler-doc-attr, r=WaffleLapkin
tidy: handle `#[cfg_attr(bootstrap, doc = "...")]` in `compiler/` comments

For the unbalanced backtick check that Waffle ran into in https://github.com/rust-lang/rust/pull/154887.

This PR cherry-picks Waffle's tidy patch in that PR (and adds some explaining comments) even though I'd say this is somewhat hacky[^1]. But since the original tidy check implementation is already based on heuristics and so are likewise fuzzy, this is probably fine in practice for most cases.

[^1]: There can be false positives/negatives like having both fragments `cfg_attr` and `doc` inside a string literal, but I would expect that to be very very niche, so it's "good enough".

(I wanted to write a regression test, but this check needs some restructuring to make it more easy to test that I don't want to bundle in this PR.)

r? wafflelapkin (or bootstrap/compiler)
2026-04-13 20:12:07 -04:00
Jacob Pratt 4691e61f79 Rollup merge of #154352 - notriddle:emit-md, r=fmease
rustdoc: dep-info for standalone markdown inputs

Part of https://github.com/rust-lang/rust/pull/146220#issuecomment-3936957755

r? @fmease
2026-04-13 20:12:07 -04:00
Jacob Pratt 7e40efc366 Rollup merge of #152688 - fmease:implied-preds-default-bounds, r=jackh726
Trait aliases: Also imply default trait bounds on type params other than `Self`

Trait aliases already correctly imply default trait bounds on `Self` type params. However, due to an oversight, they didn't do that for normal type params.

Fixes rust-lang/rust#152687.
2026-04-13 20:12:06 -04:00
Jacob Pratt 2a0b5343df Rollup merge of #154939 - chenyukang:yukang-refactor-fn-pointer-cast-suggestion, r=davidtwco
Refactor: simplify report_selection_error

Split out `suggest_cast_to_fn_pointer` for better readability.
2026-04-13 20:12:05 -04:00
Jacob Pratt 7d1b042d45 Rollup merge of #149357 - arielb1:enforce-partial-mitigations, r=rcvalle
Implement `-Z allow-partial-mitigations` (RFC 3855)

This implements `-Z allow-partial-mitigations` as an unstable option, currently with support for control-flow-guard and stack-protector.

As a difference from the RFC, we have `-Z allow-partial-mitigations=!foo` rather than `-Z deny-partial-mitigations=foo`, since I couldn't find an easy way to have an allow/deny pair of flags where the latter flag wins.

To allow for stabilization, this is only enabled starting from the next edition. Maybe a better policy is possible (bikeshed).

r? @rcvalle
2026-04-13 20:12:05 -04: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
Jonathan Brouwer a0f105e63e Remove AttributeTemplate from BUILTIN_ATTRIBUTES 2026-04-13 20:52:23 +02:00
Jonathan Brouwer ad41fc08b3 Remove EncodeCrossCrate from BUILTIN_ATTRIBUTES 2026-04-13 20:51:30 +02:00
Jonathan Brouwer 034de09cb3 Remove AttributeType from BUILTIN_ATTRIBUTES 2026-04-13 20:51:29 +02:00
Jonathan Brouwer da8cf97e64 Remove AttributeDuplicates from BUILTIN_ATTRIBUTES 2026-04-13 20:51:24 +02:00
Jonathan Brouwer e391f7717f Remove emit_fatal_malformed_builtin_attribute 2026-04-13 20:51:21 +02:00
bors 17584a1819 Auto merge of #155253 - JonathanBrouwer:rollup-lERdTAB, r=JonathanBrouwer
Rollup of 19 pull requests

Successful merges:

 - rust-lang/rust#155162 (relnotes for 1.95)
 - rust-lang/rust#140763 (Change codegen of LLVM intrinsics to be name-based, and add llvm linkage support for `bf16(xN)` and `i1xN`)
 - rust-lang/rust#153604 (Fix thread::available_parallelism on WASI targets with threads)
 - rust-lang/rust#154193 (Implement EII for statics)
 - rust-lang/rust#154389 (Add more robust handling of nested query cycles)
 - rust-lang/rust#154435 (resolve: Some import resolution cleanups)
 - rust-lang/rust#155236 (Normalize individual predicate of `InstantiatedPredicates` inside `predicates_for_generics`)
 - rust-lang/rust#155243 (cg_ssa: transmute between scalable vectors)
 - rust-lang/rust#153941 (tests/debuginfo/basic-stepping.rs: Explain why all lines are not steppable)
 - rust-lang/rust#154587 (Add --verbose-run-make-subprocess-output flag to suppress verbose run-make output for passing tests)
 - rust-lang/rust#154624 (Make `DerefPure` dyn-incompatible)
 - rust-lang/rust#154929 (Add `const Default` impls for `LazyCell` and `LazyLock`)
 - rust-lang/rust#154944 (Small refactor of `arena_cache` query values)
 - rust-lang/rust#155055 (UI automation)
 - rust-lang/rust#155062 (Move tests from `tests/ui/issues/` to appropriate directories)
 - rust-lang/rust#155131 (Stabilize feature `uint_bit_width`)
 - rust-lang/rust#155147 (Stabilize feature `int_lowest_highest_one`)
 - rust-lang/rust#155174 (Improve emission of `UnknownDiagnosticAttribute` lint)
 - rust-lang/rust#155194 (Fix manpage version replacement and use verbose version)
2026-04-13 18:32:47 +00:00
Jonathan Brouwer 9f11d53cd3 Rollup merge of #155194 - davidkna:man-version, r=clubby789
Fix manpage version replacement and use verbose version

- Fix a bug where `t!(fs::copy(&page_src, &page_dst))` was called after`fs::write`, silently overwriting the substituted content with the original template (restoring the `<INSERT VERSION HERE>` placeholder verbatim) (Related rust-lang/rust#93685)
- Use `rust_info().version()` instead of the bare version number, so the man page now includes the full version string with commit hash and date
2026-04-13 20:20:08 +02:00
Jonathan Brouwer e3d1d77058 Rollup merge of #155174 - mejrs:on_move_gating, r=JonathanBrouwer
Improve emission of `UnknownDiagnosticAttribute` lint

This checks features much less than the current implementation. See https://github.com/rust-lang/rust/pull/155155 for context. Minor fixes and comments are added in the second and third commit.
2026-04-13 20:20:07 +02:00
Jonathan Brouwer 0af1a15c9a Rollup merge of #155147 - sorairolake:stabilize-int-lowest-highest-one, r=jhpratt
Stabilize feature `int_lowest_highest_one`

Tracking issue: rust-lang/rust#145203
FCP is finished in https://github.com/rust-lang/rust/issues/145203#issuecomment-4224883617

Closes rust-lang/rust#145203

@rustbot modify labels: +T-libs-api
2026-04-13 20:20:06 +02:00
Jonathan Brouwer 0bfc5efe04 Rollup merge of #155131 - sorairolake:stabilize-uint-bit-width, r=jhpratt
Stabilize feature `uint_bit_width`

Tracking issue: rust-lang/rust#142326
FCP is finished in https://github.com/rust-lang/rust/issues/142326#issuecomment-4224883142

Closes rust-lang/rust#142326

@rustbot modify labels: +T-libs-api
2026-04-13 20:20:05 +02:00
Jonathan Brouwer b8e88c7f49 Rollup merge of #155062 - ujjwalvishwakarma2006:reorg-tests, r=Kivooeo
Move tests from `tests/ui/issues/` to appropriate directories

In this PR, I am moving the following test from `tests/ui/issues` directory to the appropriate directories, followed by the addition of issue links at the top and reblessing of the stderr files:

| old-name | new-sub-dir | new-name |
|-|-|-|
| `issue-29516.rs` | `auto-traits/` | `distinct-type-tuple-by-negative-impl.rs` |
| `issue-3874.rs` | `binding/` | `ref-in-let-lhs-in-field.rs` |
| `issue-32782.rs` | `feature-gates/` | `feature-gate-check-nested-macro-invocation.rs` |
| `issue-32782.stderr` | `feature-gates/` | `feature-gate-check-nested-macro-invocation.stderr` |
| `issue-5100.rs` | `pattern/` | `match-errors-derived-error-suppression.rs` |
| `issue-5100.stderr` | `pattern/` | `match-errors-derived-error-suppression.stderr` |
| `issue-21033.rs` | `pattern/` | `match-struct-var-having-boxed-field.rs` |

r? Kivooeo
r? Teapot4195
2026-04-13 20:20:04 +02:00
Jonathan Brouwer 2ab9ebfd98 Rollup merge of #155055 - rishi-techo-14:ui-automation, r=Kivooeo
UI automation

# To move issue-3154 and issue-16774 to functional subdirectories:

I have moved 2 tests from tests/ui/issues to their appropriate directories using "test-manager" tool.
## Changes:

- Moved tests/ui/issues/issue-3154.rs to tests/ui/borrowck/missing-lifetime-in-return.rs

- Moved tests/ui/issues/issue-16774.rs to tests/ui/deref/derefmut-closure-drop-order.rs
These moves where performed using the test-manager automation tool.
2026-04-13 20:20:04 +02:00
Jonathan Brouwer b1bb531999 Rollup merge of #154944 - zetanumbers:refactor_arena_cache_queries, r=jackh726
Small refactor of `arena_cache` query values

Query modifier `arena_cache` automatically allocates only `Some` variant of query's value of type `Option<&'tcx T>`, so `mir_callgraph_cyclic` should've been doing it from the beginning. The same could be said for any `Result<&'tcx T, ErrorGuaranteed>` as `ErrorGuaranteed` is a zero sized type, but that requires adding a new `ArenaCached` implementation.
2026-04-13 20:20:03 +02:00
Jonathan Brouwer 8d8dcf142a Rollup merge of #154929 - davidgauch:const-default-lazy, r=jhpratt
Add `const Default` impls for `LazyCell` and `LazyLock`

Follow up to these commits by @estebank https://github.com/rust-lang/rust/pull/134628 and https://github.com/rust-lang/rust/pull/151190.
Tracking issue https://github.com/rust-lang/rust/issues/143894.

cc @fmease @fee1-dead @oli-obk

This enables `static L: LazyLock<D> = Default::default()`  for any type `D: Default` which is safe as `D::default()` is only evaluated at runtime.
2026-04-13 20:20:02 +02:00
Jonathan Brouwer 3f88653f77 Rollup merge of #154624 - theemathas:deref-pure-dyn-incompat, r=jackh726
Make `DerefPure` dyn-incompatible

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

If `DerefPure` were dyn-compatible, a trait object of a subtrait of `DerefPure` could be created by unsize-coercing an existing type that implements `DerefPure`. But then the trait object could have its own non-pure impl of `Deref`/`DerefMut`, which is unsound, since the trait object would implement `DerefPure`. Thus, we make `DerefPure` dyn-incompatible.

r? types
2026-04-13 20:20:01 +02:00
Jonathan Brouwer 46997fb00f Rollup merge of #154587 - Ayuse:compiletest-quiet-run-make, r=jieyouxu
Add --verbose-run-make-subprocess-output flag to suppress verbose run-make output for passing tests

- Adds `--verbose-run-make-subprocess-output` flag to `./x test` and compiletest
- `./x test --no-capture --verbose-run-make-subprocess-output=false` suppresses verbose subprocess output for passing run-make tests
- Failed tests always print their output regardless of `--verbose-run-make-subprocess-output`
- Default behavior (verbose) is unchanged

This addresses the request from @bjorn3  which needs `--no-capture` (due to `panic=abort`) but doesn't want output dumped for every passing test.

Helps with rust-lang/rust#154069

## Test plan

- [x] `./x test tests/run-make/bare-outfile --no-capture --force-rerun` — verbose output for passing test
- [x] `./x test tests/run-make/bare-outfile --no-capture --verbose-run-make-subprocess-output=false --force-rerun` — no verbose output for passing test
- [x] Failing test still dumps output with `--verbose-run-make-subprocess-output=false`
2026-04-13 20:20:00 +02:00
Jonathan Brouwer 978fb762ac Rollup merge of #153941 - Enselic:fully-steppable, r=saethlin
tests/debuginfo/basic-stepping.rs: Explain why all lines are not steppable

Some optimization passes [_improve_](https://github.com/rust-lang/compiler-team/issues/319) compile times. So we want to run some passes even with `-Copt-level=0`. That means that some debuggable lines can be optimized away. Document that as expected behavior.

Closes https://github.com/rust-lang/rust/issues/33013.

Replaces https://github.com/rust-lang/rust/pull/151426. See that PR for some discussion.
2026-04-13 20:20:00 +02:00
Jonathan Brouwer 769d225a4a Rollup merge of #155243 - davidtwco:scalable-vectors-transmute, r=Amanieu
cg_ssa: transmute between scalable vectors

Like regular SIMD vectors, we can support casting between scalable vectors of integral or floating-point types without needing a temporary.

r? @Amanieu
2026-04-13 20:19:59 +02:00
Jonathan Brouwer 2fce4af463 Rollup merge of #155236 - adwinwhite:refactor-predicates-for-generics, r=lcnr
Normalize individual predicate of `InstantiatedPredicates` inside `predicates_for_generics`

This is a cleanup to better land rust-lang/rust#155083. It allows us to wrap individual clause in `Unnormalized` wrapper. See [this comment](https://github.com/rust-lang/rust/pull/155083#discussion_r3072219035)

Besides that, this PR also adds missing normalization in some cases.

r? @lcnr
2026-04-13 20:19:58 +02:00
Jonathan Brouwer 93884baee5 Rollup merge of #154435 - petrochenkov:cleandecl, r=jackh726
resolve: Some import resolution cleanups

See the individual commits
2026-04-13 20:19:57 +02:00
Jonathan Brouwer e39dfc5e4a Rollup merge of #154389 - Zoxc:nested-cycles, r=petrochenkov
Add more robust handling of nested query cycles

This adds more robust handling of query cycle that occur while we are already printing a query cycle error. Such nested query cycle are compiler bugs and this adds special handling so that both the nested query cycle and the outer query cycle are printed. Doubly nested query cycle errors are ignored to prevent infinite recursion.
2026-04-13 20:19:57 +02:00
Jonathan Brouwer d2fa85cd4d Rollup merge of #154193 - JonathanBrouwer:external-static, r=jdonszelmann
Implement EII for statics

This PR implements EII for statics. I've tried to mirror the implementation for functions in a few places, this causes some duplicate code but I'm also not really sure whether there's a clean way to merge the implementations.

This does not implement defaults for static EIIs yet, I will do that in a followup PR
2026-04-13 20:19:56 +02:00
Jonathan Brouwer 148ef32d65 Rollup merge of #153604 - rust-wasi-web:wasi-available-parallelism-fix, r=alexcrichton
Fix thread::available_parallelism on WASI targets with threads

The refactoring in ba462864f1 ("std: Use more unix.rs code on WASI targets") moved WASI from its own thread module into the shared unix.rs module. However, it did not carry over the available_parallelism() implementation for WASI with threads, causing it to fall through to the unsupported catch-all. This silently regressed the support originally added in f0b7008648.

Fix this by adding WASI to the standard UNIX cfg_select branch.

Depends on rust-lang/rust#155057 (Update libc to v0.2.184).
2026-04-13 20:19:55 +02:00
Jonathan Brouwer f0af5f5777 Rollup merge of #140763 - sayantn:test-amx, r=dianqk
Change codegen of LLVM intrinsics to be name-based, and add llvm linkage support for `bf16(xN)` and `i1xN`

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

This PR changes how LLVM intrinsics are codegen

# Explanation of the changes

## Current procedure

This is the same for all functions, LLVM intrinsics are _not_ treated specially
 - We get the LLVM Type of a function simply using the argument types. For example, the following function
   ```rust
   #[link_name = "llvm.sqrt.f32"]
   fn sqrtf32(a: f32) -> f32;
   ```
   will have LLVM type simply `f32 (f32)` due to the Rust signature

### Pros

 - Simpler to implement, no extra complexity involved due to LLVM intrinsics

### Cons

 - LLVM intrinsics have a well-defined signature, completely defined by their name (and if it is overloaded, the type parameters). So, this process of converting Rust signatures to LLVM signatures may not work, for example the following code generates LLVM IR without any problem
   ```rust
   #[link_name = "llvm.sqrt.f32"]
   fn sqrtf32(a: i32) -> f32;
   ```
   but the generated LLVM IR is invalid, because it has wrong signature for the intrinsic ([Godbolt](https://godbolt.org/z/6ff9hrcd5), adding `-Zverify-llvm-ir` to it will fail compilation). I would expect this code to not compile at all instead of generating invalid IR.
 - LLVM intrinsics that have types in their signature that can't be accessed from Rust (notable examples are the AMX intrinsics that have the `x86amx` type, and (almost) all intrinsics that have vectors of `i1` types) can't be linked to at all. This is a (major?) roadblock in the AMX and AVX512 support in stdarch.
 - If code uses an non-existing LLVM intrinsic, even `-Zverify-llvm-ir` won't complain. Eventually it will error out due to the non-existing function (courtesy of the linker). I don't think this is a behavior we want.

## What this PR does

 - When linking to **non-overloaded** intrinsics, we use the function `LLVMIntrinsicGetType` to directly get the function type of the intrinsic from LLVM.
 - We then use this LLVM definition to _verify_ the Rust signature, and emit a proper error if it doesn't match, instead of silently emitting invalid IR.
 - Lint if linking to deprecated or invalid LLVM intrinsics

> [!NOTE]
> This PR only focuses on non-overloaded intrinsics, overloaded can be done in a future PR

Regardless, the undermentioned functionalities work for **all** intrinsics

 - If we can't find the intrinsic, we check if it has been `AutoUpgrade`d by LLVM. If not, that means it is an invalid intrinsic, and we error out.
 - Don't allow intrinsics from other archs to be declared, e.g. error out if an AArch64 intrinsic is declared when we are compiling for x86

### Pros

 - It is now not possible (or at least, it would require _significantly_ more leaps and bounds) to introduce invalid IR using **non-overloaded** LLVM intrinsics.
 - As we are now doing the matching of Rust signatures to LLVM intrinsics ourselves, we can now add bypasses to enable linking to such non-Rust types (e.g. matching 8192-bit vectors to `x86amx` and injecting `llvm.x86.cast.vector.to.tile` and `llvm.x86.cast.tile.to.vector`s in callsite)

> [!NOTE]
> I don't intend for these bypasses to be permanent. A better approach will be introducing a `bf16` type in Rust, and allowing `repr(simd)` with `bool`s to get Rust-native `i1xN`s. These are meant to be short-time, as I mentioned, "bypass"es. They shouldn't cause any major breakage even if removed, as `link_llvm_intrinsics` is perma-unstable.

   This PR adds bypasses for `bf16` (via `i16`), `bf16xN` (via `i16xN`) and `i1xN` (via `iM`, where `M` is the smallest power of 2  s.t. `M >= N`, unless `N <= 4`, where we use `M = 8`). This will unblock AVX512-VP2INTERSECT and a lot of bf16 intrinsics in stdarch. This PR also automatically destructures structs if the types don't exactly match (this is required for us to start emitting hard errors on mismmatches).

### Cons

 - This only works for non-overloaded intrinsics (at least for now). Improving this to work with overloaded intrinsics too will involve significantly more work.

# Possible ways to extend this to overloaded intrinsics (future)

## Parse the mangled intrinsic name to get the type parameters

LLVM has a stable mangling of intrinsic names with type parameters (in `LLVMIntrinsicCopyOverloadedName2`), so we can parse the name to get the type parameters, and then just do the same thing.

### Pros
 - For _most_ intrinsics, this will work perfectly, and is a easy way to do this.

### Cons
 - The LLVM mangling is not perfectly reversible. When we have `TargetExt` types or identified structs, their name is a part of the mangling, making it impossible to reverse. Even more complexities arise when there are unnamed identified structs, as LLVM adds more mangling to the names.
 - @nikic's work on LLVM intrinsics will remove the name mangling, making this approach impossible

## Use the `IITDescriptor` table and the Rust function signature

We can use the base name to get the `IITDescriptor`s of the corresponding intrinsic, and then manually implement the _matching_ logic based on the Rust signature.

### Pros

 - Doesn't have the above mentioned limitation of the parsing approach, has correct behavior even when there are identified structs and `TargetExt` types. Also, fun fact, Rust exports all struct types as literal structs (unless it is emitting LLVM IR, then it always uses named identified structs, with mangled names)

### Cons

 - **Doesn't** actually use the type parameters in the name, only uses the base name and the Rust signature to get the llvm signature (although we _can_ check that it is the correct name). It means there would be no way to (for example) link against `llvm.sqrt.bf16` until we have `bf16` types in Rust. Because if we are using `u16`s (or any other type) as `bf16`s, then the matcher will deduce that the signature is `u16 (u16)` not `bf16 (bf16)` (which would lead to an error because `u16` is not a valid type parameter for `llvm.sqrt`), even though the intended type parameter is specified in the name.
 - Much more complex, and hard to maintain as LLVM gets new `IITDescriptorKind`s

These 2 approaches might give different results for same function. Let's take
```rust
#[link_name = "llvm.is.constant.bf16"]
fn foo(a: u16) -> bool
```
The name-based approach will decide that the type parameter is `bf16`, and the LLVM signature is `i1 (bf16)` and will inject some bitcasts at callsite.
The `IITDescriptor`-based approach will decide that the LLVM signature is `i1 (u16)`, and will see that the name given doesn't match the expected name (`llvm.is.constant.u16`), and will error out.

Reviews are welcome, as this is my first time _actually_ contributing to `rustc`

@rustbot label T-compiler A-codegen A-LLVM
r? codegen
2026-04-13 20:19:54 +02:00
Jonathan Brouwer 2b77fc4702 Rollup merge of #155162 - BoxyUwU:relnotes_1_95, r=Mark-Simulacrum
relnotes for 1.95

r? @Mark-Simulacrum

cc @rust-lang/release
2026-04-13 20:19:54 +02:00
Takayuki Maeda 5c80d9031d add a link to issue 154487 2026-04-14 02:08:26 +09:00
yukang 270cc62257 refactor: simplify fn pointer cast suggestion logic 2026-04-13 23:55:22 +08:00
León Orell Valerian Liehr 9d627dd796 Trait aliases: Imply default trait bounds on type params other than Self 2026-04-13 17:35:28 +02:00
Oli Scherer 834137afd7 Use !null pattern type in libcore 2026-04-13 17:23:03 +02:00
bors a72e2a71d8 Auto merge of #155239 - JonathanBrouwer:rollup-XUNKT4X, r=JonathanBrouwer
Rollup of 10 pull requests

Successful merges:

 - rust-lang/rust#155227 (`rust-analyzer` subtree update)
 - rust-lang/rust#153335 (Add #![unstable_removed(..)] attribute to track removed features)
 - rust-lang/rust#154932 (Handle RTN projections in assoc type restriction diagnostics)
 - rust-lang/rust#155096 (delegation: support proper interaction of user-specified args and impl Traits)
 - rust-lang/rust#155106 (cg_llvm: scalable vectors with `simd_cast` and `simd_select`)
 - rust-lang/rust#155140 (add regression test for OpenOptionsExt downstream compat)
 - rust-lang/rust#155182 (Make the expansion of guard metavars begin guard non-terminals)
 - rust-lang/rust#155226 (delegation: revert execution of hir_crate_items before delayed lowering)
 - rust-lang/rust#153997 (Use closures more consistently in `dep_graph.rs`.)
 - rust-lang/rust#155003 (update thin-vec)
2026-04-13 15:18:43 +00:00
Adwin White 7aa3f3ce52 normalize each predicate inside predicates_for_generics 2026-04-13 21:03:51 +08:00
Jonathan Brouwer f8a8c9e244 Rollup merge of #155003 - malezjaa:update-thinvec, r=davidtwco
update thin-vec

With thin-vec v0.2.15 released, copy-pasted implementation of ExtractIf can be removed.
2026-04-13 14:02:35 +02:00
Jonathan Brouwer 2f607ee662 Rollup merge of #153997 - nnethercote:closure-consistency, r=petrochenkov
Use closures more consistently in `dep_graph.rs`.

This file has several methods that take a `FnOnce() -> R` closure:
- `DepGraph::with_ignore`
- `DepGraph::with_query_deserialization`
- `DepGraph::with_anon_task`
- `DepGraphData::with_anon_task_inner`

It also has two methods that take a faux closure via an `A` argument and a `fn(TyCtxt<'tcx>, A) -> R` argument:
- DepGraph::with_task
- DepGraphData::with_task

The rationale is that the faux closure exercises tight control over what state they have access to. This seems silly when (a) they are passed a `TyCtxt`, and (b) when similar nearby functions take real closures. And they are more awkward to use, e.g. requiring multiple arguments to be gathered into a tuple. This commit changes the faux closures to real closures.

r? @Zalathar
2026-04-13 14:02:35 +02:00
Jonathan Brouwer 14b5df4749 Rollup merge of #155226 - aerooneqq:delegation-hir-crate-items-revert, r=petrochenkov
delegation: revert execution of hir_crate_items before delayed lowering

This PR reverts rust-lang/rust#154368, as after weekend consideration I don't think that it is a correct way of fixing cycles during delayed lowering:

- The number of ICEs were reported, fixing them would require to develop solution from rust-lang/rust#154368 but I am afraid that it would lead to cancer code growing,
- The [memory regression](https://github.com/rust-lang/rust/pull/154368#issuecomment-4229353764) for rustdoc was reported, it can be fixed with moving `tcx.force_delayed_owners_lowering` call earlier, but it is already bad that this is call is now required everywhere, before rust-lang/rust#154368 AST was dropped before `hir_crate_items` automatically and users of `rustc` API did not have to think about it.

I will try to come up with a more robust solution leaving rust-lang/rust#154368 as a last resort if nothing else will work.

Re-opens rust-lang/rust#154169.
Fixes rust-lang/rust#155125. Fixes rust-lang/rust#155127. Fixes rust-lang/rust#155128. Fixes rust-lang/rust#155164. Fixes rust-lang/rust#155202.
Part of rust-lang/rust#118212.

r? @petrochenkov
2026-04-13 14:02:34 +02:00
Jonathan Brouwer 49b5708d51 Rollup merge of #155182 - fmease:guard-exp-begins-guard, r=petrochenkov
Make the expansion of guard metavars begin guard non-terminals

While investigating something unrelated, I noticed a bug in the impl of unstable feature `macro_guard_matcher` (tracking issue: rust-lang/rust#153104). Namely, the following doesn't compile:

```rs
#![feature(macro_guard_matcher)]

macro_rules! a { ($guard:guard) => { b!($guard); }; }
macro_rules! b { ($guard:guard) => {}; }
a!(if true);
```

```
error: no rules expected `guard` metavariable
 --> src/lib.rs:3:41
  |
3 | macro_rules! a { ($guard:guard) => { b!($guard); }; }
  |                                         ^^^^^^ no rules expected this token in macro call
4 | macro_rules! b { ($guard:guard) => {}; }
  | -------------- when calling this macro
5 | a!(if true);
  | ----------- in this macro invocation
  |
note: while trying to match meta-variable `$guard:guard`
 --> src/lib.rs:4:19
  |
4 | macro_rules! b { ($guard:guard) => {}; }
  |                   ^^^^^^^^^^^^
  = note: this error originates in the macro `a` (in Nightly builds, run with -Z macro-backtrace for more info)
```

---

While I'm still skeptical of `guard` fragment specifiers in general (although I can't quite pinpoint why), I figured I should fix this issue.
2026-04-13 14:02:33 +02:00
Jonathan Brouwer 49f0536229 Rollup merge of #155140 - Vastargazing:open-options-ext-test, r=jdonszelmann,kivooeo
add regression test for OpenOptionsExt downstream compat

Following up on rust-lang/rust#153491, which added a warning comment there, but no automated guardrail to prevent another breaking change like rust-lang/rust#149718

This adds a simple windows-only ui test that manually implements `OpenOptionsExt`. That way, if someone accidentally adds another required method to the trait, we catch it before it reaches stable and breaks downstream crates like Tokio again.

Closes rust-lang/rust#153486
2026-04-13 14:02:33 +02:00
Jonathan Brouwer 83a57cae65 Rollup merge of #155106 - davidtwco:scalable-vector-more-simd-intrinsics, r=Amanieu
cg_llvm: scalable vectors with `simd_cast` and `simd_select`

Previously `sve_cast`'s implementation was abstracted to power both `sve_cast` and `simd_cast` which supported scalable and non-scalable vectors respectively. In anticipation of having to do this for another `simd_*` intrinsic, `sve_cast` is removed and `simd_cast` is changed to accept both scalable and non-scalable intrinsics, an approach that will scale better to the other intrinsics.

Building on the previous change, support scalable vectors with `simd_select`. Previous patches already landed the necessary changes in the implementation of this intrinsic, but didn't allow scalable vector arguments to be passed in.
2026-04-13 14:02:32 +02:00