Commit Graph

25771 Commits

Author SHA1 Message Date
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
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
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
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
Jonathan Brouwer 1a3ed2e62d Rollup merge of #156319 - bjorn3:eii_dylib_require_def, r=jdonszelmann
Require EIIs to be defined when we compile a rust dylib

The linker will complain about undefined symbols otherwise and on object file formats with two level namespaces (Mach-O and PE/COFF) it is required to know which dylib a symbol will be imported from when linking a dylib or executable.

r? @jdonszelmann
2026-05-15 20:11:41 +02:00
Jonathan Brouwer 62c2da091b Rollup merge of #148788 - TomtheCoder2:unconstrained-parameter-fix, r=davidtwco
Unconstrained parameter fix

This PR is an attempt to solve the issue described in the issue rust-lang/rust#107295
2026-05-15 20:11:41 +02:00
Michael Howell 5f2e455a1c rustdoc: add test case for -Drustdoc:: CLI param
This works, but I couldn't find any test cases for it.
2026-05-15 10:46:35 -07:00
bjorn3 860813dd9d Require EIIs to be defined when we compile a rust dylib
The linker will complain about undefined symbols otherwise and on object
file formats with two level namespaces (Mach-O and PE/COFF) it is
required to know which dylib a symbol will be imported from when linking
a dylib or executable.
2026-05-15 15:49:35 +02:00
Zalathar 5d15124c62 coverage: Reduce and clarify the context-mismatch test case 2026-05-15 22:06:32 +10:00
cijiugechu d24fd77ebe Make const param default test reproduce original ICE 2026-05-15 18:32:42 +08:00
Waffle Lapkin 53a4efa5fb disallow target_has_atomic_primitive_alignment with no value 2026-05-15 12:26:13 +02:00
cijiugechu 209ee9daac use edition 2021 2026-05-15 17:49:33 +08:00
cijiugechu 9d769128a7 comment for issue id 2026-05-15 17:49:11 +08:00
cijiugechu ecf01910d5 Avoid rustfix suggestions for macro-expanded unused imports 2026-05-15 17:43:09 +08:00
Moulins 75015f405a Remove per-variant alignment in VariantLayout
Reusing the alignment of the enclosing enum in `LayoutData::for_variant`
doesn't appear to cause any issues.
2026-05-15 04:34:51 +02:00
Moulins 3459964408 Remove unused VariantLayout.randomization_seed field
This field is only used during layout calculations, so re-synthetized
`LayoutData`s for enum variants can use a dummy value instead.
2026-05-15 04:34:51 +02:00
Moulins 0569574938 Store FieldsShape::Arbitrary fields directly in VariantLayout
Enum variants always have `Arbitrary` layout, so the enum isn't needed.
2026-05-15 04:34:51 +02:00
Moulins 1162bdc1f3 Remove redundant VariantLayout.variants field
It was always set to `Variants::Single`.
2026-05-15 04:34:48 +02:00
Moulins 464dc07de2 Introduce VariantLayout struct
For now, this is a 1-to-1 copy of `LayoutData`, but this will change.
2026-05-15 04:34:17 +02:00
Guillaume Gomez 899be9fe47 Add regression tests for associated items in rustdoc macro expansion 2026-05-15 00:42:17 +02:00
Pieter-Louis Schoeman 282ec28bf8 Implement pinned drop sugar 2026-05-14 16:54:53 +02:00