Commit Graph

25793 Commits

Author SHA1 Message Date
bors 1f8e04d34a Auto merge of #156727 - abdul2801:docs, r=GuillaumeGomez
Fix jump-to-def links broken by turbofish syntax

Fixes rust-lang/rust#156706
2026-05-20 02:37:03 +00:00
bors 4b9792692f Auto merge of #156589 - cuviper:revert-dbg-tearing, r=the8472
Revert tearing changes to `dbg!`

Since the primary change to `dbg!` in rust-lang/rust#149869, we've been chasing a few regressions:

* rust-lang/rust#153850, fixed by rust-lang/rust#154074
* rust-lang/rust#154988, fixed by rust-lang/rust#154994
* rust-lang/rust#155902, proposed fix in rust-lang/rust#155915

We already reverted this once, on beta only to prevent these regressions from shipping in 1.95.

In that most recent PR, we decided that it would be better to revert `dbg!` to its original state everywhere (`main` and 1.96-`beta`), and then we can consider it from scratch later. So here I've reverted the change and its fixes, but kept the regression tests, including the pending one.

cc @joboet @dianne @rust-lang/libs 
@rustbot label beta-nominated
2026-05-19 23:24:13 +00:00
abdul2801 afedb8727e Update turbofish.rs 2026-05-19 19:29:13 +05:30
Jonathan Brouwer 3a0c6e932c Rollup merge of #156578 - eval-exec:mir-opt-build-correct-coerce-filecheck, r=TaKO8Ki
Add FileCheck for build_correct_coerce

part of rust-lang/rust#116971
2026-05-19 15:04:44 +02:00
Jonathan Brouwer 9283c8e59b Rollup merge of #156547 - danieljofficial:move-tests-closures, r=adwinwhite
Move tests closures

