Commit Graph

22688 Commits

Author SHA1 Message Date
Stuart Cook 336c6658e4 Rollup merge of #150201 - Enselic:debugger-tests-revisions-2, r=Zalathar
compiletest: Support revisions in debuginfo (read: debugger) tests

And start using revisions in `tests/debuginfo/macro-stepping.rs` to prevent regressing both with and without `SingleUseConsts` MIR pass.

I recommend commit-by-commit review.

## ~TODO~

- [x] Verify this more carefully.
- [x] Possibly do some preparatory PRs before taking this PR out of draft.
    - [x] Rebase on https://github.com/rust-lang/rust/pull/150205 once merged so we don't have to add another "`+ 1`".

## CC

CC ``@Zalathar`` since you might have opinions about that I expose a helper function to reduce duplication

CC ``@saethlin`` since this is what we will use for `tests/debuginfo/basic-stepping.rs` in https://github.com/rust-lang/rust/pull/147426 (in the same way I use it in `tests/debuginfo/macro-stepping.rs` here)
2026-01-04 21:37:02 +11:00
bors f57b9e6f56 Auto merge of #150564 - rwardd:rwardd/option_or_codegen_tests, r=scottmcm
Added codegen tests for different forms of `Option::or`

Adds tests to check the output of the different ways of writing `Option::or`

Fixes rust-lang/rust#124533
2026-01-03 22:47:35 +00:00
Matthias Krüger 7af208fe0b Rollup merge of #150570 - Human9000-bit:main, r=jieyouxu
Removed confusing diagnostics note for trait required for `?` operator use

- **test: modified `bad-question-mark-on-trait-objects` to match expected behavior**
- **removed confusing message from diagnostics**

