Commit Graph

316793 Commits

Author SHA1 Message Date
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
bors 7d8ebe3128 Auto merge of #151852 - Zalathar:rollup-jdJCcDh, r=Zalathar
Rollup of 5 pull requests

Successful merges:

 - rust-lang/rust#151777 (    Reduce generics use in the query system.)
 - rust-lang/rust#151808 (Document a safety condition for `TypedArena::alloc_raw_slice`)
 - rust-lang/rust#151811 (Fix false positive in unused_parens caused by break)
 - rust-lang/rust#151817 (Fix missing syntax context in lifetime hygiene debug output)
 - rust-lang/rust#151844 (rustc-dev-guide subtree update)
2026-01-30 06:41:46 +00:00
Stuart Cook 5b542088ae Rollup merge of #151844 - tshepang:rdg-sync, r=tshepang
rustc-dev-guide subtree update

Subtree update of `rustc-dev-guide` to https://github.com/rust-lang/rustc-dev-guide/commit/e03697d81396383b7b81dc53ac70d8c8f654f111.

Created using https://github.com/rust-lang/josh-sync.

r? @ghost
2026-01-30 17:41:08 +11: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
bors ef2657cbaf Auto merge of #151168 - petrochenkov:rprivtit, r=eholk
privacy: Fix privacy lints in RPITITs

Visit RPITITs and report `private_interfaces`, `private_bounds` and `exported_private_dependencies` in them (these are regular, non-deprecation lints).
New hard errors are not reported, https://github.com/rust-lang/rust/pull/146470 is for hard errors.
So this PR doesn't contain any breakage or language changes.
2026-01-30 01:45:52 +00:00
Nicholas Nethercote 1c3d9abbad Reduce generics use in the query system.
`QueryStackFrame<I>` is a generic type, and the `I` parameter leaks out
to many other related types. However, it only has two instantiations in
practice:
- `QueryStackFrame<QueryStackFrameExtra>`
- `QueryStackFrame<QueryStackDeferred<'tcx>>`

And most of the places that currently use `QueryStackFrame<I>` are
actually specific to one of the instantiations. This commit removes the
unneeded genericity.

The following types are only ever used with `QueryStackDeferred<'tcx>`:
- QueryMap
- QueryJobInfo
- QueryJob
- QueryWaiter
- QueryLatchInfo
- QueryLatch
- QueryState
- QueryResult
and their `<I>` parameter is changed to `<'tcx>`.

Also, the `QueryContext::QueryInfo` associated type is removed.

`CycleError<I>` and `QueryInfo<I>` are still generic over type, because
they are used with both instantiations.

This required also adding a `<'tcx>` parameter to the traits
`QueryDispatcher` and `QueryContext`, which is annoying but I can't see
how to avoid it.
2026-01-30 10:54:28 +11:00
Tshepang Mbambo 6ea1809c5e Merge pull request #2748 from rust-lang/tshepang/sembr
sembr
2026-01-30 01:05:28 +02:00
Tshepang Mbambo 62dbe9fbab whitespace 2026-01-30 00:59:05 +02:00
Tshepang Mbambo 31eab45e4a fix sembr tool corner case 2026-01-30 00:58:42 +02:00
Nicholas Nethercote 637e2cb5e1 Rename create_query_frame_extra.
It produces a `QueryStackFrameExtra`, so `stack_` should be in the name.
2026-01-30 09:56:41 +11:00
Nicholas Nethercote 654945a736 Simplify QueryStackFrame::new.
Instead of passing a closure that computes a hash and immediately
calling it, just compute the hash and pass the value.
2026-01-30 09:56:41 +11:00
Tshepang Mbambo c3e9f0007e sembr src/rustdoc-internals/rustdoc-json-test-suite.md 2026-01-30 00:31:17 +02:00
Tshepang Mbambo 84e994ebd4 sembr src/tests/ci.md 2026-01-30 00:28:12 +02:00
Tshepang Mbambo b4ded124a7 extraneous whitespace 2026-01-30 00:27:42 +02:00
Tshepang Mbambo 654a5a3404 sembr src/compiler-team.md 2026-01-30 00:24:39 +02:00
Tshepang Mbambo d34695f503 some improvements 2026-01-30 00:21:42 +02:00
Tshepang Mbambo d7e88cf39b sembr src/git.md 2026-01-30 00:08:23 +02:00
Tshepang Mbambo ffc3b8a3f1 capitalise start of sentence 2026-01-30 00:03:23 +02:00
Tshepang Mbambo 2aea912db2 sembr src/building/suggested.md 2026-01-29 23:51:07 +02:00
Tshepang Mbambo d4764e3210 some improvements 2026-01-29 23:46:27 +02:00
bors 35a31ba763 Auto merge of #140283 - adwinwhite:fn-pointer-coercion, r=jackh726
Fix accidental type inference in array coercion