Hi, I have moved a few closures related tests. Please review them when you can find the time. This is a part of [133895](https://github.com/rust-lang/rust/issues/133895)
2026-05-19 15:04:43 +02:00
Abdul Rafey Ahmed c454d92f61 fix: improve turbofish jump-to-def handling
Handle turbofish syntax correctly in rustdoc jump-to-def links
and add regression tests covering type aliases.
2026-05-19 16:20:38 +05:30
bors 9eb3be26b4 Auto merge of #156720 - JonathanBrouwer:rollup-vArjiS4, r=JonathanBrouwer
Rollup of 13 pull requests

Successful merges:

 - rust-lang/rust#156709 (stdarch subtree update)
 - rust-lang/rust#155006 (stabilize `feature(cfg_target_has_atomic_equal_alignment)`)
 - rust-lang/rust#156444 (Implement `OsStr::split_at`)
 - rust-lang/rust#156582 (Allow `global_asm!` in statement positions)
 - rust-lang/rust#156661 (Remove `UncheckedIterator`)
 - rust-lang/rust#152367 (Derives `Copy` for `ffi::FromBytesUntilNulError`)
 - rust-lang/rust#156443 (Fix invalid suggestion for parenthesized break)
 - rust-lang/rust#156606 (Add pext/pdep as aliases for extract_bits/deposit_bits)
 - rust-lang/rust#156630 (Replace `println!` with `assert!` in HashMap documentation examples)
 - rust-lang/rust#156644 (Widen the result of `widening_mul`.)
 - rust-lang/rust#156653 (Update `sysinfo` version to `0.39.2`)
 - rust-lang/rust#156697 (Add diagnostic items for IoBufReader and StdinLock)
 - rust-lang/rust#156704 (reduce usage of `box_patterns` in tests)
2026-05-18 18:00:20 +00:00
Jonathan Brouwer 7c3bc86405 Rollup merge of #156704 - cyrgani:unbox-tests, r=mu001999
reduce usage of `box_patterns` in tests

Part of https://github.com/rust-lang/rust/issues/156110.
2026-05-18 17:07:14 +02:00
Jonathan Brouwer e7d5c0a9ef Rollup merge of #156443 - el-ev:fix-break-sugg, r=ShoyuVanilla
Fix invalid suggestion for parenthesized break

Resolves rust-lang/rust#156383

The old code incorrectly assumed `e.span` started exactly at the beginning of `break`. Fixed by locating the exact start position of `break`.
2026-05-18 17:07:09 +02:00
Jonathan Brouwer 59eda84e03 Rollup merge of #156582 - daxpedda:global-asm-statement, r=petrochenkov
Allow `global_asm!` in statement positions

This PR makes it possible to put `global_asm!` in statement positions. This is particularly useful for proc-macros, where you otherwise have to wrap them in `mod foo { global_asm!(...); }`.

I'm happy to open an ACP first (or a design meeting?).
I would also assume this needs sign-off from the lang-team?

Previously discussed on [Zulip](https://rust-lang.zulipchat.com/#narrow/channel/216763-project-inline-asm/topic/Item.20position.20global_asm/with/581784943).

r? @Amanieu
2026-05-18 17:07:06 +02:00
Jonathan Brouwer 33d6fe7a9a Rollup merge of #155006 - WaffleLapkin:stabilize_cfg_target_has_atomic_equal_alignment, r=Urgau
stabilize `feature(cfg_target_has_atomic_equal_alignment)`

See stabilization report: https://github.com/rust-lang/rust/issues/93822#issuecomment-4192399374
cc @joshtriplett
2026-05-18 17:07:04 +02:00
daxpedda 450cdb5501 Allow global_asm! in statement positions 2026-05-18 16:02:56 +02:00
Jacob Pratt 4037dda3ef Rollup merge of #156708 - aerooneqq:delegation-in-constant-body, r=petrochenkov
Add test for delegation inside const body

Fixes rust-lang/rust#155300 (it does not produce ICE anymore). Part of rust-lang/rust#118212.

r? @petrochenkov
2026-05-18 13:53:00 +02:00
Jacob Pratt 9a88f9f74f Rollup merge of #156664 - ManiSalahmand:fix-doc-comment-generic-tuple, r=petrochenkov
Avoid const generic recovery after doc comment in type

Fixes rust-lang/rust#122463.

When parsing a generic argument, rustc may snapshot the parser state and retry a failed type parse as an unbraced const generic argument. For `Vec<(/// doc
f32, f32)>`, that recovery produces a misleading follow-up E0747 after the useful “expected type, found doc comment” diagnostic.

This skips that const-generic recovery path when type parsing stopped at a doc comment, and adds a regression test for the compiler diagnostic.
2026-05-18 13:52:56 +02:00
Jacob Pratt 41ab1f8af7 Rollup merge of #156705 - aerooneqq:delegation-error-gen-no-node-id, r=petrochenkov
delegation: visit path under elided-infer lifetime rib

Up to this moment we processed delegation path under `LifetimeRibKind::Generics` which is not correct as we are processing generic args of a future call, not generic params. In this PR we visit path under
`LifetimeRibKind::Elided(LifetimeRes::Infer)`.

Fixes rust-lang/rust#156342. Part of rust-lang/rust#118212.

r? @petrochenkov
2026-05-18 13:52:55 +02:00
aerooneqq 7336e19799 Add test for delegation inside const body 2026-05-18 14:25:50 +03:00
aerooneqq 34c536c594 Visit delegation path under elided-infer lifetime rib 2026-05-18 13:43:30 +03:00
cyrgani 7450bf099e reduce usage of box_patterns in tests 2026-05-18 10:14:41 +00:00
bors a31c27a887 Auto merge of #156681 - JonathanBrouwer:rollup-wC7f2r6, r=JonathanBrouwer
Rollup of 13 pull requests

Successful merges:

 - rust-lang/rust#156196 (Include vendored sources in the rust-src component)
 - rust-lang/rust#155870 (Fix cross-compiling `macos-deployment-target-warning` test)
 - rust-lang/rust#156492 (remove/update various cfg(miri))
 - rust-lang/rust#156676 (Preserve spans when hiding do_not_recommend impls)
 - rust-lang/rust#155313 (doc(core::cmp::Eq): fix definition of symmetry)
 - rust-lang/rust#156234 (implement `into_array` for `Vec<T>`)
 - rust-lang/rust#156488 (Fix missing period in Iterator product doc comment)
 - rust-lang/rust#156572 (std: replace "safe" with "sound" in safety documentation)
 - rust-lang/rust#156624 (c ffi document fixes for c_short.md)
 - rust-lang/rust#156638 (library: Fix std compilation for espidf target in unix::process)
 - rust-lang/rust#156647 (Change division to multiplication in floating-point midpoint)
 - rust-lang/rust#156668 (Fix typo in `format_into` docs: signed -> unsigned)
 - rust-lang/rust#156677 (change `other uses of const` to `raw pointers` in const keyword docs)
2026-05-18 01:35:23 +00:00
Jonathan Brouwer 04d8b94a09 Rollup merge of #156676 - qaijuang:diagnostics-do-not-recommend-span, r=chenyukang
Preserve spans when hiding do_not_recommend impls

Fixes rust-lang/rust#156475 by restoring the root span only when the current refined span has wandered outside the parent obligation.
2026-05-18 03:19:45 +02:00
Jonathan Brouwer 1f9aa27a9e Rollup merge of #155870 - madsmtm:fix-test-arm64e, r=chenyukang
Fix cross-compiling `macos-deployment-target-warning` test

`cc()` gets target flags, which won't match with the host triple used by `bare_rustc()`.

Follow-up to https://github.com/rust-lang/rust/pull/155716, with both of these, `./x test --target arm64e-apple-darwin tests` now succeeds.

r? compiler
2026-05-18 03:19:43 +02:00
Mani Salahmand 3cc1e44225 Add issue reference to regression test 2026-05-17 23:54:13 +02:00
qaijuang 7aa831f47a preserve spans when hiding do_not_recommend impls 2026-05-17 16:12:40 -04:00
qaijuang 7442ae735d add red test 2026-05-17 16:12:19 -04:00
Jonathan Brouwer c340b0a28e Rollup merge of #156633 - eval-exec:issue-41261-regression-test, r=mu001999
Add regression test for issue #41261

Adds a regression test for rust-lang/rust#41261.
2026-05-17 15:52:42 +02:00
Jonathan Brouwer 06763ba095 Rollup merge of #156616 - notriddle:rustdoc-ui-test-cli, r=GuillaumeGomez
rustdoc: add test case for `-Drustdoc::` and `--cap-lints`

This works, but I couldn't find any test cases for it.
2026-05-17 15:52:41 +02:00
Jonathan Brouwer 9e8d48c551 Rollup merge of #156598 - cijiugechu:decl-macro-diag, r=mu001999
Avoid rustfix suggestions for macro-expanded unused imports

Avoid emitting rustfix suggestions for unused imports when the removal span is not directly editable.

Closes rust-lang/rust#147855
2026-05-17 15:52:40 +02:00
Jonathan Brouwer ded0aaba6c Rollup merge of #156585 - InvalidPathException:llvm-error, r=folkertdev
explicit tail calls: ignore some tests on unsupported LLVM targets

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

Add ignore derivatives to two tests that cause the most platforms to fail, there are two reasons:

All tests involving `musttail` should fail on these platforms due to poor support overall by LLVM, but since they have low usage and supposedly already have many tests failing we limit ignores to the two "worst" tests.

```
//@ ignore-aix
//@ ignore-csky
//@ ignore-mips
//@ ignore-mips64
//@ ignore-powerpc
//@ ignore-powerpc64
//@ ignore-thumb
```

aix/powerpc issue: https://github.com/llvm/llvm-project/issues/187119
thumb issue: https://github.com/llvm/llvm-project/issues/73167
mips has been fixed but it is in a different LLVM version than what is pinned by Rust: https://github.com/llvm/llvm-project/issues/57795

These were caused by argument/returns that do not fit in registers (e.g., indirect), they had a fix but were reverted due to lifetime issues:

```
//@ ignore-riscv64
//@ ignore-loongarch32
//@ ignore-loongarch64
```

RISC-V had a fix which got reverted: https://github.com/llvm/llvm-project/pull/191508
LoongArch fix also got reverted: https://github.com/llvm/llvm-project/pull/191525

Also add missing compiletest directive names for `ignore-csky`, `ignore-mips`, and `ignore-mips64`.

r? folkertdev
2026-05-17 15:52:40 +02:00
Jonathan Brouwer 4babf87ac3 Rollup merge of #156577 - AsakuraMizu:eii-default-dynamic, r=mejrs
Test EII UI tests with prefer-dynamic

Tracking issue: rust-lang/rust#125418

Remove `no-prefer-dynamic` from the EII UI tests now that rust-lang/rust#153648 fixed exporting EII declaration aliases from dylibs.

Fixes rust-lang/rust#151271.

Tested with:

```sh
python3 x.py test tests/ui/eii --force-rerun
```
2026-05-17 15:52:39 +02:00
Jonathan Brouwer 4bb85516e8 Rollup merge of #156376 - euclio:foreign-escapes, r=mu001999
suggest hex escapes for C-style escapes

Fixes rust-lang/rust#148884.
2026-05-17 15:52:38 +02:00
Jonathan Brouwer fe32c706ed Rollup merge of #156121 - thiago-fealves:suggest-collect-string, r=estebank
compiler: suggest `.collect()` when `String` is expected and `Iterator` is found

This commit adds a diagnostic suggestion to help users who forget to call `.collect()` when they have an iterator and the function or variable expects a `String`.

The logic checks if the expected type is `std::string::String` and if the found type implements the `Iterator` trait, if so the compiler provides a suggestion to add `.collect()`

Includes also a UI test to verify if the suggestion appears correctly
2026-05-17 15:52:35 +02:00
Jonathan Brouwer 9de8fa9347 Rollup merge of #151362 - JohnTitor:interior-mutability-sugg, r=estebank
Add interior-mutability suggestion to `static_mut_refs`

Closes https://github.com/rust-lang/rust/issues/151131
r? @estebank

I've skipped to expand catching below code as a mutable _reference_ shouldn't be involved (maybe a new lint would be needed?):
```rs
static mut COUNTER: u64 = 0;
fn main() {
    unsafe { COUNTER = 1 };
}
```
2026-05-17 15:52:35 +02:00
Jonathan Brouwer 346f43e2aa Rollup merge of #151742 - moulins:variant-layout, r=saethlin
Remove redundant information in `rustc_abi::Variants`

Follow-up to rust-lang/rust#151040; partially addresses rust-lang/rust#113988.

Replaces the nested `LayoutData` in `Variants::Multiple` by a new, smaller `VariantLayout` struct, and adjust `LayoutData::for_variant`and the layout algorithm in consequence.
This PR is best reviewed commit-by-commit.
2026-05-17 15:52:34 +02:00
Mani Salahmand 0564168895 Avoid const generic recovery after doc comment in type 2026-05-17 14:32:47 +02:00
Yuki Okushi 33d92f7b52 Add test for the case span is unavailable 2026-05-17 14:58:25 +09:00
Yuki Okushi cbaee5df1b Tweak note condition 2026-05-17 14:09:51 +09:00
Yuki Okushi 2071c66f19 Add interior-mutability suggestion to static_mut_refs 2026-05-17 14:09:51 +09:00
Mark Z. Ding 04c325f16e ignore some musttail tests on unsupported LLVM targets 2026-05-17 00:18:09 -04:00
bors 281c97c324 Auto merge of #156518 - estebank:match-rustfmt, r=mejrs
[style] rustfmt `match`es with comments in or-patterns

Using https://github.com/rust-lang/rustfmt/pull/6893, I reformatted the whole codebase. The result is that `match`es that *should have* been formatted under normal circumstances but are getting skipped now got their expected format. These match expressions were being entirely skipped because they contain or-patterns with comments in between patterns, causing rustfmt to bail out entirely. The or-patterns with comments themselves remain untouched, but now the match arm bodies and other patterns without comments do get formatted under that PR.

Because the fix in rustfmt isn't landed yet, I reworked some of the or-patterns with comments so that formatting doesn't regress. Tried doing this only in larger blocks that are more likely to regress in the meantime.

(Introduced and) removed a bunch of stray backticks \` likely left after an editor autoclosed the intended closing \`, resulting in <code>\`name\`\`</code> in comments.
2026-05-17 01:27:37 +00:00
Andy Russell e5998316eb suggest hex escapes for C-style escapes 2026-05-16 20:23:53 -04:00
bors d3cd04068e Auto merge of #152449 - GuillaumeGomez:rustdoc-bang-attr-macro, r=lolbinarycat,mejrs
rustdoc: properly support macros with multiple kinds



Since it seems like I can't reopen https://github.com/rust-lang/rust/pull/145458, opening this one. Although, it's the same PR minus the last new commit to handle a comment that was left unresolved in the original PR. All relevant details are still in the original PR though.

It's an alternative (and likely a take-over) of https://github.com/rust-lang/rust/pull/148005 since lang-team rejected the idea to add documentation on macro branches, making the multiple files approach less suitable.

This implements rust-lang/rust#145153 in rustdoc. This PR voluntarily doesn't touch anything related to intra-doc links, I'll send a follow-up if needed.

So now about the implementation itself: this is a weird case where a macro can be different things at once but still only gets one file generated. I saw two ways to implement this:
1. Handle `ItemKind::Macro` differently and iter through its `MacroKinds` values.
2. Add new placeholder variants in the `ItemKind` enum, which means that when we encounter them in rendering, we need to ignore them. It also makes the `ItemKind` enum bigger (and also needs more code to be handled). Another downside is that it needs to be handled in the JSON output.

Now there was an interesting improvement that came with this PR in the `html::render::print_item::item_module` function: I simplified its implementation and split the different parts in a `HashMap` where the key is the item type. So then, we can just iterate through the keys and open/close the section at each iteration instead of keeping an `Option<section>` around.

From RFCs:
* https://github.com/rust-lang/rust/pull/144579
* https://github.com/rust-lang/rust/pull/145208

derive:

<img width="442" height="327" alt="Screenshot From 2026-04-18 03-11-40" src="https://github.com/user-attachments/assets/f69587a0-8a2b-4080-bc8a-b63dd18f21c1" />

attr:

<img width="442" height="327" alt="Screenshot From 2026-04-18 03-11-31" src="https://github.com/user-attachments/assets/bf9b235a-9d2f-435c-a91e-167562df6b68" />

both:

<img width="442" height="327" alt="Screenshot From 2026-04-18 03-11-50" src="https://github.com/user-attachments/assets/b7e8b3c6-eb99-495b-bdf9-17ba8fb4da0d" />

r? @notriddle
2026-05-16 18:54:36 +00:00
Eval Exec 87821d9f78 Add regression test for issue 41261 2026-05-16 03:46:30 -04:00
朝倉水希 124126e083 Test EII UI tests with prefer-dynamic 2026-05-16 03:08:00 +08:00
Michael Howell 0344a02261 rustdoc: add test case for --cap-lints=allow 2026-05-15 11:13:16 -07:00
Jonathan Brouwer d1da72ad21 Rollup merge of #156604 - Zalathar:context-mismatch, r=mu001999
coverage: Reduce and clarify the context-mismatch test case

Most of the complexity in this test case isn't needed to reproduce the condition observed in https://github.com/rust-lang/rust/issues/147339.

I have checked that this reduced test case still triggers the context-mismatch in `extract_refined_covspans`.
2026-05-15 20:11:49 +02:00
Jonathan Brouwer 6708081d6b Rollup merge of #156587 - GuillaumeGomez:assoc-items-macro-expansion, r=Urgau
Correctly handle associated items in rustdoc macro expansion

Fixes rust-lang/rust#156075.

The bug was simply that it didn't cover associated items.

r? @Urgau
2026-05-15 20:11:48 +02:00
Jonathan Brouwer 04c0c8ddde Rollup merge of #156565 - aerooneqq:delegation-self-type-ice, r=petrochenkov
delegation: emit error when self type is not specified and accessed

This PR adds error reporting when we create error self type if it was not specified. In most of the tests there were other errors, so this delayed bug was not triggered, but there are cases like `reuse Default::default;` (rust-lang/rust#156388) which does not emit other errors and those delayed bugs are triggered.

Part of rust-lang/rust#118212. Fixes rust-lang/rust#156388.

r? @petrochenkov
2026-05-15 20:11:47 +02:00
Jonathan Brouwer df20e79dfc Rollup merge of #156600 - cijiugechu:false-negative-test, r=BoxyUwU
Make const param default test reproduce original ICE

As discussed in [comment](https://github.com/rust-lang/rust/pull/156325#discussion_r3247360505).

ICE using old logic:
[old-logic-ice.txt](https://github.com/user-attachments/files/27797628/old-logic-ice.txt)

r? BoxyUwU
2026-05-15 20:11:44 +02:00
Jonathan Brouwer 11af4fc167 Rollup merge of #156554 - guybedford:wasm-use-legacy-eh, r=alexcrichton
Allow user-provided `llvm_args` to override target spec arguments

This switches the order in which `-Cllvm-args` is applied between target-spec arguments and user-provided LLVM arguments.

This came up in rust-lang/rust#156061, where the target passing `-Cllvm-args=-wasm-use-legacy-eh=false` means that a user passing `-Cllvm-args=-wasm-use-legacy-eh=true` cannot override this value since the LLVM arguments support the last argument overriding the previous, and user arguments were chained first.

With this change, it is possible for Wasm targets to opt into legacy EH for compatibility with runtimes that don't yet implement the modern exnref/try_table instructions, such as Node.js 20 on V8 11.3 and older browsers. While Node.js 20 is formally EOL, many libraries will still need to support this version for a few months yet, so this would ease the transition path to modern exception handling having an opt-out.

Originally this PR added support for a dedicated `-Z` flag for switching to legacy exception handling, but fine-grained control over the arguments would be a preferable solution provided it does not conflict with other behaviours.

//cc @alexcrichton
2026-05-15 20:11:43 +02:00
Jonathan Brouwer a29e5e14c9 Rollup merge of #156452 - P8L1:implement-pin-drop-sugar-upstream, r=petrochenkov
Implement pinned drop sugar

Implements `fn drop(&pin mut self)` as sugar for `Drop::pin_drop`.

The resolver recognizes `fn drop(&pin mut self)` syntactically in trait impls and performs lookup using the effective `pin_drop` name. AST lowering independently rechecks the syntactic sugar, validates that the resolved item belongs to the actual `Drop` lang trait, and emits HIR with ident `pin_drop` for accepted sugar. Existing type checking, Drop validation, drop glue, and direct-call checks remain unchanged.

Drop identity is checked during AST lowering through `tcx.lang_items().drop_trait()`, after resolver has performed the effective `pin_drop` lookup. The resolver does not need to know whether the trait is the actual `Drop` lang item, and it no longer passes marked impl item IDs to lowering.

This intentionally preserves the base pinned-drop behavior where `#[pin_v2]` types must use `pin_drop`, while non-`#[pin_v2]` types may still implement `pin_drop`.

r? @petrochenkov

## Related

https://github.com/rust-lang/rust/pull/144537
https://github.com/rust-lang/rust/issues/130494
2026-05-15 20:11:42 +02:00