Commit graph

53148 commits

Author SHA1 Message Date
Stuart Cook
191c915560
Rollup merge of #151928 - tshepang:patch-2, r=Kivooeo
ty::context: clean some code a little

The explicit `return` was not needed
2026-02-01 14:26:47 +11:00
Stuart Cook
0b8e9610a6
Rollup merge of #151907 - Zalathar:active-key-status, r=nnethercote
Rename `QueryResult` to `ActiveKeyStatus`

Long ago, this enum was also used to hold the cached result of a query evaluation that had completed successfully, so its name made some sense.

Nowadays, successful query evaluation is represented by an entry in the query's in-memory cache, which is a separate data structure.

So this enum only deals with “active” query keys, i.e. those for which query evaluation has started, but has not yet completed successfully.

---

The split between jobs and results was introduced by:
-  https://github.com/rust-lang/rust/pull/50102.

---

There should be no change to compiler behaviour.
2026-02-01 14:26:47 +11:00
Stuart Cook
394e519690
Rollup merge of #151927 - tshepang:patch-1, r=Kivooeo
typeck_root_def_id: improve doc comment

This was initially written to be exhaustive, but one more type that can only be type-checked with its containing item has since been added, and was not mentioned. So, make it future-proof by mentioning just the one example.

Also, a previous refactor left this less readable.
2026-02-01 14:26:46 +11:00
Zalathar
bf2536ae64 Rename QueryResult to ActiveKeyStatus 2026-02-01 14:20:20 +11:00
bors
a1db344c08 Auto merge of #151924 - JonathanBrouwer:rollup-Pqp8PIn, r=JonathanBrouwer
Rollup of 5 pull requests

Successful merges:

 - rust-lang/rust#151886 (Skip unused_allocation lint when method takes &Box<Self>)
 - rust-lang/rust#150300 (Constify `fmt::from_fn`)
 - rust-lang/rust#151102 (Feature-gate `mut ref` patterns in struct pattern field shorthand)
 - rust-lang/rust#151866 (Reorganizing `tests/ui/issues` 10 tests [4/N] )
 - rust-lang/rust#151890 (Re-export `hashbrown::hash_table` from `rustc_data_structures`)
2026-01-31 23:56:07 +00:00
Tshepang Mbambo
1684417326
ty::context: clean some code a little
The explicit `return` was not needed
2026-02-01 00:31:55 +02:00
Tshepang Mbambo
4e02b6db0a
typeck_root_def_id: improve doc comment
This was initially written to be exhaustive, but one more type that can only be type-checked with its containing item has since been added, and was not mentioned. So, make it future-proof by mentioning just the one example.

Also, a previous refactor left this less readable.
2026-02-01 00:00:26 +02:00
Jonathan Brouwer
d853e9e1d6
Rollup merge of #151890 - Zalathar:hash-table, r=Kivooeo
Re-export `hashbrown::hash_table` from `rustc_data_structures`

We don't always re-export shared dependencies, but for `hashbrown::hash_table` I think it makes sense, for a few reasons:

