Commit graph

21912 commits

Author SHA1 Message Date
bors
6159a44067 Auto merge of #148434 - oli-obk:inherent-const-impl, r=fee1-dead
Inherent const impl

Some constifications are annoying because we need to repeat `T: Trait` bounds from an impl block on the individual constified `const fn`s as `T: [const] Trait`. We've brainstormed solutions before, and one would be to have separate `const impl` blocks or sth. However the final syntax will look, I decided to just impl this syntax and either have sth nice on nightly to work with or at least move the discussion along.

Also interacts with the discussion around `impl const Trait for Type` vs `const impl Trait for Type`, as we may want to use the latter to keep inherent and trait impls in sync (unless we come up with even another scheme).

* [ ] rustdoc + tests
* [ ] macro stability /regression tests

r? `@fee1-dead`

cc `@traviscross` `@rust-lang/project-const-traits`
2025-11-19 02:23:56 +00:00
bors
7c2c3c0ded Auto merge of #149063 - matthiaskrgr:rollup-6z23izv, r=matthiaskrgr
Rollup of 5 pull requests

Successful merges:

 - rust-lang/rust#147887 (Improve the documentation of atomic::fence)
 - rust-lang/rust#148281 (repr(transparent) check: do not compute check_unsuited more than once)
 - rust-lang/rust#148484 (Fix suggestion for the `cfg!` macro)
 - rust-lang/rust#149057 (`rust-analyzer` subtree update)
 - rust-lang/rust#149061 (debug-assert FixedSizeEncoding invariant)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-11-18 21:59:27 +00:00
Oli Scherer
b41c2a2870 Forbid const fn within const impls 2025-11-18 16:00:18 +00:00
Oli Scherer
ababa26251 Collect const_conditions for inherent impls 2025-11-18 16:00:18 +00:00
Oli Scherer
939afab37e Treat inherent methods in const impl blocks as const 2025-11-18 16:00:18 +00:00
Oli Scherer
00157d4a3d Allow inherent const impl blocks 2025-11-18 16:00:18 +00:00
Matthias Krüger
642300e339
Rollup merge of #148484 - JonathanBrouwer:wip_attr_style, r=jdonszelmann
Fix suggestion for the `cfg!` macro

r? `@jdonszelmann`
2025-11-18 16:52:11 +01:00
bors
3d461af2a2 Auto merge of #149059 - GuillaumeGomez:rollup-s6m2mmy, r=GuillaumeGomez
Rollup of 4 pull requests

Successful merges:

 - rust-lang/rust#148970 (std: sys: fs: uefi: Implement stat)
 - rust-lang/rust#149020 (flush_delayed: add note about stashed diagnostics)
 - rust-lang/rust#149026 (Add test for href of reexported enum variant)
 - rust-lang/rust#149049 (compiletest: Use JSON "binary-format" to decide `//@ only-elf` and `//@ ignore-elf`)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-11-18 14:07:46 +00:00
Guillaume Gomez
8642d82ff5 Add test for href of reexported enum variant 2025-11-18 12:23:32 +01:00
Guillaume Gomez
2a1bd47a4a Move tests/rustdoc/import_trait_associated_functions.rs into the reexport folder 2025-11-18 12:23:32 +01:00
Oli Scherer
2a36d33930 Give all impls a constness 2025-11-18 09:20:21 +00:00
Oli Scherer
08c391ca09 Temporarily allow const impl and impl const at the same time to migrate 2025-11-18 09:20:21 +00:00
Camille Gillot
e7991602ed Add THIR building test. 2025-11-18 00:32:51 +00:00
Camille Gillot
72444372ae Replace OffsetOf by an actual sum. 2025-11-18 00:10:03 +00:00
Matthias Krüger
0e0dac2efc
Rollup merge of #148865 - lcnr:gat-inference-hack, r=BoxyUwU
move GAT inference prevention hack

The structure of `fn assemble_and_merge_candidates` is quite messy and the differences between `Host` and `NormalizesTo` goals is large enough that we should split them entirely. Intend to change this for https://github.com/rust-lang/trait-system-refactor-initiative/issues/245 by mentoring someone: https://rust-lang.zulipchat.com/#narrow/channel/364551-t-types.2Ftrait-system-refactor/topic/ask.20for.20help/near/554696331. Think it's still fine to merge this PR without that larger change.