fixes [#150527](https://github.com/rust-lang/rust/issues/150527)
2026-01-03 10:09:29 +01:00
Matthias Krüger 78376fd39c Rollup merge of #150558 - estebank:multiple-dep-versions, r=jieyouxu
Detect cases where `?` is applied on a type that could be coming from a different crate version than expected

```
error[E0277]: `?` couldn't convert the error to `dependency::Error`
  --> replaced
   |
LL | fn main() -> Result<(), Error> {
   |              ----------------- expected `dependency::Error` because of this
...
LL |     Err(Error2)?;
   |     -----------^ the trait `From<Error2>` is not implemented for `dependency::Error`
   |     |
   |     this can't be annotated with `?` because it has type `Result<_, Error2>`
   |
   = note: the question mark operation (`?`) implicitly performs a conversion on the error value using the `From` trait
help: the trait `From<Error2>` is not implemented for `dependency::Error`
      but trait `From<()>` is implemented for it
  --> replaced
   |
LL | impl From<()> for Error {
   | ^^^^^^^^^^^^^^^^^^^^^^^
   = help: for that trait implementation, expected `()`, found `Error2`
   = note: there are multiple different versions of crate `dependency` in the dependency graph
   = help: you can use `cargo tree` to explore your dependency tree
```

The existing checks rely on having access to the actual types/traits that diverged to detect they are called the same, come from different crates with the same name. The new check is less specific, merely looking to see if the crate name the involved type belongs has multiple crates.

CC rust-lang/rust#78552.
2026-01-03 10:09:29 +01:00
Ryan Ward a2fcb0de18 fix: add CHECK directives to ret comments and be more pervasive with directive contents 2026-01-03 12:50:38 +10:30
Ryan 3df06f5083 fix: use std::num::NonZero instead of extern crate and extend information in CHECK- directives
Co-authored-by: scottmcm <scottmcm@users.noreply.github.com>
2026-01-03 10:53:54 +10:30
bors e8f3cfc0de Auto merge of #150628 - JonathanBrouwer:rollup-zy040xr, r=JonathanBrouwer
Rollup of 4 pull requests

Successful merges:

 - rust-lang/rust#149991 (Add checks for gpu-kernel calling conv)
 - rust-lang/rust#150047 (std: merge `sys::pal::common` and `sys_common` into `sys::helpers`)
 - rust-lang/rust#150441 (do not suggest method call removal if it changes receiver type)
 - rust-lang/rust#150616 (Update `browser-ui-test` version to `0.23.0`)

r? `@ghost`
`@rustbot` modify labels: rollup
2026-01-02 23:01:27 +00:00
Jonathan Brouwer 03a0155db3 Rollup merge of #150616 - GuillaumeGomez:update-browser-ui-test, r=lolbinarycat
Update `browser-ui-test` version to `0.23.0`

It comes with new features like conditions and an update to `puppeteer`.
2026-01-02 23:13:22 +01:00
Jonathan Brouwer ce43d6cd01 Rollup merge of #150441 - fee1-dead-contrib:push-smqzpwrpvqll, r=estebank
do not suggest method call removal if it changes receiver type

Fixes rust-lang/rust#149487, cc `@estebank`
2026-01-02 23:13:22 +01:00
Jonathan Brouwer 6268b9118e Rollup merge of #149991 - Flakebi:gpu-kernel-cc, r=workingjubilee
Add checks for gpu-kernel calling conv

The `gpu-kernel` calling convention has several restrictions that were not enforced by the compiler until now.
Add the following restrictions:

1. Cannot be async
2. Cannot be called
3. Cannot return values, return type must be `()` or `!`
4. Arguments should be simple, i.e. passed by value. More complicated types can work when you know what you are doing, but it is rather unintuitive, one needs to know ABI/compiler internals.
5. Export name should be unmangled, either through `no_mangle` or `export_name`. Kernels are searched by name on the CPU side, having a mangled name makes it hard to find and probably almost always unintentional.

Tracking issue: rust-lang/rust#135467
amdgpu target tracking issue: rust-lang/rust#135024

``@workingjubilee,`` these should be all the restrictions we talked about a year ago.

cc ``@RDambrosio016`` ``@kjetilkjeka`` for nvptx
2026-01-02 23:13:21 +01:00
bors 85c8ff69cb Auto merge of #150606 - JonathanBrouwer:rollup-lue4jqz, r=JonathanBrouwer
Rollup of 6 pull requests

Successful merges:

 - rust-lang/rust#150425 (mapping an error from cmd.spawn() in npm::install)
 - rust-lang/rust#150444 (Expose kernel launch options as offload intrinsic args)
 - rust-lang/rust#150495 (Correct hexagon "unwinder_private_data_size")
 - rust-lang/rust#150578 (Fix a typo in the docs of AsMut for rust-lang/rust#149609)
 - rust-lang/rust#150581 (mir_build: Separate match lowering for string-equality and scalar-equality)
 - rust-lang/rust#150594 (Fix typo in the docs of `CString::from_vec_with_nul`)

r? `@ghost`
`@rustbot` modify labels: rollup
2026-01-02 19:45:27 +00:00
Guillaume Gomez 665781513e Fix changes coming from browser-ui-test version update 2026-01-02 20:21:44 +01:00
bors 5497a36a7f Auto merge of #149658 - Enselic:non-zero-opt, r=Mark-Simulacrum
tests/codegen-llvm/some-non-zero-from-atomic-optimization.rs: New test

Closes rust-lang/rust#60044 which has one 👍 and one ❤️  vote and just **E-needs-test**.
2026-01-02 16:29:24 +00:00
Marcelo Domínguez 58e2610f71 Expose workgroup/thread dims as intrinsic args 2026-01-02 11:50:32 +01:00
bors 1b4325211c Auto merge of #150582 - jhpratt:rollup-3mal3wc, r=jhpratt
Rollup of 3 pull requests

Successful merges:

 - rust-lang/rust#150073 (Make `asm_experimental_arch` work in `allow_internal_unstable` macros)
 - rust-lang/rust#150445 (resolve: Preserve binding scopes in ambiguity errors)
 - rust-lang/rust#150580 (Document `panic!` in `Iterator::last` for rust-lang/rust#149707)

r? `@ghost`
`@rustbot` modify labels: rollup
2026-01-02 05:37:45 +00:00
Jacob Pratt 57b2e6579a Rollup merge of #150073 - daxpedda:internal-unstable-asm-experimental-arch, r=nnethercote
Make `asm_experimental_arch` work in `allow_internal_unstable` macros

This change makes it possible to use unstable `asm!`, usually requiring `feature(asm_experimental_arch)`, in proc-macros with the `allow_internal_unstable` attribute.

The test was added on a target where `asm!` is unstable: Wasm. However, this affects *any* target with an unstable `asm!` implementation.
2026-01-01 23:27:54 -05:00
Ryan Ward 66c4ead02d fix: added further CHECK-SAME labels and replaced all struct input tests with NonZero<u8> input 2026-01-02 12:54:17 +10:30
bors a47f4dfd7f Auto merge of #150519 - camelid:mgca-forbid-params-properly, r=BoxyUwU
Use more principled check for generics in const ops

Fixes rust-lang/rust#144547.
Fixes rust-lang/rust#140891.

In the future, we likely want to make the check less likely to be missed by reducing the number of external entry points to HIR type lowering.

Note: If this causes pass->error regressions (not truly regressions because those cases were mistakenly accepted), they can easily be avoided for the time being by only running the check if `is_self_alias` is true or mgca is enabled.

- **Fix parsing of mgca const blocks in array repeat exprs**
- **Use more principled check for generics in const ops**
2026-01-02 02:23:07 +00:00
Noah Lev f71e93821e mgca: Re-merge split out tests
Now that we avoid a fatal error, they can all be one test.
2026-01-01 18:12:34 -08:00
Noah Lev c7e368543c Use more principled check for generics in const ops
Instead of using a visitor in typeck, we just check, whenever lowering a
use of a param, whether the parent item is an MCG anon const during hir
ty lowering (and instantiate_value_path). If so, we report an error
since MCG anon consts should never be able to use generics. All other
kinds of anon consts are at least syntactically allowed to use generic
params.

We use a `TypeFolder` to accomplish this; this way, we look at the
fully explicit semantic representation of the type/const/whatever and
don't miss subtle cases like `Self` type aliases.
2026-01-01 18:12:34 -08:00
Ryan bf2078bfca fix: add CHECK-SAME labels to verify generated function type for u8 and [u8; 1] cases
Co-authored-by: scottmcm <scottmcm@users.noreply.github.com>
2026-01-02 12:01:55 +10:30
Jonathan Brouwer ed5a529df1 Rollup merge of #150504 - AprilNEA:fix-99173, r=JonathanBrouwer
Add regression test for issue #99173

Close rust-lang/rust#99173.

Adds a regression test for rust-lang/rust#99173, which was an ICE that occurred when a proc-macro generated code that invoked another proc-macro returning an empty `TokenStream`.
2026-01-02 00:04:08 +01:00
Jonathan Brouwer 745368c7d8 Rollup merge of #150431 - cyrgani:nfc-proc-macro-test, r=nnethercote
test and document that `proc_macro::Ident` is NFC-normalized

Previously, this was not tested at all and the test suite would pass even when replacing the `normalize_and_validate_ident` implementation with a `panic!`.
2026-01-02 00:04:07 +01:00
Jonathan Brouwer 21d3df6268 Rollup merge of #150382 - estebank:git-markers-wording, r=nnethercote
Tweak wording of diff marker diagnostic
2026-01-02 00:04:07 +01:00
human9000 cddda032d5 test: modified bad-question-mark-on-trait-objects to match expected
behaviour
2026-01-02 00:57:43 +05:00
Flakebi 33add367e2 Add checks for gpu-kernel calling conv
The `gpu-kernel` calling convention has several restrictions that were
not enforced by the compiler until now.
Add the following restrictions:

1. Cannot be async
2. Cannot be called
3. Cannot return values, return type must be `()` or `!`
4. Arguments should be primitives, i.e. passed by value. More complicated
   types can work when you know what you are doing, but it is rather
   unintuitive, one needs to know ABI/compiler internals.
5. Export name should be unmangled, either through `no_mangle` or
   `export_name`. Kernels are searched by name on the CPU side, having
   a mangled name makes it hard to find and probably almost always
   unintentional.
2026-01-01 18:34:24 +01:00
Ryan Ward 80acf74fb6 test: added codegen tests for permutations of Option::or 2026-01-01 22:28:32 +10:30
bors cc08b553b8 Auto merge of #150563 - JonathanBrouwer:rollup-9ncjbou, r=JonathanBrouwer
Rollup of 2 pull requests

Successful merges:

 - rust-lang/rust#150454 (cleanup: move c-variadic arguments handling into compute_inputs_and_output)
 - rust-lang/rust#150529 (Update books)

r? `@ghost`
`@rustbot` modify labels: rollup
2026-01-01 11:09:18 +00:00
Jonathan Brouwer 36457ce8f9 Rollup merge of #150454 - tiif:move_variadic, r=oli-obk
cleanup: move c-variadic arguments handling into compute_inputs_and_output

Previously, ``unnormalized_input_tys`` needs to be mutable because the c_variadic arguments are added to ``unnormalized_input_tys`` outside of ``compute_inputs_and_output``. This could have been done together in ``compute_inputs_and_output``.
2026-01-01 12:04:16 +01:00
bors b49c7d784e Auto merge of #150523 - Kivooeo:add-check-for-u8, r=BoxyUwU
add check for `u8`s in `lit_to_const`

Fixes rust-lang/rust#131052

r? BoxyUwU
2026-01-01 07:53:41 +00:00
Kivooeo c6b03ae9b2 add check for u8s and update test 2026-01-01 02:24:05 +00:00
Jonathan Brouwer 71b17c5c18 Rollup merge of #150264 - RalfJung:target-feature-tracking-split, r=Amanieu
split up tracking issue for target feature feature gates

https://github.com/rust-lang/rust/issues/44839 is tracking too many things at once. We usually have a separate tracking issue for each feature gate, so let's do that here as well:

-  rust-lang/rust#150244
- rust-lang/rust#150245
- rust-lang/rust#150246
- rust-lang/rust#150247
- rust-lang/rust#150248
- rust-lang/rust#150249
- rust-lang/rust#150250
- rust-lang/rust#150251
- rust-lang/rust#150252
- rust-lang/rust#150253
- rust-lang/rust#150254
- rust-lang/rust#150255
- rust-lang/rust#150256
- rust-lang/rust#150257
- rust-lang/rust#150258
- rust-lang/rust#150259
- rust-lang/rust#150260
- rust-lang/rust#150261

Closes https://github.com/rust-lang/rust/issues/44839 in favor of the ones listed above.

r? `@Amanieu`
2026-01-01 02:47:20 +01:00
Esteban Küber 22bb4fe147 Detect cases where ? is applied on a type that could be coming from a different crate version than expected
```
error[E0277]: `?` couldn't convert the error to `dependency::Error`
  --> replaced
   |
LL | fn main() -> Result<(), Error> {
   |              ----------------- expected `dependency::Error` because of this
...
LL |     Err(Error2)?;
   |     -----------^ the trait `From<Error2>` is not implemented for `dependency::Error`
   |     |
   |     this can't be annotated with `?` because it has type `Result<_, Error2>`
   |
   = note: the question mark operation (`?`) implicitly performs a conversion on the error value using the `From` trait
help: the trait `From<Error2>` is not implemented for `dependency::Error`
      but trait `From<()>` is implemented for it
  --> replaced
   |
LL | impl From<()> for Error {
   | ^^^^^^^^^^^^^^^^^^^^^^^
   = help: for that trait implementation, expected `()`, found `Error2`
   = note: there are multiple different versions of crate `dependency` in the dependency graph
   = help: you can use `cargo tree` to explore your dependency tree
```

The existing checks rely on having access to the actual types/traits that diverged to detect they are called the same, come from different crates with the same name. The new check is less specific, merely looking to see if the crate name the involved type belongs has multiple crates.
2025-12-31 23:40:16 +00:00
bors 8d670b93d4 Auto merge of #150546 - JonathanBrouwer:rollup-jkqji1j, r=JonathanBrouwer
Rollup of 5 pull requests

Successful merges:

 - rust-lang/rust#146798 (RISC-V: Implement (Zkne or Zknd) intrinsics correctly)
 - rust-lang/rust#150337 (docs: fix typo in std::io::buffered)
 - rust-lang/rust#150530 (Remove `feature(string_deref_patterns)`)
 - rust-lang/rust#150543 (`rust-analyzer` subtree update)
 - rust-lang/rust#150544 (Use --print target-libdir in run-make tests)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-12-31 18:42:17 +00:00
Jonathan Brouwer 552918bfcd Rollup merge of #150544 - bjorn3:run_make_print_target_libdir, r=Urgau,jieyouxu
Use --print target-libdir in run-make tests

This makes the tests more robust against sysroot layout changes and slightly simplifies them.
2025-12-31 17:32:07 +01:00
Jonathan Brouwer 15c467ba0c Rollup merge of #150530 - Zalathar:string-deref-patterns, r=jackh726
Remove `feature(string_deref_patterns)`

The older `string_deref_patterns` feature has been superseded by the newer and more general `deref_patterns` feature. Removing string-deref-patterns allows us to get rid of a few tricky special cases in match lowering, which are different from the special cases used by deref-patterns.

The handful of existing tests for `string_deref_patterns` have been migrated to use `deref_patterns` instead. Current nightly users of the older feature should hopefully be able to migrate to the newer feature without too much trouble.

Note that `deref_patterns` is currently marked as an “incomplete” feature, because it doesn't have an accepted RFC. But `string_deref_patterns` doesn't appear to have ever had an accepted RFC either, so arguably it should have been marked incomplete too.

---
- Tracking issue for both features: https://github.com/rust-lang/rust/issues/87121
- Original implementation: https://github.com/rust-lang/rust/pull/98914
- [Zulip thread: Can we remove `#![feature(string_deref_patterns)]`?](https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/Can.20we.20remove.20.60.23!.5Bfeature.28string_deref_patterns.29.5D.60.3F/with/565787352)
2025-12-31 17:32:06 +01:00
Jonathan Brouwer dc103c4cd9 Rollup merge of #146798 - a4lg:riscv-intrinsics-zkne_or_zknd, r=Amanieu
RISC-V: Implement (Zkne or Zknd) intrinsics correctly

On rust-lang/stdarch#1765, it has been pointed out that two RISC-V (64-bit only) intrinsics to perform AES key scheduling have wrong target feature.
`aes64ks1i` and `aes64ks2` instructions require *either* Zkne (scalar cryptography: AES encryption) or Zknd (scalar cryptography: AES decryption) extension (or both) but corresponding Rust intrinsics (in `core::arch::riscv64`) required *both* Zkne and Zknd extensions.

An excerpt from the original intrinsics:

```rust
#[target_feature(enable = "zkne", enable = "zknd")]
```

To fix that, we need to:

1.  Represent a condition where *either* Zkne or Zknd is available and
2.  Workaround an issue: `llvm.riscv.aes64ks1i` / `llvm.riscv.aes64ks2` LLVM intrinsics require either Zkne or Zknd extension.

This PR attempts to resolve them by:

1.  Adding a perma-unstable RISC-V target feature: `zkne_or_zknd` (implied from both `zkne` and `zknd`) and
2.  Using inline assembly to construct machine code directly (because `zkne_or_zknd` alone cannot imply neither Zkne nor Zknd, we cannot use LLVM intrinsics).

The author confirmed that we can construct an AES key scheduling function with decent performance using fixed `aes64ks1i` and `aes64ks2` intrinsics (with optimization enabled).
2025-12-31 17:32:04 +01:00
bjorn3 1a4e7f9aa9 Use --print target-libdir in run-make tests
This makes the tests more robust against sysroot layout changes and
slightly simplifies them.
2025-12-31 15:15:28 +00:00
Martin Nordholts 55833a9a6d tests/codegen-llvm/some-non-zero-from-atomic-optimization.rs: New test 2025-12-31 15:22:07 +01:00
Jonathan Brouwer d898dccc21 Rollup merge of #150511 - Sa4dUs:offload-inline, r=ZuseZ4
Allow inline calls to offload intrinsic

Removes explicit insertion point handling and recovers the pointer at the end of the saved basic block.

r? `@ZuseZ4`

fixes: https://github.com/rust-lang/rust/issues/150413
2025-12-31 14:30:48 +01:00
Jonathan Brouwer 5183d8f15d Rollup merge of #150193 - Bryntet:parse_instruction_set, r=JonathanBrouwer
Port `#[instruction_set]` to attribute parser

Please note the test changes, and deprecation of `E0778` and `E0779`

In my opinion, all errors related to this attribute are improved I think, except for if you have `#[instruction_set(arm::)]` in which case there's an `error: expected identifier, found <eof>`, which is quite unhelpful I think, but this seems to be a limitation of the general attribute parsing flow

r? `@JonathanBrouwer`
2025-12-31 14:30:47 +01:00
Marcelo Domínguez 41a24c4b58 Add offload test for control flow handling 2025-12-31 13:11:28 +01:00
bors 2848c2ebe9 Auto merge of #147361 - saethlin:fallible-cycle-detection, r=oli-obk
Make inliner cycle detection a fallible process

The query `mir_callgraph_cyclic` is supposed to find _all_ callees that _may_ lead to a recursive call back to the given `LocalDefId`. But that query was built using a function which recurses through the call graph and tries to locally handle hitting the recursion limit during the walk. That is wrong. If the recursion limit is encountered, the set may be incomplete and thus useless. If we hit the recursion limit the only correct thing to do is bail.

Some benchmarks improve because for some functions we will bail out of the call graph walk faster. Some benchmarks regress because we do less inlining, but that is quite rare with the default recursion depth.

Originally I thought this might be a fix for https://github.com/rust-lang/rust/issues/131960, but it turns out that it is _actually_ a fix for https://github.com/rust-lang/rust/issues/146998.
2025-12-31 10:05:42 +00:00
Zalathar ef8d943ecd Remove feature(string_deref_patterns) 2025-12-31 14:21:38 +11:00
Ben Kimock cee7f5ed31 Add a regression test 2025-12-30 22:21:03 -05:00
Edvin Bryntesson acd6ba4edb Port #[instruction_set] to attribute parser 2025-12-31 03:01:05 +01:00
Jonathan Brouwer 4b49c9f9d8 Rollup merge of #150420 - h3fang:sve-debuginfo-fix, r=workingjubilee
Do not spill operand debuginfo to stack for AArch64 SVE predicates `<vscale x N x i1>` where `N != 16`

This pull request tries to fix rust-lang/rust#150419.

The debuginfo for AArch64 SVE predicates `<vscale x N x i1>` where `N != 16` should be ignored by this [commit](https://github.com/rust-lang/rust/pull/143924/changes/89eea57594e3e1d8e618dd530ea1c8e7c9b4c7a4).

https://github.com/rust-lang/rust/blob/89eea57594e3e1d8e618dd530ea1c8e7c9b4c7a4/compiler/rustc_codegen_ssa/src/mir/debuginfo.rs#L438-L452

But in line 446, the `marker_type.kind()` is `ty::Bool` instead of `ty::Slice`, so the code doesn't work as intended.

This pull request uses the [`Ty::scalable_vector_element_count_and_type`](https://github.com/rust-lang/rust/blob/main/compiler/rustc_middle/src/ty/sty.rs#L1272) method to fix the condition checks for  `<vscale x N x i1>` where `N != 16` and add a compiletest for this case.
2025-12-30 23:27:44 +01:00
Noah Lev 319735d8c9 Fix parsing of mgca const blocks in array repeat exprs
There was an inconsistency where in the case of array repeat
expressions, we forgot to eat the `const` keyword of mgca const blocks.
Thus, we ended up parsing them as an anon const containing an inline
const, instead of simply an anon const as they should be.

This commit fixes that issue and also makes the parsing for mgca const
blocks more consistent and simpler in general. For example, we avoid
doing a lookahead check to ensure there's a curly brace coming. There
should always be one after a `const` keyword in an expression context,
and that's handled by the mgca const block parsing function.
2025-12-30 11:30:31 -08:00
Jonathan Brouwer 4b6f783e32 Rollup merge of #150509 - AprilNEA:fix-137823, r=petrochenkov
Adds a regression test for #137823

Adds a regression test for rust-lang/rust#137823. The test ensures that recursive generic function instantiation properly triggers the recursion limit error instead of ICE-ing with `type variables should not be hashed`.

Closes rust-lang/rust#137823
2025-12-30 15:06:17 +01:00
AprilNEA 36f86f9e6a Adds a regression test for 137823 2025-12-30 19:52:02 +08:00