Commit Graph

25629 Commits

Author SHA1 Message Date
Guillaume Gomez d0ff143b06 Correctly generate bang macro declaration in docs for attr/derive kinds 2026-05-10 02:37:58 +02:00
Guillaume Gomez 9b2fecbfe9 Handle new kinds of macros at once 2026-05-10 02:37:57 +02:00
Guillaume Gomez afcada6d03 Fix link to attr/derive bang macros 2026-05-10 02:37:57 +02:00
Guillaume Gomez f2e8de7962 Add search test for new macro kinds 2026-05-10 02:37:57 +02:00
Guillaume Gomez 72abf90d22 Deduplicate "attributes" and "attribute macros" sections IDs 2026-05-10 02:37:57 +02:00
Guillaume Gomez 0299472949 Add tests for attribute bang macros in rustdoc 2026-05-10 02:37:57 +02:00
Jacob Pratt 80263e17a3 Rollup merge of #156235 - rajgandhi1:compiler_stack_overflow_fix, r=adwinwhite
fix: Guard SizeSkeleton::compute against stack overflow

Fixes rust-lang/rust#156137

Fix: extract the recursion into a private `compute_inner` that carries a depth counter. When depth exceeds the crate's recursion limit, return `LayoutError::Unknown` and let the existing transmute size-check produce a normal error instead of crashing.

A regression test is included in `tests/ui/transmute/`.
2026-05-09 09:27:58 -04:00
Jacob Pratt 71e64b9d25 Rollup merge of #156124 - nnethercote:StableHash-renamings-2, r=jieyouxu
Make stable hashing names consistent (part 2)

This PR finishes the implementation of MCP 893.

r? @jieyouxu
2026-05-09 09:27:58 -04:00
rajgandhi1 7a900df1b9 Guard SizeSkeleton::compute against stack overflow 2026-05-09 16:02:15 +05:30
Matthias Krüger eabe4620e5 Rollup merge of #156333 - TaKO8Ki:fix-dotdotdot-rest-pattern-unicode-span, r=Urgau
Avoid invalid spans in dotdotdot rest pattern suggestions

Fixes rust-lang/rust#156316

The parser recovers Unicode confusables such as `···` as `...`, while keeping the original source span over the multibyte characters.

`recover_dotdotdot_rest_pat` built its suggestion by subtracting `BytePos(1)` from the end of that recovered token span. For multibyte characters, that can create a span boundary inside a UTF-8, causing diagnostic emission to ICE.

This changes the suggestion to replace the whole recovered token span with `..` instead of slicing off one byte.
2026-05-08 20:39:27 +02:00
Matthias Krüger b2cdfa26e4 Rollup merge of #156306 - danieljofficial:move-tests-consts, r=TaKO8Ki
Move tests consts

Hi I have moved some tests from ui/issues into the fitting ui/consts folder

Fixes a part of rust-lang/rust#133895
2026-05-08 20:39:26 +02:00
Matthias Krüger 62396df898 Rollup merge of #156244 - el-ev:issue156060, r=mu001999
fix incorrect suggestions in private import diagnostic

Resolves rust-lang/rust#156060.

1. In nested imports like `use two::{One, ...}`, the diagnostic suggested replacing the `One` with a multi-segment path of a different module, producing invalid code like `use crate::two::{one::One, Two}`. Skip it when `single_nested == true`.
2. Stop unconditionally skipping the first segment of `import.module_path`, which can produce incorrect paths in edition 2018 and later.
3. Mark the suggestion as "directly" instead of "through the re-export" when the import's source is the definition itself.
2026-05-08 20:39:25 +02:00
Takayuki Maeda e2b66ef351 add regression test for unicode dotdotdot rest pattern 2026-05-09 01:27:23 +09:00
bors 8068e2fc9a Auto merge of #156324 - JonathanBrouwer:rollup-HKA8242, r=JonathanBrouwer
Rollup of 4 pull requests