Fixes rust-lang/rust#136420.

If the expectation of array element is a type variable, we should avoid resolving it to the first element's type and wait until LUB coercion is completed.
We create a free type variable instead which is only used in this `CoerceMany`.

[`check_expr_match`](https://github.com/rust-lang/rust/blob/847e3ee6b0e614937eee4e6d8f61094411eadcc0/compiler/rustc_hir_typeck/src/_match.rs#L72) and [`check_expr_if`](https://github.com/rust-lang/rust/blob/847e3ee6b0e614937eee4e6d8f61094411eadcc0/compiler/rustc_hir_typeck/src/expr.rs#L1329) where `CoerceMany` is also used do the [same](https://github.com/rust-lang/rust/blob/847e3ee6b0e614937eee4e6d8f61094411eadcc0/compiler/rustc_hir_typeck/src/expectation.rs#L50). 

### [FCP Proposal](https://github.com/rust-lang/rust/pull/140283#issuecomment-2933771068):
> Array expressions normally lub their element expressions' types to ensure that things like `[5, 5_u8]` work and don't result in type mismatches. When invoking a generic function `fn foo<T>(_: [T; N])` with an array expression, we end up with an infer var for the element type of the array in the signature. So when typecking the first array element we compare its type with the infer var and thus subsequently require all other elements to be the same type.
> 
> This PR changes that to instead fall back to "not knowing" that the argument type is array of infer var, but just having an infer var for the entire argument. Thus we typeck the array expression normally, lubbing the element expressions, and then in the end comparing the array expression's type with the array of infer var type.
> 
> Things like
> 
> ```rust
> fn foo() {}
> fn bar() {} 
> fn f<T>(_: [T; 2]) {}
> 
> f([foo, bar]);
> ```
> 
> and
> 
> ```rust
> struct Foo;
> struct Bar;
> trait Trait {}
> impl Trait for Foo {}
> impl Trait for Bar {} 
> fn f<T>(_: [T; 2]) {}
> 
> f([&Foo, &Bar as &dyn Trait]);
> ```

### Remaining inconsistency with `if` and `match`(rust-lang/rust#145048):
The typeck of array always uses the element coercion target type as the expectation of element exprs while `if` and `match` use `NoExpectation` if the expected type is an infer var.
This causes that array doesn't support nested coercion. 
```rust
fn foo() {}
fn bar() {}
fn main() {
    let _ =  [foo, if false { bar } else { foo }]; // type mismatch when trying to coerce `bar` into `foo` in if-then branch coercion.
}
```
But we can't simply change this behavior to be the same as `if` and `match` since [many code](https://github.com/rust-lang/rust/pull/140283#issuecomment-3190564399) depends on using the first element's type as expectation.
2026-01-29 21:36:31 +00:00
Tshepang Mbambo 7d8b5324eb sembr src/debuginfo/lldb-visualizers.md 2026-01-29 23:27:41 +02:00
Tshepang Mbambo 43fc5a40ee sembr src/walkthrough.md 2026-01-29 23:14:55 +02:00
Tshepang Mbambo dd4870d0cc fix sembr tool corner case 2026-01-29 23:13:39 +02:00
Tshepang Mbambo dd8ae230c7 some improvements 2026-01-29 23:08:29 +02:00
Tshepang Mbambo 03b8ebb91c sembr src/tests/ui.md 2026-01-29 22:09:02 +02:00
Tshepang Mbambo 93049c3488 fix sembr tool corner case 2026-01-29 22:06:56 +02:00
Tshepang Mbambo b643676267 misc improvements 2026-01-29 21:57:55 +02:00
Tshepang Mbambo 83eae6253a sembr src/tests/compiletest.md 2026-01-29 21:15:07 +02:00
Tshepang Mbambo c4718ea1d9 missing pause 2026-01-29 21:08:37 +02:00
Tshepang Mbambo 481d49de09 missing word 2026-01-29 21:08:19 +02:00
Tshepang Mbambo b128539624 sembr src/tracing.md 2026-01-29 20:57:08 +02:00
Tshepang Mbambo 74b96acf75 Merge pull request #2747 from rust-lang/rustc-pull
Rustc pull update
2026-01-29 20:54:37 +02:00
The rustc-josh-sync Cronjob Bot 8f9dd9e570 Merge ref '370143facfb3' from rust-lang/rust
Pull recent changes from https://github.com/rust-lang/rust via Josh.

Upstream ref: rust-lang/rust@370143facf
Filtered ref: rust-lang/rustc-dev-guide@e706cc1e62
Upstream diff: https://github.com/rust-lang/rust/compare/0462e8f7e51f20692b02d68efee68bb28a6f4457...370143facfb348ad3b29749c0393402d76b280c3

This merge was created using https://github.com/rust-lang/josh-sync.
2026-01-29 18:52:57 +00:00
The rustc-josh-sync Cronjob Bot f0bb4e649f Prepare for merging from rust-lang/rust
This updates the rust-version file to 370143facf.
2026-01-29 18:52:52 +00:00
Tshepang Mbambo 6910e978b9 Merge pull request #2746 from rust-lang/fix-redirects
fix redirects
2026-01-29 20:44:33 +02:00
Tshepang Mbambo c943cd9b8c fix redirects 2026-01-29 20:43:03 +02:00
bors 842bd5be25 Auto merge of #151835 - JonathanBrouwer:rollup-ayQY8NW, r=JonathanBrouwer
Rollup of 8 pull requests

Successful merges:

 - rust-lang/rust#147387 (hir_owner_parent optimized to inlined call for non-incremental build)
 - rust-lang/rust#150271 (Move struct placeholder pt2)
 - rust-lang/rust#151283 (Suggest ignore returning value inside macro for unused_must_use lint)
 - rust-lang/rust#151565 (Rename, clarify, and document code for "erasing" query values)
 - rust-lang/rust#149482 (thread::scope: document how join interacts with TLS destructors)
 - rust-lang/rust#151827 (Use `Rustc` prefix for `rustc` attrs in `AttributeKind`)
 - rust-lang/rust#151833 (Treat unions as 'data types' in attr parsing diagnostics)
 - rust-lang/rust#151834 (Update `askama` version to `0.15.4`)
2026-01-29 16:48:31 +00:00
Jonathan Brouwer 0f318f9cea Rollup merge of #151834 - GuillaumeGomez:update-askama, r=GuillaumeGomez
Update `askama` version to `0.15.4`

Hopefully it's the last `askama` update before a while. ^^'

r? ghost
2026-01-29 17:47:32 +01:00
Jonathan Brouwer eeb3a24813 Rollup merge of #151833 - clubby789:union-adt, r=JonathanBrouwer
Treat unions as 'data types' in attr parsing diagnostics

I found 'data types _and_ unions' to be a little surprising
2026-01-29 17:47:32 +01:00
Jonathan Brouwer 35c608be4b Rollup merge of #151827 - clubby789:rustc-attr-names, r=jdonszelmann,JonathanBrouwer
Use `Rustc` prefix for `rustc` attrs in `AttributeKind`

cc rust-lang/rust#131229

Most `rustc_...` attrs have their variants named `RustcAttrName`, but several do not. Rename these attributes for consistency.

r? @jdonszelmann
2026-01-29 17:47:31 +01:00
Jonathan Brouwer faa0d67374 Rollup merge of #149482 - RalfJung:scope-tls-dtors, r=joboet
thread::scope: document how join interacts with TLS destructors

Fixes https://github.com/rust-lang/rust/issues/116237 by documenting the current behavior regarding thread-local destructors as intended. (I'm not stoked about this, but documenting it is better than leaving it unclear.)

This also adds documentation for explicit `join` calls (both for scoped and regular threads), saying that those *will* wait for TLS destructors. That reflects my understanding of the current implementation, which calls `join` on the native thread handle. Are we okay with guaranteeing that? I think we should, so people have at least some chance of implementing "wait for all destructors" manually. This fixes https://github.com/rust-lang/rust/issues/127571.

Cc @rust-lang/libs-api
2026-01-29 17:47:31 +01:00
Jonathan Brouwer 3991cf6974 Rollup merge of #151565 - Zalathar:erase, r=petrochenkov
Rename, clarify, and document code for "erasing" query values

In order to reduce compile times and code size for the compiler itself, the query system has a mechanism for “erasing” and ”restoring” query values in certain contexts. See https://github.com/rust-lang/rust/pull/109333 for the original implementation.

Unfortunately, the erasure system has very little documentation, and involves a dizzying assortment of similarly-named types, traits, and functions.

This PR therefore renames several parts of the erasure API and implementation to hopefully be clearer, and adds comments to better explain the purpose and mechanism behind value erasure.

Summary of renames:
- fn `erase` → `erase_val` (avoiding ambiguity with module `erase`)
- fn `restore` → `restore_val`
- type `Erase<T>` → `Erased<T>` (for actual erased values of `T`)
- trait `EraseType` → `Erasable` (for types that can be erased and restored)
- associated type `EraseType::Result` → `Erasable::Storage`
- implementation-detail struct `Erased<T>` → `ErasedData<Storage>`

There should be no change to compiler behaviour.
2026-01-29 17:47:30 +01:00
Jonathan Brouwer adcdb6c2c3 Rollup merge of #151283 - chenyukang:yukang-fix-macro-unused, r=petrochenkov
Suggest ignore returning value inside macro for unused_must_use lint

Fixes rust-lang/rust#151269

The first commit fix the original issue,
the second commit is a code refactoring in this lint.
2026-01-29 17:47:30 +01:00
Jonathan Brouwer 40d7cb890f Rollup merge of #150271 - Jamesbarford:chore/refactor-struct-placeholder-pt2, r=lcnr
Move struct placeholder pt2

r? ghost
2026-01-29 17:47:29 +01:00
Jonathan Brouwer 9a9f303a35 Rollup merge of #147387 - azhogin:azhogin/hir_owner_parent_opt, r=petrochenkov
hir_owner_parent optimized to inlined call for non-incremental build

Continuation of https://github.com/rust-lang/rust/pull/146880 and https://github.com/rust-lang/rust/pull/147232.
'hir_owner_parent' query renamed 'hir_owner_parent_q'. hir_owner_parent inlined function added to optimize performance in case of non-incremental build.

'hir_owner_parent' query has low normalized average execution time (163ns) and good cache_hits (5773) according Daria's processed statistics. 'source_span', for comparison, has avg_ns_norm = 66ns and cache_hits = 11361.

Optimization may be profitable for queries with low normalized average execution time (to replace cache lookup into inlined call) and be significant with good cache_hits.
| Query | cache_hits | min_ns | max_ns | avg_ns_norm |
| ------------- | ------------- | ------------- | ------------- | ------------- |
source_span | 11361 | 18 | 2991 | 66
hir_owner_parent | 5773 | 52 | 1773 | 163
is_doc_hidden | 3134 | 47 | 1111 | 285
lookup_deprecation_entry | 13905 | 36 | 6208 | 287
object_lifetime_default | 5840 | 63 | 4688 | 290
upvars_mentioned | 2575 | 75 | 7722 | 322
intrinsic_raw | 21235 | 73 | 3453 | 367

Draft PR to measure performance changes.
2026-01-29 17:47:29 +01:00