Commit Graph

56739 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
qaijuang 7aa831f47a preserve spans when hiding do_not_recommend impls 2026-05-17 16:12:40 -04:00
Jonathan Brouwer fc7ac3de0c Rollup merge of #156636 - Human9000-bit:mir-transform-ref, r=Kivooeo
minor `rustc_mir_transform` cleanup

Some minor things I noticed here and there while reading though code
2026-05-17 15:52:43 +02:00
Jonathan Brouwer 4cce8bcdc8 Rollup merge of #156635 - bb1yd:rename_unexpected_try_recover, r=JohnTitor
rename unexpected_try_recover function

While reading the code, the doc comment and the name of the function `unexpected_try_recover` confused me. The doc said it tries to recover if it is a closing delimiter but I see no recovering code and the function always return an error.

So I change the name of the function to `unexpected_err` and change the return value to `Diag<'a>`. I also update the doc comment.
2026-05-17 15:52:42 +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 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 b0c869a35e Rollup merge of #156596 - nnethercote:split-LintExpectation, r=GuillaumeGomez
Split `LintExpectationId`s

This PR makes clearer where stable and unstable `LintExpectationIds` can occur, plus a few other small cleanups. Details in individual commits.

r? @GuillaumeGomez
2026-05-17 15:52:37 +02:00
Jonathan Brouwer ff42fc00d4 Rollup merge of #156208 - BorrowSanitizer:codegen-emit-retag-1, r=saethlin
Emit retags in codegen to support BorrowSanitizer (part 1)

Tracking issue: rust-lang/rust#154760
[Zulip Thread](https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/Staging.20for.20emitting.20retags.20in.20codegen/with/593004012)

This is the first of several PRs that will add experimental support for emitting retags as function calls in codegen. Each PR will be a minimal, improved slice of the changes in rust-lang/rust#155965.

This PR contains all of the changes that will affect codegen backends. It adds methods to `IntrinsicCallBuilderMethods` for emitting each kind of retag call.

cc: @RalfJung
2026-05-17 15:52:36 +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 ee8949e513 Add FIXME for interior_mutability_suggestion 2026-05-17 15:03:24 +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
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
Nicholas Nethercote 6c9d519d37 Add some comments to ShallowLintLevelMap
Describing things that took me a while to work out.
2026-05-16 21:20:02 +10:00
Nicholas Nethercote 36738a1f0e Remove some low-value method wrappers
I find these make the code harder to understand.
2026-05-16 21:20:02 +10:00
Nicholas Nethercote 22cf1fb6fe Split LintExpectationId
`LintExpectationId` has two variants, `Unstable` and `Stable`. There are
some places where both variants are possible, but there are also places
where only one of `Unstable` or `Stable` is possible.

This commit encodes this into the type system by introducing
new types `UnstableLintExpectationId` and `StableLintExpectationId`. The
variants of `LintExpectationId` now enclose these. This makes it clearer
what values are possible where.

Other things of note:
- `LintLevelsProvider` gets an associated type and some method changes.
- `LintContext` gets an associated type.
- `LevelSpec` is made generic. `UnstableLevelSpec` and `StableLevelSpec`
  typedefs are added.
- The unstable types are now guaranteed by the type system to never be
  stably hashed. Previously this was a runtime check.
2026-05-16 21:16:35 +10:00
human9000 053761df0a minor rustc_mir_transform cleanup 2026-05-16 14:06:44 +05:00
b1yd 6d91f14af9 fix 2026-05-16 16:03:00 +08:00
Esteban Küber 5cd51c0edd Place comment in the right place 2026-05-16 00:33:43 +00:00
bors 3514361554 Auto merge of #156617 - JonathanBrouwer:rollup-M30TGcY, r=JonathanBrouwer
Rollup of 12 pull requests

