Commit graph

9833 commits

Author SHA1 Message Date
Jonathan Brouwer
db10879fd1
Rollup merge of #151096 - rm-providers-deref, r=oli-obk
Remove `Deref`/`DerefMut` impl for `Providers`.

It's described as a "backwards compatibility hack to keep the diff small". Removing it requires only a modest amount of churn, and the resulting code is clearer without the invisible derefs.

r? @oli-obk
2026-01-14 11:05:42 +01:00
Jonathan Brouwer
4e4bee8add
Rollup merge of #150406 - matches-let-chain, r=Kivooeo,oli-obk,BoxyUwU,fmease
Change some `matches!(.., .. if ..)` with let-chains

Follow up to rust-lang/rust#149933.
2026-01-14 11:05:37 +01:00
Zalathar
414e00d350 Clarify the docs/examples for ProjectionElem::ConstantIndex 2026-01-14 18:10:23 +11:00
Nicholas Nethercote
3aa31788b5 Remove Deref/DerefMut impl for Providers.
It's described as a "backwards compatibility hack to keep the diff
small". Removing it requires only a modest amount of churn, and the
resulting code is clearer without the invisible derefs.
2026-01-14 15:55:59 +11:00
mejrs
a1e2cea685 Port do_not_recommend to new attr parsing 2026-01-13 20:43:37 +01:00
Esteban Küber
814647f047 Change some matches!(.., .. if ..) with let-chains 2026-01-13 17:13:22 +00:00
Jonathan Brouwer
dc6afd74dd
Rollup merge of #150883 - improve-deprecated-intra-doc-span, r=camelid
Improve span for "unresolved intra doc link" on `deprecated` attribute

Follow-up of rust-lang/rust#150721.

To make this work, I replaced the `Symbol` by an `Ident` to keep the `Span` information.

cc @folkertdev
r? @camelid
2026-01-13 09:01:30 +01:00
Matthias Krüger
12b1f3f145
Rollup merge of #150920 - hook-build-mir, r=tiif
Use a hook to decouple `rustc_mir_transform` from `rustc_mir_build`

I noticed that the only point of direct contact between the `rustc_mir_transform` and `rustc_mir_build` crates is a single `build_mir` function, which could easily be changed to a hook function instead.

By making that function a hook, we can make `rustc_mir_transform` no longer have a dependency on `rustc_mir_build`, allowing them to be built/rebuilt independently. That should hopefully allow slightly more parallelism in clean builds and incremental rebuilds of the compiler.
2026-01-12 13:32:09 +01:00
dianqk
ac80ccec5f
Only use SSA locals in SimplifyComparisonIntegral 2026-01-12 18:16:34 +08:00
rust-bors[bot]
44a5b55557
Auto merge of #150748 - nnethercote:canonicalizer-cleanups, r=lcnr
Canonicalizer cleanups

Some cleanups in and around the canonicalizers, found while I was looking closely at this code.

r? @lcnr
2026-01-11 22:58:38 +00:00
rust-bors[bot]
1279939b38
Auto merge of #150957 - matthiaskrgr:rollup-Cf6MsNU, r=matthiaskrgr
Rollup of 14 pull requests

Successful merges:

 - rust-lang/rust#148941 (stabilize `Peekable::next_if_map` (`#![feature(peekable_next_if_map)]`))
 - rust-lang/rust#150368 (adding Ordering enum to minicore.rs, importing minicore in "tests/assembly-llvm/rust-abi-arg-attr.rs" test file)
 - rust-lang/rust#150668 (Unix implementation for stdio set/take/replace)
 - rust-lang/rust#150743 (Reword the collect() docs)
 - rust-lang/rust#150776 (Fix the connect_error test on FreeBSD 15+)
 - rust-lang/rust#150781 (Use `rand` crate more idiomatically)
 - rust-lang/rust#150812 (Bump `diesel` to the most recent commit in `cargotest`)
 - rust-lang/rust#150862 (std: sys: fs: uefi: Implement File::flush)
 - rust-lang/rust#150873 (Reenable GCC CI download)
 - rust-lang/rust#150908 (llvm: Update `reliable_f16` configuration for LLVM22)
 - rust-lang/rust#150918 (std: sys: fs: uefi: Implement File::seek)
 - rust-lang/rust#150922 (Subscribe myself to attr parsing)
 - rust-lang/rust#150930 (Remove special case for `AllowedTargets::CrateLevel`)
 - rust-lang/rust#150942 (Port `#[rustc_has_incoherent_inherent_impls]` to attribute parser)

