Commit Graph

56581 Commits

Author SHA1 Message Date
Jonathan Brouwer 7843355462 Rollup merge of #156384 - Zalathar:pretty-def-id, r=tiif
Remove some dead code for dumping MIR for a single DefId

The functions that call `dump_mir_def_ids` are themselves never called with a specific DefId; they always dump MIR for the entire crate.
2026-05-11 10:29:20 +02:00
Jonathan Brouwer a466915cd8 Rollup merge of #156372 - RalfJung:allows_weak_linkage, r=oli-obk
remove allows_weak_linkage target spec flag

The flag doesn't actually do anything. I have no idea what it's original purpose was.

It got introduced in https://github.com/rust-lang/rust/commit/59cfe904dcfbe2c3ad5396131b3d3ba6b7179fdd, but already a few months later in https://github.com/rust-lang/rust/commit/57950982b27c6ab45509c1f2db4a01fa1d2cfebb both of its uses were removed when the entire file `src/librustc_trans/closure.rs` got deleted.

It seems like back in the day we used weak linkage for closures by default and MinGW wasn't happy about that? But not much later the way we compile closures got changed, making the work-around unnecessary. The flag has then persisted unused for 10 years. A couple of Windows/UEFI targets are setting `allows_weak_linkage: false` but I assume that was just cargo-culted.

But to be sure, let's ping the folks listed for the affected targets and other Windows folks:
@dvdhrm @nicholasbishop @Berrysoft @mati865 @thomcc  @tbu- @ChrisDenton
2026-05-11 10:29:19 +02:00
Jonathan Brouwer 8880b2ce0e Rollup merge of #156406 - petrochenkov:modata2, r=nnethercote
resolve: Module-related refactorings

Extracted parts of https://github.com/rust-lang/rust/pull/156362 that don't require splitting `(Local,Extern)ModuleData` into separate data structures.

- Some `expect_local` assertions are added
- Methods that need to exist on all of `Module` and `(Local,Extern)Module` are implemented for `ModuleData`
- Methods that need to exist on `ModuleKind` are moved to `ModuleKind`
- Some unnecessary complicated logic using `graph_root` is simplified
-  `glob_importers` are filled and used only for local modules.
- Some unnecessary logic is skipped for extern modules in `resolve_ident_in_module_non_globs_unadjusted`
- Module construction functions are cleaned up
- `module_to_string` is simplified

r? @nnethercote
2026-05-11 10:29:16 +02:00
Jonathan Brouwer f57cc28c76 Rollup merge of #156147 - Manishearth:icu4xup, r=Mark-Simulacrum
Update ICU4X to 2.2

Needs a data regen.
2026-05-11 10:29:15 +02:00
bors 4b0c9d76ae Auto merge of #156405 - JonathanBrouwer:rollup-yJcad1j, r=JonathanBrouwer
Rollup of 10 pull requests

Successful merges:

 - rust-lang/rust#156394 (miri subtree update)
 - rust-lang/rust#154972 (Implement `core::arch::return_address` and tests)
 - rust-lang/rust#155679 (rustdoc: Reify emission types)
 - rust-lang/rust#155982 (Fix closure HIR span context mismatch)
 - rust-lang/rust#156323 (Handle --print=backend-has-mnemonic in cg_clif)
 - rust-lang/rust#156387 (std fs tests: avoid matching on OS-provided error string)
 - rust-lang/rust#156129 (compiletest: Migrate from `PassMode`/`FailMode` to `PassFailMode`)
 - rust-lang/rust#156192 (core: Replace `ptr::slice_from_raw_parts` with `slice::from_raw_parts`)
 - rust-lang/rust#156365 (stream_send_recv_stress tests: wait for threads to finish)
 - rust-lang/rust#156368 (Fix invalid unreachable in is_known_valid_scrutinee for Reborrow)
2026-05-10 19:58:51 +00:00
Vadim Petrochenkov a07cc548e4 resolve: Module-related refactorings 2026-05-10 20:11:34 +03:00
Jonathan Brouwer cfd0d4c150 Rollup merge of #156368 - aapoalas:reborrow-in-match-statement, r=Nadrieril
Fix invalid unreachable in is_known_valid_scrutinee for Reborrow