Successful merges:

 - rust-lang/rust#156246 (Introduce a `RerunNonErased` error type mirroring `NoSolution`, to better track when we're bailing)
 - rust-lang/rust#156038 (turn `compute_goal_fast_path` into a single match)
 - rust-lang/rust#156291 (Treat MSVC "performing full link" message as informational)
 - rust-lang/rust#156301 (Avoid ICE when suggesting as_ref for ill-typed closure receivers)
2026-05-08 14:56:56 +00:00
Jonathan Brouwer 01cccf92dc Rollup merge of #156301 - TaKO8Ki:fix-156299-closure-receiver-suggestion-ice, r=wesleywiser
Avoid ICE when suggesting as_ref for ill-typed closure receivers

Fixes rust-lang/rust#156299

When building mismatch suggestions, `can_use_as_ref` may inspect the receiver of a method call that is itself an ill-typed closure expression. In that recovery path, the receiver may not have a recorded type in `TypeckResults`.

Use `expr_ty_opt` instead of `expr_ty` so the optional `as_ref()` suggestion is skipped when the receiver type is unavailable.
2026-05-08 16:18:42 +02:00
Jonathan Brouwer fbc52c9ecf Rollup merge of #156291 - kupiakos:msvc-link-info, r=jyn514,mati865
Treat MSVC "performing full link" message as informational

When the MSVC incremental linker finds a .ilk file for incremental linking but its associated .exe file is missing, this message is printed to stdout:

```text
LINK : ...\foo.exe not found or not build by the last incremental link; performing full link
```

However, if both the .ilk and .exe files are missing (for a clean build), the message isn't printed and it still does a full link. So, the presence of the message doesn't affect the result of the build.

See rust-lang/rust#156209 for further context.

r? @mati865
cc @jyn514
2026-05-08 16:18:41 +02:00
Iris Shi 6d5fc3275f combine tests into one file 2026-05-08 20:42:22 +08:00
Jana Dönszelmann 180725cff6 consistently encode failure reason (nosolution or rerun) in the error type 2026-05-08 14:35:58 +02:00
Iris Shi a28de9fb1c update tests 2026-05-08 18:30:23 +08:00
danieljofficial 2a119e8c4f add issue links and bless 2026-05-08 10:36:04 +01:00
Jonathan Brouwer 565ee37312 Rollup merge of #156214 - qaijuang:fix-lints-that-dont-need-to-run-incr, r=nnethercote
Do not cache `lints_that_dont_need_to_run` across sessions

The `lints_that_dont_need_to_run` query depends on the lint store (which includes internal lints under `-Zunstable-options`). Because that flag is deliberately not part of the incremental command-line hash, incremental builds could load stale results from sessions with a different lint configuration, leading to an ICE.

This PR marks the query `eval_always` so it is recomputed for the current session instead of being loaded from cache.

Fixes rust-lang/rust#156182.
2026-05-08 11:35:34 +02:00
Jonathan Brouwer 6133b7e062 Rollup merge of #155734 - qaijuang:cfg-select-doc-comment, r=JonathanBrouwer
Reject outer attributes on `cfg_select` branches

Fixes rust-lang/rust#155701.
2026-05-08 11:35:31 +02:00
Jonathan Brouwer c6fbd9f8a7 Rollup merge of #154498 - RalfJung:option-deprecations, r=fmease
turn some long-deprecated -C options into errors

