Commit Graph

55937 Commits

Author SHA1 Message Date
Augie Fackler f6b8f0b6f1 rustc_llvm: update opt-level handling for LLVM 23
LLVM 23 removed Os and Oz optimization pipelines and the PR says to use
O2 with optsize or minsize instead as appropriate.
2026-04-22 13:25:35 -04:00
bors cf1817bc6e Auto merge of #155634 - jhpratt:rollup-lo99oO5, r=jhpratt
Rollup of 7 pull requests

Successful merges:

 - rust-lang/rust#155589 (Forbid `check-pass`/`build-pass`/`run-pass` directives in incremental tests)
 - rust-lang/rust#155610 (Add missing `dyn` keyword to `trait_alias` page of the Unstable Book)
 - rust-lang/rust#155615 (test cleanups for `ui/derives` and `ui/deriving`)
 - rust-lang/rust#154874 (Fix ICE for inherited const conditions on const closures)
 - rust-lang/rust#155605 (std: Update support for `wasm32-wasip3`)
 - rust-lang/rust#155613 (c-variadic: tweak `std` docs)
 - rust-lang/rust#155619 (Remove a bunch of unnecessary explicit lifetimes from the ast validator)
2026-04-22 06:20:12 +00:00
Jacob Pratt 6fa2b1d01a Rollup merge of #155619 - oli-obk:ast-validation-lifetimes, r=dingxiangfei2009
Remove a bunch of unnecessary explicit lifetimes from the ast validator

Noticed while fiddling with error reporting. None of the lifetimes were ever used for anything
2026-04-22 01:53:43 -04:00
Jacob Pratt b622dd00fb Rollup merge of #154874 - cijiugechu:fix-const-closure-inherited-conditions, r=oli-obk
Fix ICE for inherited const conditions on const closures

Synchronize `evaluate_host_effect_for_fn_goal` with the behavior of `extract_fn_def_from_const_callable` in new solver.

Closes rust-lang/rust#153861 .
2026-04-22 01:53:41 -04:00
bors 1bfcb284f7 Auto merge of #155392 - WaffleLapkin:alias-termmm, r=BoxyUwU
`AliasTerm` refactor

follow up to https://github.com/rust-lang/rust/pull/154758
tracking issue: https://github.com/rust-lang/rust/issues/154941
2026-04-22 02:57:46 +00:00
bors f9988fefd3 Auto merge of #155611 - JonathanBrouwer:rollup-hUV99y1, r=JonathanBrouwer
Rollup of 5 pull requests

Successful merges:

 - rust-lang/rust#155546 (Improve E0308 error message for `impl Trait` return mismatches)
 - rust-lang/rust#152834 (Fix incorrect `let` to `const` suggestion for pattern bindings)
 - rust-lang/rust#155425 (Remove duplicated `Flags` methods.)
 - rust-lang/rust#155547 (Use per-parent disambiguators everywhere)
 - rust-lang/rust#155590 (Remove AttributeLintKind variants - part 5)
2026-04-21 23:34:47 +00:00
Oli Scherer fe2e5a9cfa Remove a bunch of unnecessary explicit lifetimes from the ast validator 2026-04-21 23:21:23 +02:00
Jonathan Brouwer 79e2ff7d72 Rollup merge of #155590 - GuillaumeGomez:rm-attributelintkind, r=JonathanBrouwer
Remove AttributeLintKind variants - part 5

Part of https://github.com/rust-lang/rust/issues/153099.

r? @JonathanBrouwer
2026-04-21 20:42:53 +02:00
Jonathan Brouwer aa3335484f Rollup merge of #155547 - aerooneqq:better-disambiguators, r=oli-obk
Use per-parent disambiguators everywhere