Failed merges:

 - rust-lang/rust#150943 (Port `#[must_not_suspend]` to attribute parser)

r? @ghost
2026-01-11 12:16:33 +00:00
Matthias Krüger
83924065f7
Rollup merge of #150942 - port_more_attrs, r=jdonszelmann
Port `#[rustc_has_incoherent_inherent_impls]` to attribute parser

Tracking issue: rust-lang/rust#131229
no tests changed here at all, so maybe we should add some but would like to know what kind of tests would be good to add

r? @JonathanBrouwer
2026-01-11 09:56:52 +01:00
rust-bors[bot]
08f833aa17
Auto merge of #150540 - JonathanBrouwer:incremental_test, r=cjgillot
Also hash spans inside the same file as relative (V2)

Hashes spans relatively to their parent, even if they are not contained inside their parent.

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

Closes https://github.com/rust-lang/rust/pull/143882, as this is a successor PR
This PR is very closely based on that PR with a few minor changes, so to give proper credit I made @cjgillot coauthor of the commit.
2026-01-11 08:54:50 +00:00
Stuart Cook
e25d7a898a
Rollup merge of #150799 - mcga, r=BoxyUwU
Fix ICE: can't type-check body of DefId  for issue #148729

This commit fixes https://github.com/rust-lang/rust/issues/148729 for min_const_generic_args https://github.com/rust-lang/rust/issues/132980.

It's pretty small PR. The first commit makes sure that the `type_const`s are made into normal consts in const expressions.

The next one just handles the case https://github.com/rust-lang/rust/issues/148729 of where the type of the const was omitted at which point it was trying to treat a `type_const` again as a regular const. That obviously will fail since a type_const does not have a body.

@rustbot label +F-associated_const_equality +F-min_generic_const_args +I-ICE
2026-01-11 14:27:56 +11:00
Stuart Cook
8a5c66efb9
Rollup merge of #150788 - thir-pat, r=Nadrieril
THIR patterns: Replace `AscribeUserType` and `ExpandedConstant` wrappers with per-node data

This PR removes the `AscribeUserType` and `ExpandedConstant` variants from `thir::PatKind`, and replaces them with an `Option<Box<PatExtra>>` field attached to every `thir::Pat`.

### Why remove these variants?

Unlike other THIR pattern kinds, these variants are mere “wrappers” that exist to attach some additional information to an underlying pattern node.

There are several places where code that consumes THIR patterns needs to carefully “unpeel” any wrapper nodes, in order to match on the underlying pattern. This is clunky, and easy to forget to do, especially since it's not always obvious where the wrapper nodes can and can't appear.

Attaching the data to an optional per-node field makes it easier for consuming code to simply ignore the extra data when it is not relevant.