- `-Car` has been documented to do nothing for more than 8 years (https://github.com/rust-lang/rust/commit/691ab6c5bf597e98a4bae94b9a433f029f9ca9c1)  and causes a warning for more than a year (https://github.com/rust-lang/rust/pull/135126).
- `-Cno-stack-check` has been made a NOP and deprecated with a warning more than 9 years ago (https://github.com/rust-lang/rust/commit/c670293630611cdf677cfc5bc9a17ba378f78b84)
- `-Cinline-threshold` has been made a NOP and deprecated with a warning almost 2 years ago (https://github.com/rust-lang/rust/pull/124712).

With them being ignored there's always a risk someone thinks they'll do something and they don't notice the warning. I think these have been deprecated for long enough that we can turn them into hard errors.

Also change the type of these fields to `()` so there's no information here that the rest of the compiler could use. This supersedes the `rustc_lint_opt_deny_field_access` trick.

MCP: https://github.com/rust-lang/compiler-team/issues/978
2026-05-08 11:35:31 +02:00
Jonathan Brouwer bc8c0ed9ec Rollup merge of #156298 - joshtriplett:extend-to-widen, r=nia-e
Rename the unstable integer `extend` function to `widen`

This is consistent with our use of `widening` elsewhere.

Suggested-by: Gabriel Bjørnager Jensen <gabriel@achernar.io>
2026-05-08 11:35:30 +02:00
Qai Juang d42a92b18d Reject outer attributes on cfg_select branches
* Lint doc comments in cfg_select branches
* test with multi-line doc comment

Co-authored-by: Copilot <copilot@github.com>
* Reject outer attributes on `cfg_select` branches
* address nits and gotchas

Co-authored-by: Copilot <copilot@github.com>
* one more test

Co-authored-by: Copilot <copilot@github.com>
* avoid snapshotting and classify recovered doc comments directly
2026-05-08 09:14:09 +00:00
Ralf Jung bb4615d68a adjust tests for these removed features 2026-05-08 08:40:40 +02:00
Takayuki Maeda 83d39fbaa3 add regression test for closure receiver suggestion ICE 2026-05-08 15:05:49 +09:00
Josh Triplett 024032e66b Rename the unstable integer extend function to widen
This is consistent with our use of `widening` elsewhere.

Suggested-by: Gabriel Bjørnager Jensen <gabriel@achernar.io>
2026-05-07 22:44:22 -07:00
Nicholas Nethercote d24bd323db Rename tests/ui-fulldeps/hash-stable-is-unstable.*
Part of MCP 983.
2026-05-08 15:22:41 +10:00
bors 3e353d7353 Auto merge of #156274 - lokirithm:reorg-tests-03, r=wesleywiser
Reorg tests 03

| old-name | new-sub-dir | new-name |
|-|-|-|
| `issue-38727.rs` [issue](https://github.com/rust-lang/rust/issues/38727) | `abi/` | `return-ref-as-immediate-in-codegen.rs` |
| `issue-38437.rs` [issue](https://github.com/rust-lang/rust/issues/38437) | `mir/` | `reset-discriminant-drop-flag-on-partial-move.rs` |
| `issue-31910.rs` [issue](https://github.com/rust-lang/rust/issues/31910) | `associated-consts/` | `associated-const-in-enum-discriminant.rs` |
| `issue-31910.stderr` | `associated-consts/` | `associated-const-in-enum-discriminant.stderr` |
| `issue-48159.rs` [issue](https://github.com/rust-lang/rust/issues/48159) | `packed/` | `packed-c-style-struct.rs` |

r? Kivooeo
2026-05-08 05:02:55 +00:00
Nicholas Nethercote ad6647f904 Rename the span_hash_stable method as stable_hash_span.
Likewise for the corresponding incremental test.

Part of MCP 983.
2026-05-08 14:37:20 +10:00
Iris Shi 1ad59ef182 mark the suggestion as directly when it is 2026-05-08 10:42:03 +08:00
bors 63b1dfc0e0 Auto merge of #156290 - JonathanBrouwer:rollup-PNM9rEm, r=JonathanBrouwer
Rollup of 6 pull requests

Successful merges:

 - rust-lang/rust#156061 (Support `-Cpanic=unwind` on WASI targets)
 - rust-lang/rust#151753 (Experiment: Reborrow traits)
 - rust-lang/rust#156280 (Add regression test for closure return ICE)
 - rust-lang/rust#152487 (core: drop unmapped ZSTs in array `map`)
 - rust-lang/rust#153759 (Add a suite of ChunkedBitSet union/subtract/intersect test scenarios)
 - rust-lang/rust#156198 (Add `sync` option to `-Z threads` to force synchronization on one thread)
2026-05-07 23:03:11 +00:00
Alyssa Haroldsen 39c766e310 Treat MSVC "performing full link" message as informational
When the MSVC incremental linker finds a .ilk file for incremental
linking but its associated .exe file is missing, this message is
printed to stdout in 1 line:

LINK : ...\foo.exe not found or not build by the last incremental link;
performing full link

However, if both the .ilk and .exe files are missing (for a clean
build), the message isn't printed and it still does a full link. So, the
presence of the message doesn't affect the result of the build.
2026-05-07 13:59:23 -07:00
Jonathan Brouwer e56e388df9 Rollup merge of #156280 - TaKO8Ki:issue-155893-closure-return-ice, r=lqd
Add regression test for closure return ICE

Fixes rust-lang/rust#155893
2026-05-07 22:44:04 +02:00
Jonathan Brouwer 96e4153100 Rollup merge of #151753 - aapoalas:aapoalas/reborrow-and-coerce-shared-first-version, r=oli-obk
Experiment: Reborrow traits

With this PR we now have basic functional Reborrow and CoerceShared traits. The current limitations are:

1. Reborrowable types can only have one lifetime parameter, so as to avoid having to figure out and store in rmeta the information of which lifetimes weaken during reborrowing.
2. Reborrowing of `&mut` wrappers is working (though I've not tested generic wrappers like `Option<&mut T>` yet), but CoerceShared of `&mut` wrappers currently causes an ICE.

The remaining tasks to complete before I'd consider this PR mergeable are:

- [x] Fix ICE on CoerceShared. Unfortunately this might require dipping into rmeta.
- [x] Expand the tests to give a more complete view of the current state of the experiment.

Reborrow traits experiment: rust-lang/rust#145612

Co-authored by @dingxiangfei2009
2026-05-07 22:44:03 +02:00
Jonathan Brouwer 71597bc71c Rollup merge of #156061 - alexcrichton:unwinding-onw-asi, r=bjorn3
Support `-Cpanic=unwind` on WASI targets

This commit is some minor updates/restructuring in a few locations with the end result being supporting `-Cpanic=unwind` on WASI targets. This continues to be off-by-default insofar as WASI targets default to `-Cpanic=abort`, meaning that actually using anything in this commit requires `-Zbuild-std`. Specifically the changes made here are:

* The self-contained sysroot for WASI targets now contains a copy of `libunwind.a` from wasi-sdk, first shipped with wasi-sdk-33 (also updated here).
* The `unwind` crate here in this repository uses the `libunwind` module instead of the custom bare-metal wasm implementation of exceptions. This means that Rust uses the `_Unwind_*` symbols which allows it to interoperate with C/C++/etc.
* Wasm targets are all updated to pass the LLVM argument `-wasm-use-legacy-eh=false` to differ from LLVM's/clang's default of using the legacy exception handling proposal for WebAssembly. This has no effect by default because `panic=abort` is used on most targets. Emscripten is exempted from this as the Emscripten target is explicitly intended to follow LLVM's/clang's defaults.
* There's a single test in the test suite that links to the `panic_unwind` crate which ended up requiring `-Wexceptions` from Wasmtime, so the test parts were updated and Wasmtime was updated in CI, too.

The net result of all of this is that this should not actually affect any WebAssembly target's default behavior. Optionally, though, WASI programs can be built with exception handling via:

    RUSTFLAGS='-Cpanic=unwind' cargo +nightly run -Z build-std --target wasm32-wasip2

Effectively `-Zbuild-std` and `-Cpanic=unwind` is all that's necessary to enable this support on wasm targets.

Finally, this ends up closing rust-lang/rust#154593 as well. The WASI targets are now defined to use `-lunwind` to implement unwinding. This means that the in-tree definition of `__cpp_exception` is no longer of concern and the definition is always sourced externally. If Rust is linked with other C/C++ code using WASI then these idioms are compatible with wasi-sdk, for example, to use that as a linker. The main caveat is that when using an external linker the `-fwasm-exceptions` argument needs to be passed to `clang` for it to be able to find the `libunwind.a` library to link against.

Closes rust-lang/rust#154593
2026-05-07 22:44:02 +02:00
Alex Crichton 506693e7d6 Support -Cpanic=unwind on WASI targets
This commit is some minor updates/restructuring in a few locations with
the end result being supporting `-Cpanic=unwind` on WASI targets. This
continues to be off-by-default insofar as WASI targets default to
`-Cpanic=abort`, meaning that actually using anything in this commit
requires `-Zbuild-std`. Specifically the changes made here are:

* The self-contained sysroot for WASI targets now contains a copy of
  `libunwind.a` from wasi-sdk, first shipped with wasi-sdk-33 (also
  updated here).
* The `unwind` crate here in this repository uses the `libunwind` module
  instead of the custom bare-metal wasm implementation of exceptions.
  This means that Rust uses the `_Unwind_*` symbols which allows it to
  interoperate with C/C++/etc.
* Wasm targets are all updated to pass the LLVM argument
  `-wasm-use-legacy-eh=false` to differ from LLVM's/clang's default of
  using the legacy exception handling proposal for WebAssembly. This has
  no effect by default because `panic=abort` is used on most targets.
  Emscripten is exempted from this as the Emscripten target is
  explicitly intended to follow LLVM's/clang's defaults.
* There's a single test in the test suite that links to the
  `panic_unwind` crate which ended up requiring `-Wexceptions` from
  Wasmtime, so the test parts were updated and Wasmtime was updated in
  CI, too.

The net result of all of this is that this should not actually affect
any WebAssembly target's default behavior. Optionally, though, WASI
programs can be built with exception handling via:

    RUSTFLAGS='-Cpanic=unwind' cargo +nightly run -Z build-std --target wasm32-wasip2

Effectively `-Zbuild-std` and `-Cpanic=unwind` is all that's necessary
to enable this support on wasm targets.

Finally, this ends up closing 154593 as well. The WASI targets are now
defined to use `-lunwind` to implement unwinding. This means that the
in-tree definition of `__cpp_exception` is no longer of concern and the
definition is always sourced externally. If Rust is linked with other
C/C++ code using WASI then these idioms are compatible with wasi-sdk,
for example, to use that as a linker. The main caveat is that when using
an external linker the `-fwasm-exceptions` argument needs to be passed
to `clang` for it to be able to find the `libunwind.a` library to link
against.

Closes 154593
2026-05-07 12:51:29 -07:00
bors f964de49bc Auto merge of #149468 - chenyukang:yukang-fix-ice-149278, r=lcnr
Skipping borrowck because of trivial const



r? @saethlin

the [assertion](https://github.com/chenyukang/rust/blob/31c38576a4cf1a0864af536f62d11f829db1c7c8/compiler/rustc_mir_transform/src/lib.rs#L424) is added in PR: https://github.com/rust-lang/rust/pull/148040

I think we also need to skip trvial const in `mir_borrowck`.
2026-05-07 19:45:59 +00:00
Aapo Alasuutari 2d88ee87dd Reborrow traits 2026-05-07 21:55:44 +03:00
danieljofficial dcaef5f688 move consts ui tests into its folder 2026-05-07 17:42:25 +01:00
Iris Shi 05b97f76a4 address review comment 2026-05-07 23:43:25 +08:00
bors ffccab6abe Auto merge of #156278 - JonathanBrouwer:rollup-O8O1IcI, r=JonathanBrouwer
Rollup of 10 pull requests

Successful merges:

 - rust-lang/rust#146273 (lint ImproperCTypes: refactor linting architecture (part 2))
 - rust-lang/rust#154025 (Add `keepalive`, `set_keepalive` to `TcpStream` implementations)
 - rust-lang/rust#156024 (CFI: Fix LTO for `#![no_builtins]` crates with CFI)
 - rust-lang/rust#156243 (Move CrateInfo computation after codegen_crate)
 - rust-lang/rust#154846 (Add better default spans for the `Ty` impl of `QueryKey`)
 - rust-lang/rust#155220 (cg_clif: Don't show verbose run-make cmd output for passing tests)
 - rust-lang/rust#156204 (Implemented `PathBuf::into_string`)
 - rust-lang/rust#156245 (Move invocation_temp into OutputFilenames)
 - rust-lang/rust#156250 (add a few new solver normalization tests)
 - rust-lang/rust#156265 (Remove unused `ToStableHashKey` impls.)
2026-05-07 14:59:29 +00:00
Takayuki Maeda ddddb4d109 add regression test for closure return ICE 2026-05-07 23:33:00 +09:00
yukang 8e1f263f66 Skipping borrowck because of trivial const 2026-05-07 22:18:58 +08:00
Jonathan Brouwer 80af49a07f Rollup merge of #156250 - lqd:normalization-tests, r=lcnr
add a few new solver normalization tests

As discussed [on zulip](https://rust-lang.zulipchat.com/#narrow/channel/364551-t-types.2Ftrait-system-refactor/topic/ask.20for.20help/near/593097133), this PR adds the handful of new solver revisions and tests from https://github.com/rust-lang/trait-system-refactor-initiative/issues/139. Most cases that issue mentions were already fixed by https://github.com/rust-lang/rust/pull/140672 in 1.88, and some cases, we expect, by https://github.com/rust-lang/rust/pull/155767.

The issue about defaulted type parameters applies to both solvers and will be tracked in https://github.com/rust-lang/rust/issues/156271 instead.

Closes https://github.com/rust-lang/trait-system-refactor-initiative/issues/139.

r? lcnr
I'm not sure where the best place for the tests would be, do you have a better location in mind?
2026-05-07 14:13:55 +02:00
Jonathan Brouwer ce44b53e77 Rollup merge of #154846 - Zoxc:ty-def-span, r=lcnr
Add better default spans for the `Ty` impl of `QueryKey`

This add default spans for `Ty` in its implementation of `QueryKey`. This is useful so we can get spans for the `layout_of`  query which shows up in cycle errors.
2026-05-07 14:13:52 +02:00
Jonathan Brouwer c5941a03a2 Rollup merge of #156243 - bjorn3:lto_refactors18, r=mu001999
Move CrateInfo computation after codegen_crate

CrateInfo is only necessary during linking and non-local LTO.

Part of https://github.com/rust-lang/compiler-team/issues/908
2026-05-07 14:13:51 +02:00
Jonathan Brouwer 25494215e7 Rollup merge of #156024 - rcvalle:rust-cfi-fix-142284, r=bjorn3
CFI: Fix LTO for `#![no_builtins]` crates with CFI

Fixes LTO for `#![no_builtins]` crates with CFI enabled by using rustc's `EmitObj::Bitcode` path (and emitting LLVM bitcode in the `.o` for linker-based LTO).

It also adds tests that verify that the examples in [rust-cfi-examples](https://github.com/rcvalle/rust-cfi-examples) build and run with `-Zbuild-std` to prevent other future regressions.
2026-05-07 14:13:51 +02:00
bors 32bd660612 Auto merge of #156267 - jhpratt:rollup-xaL6466, r=jhpratt
Rollup of 12 pull requests

Successful merges:

 - rust-lang/rust#156173 (Fewer global node_id_to_def_id lookups)
 - rust-lang/rust#156177 (windows/time: avoid being too close to 0)
 - rust-lang/rust#155961 (Deny warnings in the test for crates that are available on stable)
 - rust-lang/rust#155981 (Use special DefIds for aliases)
 - rust-lang/rust#156130 (Fold/visit tweaks)
 - rust-lang/rust#156131 (Metadata macro/query cleanups)
 - rust-lang/rust#156202 (llvm: Use correct type for splat mask)
 - rust-lang/rust#156223 (Refactor `Type::size` field to `TypeId::size` method for `type_info`)
 - rust-lang/rust#156227 (Add Trusty OS to the generic error implementation.)
 - rust-lang/rust#156237 (compiletest: prevent directives from having multiple revisions)
 - rust-lang/rust#156241 (Move tests coercion)
 - rust-lang/rust#156258 (Document wasi-sdk minimum versions for WASI targets)
2026-05-07 11:51:24 +00:00