Successful merges:

 - rust-lang/rust#148788 (Unconstrained parameter fix)
 - rust-lang/rust#156319 (Require EIIs to be defined when we compile a rust dylib)
 - rust-lang/rust#156452 (Implement pinned drop sugar)
 - rust-lang/rust#156554 (Allow user-provided `llvm_args` to override target spec arguments)
 - rust-lang/rust#156571 (Disable `main_needs_argc_argv` for Wasm)
 - rust-lang/rust#156600 (Make const param default test reproduce original ICE)
 - rust-lang/rust#156493 (actually run the temp_dir doctest)
 - rust-lang/rust#156556 (Require UTF-8 in `Utf8Pattern::StringPattern`)
 - rust-lang/rust#156565 (delegation: emit error when self type is not specified and accessed)
 - rust-lang/rust#156586 (Use DropCtxt::new_block and new_block_with_statements systematically.)
 - rust-lang/rust#156587 (Correctly handle associated items in rustdoc macro expansion)
 - rust-lang/rust#156604 (coverage: Reduce and clarify the context-mismatch test case)
2026-05-15 21:40:32 +00:00
Jonathan Brouwer 7e35a7ef98 Rollup merge of #156586 - cjgillot:elaborate-new-block, r=oli-obk
Use DropCtxt::new_block and new_block_with_statements systematically.

Misc cleanups I found while staring at that code.
2026-05-15 20:11:47 +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 e34cec62bb Rollup merge of #156571 - daxpedda:wasm-main, r=alexcrichton
Disable `main_needs_argc_argv` for Wasm

AFAIU this explains to the "Rust Runtime" that `main()` doesn't need `argc`/`argv`. Newer Wasm targets have explicitly disabled this, this PR changes it so that the base Wasm configuration affecting all Wasm targets disables this now.

This affects the following targets:
- `wasm32-unknown-unknown`
- `wasm32v1-none`
- `wasm64-unknown-unknown`

The only Wasm target where `main_needs_argc_argv` is still enabled is `wasm32-unknown-emscripten`. @hoodmane let me know and I can remove it there as well.

Credit goes to @Spxg for stumbling on this.

r? @alexcrichton
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
bors d7f14d3d89 Auto merge of #156218 - cjgillot:dest-prop-range, r=Amanieu
DestinationPropagation: compute liveness as ranges instead of traveling bitsets

The current implementation of `save_as_liveness` is very slow, and consists in inserting a traveling bitset in an interval set.

As the `MaybeLiveLocals` has a gen-kill property, we can leverage it to make it faster. "Gen" is creating a new interval. "Kill" is ending this interval, ripe to save in the interval set.
2026-05-15 18:05:42 +00:00
Ian McCormack e15861bdd2 Add trait methods for experimental retags to cg. 2026-05-15 12:34:03 -04: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
Waffle Lapkin 53a4efa5fb disallow target_has_atomic_primitive_alignment with no value 2026-05-15 12:26:13 +02:00
cijiugechu ecf01910d5 Avoid rustfix suggestions for macro-expanded unused imports 2026-05-15 17:43:09 +08:00
Nicholas Nethercote 40332688e0 Remove an unnecessary push argument
It's always `None`.
2026-05-15 17:57:58 +10:00
Nicholas Nethercote 19c6365110 Inline and remove late_lint_crate_inner
It has a single call site.
2026-05-15 17:56:27 +10: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
Camille Gillot 6e7b089cb9 Use DropCtxt::new_block and new_block_with_statements systematically. 2026-05-14 22:15:20 +00:00
Camille Gillot d76d4cd69e Untuple method parameters. 2026-05-14 22:15:20 +00:00
Camille Gillot 5a12d48b62 Prefer tracing::instrument. 2026-05-14 22:15:19 +00:00
daxpedda 1b7609cf1c Disable main_needs_argc_argv for Wasm 2026-05-14 19:06:32 +02:00
Pieter-Louis Schoeman 282ec28bf8 Implement pinned drop sugar 2026-05-14 16:54:53 +02:00