Fixes rust-lang/rust#156304

Part of the Reborrow traits experiment rust-lang/rust#145612
2026-05-10 19:05:48 +02:00
Jonathan Brouwer 5246f6e4bc Rollup merge of #156323 - bjorn3:clif_has_mnemonic, r=wesleywiser
Handle --print=backend-has-mnemonic in cg_clif

And introduce a `has_mnemonic` method on `CodegenBackend` just like `--print=backend-has-zstd`.
2026-05-10 19:05:44 +02:00
Jonathan Brouwer 29961709f1 Rollup merge of #155982 - cijiugechu:gio-ice-repro, r=chenyukang
Fix closure HIR span context mismatch

Ensure span has the closure expression's SyntaxContext.

Closes rust-lang/rust#155724
2026-05-10 19:05:44 +02:00
Jonathan Brouwer 30ec142b97 Rollup merge of #154972 - chorman0773:return_address, r=Mark-Simulacrum
Implement `core::arch::return_address` and tests

Tracking issue: rust-lang/rust#154966

Implements libs-team#768
2026-05-10 19:05:42 +02:00
bors e8f92f5769 Auto merge of #144537 - frank-king:feature/pin-drop, r=petrochenkov
Add `Drop::pin_drop` for pinned drops





This PR is part of the `pin_ergonomics` experiment (the tracking issue is rust-lang/rust#130494). It allows implementing `Drop` with a pinned `self` receiver, which is required for safe pin-projection.

Implementations:
- [x] At least and at most one of `drop` and `pin_drop` should be implemented.
- [x] No direct call of `drop` or `pin_drop`. They should only be called by the drop glue.
- [x] `pin_drop` must and must only be used with types that support pin-projection (i.e. types with `#[pin_v2]`).
- [ ] Allows writing `fn drop(&pin mut self)` and desugars to `fn pin_drop(&pin mut self)`. (Will be in the next PRs)
2026-05-10 16:43:01 +00:00
bors 99eed207b4 Auto merge of #156185 - petrochenkov:queffvis, r=mu001999
resolve: Evaluate private visibilities eagerly in eff vis computation

It's cheaper to evaluate them now when `Decl`arations keep their parent modules.
2026-05-10 09:28:26 +00:00
Aapo Alasuutari 5c0718be11 fix(reborrow): invalid unreachable in is_known_valid_scrutinee 2026-05-10 11:07:30 +03:00
Zalathar 9d01bf83f9 Remove some dead code for dumping MIR for a single DefId 2026-05-10 17:18:35 +10:00
bors d1961bebe0 Auto merge of #156378 - matthiaskrgr:rollup-NO89xfV, r=matthiaskrgr
Rollup of 11 pull requests

Successful merges:

 - rust-lang/rust#149362 (Add Command::get_resolved_envs)
 - rust-lang/rust#155705 (Add `str::word_to_titlecase()` to `alloc`)
 - rust-lang/rust#155970 (Add mention of sendfile(2) and splice(2) to fs::copy() documentation.)
 - rust-lang/rust#156006 (Update a bunch of bootstrap dependencies to remove windows-target)
 - rust-lang/rust#156169 (Change `SwitchInt` handling in dataflow analysis.)
 - rust-lang/rust#155188 (Add regression test for issue 144329)
 - rust-lang/rust#155515 (error on empty `export_name`)
 - rust-lang/rust#155817 (validate `#[link_name = "..."]` & `#[link(name = "...")]` parameters)
 - rust-lang/rust#156107 (remove turbofish notation + use None / Some instead of Option:: (in match documentation))
 - rust-lang/rust#156133 (mark some panicking methods around Duration as track_caller)
 - rust-lang/rust#156363 (`rustc_attr_parsing`: add `AcceptContext::expect_string_literal`)
2026-05-10 06:05:52 +00:00
Vadim Petrochenkov cc630bc470 resolve: Evaluate private visibilities eagerly in eff vis computation 2026-05-10 08:06:03 +03:00
Matthias Krüger ddecb76c99 Rollup merge of #156363 - scrabsha:attributes/expect-string-literal, r=JonathanBrouwer
`rustc_attr_parsing`: add `AcceptContext::expect_string_literal`
2026-05-10 03:17:04 +02:00
Matthias Krüger 99abbd6a01 Rollup merge of #155817 - folkertdev:link-name-null-empty, r=mejrs
validate `#[link_name = "..."]` & `#[link(name = "...")]` parameters

fixes https://github.com/rust-lang/rust/issues/155776
fixes https://github.com/rust-lang/rust/issues/155484

specifically, do not allow NULL bytes and the empty string in `#[link_name = "..."]` and `#[link(name = "...")]`.

Like some of the others I think this formally needs to be looked at by T-lang because these errors would not show up if not linking.

The LLVM erorr on `#[linke_name = "\0"]` is emitted here, it is not e.g. target-specific.

https://github.com/llvm/llvm-project/blob/d593279c0b2891f0b0c8af3f70a1a0383b4ad1b5/llvm/lib/IR/Value.cpp#L336-L342

On `#[link(name = "")]` we already error today. A NULL byte in `#[link(name = "\0")]` is caught by the linker (https://godbolt.org/z/vnz9sYbPs), using `#[link_name = ""]` makes LLVM generate a name (https://godbolt.org/z/1hWEo4cxf) which is not useful and likely to cause linker errors.

r? jdonszelmann
2026-05-10 03:17:02 +02:00
Matthias Krüger 6b93655434 Rollup merge of #155515 - folkertdev:export-name-not-empty, r=jdonszelmann
error on empty `export_name`

fixes https://github.com/rust-lang/rust/issues/155495

Using an empty string as the name makes LLVM make up a name. However this name can be inconsistent between compilation units, which is UB and can cause linking errors, and some parts of LLVM just crash on the empty name (see the linked issue).

As far as we know there is only one valid pattern that could use this, a `#[used]` static that is not referenced by the program at all. That is not UB, but the `export_name` is not required for that to work, just normal rust name mangling would do fine.

Technically this is a breaking change, but it seems unlikely that this actually breaks code in the wild that wasn't already broken. I'll leave it up to T-lang to determine what is required here (crater run, FCW, ...), but my gut feeling is that we could just merge this and nobody would notice.
2026-05-10 03:17:01 +02:00
Matthias Krüger 02f733bb48 Rollup merge of #156169 - nnethercote:simplify-SwitchInt-stuff, r=cjgillot
Change `SwitchInt` handling in dataflow analysis.

We call `get_switch_int_data` once for the switch and then pass that data to `apply_switch_int_edge_effect` for each switch target.

The only case in practice is `MaybePlacesSwitchIntData` which does an awkward thing, maintaining an index into the discriminants and updating it on each call to `apply_switch_int_edge_effect`.

This commit changes things to do more work up front in `get_switch_int_data`, in order to then do less work in `apply_switch_int_edge_effect`. This avoids the need for the `variants` and `next_discr` methods and the discriminants index. Overall it's a little simpler.

r? @cjgillot
2026-05-10 03:17:00 +02:00
bors ce89c89857 Auto merge of #148214 - WaffleLapkin:never-worn-never-type, r=fee1-dead
Consider `Result<T, Uninhabited>` and `ControlFlow<Uninhabited, T>` to be equivalent to `T` for must use lint





This is an extension to rust-lang/rust#147382.

With this PR `Result<T, Uninhabited>` and `ControlFlow<Uninhabited, T>` considered as must use iif `T` must be used.

For such cases the lint will mention that `T` is wrapped in a `Result`/`ControlFlow` with an uninhabited error/break.

The reasoning here is that `Result<T, Uninhabited>` is equivalent to `T` in which values can be represented and thus the must-used-ness should also be equivalent.

Fixes https://github.com/rust-lang/rust/issues/65861
2026-05-09 22:49:40 +00:00
Ralf Jung f0ab0ce824 remove allows_weak_linkage target spec flag 2026-05-09 21:20:11 +02:00
Sasha Pourcelot dcdba78e7e rustc_attr_parsing: add AcceptContext::expect_string_literal 2026-05-09 14:21:05 +00:00
Sasha Pourcelot 9097f5b67a rustc_attr_parsing: improve error message for codegen attributes 2026-05-09 14:10:52 +00:00
Jacob Pratt c32a2cd0a2 Rollup merge of #156353 - petrochenkov:selfdecl, r=mu001999
resolve: Set correct parent and expansion for `self` declarations

Follow up to https://github.com/rust-lang/rust/pull/146972 and https://github.com/rust-lang/rust/pull/154313.

The `parent` seems to not be used yet, it will ICE if used (https://github.com/rust-lang/rust/pull/156185 uses it).
The `expn_id` is only relevant to macros 2.0, I won't bother coming up with a test.
2026-05-09 09:27:59 -04: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
Frank King 0fc0057f8d Fix: Add a span to AttributeKind::PinV2 2026-05-09 19:10:18 +08:00
Frank King 334ed47d07 Add Drop::pin_drop for structually pinned types 2026-05-09 19:10:18 +08:00
rajgandhi1 7a900df1b9 Guard SizeSkeleton::compute against stack overflow 2026-05-09 16:02:15 +05:30
Vadim Petrochenkov 16729bcb2d resolve: Set correct parent and expansion for self declarations 2026-05-09 11:19:29 +03:00
bors 4a997eeefb Auto merge of #156297 - ChayimFriedman2:lang-items-traits, r=mejrs
Implement some trait for next solver's lang item enums

rust-analyzer needs that.
2026-05-08 23:44:40 +00:00
Sasha Pourcelot a275453887 replace leftover call to ArgParser::list with AcceptContext::expect_lits 2026-05-08 19:03:50 +00:00
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 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
Matthias Krüger dbc4f62a0b Rollup merge of #156141 - jdonszelmann:use-right-typingmode, r=lcnr
Resolve some cases of #132279 by using the right typing mode in the next solver

r? @lcnr

Convert 3 FIXMEs of rust-lang/rust#132279 to using the right typing mode when we can (`tcx.use_typing_mode_borrowck()`)

Also resolves https://github.com/rust-lang/rust/pull/155093, which I closed
2026-05-08 20:39:24 +02:00
Takayuki Maeda 431017bb55 avoid byte slicing in dotdotdot rest pattern suggestion 2026-05-09 01:27:40 +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
Jonathan Brouwer ffe32f086b Rollup merge of #156038 - jdonszelmann:fast-path-single-match, r=lcnr
turn `compute_goal_fast_path` into a single match

r? @lcnr
@rustbot blocked on https://github.com/rust-lang/rust/pull/155443
2026-05-08 16:18:40 +02:00
bjorn3 c2ab95fb61 Handle --print=backend-has-mnemonic in cg_clif
And introduce a has_mnemonic method on CodegenBackend just like
--print=backend-has-zstd
2026-05-08 16:08:56 +02:00
Jana Dönszelmann 0d65aa285f move drop bomb from OpaqueTypeStorage into InferCtxt's Drop 2026-05-08 14:39:03 +02:00
Jana Dönszelmann 180725cff6 consistently encode failure reason (nosolution or rerun) in the error type 2026-05-08 14:35:58 +02:00
Jana Dönszelmann 687f839266 return faster from internal iterators 2026-05-08 14:10:56 +02:00
Jana Dönszelmann 0aefbd13c3 use the right typing mode in lints 2026-05-08 14:07:46 +02:00
Jana Dönszelmann 68f9143013 use the right typing mode for each mir phase 2026-05-08 14:07:46 +02:00
Jana Dönszelmann 22d28263cf remove param_env from HasTypingEnv 2026-05-08 14:07:46 +02: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 91d4f8b71b Rollup merge of #156175 - nnethercote:dep_graph-cleanups, r=adwinwhite
Dep graph cleanups

Minor cleanups I found while looking at dep graph code. Details in individual commits.

r? @adwinwhite
2026-05-08 11:35:33 +02:00