fixes https://github.com/rust-lang/trait-system-refactor-initiative/issues/256

r? `@BoxyUwU`
2025-11-17 18:07:33 +01:00
Matthias Krüger
3bc1eaa66a
Rollup merge of #148698 - tiif:const_query_cycle, r=BoxyUwU
Fix query cycle when encounter unevaluated const

Fixes https://github.com/rust-lang/trait-system-refactor-initiative/issues/249

In this PR, the environment is dropped when evaluating const that does not have any generic parameter to fix the query cycle.
2025-11-17 18:07:33 +01:00
bors
cc328c1238 Auto merge of #149013 - Zalathar:rollup-io1ddhc, r=Zalathar
Rollup of 11 pull requests

Successful merges:

 - rust-lang/rust#148505 (add larger test for `proc_macro` `FromStr` implementations)
 - rust-lang/rust#148752 (Constify `ManuallyDrop::take`)
 - rust-lang/rust#148757 (Constify `mem::take`)
 - rust-lang/rust#148855 (Error if an autodiff user does not set lto=fat)
 - rust-lang/rust#148912 (add note to `lines` docs about empty str behavior)
 - rust-lang/rust#148958 (Run codegen tests on a 32-bit target in PR CI)
 - rust-lang/rust#148994 (Abi compatibility test cleanup)
 - rust-lang/rust#148999 (Tweak Motor OS linker preset, fix `remote-test-server` for Motor OS)
 - rust-lang/rust#149004 (compiletest: Avoid race condition in file deletion)
 - rust-lang/rust#149008 (triagebot: remove jsha from notifications for rustdoc HTML)
 - rust-lang/rust#149010 (compiletest: Remove the "wasm32-bare" alias for `wasm32-unknown-unknown`)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-11-17 07:49:48 +00:00
Stuart Cook
06304ef100
Rollup merge of #149010 - Zalathar:wasm32-bare, r=jieyouxu
compiletest: Remove the "wasm32-bare" alias for `wasm32-unknown-unknown`

- Follow-up to https://github.com/rust-lang/rust/pull/148969

This "wasm32-bare" alias, understood by compiletest's `//@ ignore-wasm32-bare` and `//@ only-wasm32-bare` directives, dates all the way back to the original introduction of the `wasm32-unknown-unknown` target in https://github.com/rust-lang/rust/pull/45905.

But there is no compelling reason to use an alias instead of the full target name.

r? jieyouxu
2025-11-17 16:41:07 +11:00
Stuart Cook
b979e1ef06
Rollup merge of #148994 - folkertdev:abi-compatibility-cleanup, r=jieyouxu
Abi compatibility test cleanup

r? `@jieyouxu`

- moves `NonNull` (and some friends) into `minicore.rs` so it can be re-used.
- tests the abi compatibility of a couple more targets. It's useful to have a comprehensive overview of all ABIs that rust has some amount of support for, e.g. testing for c-variadic or guaranteed tail calls (cc https://github.com/rust-lang/rust/issues/148748)
2025-11-17 16:41:04 +11:00
Stuart Cook
e34ef247cc
Rollup merge of #148855 - ZuseZ4:autodiff-lto-error, r=bjorn3
Error if an autodiff user does not set lto=fat

Based on your feedback, I started to provide a nice error message for a lack of `lto=fat`, instead of us forcing it.

In a next step, we should replace  `RUSTFLAGS="-Zautodiff=Enable"` with another Cargo.toml setting, as discussed here: https://github.com/rust-lang/rust/issues/147487#issuecomment-3446558644

As another improvement, we should also figure out why rlib builds do not properly obey the fat=lto setting.

```````@bjorn3```````
2025-11-17 16:41:02 +11:00
Stuart Cook
2fbdc8a3ae
Rollup merge of #148505 - cyrgani:pm-tests, r=madsmtm
add larger test for `proc_macro` `FromStr` implementations