(One downside is that it is now easier to accidentally ignore the extra data when it *is* relevant, but I think that's generally a favourable tradeoff.)

### Impact

After this change, THIR pattern trees should be “logically identical” to the previous THIR pattern trees, in the sense that information that was carried by wrapper nodes should now be directly attached to the non-wrapper nodes that were being wrapped. Types and spans associated with THIR pattern nodes should (hopefully!) still be accurate.

There should be no change to the output of THIR-based checks or MIR building.
2026-01-11 14:27:56 +11:00
Edvin Bryntesson
76fcac2371
Port #[rustc_has_incoherent_inherent_impls] to attribute parser 2026-01-10 23:58:03 +01:00
Zalathar
539e855008 Use a hook to decouple rustc_mir_transform from rustc_mir_build 2026-01-10 22:14:35 +11:00
Matthias Krüger
727688a8e4
Rollup merge of #150713 - mgca-typeck-struct-fields, r=BoxyUwU
mgca: Type-check fields of struct expr const args

Fixes rust-lang/rust#150623.
Fixes rust-lang/rust#150712. Fixes rust-lang/rust#150714. Fixes rust-lang/rust#150734.

r? @BoxyUwU
2026-01-10 08:33:56 +01:00
Keith-Cancel
f982bc6a2d Fix ICE: can't type-check body of DefId, since type_consts don't have a body.
Handling for inherent associated consts is missing elsewhere, remove so it can be handled later in that handling.

Diagnostic not always be emitted on associated constant

Add a test case and Fix for a different ICE I encountered.

I noticed when trying various permuations of the test case code to see if I could find anymore ICEs. I did, but not one that I expected. So in the instances of the a named const not having any args, insantiate it directly. Since it is likely an inherent assocaiated const.

Added tests.

Centralize the is_type_const() logic.

I also noticed basically the exact same check in other part the code.

Const blocks can't be a type_const, therefore this check is uneeded.

Fix comment spelling error.

get_all_attrs is not valid to call for all DefIds it seems.

Make sure that if the type is omitted for a type_const that we don't ICE.

Co-Authored-By: Boxy <rust@boxyuwu.dev>
2026-01-09 14:45:33 -08:00
Guillaume Gomez
f9c71df88a Improve span for "unresolved intra doc link" on deprecated attribute 2026-01-09 20:36:52 +01:00
Zalathar
8516c64115 Replace AscribeUserType and ExpandedConstant with per-node data 2026-01-09 16:46:08 +11:00
Zalathar
bd77048303 Initial plumbing for thir::PatExtra 2026-01-09 16:32:23 +11:00
Matthias Krüger
d464630301
Rollup merge of #150811 - defid-aliases, r=bjorn3
Store defids instead of symbol names in the aliases list

I was honestly surprised this worked in the past. This causes a cycle error since we now compute a symbol name in codegen_attrs, and then compute codegen attrs when we try to get the symbol name.

It only worked when there weren't any codegen attributes to begin with, causing symbol name computation to skip the call to codegen_attrs.

Like this we won't have the same problem.

r? @bjorn3
2026-01-08 22:21:21 +01:00
Jonathan Brouwer
dc505a51a4
Hash all spans relatively to their parent
Co-authored-by: Camille Gillot <gillot.camille@gmail.com>
2026-01-08 21:20:17 +01:00
Noah Lev
1c2cb16e82 mgca: Type-check fields of tuple expr const args 2026-01-08 11:09:07 -08:00
Jana Dönszelmann
6b88c6b7c2
store defids instead of symbol names in the aliases list 2026-01-08 16:25:27 +01:00
Nicholas Nethercote
a07f71704a Add comments about predicate folding.
This explains why the predicate folding code looks different to the
ty/const folding code, something I was wondering.
2026-01-08 15:03:56 +11:00
Nicholas Nethercote
4ae3c85a5e Use the name var_kinds more.
Variables that are collections of `CanonicalVarKind` are sometimes
called `var_kinds` and sometimes called `variables`. The former is much
better, because `variables` is (a) non-descript, and (b) often used
nearby for collections of `I::GenericArg`. I found the inconsistency
made the canonicalization code harder to understand.

This commit renames various `variables` things as `var_kinds`.
2026-01-08 13:37:34 +11:00
mu001999
d572e6d415 Add span field for ConstArg 2026-01-07 08:44:32 +08:00
Vadim Petrochenkov
460f22c388 resolve: Rename NameBinding(Data,Kind) to Decl(Data,Kind)
Also, rename `DeclKind::Res` to `DeclKind::Def`.
2026-01-06 18:21:37 +03:00
AprilNEA
4421270516
Merge associated_const_equality feature gate into MGCA
This removes `associated_const_equality` as a separate feature gate and makes it part of `min_generic_const_args` (mgca).

Key changes:
  - Remove `associated_const_equality` from unstable features, add to removed
  - Update all test files to use `min_generic_const_args` instead
  - Preserve the original "associated const equality is incomplete" error message by specially handling `sym::associated_const_equality` spans in `feature_gate.rs`
  - Rename FIXME(associated_const_equality) to FIXME(mgca)
2026-01-05 12:31:42 +08:00
Matthias Krüger
df246c107a
Rollup merge of #149681 - petrochenkov:openapi1, r=davidtwco
resolve: Split `Scope::Module` into two scopes for non-glob and glob bindings

This is a re-implementation of https://github.com/rust-lang/rust/pull/144131 with all the issues mentioned there fixed.

As it turned out, the non-trivial part of the split was already done in https://github.com/rust-lang/rust/pull/149454/commits/c91b6ca58d4d870d3099db1defbd8c1f26a7d851, so the remaining part implemented in this PR is *mostly* mechanical.

After addressing the issue of already found bindings being lost due to indeterminacies in outer scopes (7e890bfa87) and adding one missing `Stage::Late` in `Finalize` the scope splitting refactoring just worked.
(One more ICE was revealed by the refactoring, but not caused by it, fixed up in the last commit.)

This is a part of implementation for the [Open API](https://rust-lang.github.io/rust-project-goals/2025h1/open-namespaces.html) proposal.
2026-01-04 21:14:04 +01:00
Matthias Krüger
78376fd39c
Rollup merge of #150558 - estebank:multiple-dep-versions, r=jieyouxu
Detect cases where `?` is applied on a type that could be coming from a different crate version than expected

```
error[E0277]: `?` couldn't convert the error to `dependency::Error`
  --> replaced
   |
LL | fn main() -> Result<(), Error> {
   |              ----------------- expected `dependency::Error` because of this
...
LL |     Err(Error2)?;
   |     -----------^ the trait `From<Error2>` is not implemented for `dependency::Error`
   |     |
   |     this can't be annotated with `?` because it has type `Result<_, Error2>`
   |
   = note: the question mark operation (`?`) implicitly performs a conversion on the error value using the `From` trait
help: the trait `From<Error2>` is not implemented for `dependency::Error`
      but trait `From<()>` is implemented for it
  --> replaced
   |
LL | impl From<()> for Error {
   | ^^^^^^^^^^^^^^^^^^^^^^^
   = help: for that trait implementation, expected `()`, found `Error2`
   = note: there are multiple different versions of crate `dependency` in the dependency graph
   = help: you can use `cargo tree` to explore your dependency tree
```

The existing checks rely on having access to the actual types/traits that diverged to detect they are called the same, come from different crates with the same name. The new check is less specific, merely looking to see if the crate name the involved type belongs has multiple crates.

CC rust-lang/rust#78552.
2026-01-03 10:09:29 +01:00
Jonathan Brouwer
9c6a4b05bc
Rollup merge of #150581 - Zalathar:string, r=Nadrieril
mir_build: Separate match lowering for string-equality and scalar-equality

- Follow-up to https://github.com/rust-lang/rust/pull/150238
---

This PR takes some match-lowering code that is responsible for equality tests, and splits it into distinct code paths for string-equality and scalar-equality.

The split results in more lines of code overall, but makes the separated code paths easier to understand individually.

r? Nadrieril
2026-01-02 19:00:17 +01:00
Vadim Petrochenkov
3f3db93651 metadata: Stop keeping AmbiguityKind in name bindings
It can only be `GlobVsGlob` now.
2026-01-02 16:00:12 +03:00
Zalathar
3c7c439812 Split out a separate PatConstKind::String 2026-01-02 13:53:57 +11:00
bors
a47f4dfd7f Auto merge of #150519 - camelid:mgca-forbid-params-properly, r=BoxyUwU
Use more principled check for generics in const ops

Fixes rust-lang/rust#144547.
Fixes rust-lang/rust#140891.

In the future, we likely want to make the check less likely to be missed by reducing the number of external entry points to HIR type lowering.

Note: If this causes pass->error regressions (not truly regressions because those cases were mistakenly accepted), they can easily be avoided for the time being by only running the check if `is_self_alias` is true or mgca is enabled.

- **Fix parsing of mgca const blocks in array repeat exprs**
- **Use more principled check for generics in const ops**
2026-01-02 02:23:07 +00:00
Noah Lev
c7e368543c Use more principled check for generics in const ops
Instead of using a visitor in typeck, we just check, whenever lowering a
use of a param, whether the parent item is an MCG anon const during hir
ty lowering (and instantiate_value_path). If so, we report an error
since MCG anon consts should never be able to use generics. All other
kinds of anon consts are at least syntactically allowed to use generic
params.

We use a `TypeFolder` to accomplish this; this way, we look at the
fully explicit semantic representation of the type/const/whatever and
don't miss subtle cases like `Self` type aliases.
2026-01-01 18:12:34 -08:00
Esteban Küber
22bb4fe147 Detect cases where ? is applied on a type that could be coming from a different crate version than expected
```
error[E0277]: `?` couldn't convert the error to `dependency::Error`
  --> replaced
   |
LL | fn main() -> Result<(), Error> {
   |              ----------------- expected `dependency::Error` because of this
...
LL |     Err(Error2)?;
   |     -----------^ the trait `From<Error2>` is not implemented for `dependency::Error`
   |     |
   |     this can't be annotated with `?` because it has type `Result<_, Error2>`
   |
   = note: the question mark operation (`?`) implicitly performs a conversion on the error value using the `From` trait
help: the trait `From<Error2>` is not implemented for `dependency::Error`
      but trait `From<()>` is implemented for it
  --> replaced
   |
LL | impl From<()> for Error {
   | ^^^^^^^^^^^^^^^^^^^^^^^
   = help: for that trait implementation, expected `()`, found `Error2`
   = note: there are multiple different versions of crate `dependency` in the dependency graph
   = help: you can use `cargo tree` to explore your dependency tree
```

The existing checks rely on having access to the actual types/traits that diverged to detect they are called the same, come from different crates with the same name. The new check is less specific, merely looking to see if the crate name the involved type belongs has multiple crates.
2025-12-31 23:40:16 +00:00
Jonathan Brouwer
15c467ba0c
Rollup merge of #150530 - Zalathar:string-deref-patterns, r=jackh726
Remove `feature(string_deref_patterns)`

The older `string_deref_patterns` feature has been superseded by the newer and more general `deref_patterns` feature. Removing string-deref-patterns allows us to get rid of a few tricky special cases in match lowering, which are different from the special cases used by deref-patterns.

The handful of existing tests for `string_deref_patterns` have been migrated to use `deref_patterns` instead. Current nightly users of the older feature should hopefully be able to migrate to the newer feature without too much trouble.

Note that `deref_patterns` is currently marked as an “incomplete” feature, because it doesn't have an accepted RFC. But `string_deref_patterns` doesn't appear to have ever had an accepted RFC either, so arguably it should have been marked incomplete too.

---
- Tracking issue for both features: https://github.com/rust-lang/rust/issues/87121
- Original implementation: https://github.com/rust-lang/rust/pull/98914
- [Zulip thread: Can we remove `#![feature(string_deref_patterns)]`?](https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/Can.20we.20remove.20.60.23!.5Bfeature.28string_deref_patterns.29.5D.60.3F/with/565787352)
2025-12-31 17:32:06 +01:00
Zalathar
ef8d943ecd Remove feature(string_deref_patterns) 2025-12-31 14:21:38 +11:00
Ben Kimock
74e0a9aa81 Make inliner cycle detection a fallible process 2025-12-30 22:01:49 -05:00
Zalathar
89f7d70045 Remove several remnants of #![feature(inline_const_pat)] 2025-12-30 14:29:35 +11:00
Kivooeo
b29cc9860b refactor destructure_const 2025-12-28 16:12:27 +00:00
Jonathan Brouwer
d63068b3b4
Rollup merge of #150405 - estebank:matches-could-be-equals, r=Kivooeo
Don't use `matches!` when `==` suffices

In the codebase we sometimes use `matches!` for values that can actually just be compared. Replace them with `==`.

Subset of rust-lang/rust#149933.
2025-12-27 13:42:01 +01:00
Esteban Küber
9f566f2463 Don't use matches! when == suffices
In the codebase we sometimes use `matches!` for values that can actually just be compared. Replace them with `==`.
2025-12-26 20:28:19 +00:00
Tobias Bieniek
86cef2ff98
compiler/middle/lint: Suggest #[expect(dead_code)] as alternative to #[allow(dead_code)] 2025-12-26 08:38:20 +01:00
aerooneqq
3f477dd710 Recursive delegation improvements 2025-12-25 14:49:01 +03:00
bors
5a7ad8ee06 Auto merge of #150324 - matthiaskrgr:rollup-cl7wrqn, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - rust-lang/rust#149800 (Fix ICE in normalization during closure capture analysis (rust-lang/rust#149746))
 - rust-lang/rust#150182 (Don't export upstream monomorphizations from compiler-builtins)
 - rust-lang/rust#150216 (Tidying up tests/ui/issues 15 tests [6/N])
 - rust-lang/rust#150308 (Update bors configuration)
 - rust-lang/rust#150314 (rustc-dev-guide subtree update)
 - rust-lang/rust#150319 (use new term in description of --target)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-12-24 03:02:44 +00:00
Matthias Krüger
62129792bb
Rollup merge of #150182 - saethlin:dont-prefer-c-builtins, r=bjorn3
Don't export upstream monomorphizations from compiler-builtins
2025-12-24 00:54:35 +01:00