This PR addressing the following concerns about per-parent disambiguators (rust-lang/rust#153955):

- DisambiguatorState is removed, PerParentDisambiguatorState is now used everywhere,
- Steals were removed from every per-parent disambiguator in resolver,
- It adds `parent` field in `PerParentDisambiguatorState` in `#[cfg(debug_assertions)]` for asserting that per-parent disambiguator corresponds to the same `LocalDefId` which is passed into `create_def`,
- ~Removes `Disambiguator` trait replacing it with `Disambiguator` enum, with this change we no longer expose `next` method (as trait should be public otherwise the warning will be emitted). It may affect perf in a negative way though.~

~Those changes should not fix perf issues that were [reported](https://github.com/rust-lang/rust/pull/153955#issuecomment-4269223191), perf run that was attempted [before](https://github.com/rust-lang/rust/pull/153955#issuecomment-4214516698) showed much better results. Performance can be probably fixed by removing per-parent disambiguators replacing them with a single one as it was before, then it will be passed to AST -> HIR lowering and modified. For delayed owners we can store ~followup disambiguators as it was in the beginning of the rust-lang/rust#153955~ per-parent disambiguators. This solution should save achievements from rust-lang/rust#153955 (removed `DefPathData` variants).
However, I would prefer to keep per-parent disambiguators as it seems a better architectural solution for me.~

r? @petrochenkov
cc @oli-obk
2026-04-21 20:42:52 +02:00
Jonathan Brouwer 63b6bd933e Rollup merge of #155425 - nnethercote:rm-dup-Flags-methods, r=nikomatsakis
Remove duplicated `Flags` methods.

The `Flags` trait has two methods: `flags` and `outer_exclusive_binder`. Multiple types impl this trait and then also have duplicate inherent methods with the same names; these are all marked with "Think about removing this" comments. This is left over from things being moved into `rustc_type_ir`.

This commit removes those inherent methods. This requires adding `use Flags` to a number of files.

r? @lcnr
2026-04-21 20:42:51 +02:00
Jonathan Brouwer 65fcd87abd Rollup merge of #152834 - lapla-cogito:issue_152831, r=jackh726
Fix incorrect `let` to `const` suggestion for pattern bindings

When a variable from a pattern binding was referenced inside a `const {}` block, the compiler incorrectly suggested replacing `let` with `const`. This was reported in rust-lang/rust#152831 for `if let`, but also applies to `while let` and `let ... else`.
2026-04-21 20:42:51 +02:00
Jonathan Brouwer 5abe5ea630 Rollup merge of #155546 - Unique-Usman:ua/impl_traits, r=estebank
Improve E0308 error message for `impl Trait` return mismatches

When a function returns `impl Trait`, all branches must return the same concrete type. Previously, the compiler showed:

    expected `First` because of return type

This was misleading, as it suggested the return type was `First`, rather than any single type implementing the trait.

Update the diagnostic to:

    expected a single type implementing `Value` because of return type

Also highlight the first return expression to make it clearer why subsequent returns do not match.
2026-04-21 20:42:50 +02:00
Guillaume Gomez 940d0f8245 Remove AttributeLintKind::UnknownCrateTypesSuggestion variant 2026-04-21 19:28:53 +02:00
Guillaume Gomez 6b782884e7 Remove AttributeLintKind::DoNotRecommendDoesNotExpectArgs variant 2026-04-21 19:28:46 +02:00
Guillaume Gomez a9f16fa646 Remove AttributeLintKind::AttrCrateLevelOnly variant 2026-04-21 19:28:34 +02:00
Guillaume Gomez 33b896a067 Remove AttributeLintKind::DocTestLiteral variant 2026-04-21 19:28:27 +02:00
Guillaume Gomez b1cc9a60d8 Remove AttributeLintKind::DocTestUnknown variant 2026-04-21 19:28:16 +02:00
Guillaume Gomez 2ccad45f29 Remove AttributeLintKind::DocTestTakesList variant 2026-04-21 19:27:21 +02:00
bors d2f88d4b65 Auto merge of #155599 - JonathanBrouwer:rollup-cI1hRiI, r=JonathanBrouwer
Rollup of 4 pull requests

Successful merges:

 - rust-lang/rust#152611 (Modify error message of importing inherent associated items when `#[feature(import_trait_associated_functions)]` is enabled)
 - rust-lang/rust#155359 (Improperctypes refactor2.2)
 - rust-lang/rust#155036 (Store a PathBuf rather than SerializedModule for cached modules)
 - rust-lang/rust#155554 (add warning message when using x fix)
2026-04-21 16:48:52 +00:00
lapla 90c03d8ff4 Flatten nested tuple destructuring 2026-04-22 00:24:19 +09:00
lapla a687f0b658 Fix incorrect let to const suggestion for pattern bindings 2026-04-22 00:24:08 +09:00
aerooneqq 2e6a082513 Use per-parent disambiguators 2026-04-21 18:23:40 +03:00
Jonathan Brouwer 8ffe107470 Rollup merge of #155036 - bjorn3:lto_refactors16, r=TaKO8Ki
Store a PathBuf rather than SerializedModule for cached modules

In cg_gcc `ModuleBuffer` already only contains a path anyway. And for moving LTO into `-Zlink-only` we will need to serialize `MaybeLtoModules`. By storing a path cached modules we avoid writing them to the disk a second time during serialization of `MaybeLtoModules`.

Some further improvements will require changes to cg_gcc that I would prefer landing in the cg_gcc repo to actually test the LTO changes in CI.

Part of https://github.com/rust-lang/compiler-team/issues/908
2026-04-21 16:53:39 +02:00
Jonathan Brouwer f21c57d8c6 Rollup merge of #155359 - niacdoial:improperctypes-refactor2.2, r=petrochenkov
Improperctypes refactor2.2

This is "part 2/3 of 2/3 of 1/2" of the original pull request https://github.com/rust-lang/rust/pull/134697 (refactor plus overhaul of the ImproperCTypes family of lints)
(all pulls of this series of pulls are supersets of the previous pulls.)
previous pull: https://github.com/rust-lang/rust/pull/155358
next pull: https://github.com/rust-lang/rust/pull/146273

This commit splits the lint's `visit_type` function into multiple functions that focus on specific things:
- visit_indirection (references, boxes, raw pointers)
- visit_variant_fields (the list of fields of a struct, enum variant, or union)
- visit_enum
- visit_struct_or_union
- visit_type (most "easy" decisions such as labeling `char` unsafe are here)

since, during these visits, we often move from an "outer type" to an "inner type" (structs, arrays, pointers, etc...),
two structs have been added to track the current state of a visit:
- VisitorState tracks the state related to the "original type" being checked (function argument/return, static variable)
- OuterTyData tracks the data related to the type "immediately outer to the current visited type"

r? petrochenkov (because you asked me to)
2026-04-21 16:53:38 +02:00
Jonathan Brouwer 04dfc2b595 Rollup merge of #152611 - CoCo-Japan-pan:fix-148009, r=jackh726
Modify error message of importing inherent associated items when `#[feature(import_trait_associated_functions)]` is enabled

Fixes rust-lang/rust#148009

This PR improves the diagnostic for importing inherent associated items from a struct or union when
`#[feature(import_trait_associated_functions)]` (rust-lang/rust#134691) is enabled.

Previously, this would result in a "not a module" error. This change provides a more specific error message clarifying that only trait associated items can be imported, while inherent associated items remain ineligible for import.

Enums are currently excluded from this change because their variants are valid import targets and require distinct handling.
2026-04-21 16:53:37 +02:00
niacdoial 7bb9851ae8 ImproperCTypes: remove special cases through better state tracking
Another interal change that shouldn't impact rustc users.
Code called outside of `visit_type` (and callees) is moved inside, by
adding new types to properly track the state of a type visitation.
- OuterTyKind tracks the knowledge of the type "directly outside of" the
  one being visited (if we are visiting a struct's field, an array's
  element, etc)
- RootUseFlags tracks the knowledge of how the "original type being
  visited" is used: static variable, function argument/return, etc.
2026-04-21 15:08:51 +02:00
Jacob Pratt b646067bfd Rollup merge of #155586 - oli-obk:assert-ignored-feed, r=petrochenkov
Ensure we don't feed owners from ast lowering if we ever make that query tracked

follow-up to rust-lang/rust#153489

I don't expect this to ever really be an issue, but better safe than sorry 😆
2026-04-21 08:22:17 -04:00
Jacob Pratt 02fc33b679 Rollup merge of #155572 - mejrs:move_target_checks, r=JonathanBrouwer,GuillaumeGomez
Move diagnostic attribute target checks from check_attr

Move diagnostic attribute target checks into their targets. Part of https://github.com/rust-lang/rust/issues/131229#issuecomment-3959910413

This is much easier with `emit_dyn_lint` :) (thanks @GuillaumeGomez !)

I think there might be some opportunity to simplify all these `check_diagnostic_*` methods in `check_attr`. However there are some diagnostic attribute prs in flight and I'd like to wait for those to land first and then think about it. So that PR is not for today.

r? @JonathanBrouwer (or @GuillaumeGomez if you want)
2026-04-21 08:22:17 -04:00
Jacob Pratt 3b4c17915e Rollup merge of #154377 - mu001999-contrib:fix/dead-code, r=TaKO8Ki
Fix `#[expect(dead_code)]` liveness propagation

Fixes https://github.com/rust-lang/rust/issues/154324
Fixes https://github.com/rust-lang/rust/issues/152370 (cc @eggyal)

Previously, when traversing from a `ComesFromAllowExpect::Yes` item (i.e., with `#[allow(dead_code)]` or `#[expect(dead_code)]`), other `ComesFromAllowExpect::Yes` items reached during propagation would be updated to `ComesFromAllowExpect::No` and inserted into `live_symbols`. That caused `dead_code` lint couldn't be emitted correctly.

After this PR, `ComesFromAllowExpect::Yes` items no longer incorrectly update other `ComesFromAllowExpect::Yes` items during propagation or mark them live by mistake, then `dead_code` lint could behave as expected.
2026-04-21 08:22:16 -04:00
Jacob Pratt 545e7dc06c Rollup merge of #151194 - chenyukang:yukang-fix-150701-async-closure, r=wesleywiser
Fix wrong suggestion for returning async closure

Fixes rust-lang/rust#150701

r? @estebank
2026-04-21 08:22:15 -04:00
Jacob Pratt eb2c80dabe Rollup merge of #155582 - nnethercote:overhaul-flat_map_in_place, r=chenyukang
Rewrite `FlatMapInPlace`.

Replace the hacky macro with a generic function and a new `FlatMapInPlaceVec` trait. More verbose but more readable and typical.

LLM disclosure: I asked Claude Code to critique this file and it suggested the generic function + trait idea. I implemented the idea entirely by hand.

r? @chenyukang
2026-04-21 08:22:14 -04:00
Waffle Lapkin be8bfb2d69 x fmt
I have no idea what caused this change, I don't think other commits
changed anything near these lines?..
2026-04-21 12:42:52 +02:00
Waffle Lapkin 54abf6d683 remove unused parameter from opt_alias_variances 2026-04-21 12:28:26 +02:00
Waffle Lapkin e8b6c9737e fix ty::UnevaluatedConst<I>>->AliasTerm<I> conversion 2026-04-21 12:28:25 +02:00
Waffle Lapkin 0ff2fe8eef add AliasTermTy::with_args to simplify a common-ish pattern 2026-04-21 12:28:24 +02:00
Waffle Lapkin d7986943e4 AliasTermTy refactor: fixup compiler 2026-04-21 12:28:22 +02:00
Waffle Lapkin 3484c89c0b AliasTermTy refactor: API changes 2026-04-21 12:28:21 +02:00
mejrs 3990dda860 say "implementation(s) in "not on trait impl" lints 2026-04-21 11:30:14 +02:00
mejrs 80fb0aa44e Move diagnostic::do_not_recommend target checking 2026-04-21 11:30:00 +02:00
mejrs c62be6e992 Move diagnostic::on_unknown target check 2026-04-21 11:30:00 +02:00
mejrs 59503ecb5e Move diagnostic::on_unimplemented target check 2026-04-21 11:30:00 +02:00
mejrs 26d2c30682 Move diagnostic::on_move target check 2026-04-21 11:29:59 +02:00
mejrs 5ba06cccd0 Always refer to non-const trait impls 2026-04-21 11:29:58 +02:00
mejrs 39f517fd18 Move diagnostic::on_const target check 2026-04-21 11:29:41 +02:00
Oli Scherer b1c7595965 Ensure we don't feed owners from ast lowering if we ever make that query tracked 2026-04-21 08:56:02 +02:00
Nicholas Nethercote 21cd762cd1 Rewrite FlatMapInPlace.
Replace the hacky macro with a generic function and a new
`FlatMapInPlaceVec` trait. More verbose but more readable and typical.

LLM disclosure: I asked Claude Code to critique this file and it
suggested the generic function + trait idea. I implemented the idea
entirely by hand.
2026-04-21 15:52:55 +10:00
bors 9ab01ae53c Auto merge of #155491 - ohadravid:faster-storage-in-copyprop-and-gvn, r=saethlin
Fix performance regression introduced in #142531 by excluding `Storage{Live,Dead}` from CGU size estimation



Fix performance regression introduced in rust-lang/rust#142531 ([rust-timer comment](https://github.com/rust-lang/rust/pull/142531#issuecomment-4273712294)) by excluding `Storage{Live,Dead}` from CGU size estimation.

Also, avoid unneeded work for storage removal in non-opt builds in CopyProp and GVN
by allocating local sets for the storage accounting only when `tcx.sess.emit_lifetime_markers()`. 

r? saethlin
2026-04-21 05:35:16 +00:00
bors 84c1190072 Auto merge of #155576 - jhpratt:rollup-F5kv4Uy, r=jhpratt
Rollup of 5 pull requests

Successful merges:

 - rust-lang/rust#153411 (Offload slice support)
 - rust-lang/rust#154557 (Make E0284 generic argument suggestions more explicit)
 - rust-lang/rust#154933 (Suggest removing `&` when awaiting a reference to a future)
 - rust-lang/rust#155524 (Fix LLVM offload install docs to use semicolon-separated CMake lists)
 - rust-lang/rust#155568 (Update books)
2026-04-21 02:16:22 +00:00
Jacob Pratt 03dc6a3a28 Rollup merge of #154933 - fru1tworld:fix-87211-ref-future-diagnostic, r=chenyukang
Suggest removing `&` when awaiting a reference to a future

Fixes rust-lang/rust#87211

When `.await`ing `&impl Future`, suggest removing the `&` instead of removing `.await`.
2026-04-20 20:50:22 -04:00
Jacob Pratt a8e1664fd8 Rollup merge of #154557 - Muhtasim-Rasheed:issue-147313-improve-help, r=chenyukang
Make E0284 generic argument suggestions more explicit

Closes rust-lang/rust#147313

Previously, when type annotations were missing for a function call, rust suggested: "consider specifying the generic argument". This PR improves the diagnostics:

- If only one generic type is missing:
  "consider specifying a concrete type for the generic type `<T>`" with the turbofish being "::\<SomeConcreteType>"
- If only one const generic is missing:
  "consider specifying a const for the const generic `<CONST>`" with the turbofish being "::<SOME_CONST>"

Multiple missing generics still produce the original more general suggestion
2026-04-20 20:50:21 -04:00