Currently, there are only few tests that check the output of `TokenStream::from_str` and `Literal::from_str` (which is somewhat understandable as the rustc implementation just delegates these calls to the parser). In preparation for both the standalone backend (rust-lang/rust#130856) which will probably need to reimplement this logic as well as for removing panics from these functions (rust-lang/rust#58736), this PR adds a test which shows the various messy ways of how these functions report errors and the return values for successful parses.
Followup PRs such as rust-lang/rust#147859 will change more and more of these "diagnostic + error"s into `LexErrors`.

The test structure with the extra module is used to allow reusing it later easily for the standalone backend.
2025-11-17 16:41:00 +11:00
bors
89fe96197d Auto merge of #148478 - RalfJung:rotating-funnel, r=Mark-Simulacrum
use funnel shift as fallback impl for rotating shifts

That lets us remove this gnarly implementation from Miri and const-eval.

However, `rotate_left`/`rotate_right` are stable as const fn, so to do this we have to `rustc_allow_const_fn_unstable` a bunch of const trait stuff. Is that a bad idea? Cc `@oli-obk` `@fee1-dead`
2025-11-17 04:36:16 +00:00
Zalathar
31902f3838 Remove the "wasm32-bare" alias for wasm32-unknown-unknown
There is no compelling reason to use this alias instead of the full target
name.
2025-11-17 14:11:07 +11:00
cyrgani
7194c921ca add larger test for proc_macro FromStr implementations 2025-11-16 23:14:51 +01:00
Matthias Krüger
46650a196f
Rollup merge of #148881 - folkertdev:cfg-select-codegen-naked, r=Mark-Simulacrum
use `cfg_select!` to pick assembly in codegen test

This makes it a bit easier to see what assembly is actually used.
2025-11-16 20:40:22 +01:00
Matthias Krüger
79d765ed38
Rollup merge of #148703 - pitaj:rangefrom-overflow_checks, r=Mark-Simulacrum
Use `overflow_checks` intrinsic so `IterRangeFrom` yields MAX before panicking in debug

Based on rust-lang/rust#128666. For your convenience, here is the [diff from that PR](https://github.com/pitaj/rust/compare/intrinsic-overflow_checks...pitaj:rust:rangefrom-overflow_checks).

When `overflow_checks` are enabled, the following code will output as shown
```rust
for n in std::range::RangeFrom::from(253_u8..) {
    println!("{n}");
}
// 253
// 254
// 255
// panic
```

Which is a change from the current behavior, where it will panic after printing 254.

This behavior was [requested by the libs team](https://github.com/rust-lang/rust/issues/125687#issuecomment-2151118208)

r? `@Mark-Simulacrum`
2025-11-16 20:40:22 +01:00
Folkert de Vries
96c64272e2
abi/compatibility: test some additional targets 2025-11-16 13:13:59 +01:00
Folkert de Vries
4fd0dc1050
move NonNull into minicore 2025-11-16 13:13:18 +01:00
bors
b25b6eab7f Auto merge of #148992 - Zalathar:rollup-c1aqvox, r=Zalathar
Rollup of 3 pull requests

Successful merges:

 - rust-lang/rust#145954 (stabilize extern_system_varargs)
 - rust-lang/rust#148962 (fix(span): track unnormalized source len for dep-info)
 - rust-lang/rust#148969 (compiletest: Don't apply "emscripten" directives to `wasm32-unknown-unknown`)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-11-16 10:19:40 +00:00
Stuart Cook
a528a58a19
Rollup merge of #145954 - RalfJung:syscall-c-variadics, r=jackh726
stabilize extern_system_varargs

Based on top of https://github.com/rust-lang/rust/pull/144066. This has been already FCP'd over there, but `@workingjubilee` has some concerns regarding "system" varargs specifically (IIUC).

Reference PR: https://github.com/rust-lang/reference/pull/2069.
2025-11-16 20:30:53 +11:00
bors
e1a2ec6051 Auto merge of #148259 - RalfJung:const-ptr-fragment, r=oli-obk
const-eval: fix and re-enable pointer fragment support

The pointer fragment support from https://github.com/rust-lang/rust/pull/144081 got disabled due to https://github.com/rust-lang/rust/issues/146291. This brings it back. To fix the issue, the per-byte provenance fragment tracking tracks *both* the provenance and raw address of the full pointer, so we can ensure that only fragments that are truly part of the same pointer are being merged.

r? `@oli-obk`
Cc `@theemathas`
Fixes https://github.com/rust-lang/const-eval/issues/72 again.
Also fixes https://github.com/rust-lang/rust/issues/147959.

`@traviscross` I assume this won't need another t-lang FCP since it already got FCP'd in rust-lang/rust#144081?
2025-11-16 07:09:45 +00:00
Peter Jaszkowiak
0e5c96c3ec IterRangeFrom: overflow panic after yielding MAX
check overflow after yielding MAX value
new `0_u8..` will yield `255` and only panic on the subsequent `next()`
2025-11-15 21:29:59 -07:00
Stuart Cook
e00af8be3d
Rollup merge of #148984 - Muscraft:update-annotate-snippets, r=Kivooeo
chore: Update annotate-snippets to 0.12.9

This PR updates `annotate-snippets` to `0.12.9`, which includes a fix for rust-lang/rust#148070.

fixes rust-lang/rust#148070
2025-11-16 14:40:06 +11:00
Stuart Cook
6ad2331ce8
Rollup merge of #148968 - scottmcm:try-block-brace-tests, r=Kivooeo
Add another *ExprWithBlock* test for `try` blocks

Looking to address this open item from rust-lang/rust#31436

> Add a test confirming that it's an `ExprWithBlock`, so works in a match arm without a comma

It turns out that rust-lang/rust#120540 addressed that one, but it made me think of this other case that probably ought to have some kind of test as well.
2025-11-16 14:40:05 +11:00
Stuart Cook
788788b37d
Rollup merge of #148956 - folkertdev:reenable-wasm-abi-test, r=bjorn3
re-enable wasm abi test

The `wasm32-unknown-unknown` ABI has been fixed for a while now https://github.com/rust-lang/rust/issues/115666, so this test can be re-enabled and the fixme removed.

r? ``@bjorn3``
2025-11-16 14:40:02 +11:00
Stuart Cook
38b534161c
Rollup merge of #148859 - ZhongyaoChen:fix-riscv-overflow-checks-test-fail, r=Mark-Simulacrum
Fix overflow-checks test for RISC-V target

The overflow-checks codegen test was failing on riscv64gc target because the FileCheck pattern did not account for ABI extension attributes. RISC-V LP64 ABI requires integer types smaller than XLEN (64-bit) to be zero-extended or sign-extended to register width.

For u8 parameters, RISC-V generates:
  i8 noundef zeroext %a, i8 noundef zeroext %b

While x86_64 and aarch64 generate:
  i8 noundef %a, i8 noundef %b

The original CHECK pattern only matched the format without the `zeroext` attribute, causing test failures on RISC-V.

This patch makes the zeroext attribute optional in the FileCheck pattern using `{{( zeroext)?}}`, allowing the test to pass on architectures that add ABI extension attributes (e.g., RISC-V).

Test results before fix:
- x86_64-unknown-linux-gnu: 3 passed
- aarch64-unknown-linux-gnu: 3 passed
- riscv64gc-unknown-linux-gnu: 1 passed, 2 failed

Test results after fix:
- x86_64-unknown-linux-gnu: 3 passed
- aarch64-unknown-linux-gnu: 3 passed
- riscv64gc-unknown-linux-gnu: 3 passed
2025-11-16 14:40:00 +11:00
Scott Schafer
463c6cea68
chore: Update annotate-snippets to 0.12.9 2025-11-15 14:45:21 -07:00
Scott McMurray
e10a7db4d4 Add another *ExprWithBlock* test for try blocks 2025-11-15 01:28:54 -08:00
Ralf Jung
324e47ba2b when writing a scalar pair, always reset the entire destination range 2025-11-15 10:09:43 +01:00
Ralf Jung
907fd85e16 const-eval: fix and re-enable pointer fragment support 2025-11-15 10:09:42 +01:00
bors
733108b6d4 Auto merge of #148706 - dianne:slightly-lazier-temporary-scoping, r=cjgillot
compute temporary scopes when building MIR, not THIR

This accomplishes two things:
- Makes the THIR slightly smaller by not attaching a full `TempLifetime` to every expression.
- Reduces the number of traversals of the `ScopeTree` by only calling `ScopeTree::temporary_scope` when building MIR for something that needs to be dropped in a temporary scope.
2025-11-15 04:33:47 +00:00
Folkert de Vries
583d5de732
re-enable wasm abi test 2025-11-15 00:17:14 +01:00
Stuart Cook
f61bfb0037
Rollup merge of #148725 - scottmcm:experiment-new-try-block-v3, r=petrochenkov
Implement the alternative `try` block desugaring

As discussed in https://github.com/rust-lang/rfcs/pull/3721#issuecomment-3208342727, update the `try` in nightly to match the RFC as a way to experiment.

This addresses the following unresolved issue from https://github.com/rust-lang/rust/issues/31436

>  Address issues with type inference (`try { expr? }?` currently requires an explicit type annotation somewhere).
2025-11-14 19:57:06 +11:00
Stuart Cook
bf7d5539f7
Rollup merge of #148638 - chenyukang:yukang-fix-148634-repr-simd-enum-ice, r=Kivooeo,lcnr
Fix ICE for repr simd on non struct

Fixes rust-lang/rust#148634

The ICE happened because
995c11894f/compiler/rustc_middle/src/ty/mod.rs (L1531)

will always set `IS_SIMD` according to `get_all_attrs`, and since we already report error `attribute should be applied to a struct`, it's OK to bypass here.
2025-11-14 19:57:06 +11:00
bors
c880acdd31 Auto merge of #148931 - Zalathar:rollup-yfyhpcw, r=Zalathar
Rollup of 15 pull requests

Successful merges:

 - rust-lang/rust#148543 (Correctly link to associated trait items in reexports)
 - rust-lang/rust#148808 (Some resolve cleanups)
 - rust-lang/rust#148812 (coverage: Associate hole spans with expansion tree nodes )
 - rust-lang/rust#148826 (CStr docs: Fix CStr vs &CStr confusion)
 - rust-lang/rust#148850 (Implement `Read::read_array`)
 - rust-lang/rust#148867 (Refactor `Box::take`)
 - rust-lang/rust#148870 (Remove unused LLVMModuleRef argument)
 - rust-lang/rust#148878 (error when ABI does not support guaranteed tail calls)
 - rust-lang/rust#148901 (Disable rustdoc-test-builder test partially for SGX target.)
 - rust-lang/rust#148902 (add missing s390x target feature to std detect test)
 - rust-lang/rust#148904 (waffle: stop watching codegen ssa)
 - rust-lang/rust#148906 (Expose fmt::Arguments::from_str as unstable.)
 - rust-lang/rust#148907 (add assembly test for infinite recursion with `become`)
 - rust-lang/rust#148928 (Move & adjust some `!`-adjacent tests)
 - rust-lang/rust#148929 (ignore `build-rust-analyzer` even if it's a symlink)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-11-14 05:29:52 +00:00
yukang
1610851356 add Tainted for NonAsmTypeReason 2025-11-14 12:42:50 +08:00
Scott McMurray
e5803fceed Move into_try_type to a free function 2025-11-13 19:53:02 -08:00
Stuart Cook
1c32a0b6bb
Rollup merge of #148928 - WaffleLapkin:always-test, r=jieyouxu
Move & adjust some `!`-adjacent tests

I'm trying to clean up tests relating to the never type...
2025-11-14 13:14:10 +11:00
Stuart Cook
6bbc4cb995
Rollup merge of #148907 - folkertdev:tail-call-infinite-recursion, r=WaffleLapkin
add assembly test for infinite recursion with `become`

tracking issue: https://github.com/rust-lang/rust/issues/112788
fixes https://github.com/rust-lang/rust/issues/125698

Check that infinite recursion via `become` does not grow the stack (even on opt-level 0). The incomplete implementation of `become` did not guarantee that earlier. Although it's unlikely this ever regresses we may as well test it and close the issue.

r? ```@WaffleLapkin```
2025-11-14 13:14:08 +11:00
Stuart Cook
79e10134cf
Rollup merge of #148901 - sardok:disable_rustdoc_test_builder_sgx, r=GuillaumeGomez
Disable rustdoc-test-builder test partially for SGX target.

The `rustdoc-test-builder` test started to fail after https://github.com/rust-lang/rust/pull/148608 for SGX target. The reason is, sgx binary can not be executed directly so rustdoc fails to execute passed `--test-builder` binary. This PR simply ignores the success part just like it is ignore for `wasm` target.
2025-11-14 13:14:06 +11:00