- The lower-level `HashTable` type is already part of the public API of `rustc_data_structures` via the `ShardedHashMap` type alias, and other compiler crates currently depend on being able to access its internal hash tables.
- The `Cargo.toml` entry for `hashbrown` is non-trivial, making it harder to keep in sync and harder to move between crates as needed.
  - [And we currently aren't using `[workspace.dependencies]` for various reasons.](https://github.com/rust-lang/rust/pull/146113)
- It's fine for other compiler crates to use `hash_table` specifically (with care), but they probably shouldn't be using the higher-level `hashbrown::HashMap` and `hashbrown::HashSet` types directly, because they should prefer the various map/set aliases defined by `rustc_data_structures`. Re-exporting only `hash_table` helps to discourage use of those other types.

There should be no change to compiler behaviour.
2026-01-31 21:42:47 +01:00
Jonathan Brouwer
70f1120363
Rollup merge of #151102 - zachs18:mut-ref-in-struct-pattern-shorthand-gate, r=JonathanBrouwer
Feature-gate `mut ref` patterns in struct pattern field shorthand

Tracking issue for `mut_ref` (and other parts of Match Ergonomics 2024): https://github.com/rust-lang/rust/issues/123076

https://github.com/rust-lang/rust/pull/123080 introduced `mut ref`[^1] patterns (for by-reference bindings where the binding itself is mutable), feature-gated behind the `mut_ref` feature, except for in struct pattern shorthand, where the feature gating was missing. Thus, `mut ref` patterns in struct pattern shorthand has been unintentionally stable for ~18 months (since 1.79.0 ([compiler explorer](https://rust.godbolt.org/z/4WTrvhboT))).

This PR adds feature-gating for `mut ref` patterns in struct pattern shorthand. Since this is reverting an accidental stabilization, this probably needs a crater run and a T-lang FCP?

Some alternative possibilities:

* Do nothing (let the inconsistency exist until `feature(mut_ref)` is stabilized)
* Document the existing behavior
* Do a FCW instead of fully feature-gating
* Stabilize `feature(mut_ref)`

CC https://github.com/rust-lang/rust/pull/123080#issuecomment-3746793632

CC @Nadrieril

[^1]: everything in this description also applies analogously to `mut ref mut` patterns.
2026-01-31 21:42:46 +01:00
Jonathan Brouwer
1c6f67f659
Rollup merge of #151886 - chenyukang:yukang-fix-151846-unused-allocation-box-ref, r=petrochenkov
Skip unused_allocation lint when method takes &Box<Self>

Fixes rust-lang/rust#151846
2026-01-31 21:42:45 +01:00
bors
905b926967 Auto merge of #151622 - scottmcm:elide-more-transmutes, r=cjgillot
GVN: Elide more intermediate transmutes

We already skipped intermediate steps like `u32` or `i32` that support any (initialized) value.

This extends that to also allow skipping intermediate steps whose values are a superset of either the source or destination type.  Most importantly, that means that `usize` → `NonZeroUsize` → `ptr::Alignment` and `ptr::Alignment` → `NonZeroUsize` → `usize` can skip the middle because `NonZeroUsize` is a superset of `Alignment`.

Then `Alignment::as_usize` is updated to take advantage of that and let us remove some more locals in a few places.

r? cjgillot
2026-01-31 20:42:37 +00:00
bors
8afe9ff1ca Auto merge of #151911 - JonathanBrouwer:rollup-ACi3J2a, r=JonathanBrouwer
Rollup of 3 pull requests

Successful merges:

 - rust-lang/rust#151908 (Remove unused method `DroplessArena::contains_slice`)
 - rust-lang/rust#151850 (refactor: add an `enum DerefAdjustKind` in favor of `Option<OverloadedDeref>`)
 - rust-lang/rust#151889 (Fix ICE when parsing frontmatter without newline)
2026-01-31 16:24:16 +00:00
Jonathan Brouwer
874c5d2275
Rollup merge of #151889 - chenyukang:yukang-fix-151882-frontmatter-ice, r=Kivooeo
Fix ICE when parsing frontmatter without newline

Fixes rust-lang/rust#151882

we can not add a normal test case for it:
- no newline at the end of file, we can bypass this with change test file name with `ignore-tidy`
- multiple errors in stderr, this conflicts with the previous bypass, seems we can not add multiple error annotations in one line

anyway, I added a `run-make` test for it.
2026-01-31 15:17:05 +01:00
Jonathan Brouwer
1b7a7c7514
Rollup merge of #151850 - frank-king:refactor/pin-coerce-2, r=jackh726
refactor: add an `enum DerefAdjustKind` in favor of `Option<OverloadedDeref>`

Part of rust-lang/rust#149130.

r? jackh726
2026-01-31 15:17:05 +01:00
Jonathan Brouwer
5d166b7095
Rollup merge of #151908 - Zalathar:contains-slice, r=chenyukang
Remove unused method `DroplessArena::contains_slice`

- This method was added for https://github.com/rust-lang/rust/pull/120128.
- It became unused in https://github.com/rust-lang/rust/pull/136593.

Checking whether a particular slice is within an arena is a bit of a sketchy operation, so if there's no pressing need for it then I think we're better off not having it lying around.
2026-01-31 15:17:04 +01:00
bors
78865ca937 Auto merge of #151897 - matthiaskrgr:rollup-eTQjYr5, r=matthiaskrgr
Rollup of 4 pull requests

Successful merges:

 - rust-lang/rust#151262 (Introducing clap on tidy)
 - rust-lang/rust#151896 (Revert enabling `outline-atomics` on various platforms)
 - rust-lang/rust#151849 (refactor: remove `Ty::pinned_ref` in favor of `Ty::maybe_pinned_ref`)
 - rust-lang/rust#151892 (Document enum types used as values for E0423)
2026-01-31 12:59:26 +00:00
Zalathar
e60c475471 Remove unused method DroplessArena::contains_slice 2026-01-31 22:56:49 +11:00
bors
271951ba18 Auto merge of #151881 - Zoxc:index_to_node_ptr, r=eholk
Pass `DepNode` by reference more places

Pass `DepNode` by reference more places as it would typically need 3 registers.
2026-01-31 09:45:26 +00:00
Matthias Krüger
72f163cb48
Rollup merge of #151892 - chahar-ritik:e0423-enum-doc, r=Kivooeo
Document enum types used as values for E0423

### Problem

The E0423 error explanation did not include an example for enum types being used
as values, which is a common source of confusion for users.

For example, the following code:

```rust
fn main() {
    let x = Option::<i32>;
}
```
2026-01-31 10:41:53 +01:00
Matthias Krüger
29fcd639b7
Rollup merge of #151849 - frank-king:refactor/pin-coerce-1, r=jackh726
refactor: remove `Ty::pinned_ref` in favor of `Ty::maybe_pinned_ref`

Also returns the `Region` of the reference type in `Ty::maybe_pinned_Ref`.

Part of rust-lang/rust#149130.

r? jackh726
2026-01-31 10:41:53 +01:00
yukang
dc48704f98 Fix ICE when parsing frontmatter without newline 2026-01-31 08:51:40 +00:00
Frank King
996425b295 refactor: add an enum DerefAdjustKind in favor of Option<OverloadedDeref> 2026-01-31 16:25:32 +08:00
Trevor Gross
9fb68d60ef Revert "Enable outline-atomics by default on AArch64 Windows platforms"
This reverts commit 1ed1b6e267.
2026-01-31 07:08:17 +00:00
Trevor Gross
1173034b7b Revert "Enable outline-atomics by default on AArch64 Android"
This reverts commit c455903978.
2026-01-31 07:08:11 +00:00
Trevor Gross
a9da102e20 Revert "Enable outline-atomics by default on AArch64 Fuchsia"
This reverts commit 21525f862d.
2026-01-31 07:08:05 +00:00
Trevor Gross
63e16520a2 Revert "Enable outline-atomics by default on AArch64 OpenBSD"
This reverts commit 66c150c1fa.
2026-01-31 07:07:59 +00:00
Trevor Gross
54f88be3cd Revert "Enable outline-atomics by default on AArch64 FreeBSD"
This reverts commit 383053e016.
2026-01-31 07:07:53 +00:00
ritik chahar
daaff44cbc Fix tidy formatting manually for E0423.md 2026-01-31 10:46:58 +05:30
ritik chahar
9cdcd0c3fa Document enum types used as values for E0423 2026-01-31 10:15:19 +05:30
Zalathar
04e6afe20a Re-export hashbrown::hash_table from rustc_data_structures 2026-01-31 14:48:50 +11:00
John Kåre Alsaker
8869b7b356 Pass DepNode by reference more places 2026-01-31 00:29:30 +01:00
Jonathan Brouwer
4884de4452
Rollup merge of #151873 - petrochenkov:resrefact, r=lqd,estebank
resolve: Remove `force` parameter from `resolve_ident_in_scope`

`force == true` is used for turning `Determinacy::Undetermined` into `Determinacy::Determined` during error recovery.
It's only needed in two places:
- `resolve_macro_or_delegation_path` - the normal case
- `resolve_path_with_ribs` - obscure case, only when resolving visibilities and only for improving diagnostics in `tests\ui\resolve\visibility-indeterminate.rs`, I'm not actually sure if we should keep it

In other cases `Determinacy::Undetermined` is just ignored or can be propagated.
2026-01-30 21:33:11 +01:00
Jonathan Brouwer
58f03f5fe5
Rollup merge of #151281 - fee1-dead-contrib:push-zmqtzvuvlmuk, r=oli-obk
constify `Iterator`, take IV

Like its predecessors (rust-lang/rust#92433, rust-lang/rust#102225, rust-lang/rust#106541), this PR allows one to make `Iterator` implementations `const`, and thus enables the ability to have `for` loops in `const` contexts. I've also included constifying `Option as IntoIterator`, `option::IntoIter as Iterator` as a minimal dogfooding example.

But unlike its predecessors, it uses a new attribute (not unsound anymore!) that prevents any `Iterator` extension methods from being called. This is intentionally made minimal for an initial approval, the fun stuff like `.fold`, `Range as Iterator` could be done later.

cc @rust-lang/wg-const-eval, cc @oli-obk to review the compiler parts

cc rust-lang/rust#92476
2026-01-30 21:33:11 +01:00
Vadim Petrochenkov
ea0ee492bd resolve: Remove force parameter from resolve_ident_in_scope 2026-01-30 21:32:37 +03:00
Deadbeef
02e10b2d90 fix issues and ui tests, address reviews 2026-01-30 15:59:34 +00:00
Deadbeef
38ee80d48e add #[rustc_non_const_trait_method] 2026-01-30 15:52:38 +00:00
bors
36e2b8a3a7 Auto merge of #151860 - JonathanBrouwer:rollup-FqYVDlY, r=JonathanBrouwer
Rollup of 4 pull requests

Successful merges:

 - rust-lang/rust#151376 (Fix performance issue in liveness checking)
 - rust-lang/rust#151851 (Remove redundant `IntoQueryParam` calls from query plumbing)
 - rust-lang/rust#151854 (Show break type expectation cause for let-else)
 - rust-lang/rust#151859 (Disable append-elements.rs test with debug assertions)
2026-01-30 15:41:56 +00:00
Jonathan Brouwer
b243d015f4
Rollup merge of #151854 - chenyukang:yukang-fix-142602-let-else-break-diag, r=Kivooeo
Show break type expectation cause for let-else

Fixes rust-lang/rust#142602
2026-01-30 13:20:25 +01:00
Jonathan Brouwer
cfadcbe3ea
Rollup merge of #151851 - Zalathar:into-query-param, r=lqd
Remove redundant `IntoQueryParam` calls from query plumbing

In each of these contexts, the key must have already been converted by the caller, since otherwise it wouldn't have type `Cache::Key`.

There should be no change to compiler behaviour.
2026-01-30 13:20:24 +01:00
Jonathan Brouwer
a4b553804b
Rollup merge of #151376 - chenyukang:yukang-fix-perf, r=lqd
Fix performance issue in liveness checking

r? @ghost

from https://github.com/rust-lang/rust/pull/150955#issuecomment-3769274223
2026-01-30 13:20:23 +01:00
Jonathan Brouwer
e19cb30813
Rollup merge of #151831 - clubby789:port-rustc-layout, r=JonathanBrouwer
Port `rustc_layout` to attribute parser

Tracking issue: rust-lang/rust#131229

Uses rust-lang/rust#151827

r? jdonszelmann
2026-01-30 12:12:05 +01:00
Zalathar
e044220de5 Make will_cache_on_disk_for_key_fn optional in query vtables 2026-01-30 21:18:29 +11:00
Zalathar
d39609b719 Make is_loadable_from_disk_fn optional in query vtables 2026-01-30 21:16:25 +11:00
Zalathar
d5e80aa714 Make try_load_from_disk_fn optional in query vtables 2026-01-30 21:16:25 +11:00
yukang
91feb76d94 Skip unused_allocation lint when method takes &Box<Self> 2026-01-30 09:14:03 +00:00
yukang
9c135ad1e0 Show break type expectation cause for let-else 2026-01-30 08:42:12 +00:00
Stuart Cook
dcc74dd6e3
Rollup merge of #151817 - aytey:fix_lifetime_unpretty_hygiene, r=jdonszelmann
Fix missing syntax context in lifetime hygiene debug output

`-Zunpretty=expanded,hygiene` was not printing the syntax context for lifetimes. For example, two macro-generated lifetimes `'a` with different hygiene would both print as `/* 2538 */` instead of `/* 2538#0 */` and `/* 2538#1 */`, making it impossible to distinguish them.

This was fixed by changing `print_lifetime` to call `ann_post()` with the full `Ident`, matching how regular identifiers are handled in `print_ident`.

Closes: rust-lang/rust#151797
2026-01-30 17:41:07 +11:00
Stuart Cook
45009749b5
Rollup merge of #151811 - chenyukang:yukang-fix-143256-unused-parens-labeled-loops, r=Kivooeo
Fix false positive in unused_parens caused by break

Fixes rust-lang/rust#143256
2026-01-30 17:41:07 +11:00
Stuart Cook
611ebade75
Rollup merge of #151808 - Zalathar:alloc-raw-slice, r=Kivooeo
Document a safety condition for `TypedArena::alloc_raw_slice`

This method was marked safe in https://github.com/rust-lang/rust/pull/116224/commits/51edc219906f0973dd66b4b6ff5ff0ac857a4cc6, because there was no apparent reason for it to be unsafe.

However, I believe that `alloc_raw_slice` does actually impose a significant safety obligation on its caller, because the caller must ensure that each slot in the slice is properly initialized before the arena is dropped.

This is because the arena's Drop impl will unconditionally drop every storage slot that has been handed out, so it has no way to handle slots that were accidentally left uninitialized because a hypothetical caller of `alloc_raw_slice` panicked before initializing them.
2026-01-30 17:41:06 +11:00
Stuart Cook
0af845db6b
Rollup merge of #151777 - nnethercote:query-stack-3, r=nnethercote
Reduce generics use in the query system.

In rust-lang/rust#151203 I tried and failed to simplify `QueryStackFrame`. This is an alternative approach. There is no functional change, just tweaking of some names and types to make things clearer. Best reviewed one commit at a time.

r? @oli-obk
2026-01-30 17:41:06 +11:00