about summary refs log tree commit diff
AgeCommit message (Collapse)AuthorLines
2025-08-21Merge pull request #20496 from ChayimFriedman2/symbols-attachChayim Refael Friedman-12/+16
Attach the DB in symbol queries
2025-08-21Handle `ReEarlyParam` in `type_name`.Nicholas Nethercote-4/+20
Fixes #145696.
2025-08-21Attach the DB in symbol queriesChayim Refael Friedman-12/+16
2025-08-21Auto merge of #145244 - lcnr:handle-opaque-types-before-region-inference, ↵bors-1403/+1317
r=BoxyUwU support non-defining uses of opaques in borrowck Reimplements the first part of rust-lang/rust#139587, but limited to only the new solver. To do so I also entirely rewrite the way we handle opaque types in borrowck even on stable. This should not impact behavior however. We now support revealing uses during MIR borrowck with the new solver: ```rust fn foo<'a>(x: &'a u32) -> impl Sized + use<'a> { let local = 1; foo::<'_>(&local); x } ``` ### How do opaque types work right now Whenever we use an opaque type during type checking, we remember this use in the `opaque_type_storage` of the `InferCtxt`. Right now, we collect all *member constraints* at the end of MIR type check by looking at all uses from the `opaque_type_storage`. We then apply these constraints while computing the region values for each SCC. This does not add actual region constraints but directly updates the final region values. This means we need to manually handle any constraints from member constraints for diagnostics. We do this by separately tracking `applied_member_constraints` in the `RegionInferenceContext`. After we've finished computing the region values, it is now immutable and we check whether all member constraints hold. If not, we error. We now map the hidden types of our defining uses to the defining scope. This assumes that all member constraints apply. To handle non-member regions, we simply map any region in the hidden type we fail to map to a choice region to `'erased` https://github.com/rust-lang/rust/blob/b1b26b834d85e84b46aa8f8f3ce210a1627aa85f/compiler/rustc_borrowck/src/region_infer/opaque_types.rs#L126-L132 ### How do we handle opaque types with this PR MIR type check still works the same by populating the `opaque_type_storage` whenever we use an opaque type. We now have a new step `fn handle_opaque_type_uses` which happens between MIR type check and `compute_regions`. This step looks at all opaque type uses in the storage and first checks whether they are defining: are the arguments of the `opaque_type_key` unique region parameters. *With the new solver we silently ignore any *non-defining* uses here. The old solver emits an errors.* `fn compute_concrete_opaque_types`: We then collect all member constraints for the defining uses and apply them just like we did before. However, we do it on a temporary region graph which is only used while computing the concrete opaque types. We then use this region graph to compute the concrete type which we then store in the `root_cx`. `fn apply_computed_concrete_opaque_types`: Now that we know the final concrete type of each opaque type and have mapped them to the definition of the opaque. We iterate over all opaque type uses and equate their hidden type with the instantiated final concrete type. This is the step which actually mutates the region graph. The actual region checking can now entirely ignores opaque types (outside of the `ConstraintCategory` from checking the opaque type uses). ### Diagnostics issue (chill) Because we now simply use type equality to "apply member constraints" we get ordinary `OutlivesConstraint`s, even if the regions were already related to another. This is generally not an issue, expect that it can *hide* the actual region constraints which resulted in the final value of the opaque. The constraints we get from checking against the final opaque type definition relies on constraints we used to compute that definition. I mostly handle this by updating `find_constraint_path_between_regions` to first ignore member constraints in its search and only if that does not find a path, retry while considering member constraints. ### Diagnostics issue (not chill) A separate issue is that `find_constraint_paths_between_regions` currently looks up member constraints by their **scc**, not by region value: https://github.com/rust-lang/rust/blob/2c1ac85679678dfe5cce7ea8037735b0349ceaf3/compiler/rustc_borrowck/src/region_infer/mod.rs#L1768-L1775 This means that in the `borrowck-4` test, the resulting constraint path is currently ``` ('?2: '?5) due to Single(bb0[5]) (None) (Boring) (ConstraintSccIndex(1): ConstraintSccIndex(1)), ('?5: '?3) due to Single(bb0[6]) (None) (Boring) (ConstraintSccIndex(1): ConstraintSccIndex(1)), ('?3: '?0) due to All(src/main.rs:15:5: 15:6 (#0)) (None) (OpaqueType) (ConstraintSccIndex(1): ConstraintSccIndex(1)) ``` Here `'?3` is equal to `'?4`, but the reason why it's in the opaque is that it's related to `'?4`. With my PR this will be correctly tracked so we end up with ``` ('?2: '?5) due to Single(bb0[5]) (None) (Boring) (ConstraintSccIndex(1): ConstraintSccIndex(1)), ('?5: '?3) due to Single(bb0[6]) (None) (Boring) (ConstraintSccIndex(1): ConstraintSccIndex(1)), ('?3: '?4) due to Single(bb0[6]) (None) (Assignment) (ConstraintSccIndex(1): ConstraintSccIndex(1)), ('?4: '?0) due to All(src/main.rs:15:5: 15:6 (#0)) (None) (OpaqueType) (ConstraintSccIndex(1): ConstraintSccIndex(1)), ``` This additional `Assignment` step then worsens the error message as we stop talking about the fact that the closures is returned from the function. Fixing this is hard. I've looked into this and it's making me sad :< Properly handling this requires some deeper changes to MIR borrowck diagnostics and that seems like too much for this PR. Given that this only impacts a single test, it seems acceptable to me. r? `@ghost`
2025-08-21fix: `semicolon_inside_block` FP when attribute over expr is not enabledyanglsh-0/+53
2025-08-21fix: `unnecessary_safety_comment` does not lint for the first lineyanglsh-8/+75
2025-08-21fix: `redundant_closure` suggests wrongly with deref overloadyanglsh-9/+130
2025-08-21move few complex initialization from config to parse-innerbit-aloo-49/+61
2025-08-20Add codegen regression testsokaneco-0/+182
Most of these regressions concern elimination of panics and bounds checks that were fixed upstream by LLVM.
2025-08-21Introduce ProjectionElem::try_map.Camille GILLOT-93/+67
2025-08-20Diff-massaging commitltdk-87/+70
2025-08-20Move WTF-8 code from std to core/allocltdk-1278/+331
2025-08-20Copy WTF-8 code into core/alloc (for better diffs)ltdk-0/+1083
2025-08-20Migrate `panic_unwind` to use `cfg_select!`Josh Stone-14/+20
2025-08-20Auto merge of #145259 - nikic:read-only-capture, r=wesleywiserbors-14/+51
Tell LLVM about read-only captures `&Freeze` parameters are not only `readonly` within the function, but any captures of the pointer can also only be used for reads. This can now be encoded using the `captures(address, read_provenance)` attribute.
2025-08-20rustc_hir_id: Add a comment explaining why the crate existsJosh Triplett-0/+2
2025-08-20Eliminate unnecessary dependency from `rustc_traits` to `rustc_hir`Josh Triplett-4/+2
`rustc_traits` only uses `DefId`, which is a re-export from `rustc_span`.
2025-08-20Eliminate unnecessary dependency from `rustc_mir_dataflow` to `rustc_hir`Josh Triplett-4/+2
`rustc_mir_dataflow` only uses `DefId`, which is a re-export from `rustc_span`.
2025-08-20rustc_lint_defs: Eliminate the dependency on `rustc_hir` for `Namespace`Josh Triplett-12/+10
`rustc_lint_defs` uses `rustc_hir` solely for the `Namespace` type, which it only needs the static description from. Use the static description directly, to eliminate the dependency on `rustc_hir`. This reduces a long dependency chain: - Many things depend on `rustc_errors` - `rustc_errors` depends on `rustc_lint_defs` - `rustc_lint_defs` depended on `rustc_hir` prior to this commit - `rustc_hir` depends on `rustc_target`
2025-08-20rustc_lint_defs: Use `DefPathHash` from `rustc_span` rather than `rustc_hir`Josh Triplett-1/+1
2025-08-20Update test output for change to number of cratesJosh Triplett-5/+5
2025-08-20Split `rustc_hir_id` out of `rustc_hir`Josh Triplett-35/+61
Some crates depend on `rustc_hir` but only want `HirId` and similar id types. `rustc_hir` is a heavy dependency, since it pulls in `rustc_target`. Split these types out into their own crate `rustc_hir_id`. This allows `rustc_errors` to drop its direct dependency on `rustc_hir`. (`rustc_errors` still depends on `rustc_hir` indirectly through `rustc_lint_defs`; a subsequent commit will fix that.)
2025-08-20Move `IntoDiagArg` earlier in the dependency chainsJosh Triplett-395/+425
`rustc_errors` depends on numerous crates, solely to implement its `IntoDiagArg` trait on types from those crates. Many crates depend on `rustc_errors`, and it's on the critical path. We can't swap things around to make all of those crates depend on `rustc_errors` instead, because `rustc_errors` would end up in dependency cycles. Instead, move `IntoDiagArg` into `rustc_error_messages`, which has far fewer dependencies, and then have most of these crates depend on `rustc_error_messages`. This allows `rustc_errors` to drop dependencies on several crates, including the large `rustc_target`. (This doesn't fully reduce dependency chains yet, as `rustc_errors` still depends on `rustc_hir` which depends on `rustc_target`. That will get fixed in a subsequent commit.)
2025-08-20test(rustfmt): Verify frontmatter is preservedEd Page-0/+74
This is to prove that the frontmatter is preserved. The choices in tests is intended for showing the different parts of the proposed Style Guide for frontmatters.
2025-08-20Merge pull request #1901 from folkertdev/wasm-read-unalignedAmanieu d'Antras-24/+14
wasm: use `{read, write}_unaligned` methods
2025-08-20Merge pull request #1899 from dpaoliello/arm64ecFolkert de Vries-12/+823
Add testing for Arm64EC Windows
2025-08-20s390x: link to a missed optimizationFolkert de Vries-0/+3
2025-08-20s390x: implement `vec_sld` using `fshl`Folkert de Vries-9/+46
2025-08-20s390x: implement `vec_subc_u128` using `overflowing_sub`Folkert de Vries-6/+4
2025-08-20s390x: implement `vec_mulo` using `core::intrinsics::simd`Folkert de Vries-36/+32
2025-08-20wasm: use `{read, write}_unaligned` methodsFolkert de Vries-24/+14
2025-08-20s390x: implement `vec_mule` using `core::intrinsics::simd`Folkert de Vries-38/+47
2025-08-20s390x: add `assert_instr` for `vec_extend`Folkert de Vries-6/+3
2025-08-20s390x: add `assert_instr` for `vec_round`Folkert de Vries-4/+2
2025-08-20s390x: define `unpack_low` using `core::intrinsics::simd`Folkert de Vries-9/+8
2025-08-20Merge pull request #1897 from nikic/dummyFolkert de Vries-199/+212
Fix CI after LLVM upgrade
2025-08-20fix: typoTuomas Tajakka-1/+1
The return type is correct in the source code but incorrect in the docstring
2025-08-20fix whatever this isAda Alakbarova-6/+5
2025-08-20make a big let-chainAda Alakbarova-19/+9
2025-08-20merge patsAda Alakbarova-2/+2
2025-08-20Detect missing `if let` or `let-else`Esteban Küber-0/+158
During `let` binding parse error and encountering a block, detect if there is a likely missing `if` or `else`: ``` error: expected one of `.`, `;`, `?`, `else`, or an operator, found `{` --> $DIR/missing-if-let-or-let-else.rs:14:25 | LL | let Some(x) = foo() { | ^ expected one of `.`, `;`, `?`, `else`, or an operator | help: you might have meant to use `if let` | LL | if let Some(x) = foo() { | ++ help: alternatively, you might have meant to use `let else` | LL | let Some(x) = foo() else { | ++++ ```
2025-08-20make download context lean and remove mutable typesbit-aloo-79/+89
2025-08-20Auto merge of #144086 - clubby789:alloc-zeroed, r=nikicbors-0/+36
Pass `alloc-variant-zeroed` to LLVM Makes use of https://github.com/llvm/llvm-project/pull/138299 (once we pull in a version of LLVM with this attribute). ~~Unfortunately also requires https://github.com/llvm/llvm-project/pull/149336 to work.~~ Closes rust-lang/rust#104847
2025-08-20Enable triagebot `[review-changes-since]` featureUrgau-0/+5
2025-08-20Adjust test to still show miscompileNikita Popov-0/+3
The capture of i in assert_ne!() is now known read-only, which enables early SROA. Block this by passing i to println, where we currently cannot recognize this.
2025-08-20Tell LLVM about read-only capturesNikita Popov-14/+48
`&Freeze` parameters are not only `readonly` within the function, but any captures of the pointer can also only be used for reads. This can now be encoded using the `captures(address, read_provenance)` attribute.
2025-08-21Add flock support for cygwin王宇逸-0/+10
2025-08-20Merge pull request #2546 from lolbinarycat/patch-7nora-3/+3
Update bootstrapping docs to account for new stage meanings
2025-08-20Instantiate higher-ranked binder with erased when checking IntoIterator ↵Michael Goulet-9/+25
predicate query instability
2025-08-20Merge pull request #2549 from lumiscosity/optimize-imagesnora-0/+0
Losslessly optimize PNG files