about summary refs log tree commit diff
path: root/compiler
AgeCommit message (Collapse)AuthorLines
2025-07-30Rollup merge of #144666 - compiler-errors:correct-late, r=lqdStuart Cook-6/+21
Make sure to account for the right item universal regions in borrowck Fixes https://github.com/rust-lang/rust/issues/144608. The ICE comes from a mismatch between the liberated late bound regions (i.e. "`ReLateParam`"s) that come from promoting closure outlives, and the regions we have in our region vid mapping from `UniversalRegions`. When building `UniversalRegions`, we end up using the liberated regions from the binder of the closure's signature: https://github.com/rust-lang/rust/blob/c8bb4e8a126cf38cff70cea488a3a423a5321954/compiler/rustc_borrowck/src/universal_regions.rs#L521 Notably, this signature may be anonymized if the closure signature being deduced comes from an external constraints: https://github.com/rust-lang/rust/blob/c8bb4e8a126cf38cff70cea488a3a423a5321954/compiler/rustc_hir_typeck/src/closure.rs#L759-L762 This is true in the test file I committed, where the signature is influenced by the `impl FnMut(&mut ())` RPIT. However, when promoting a type outlives constraint we end up creating a late bound lifetime mapping that disagrees with those liberated late bound regions we constructed in `UniversalRegions`: https://github.com/rust-lang/rust/blob/c8bb4e8a126cf38cff70cea488a3a423a5321954/compiler/rustc_borrowck/src/universal_regions.rs#L299 Specifically, in `for_each_late_bound_region_in_item` (which is called by `for_each_late_bound_region_in_recursive_scope`), we were using `tcx.late_bound_vars` which uses the late bound regions *from the HIR*. This query both undercounts the late bound regions (e.g. those that end up being deduced from bounds), and also doesn't account for the fact that we anonymize them in the signature as mentioned above. https://github.com/rust-lang/rust/blob/c8bb4e8a126cf38cff70cea488a3a423a5321954/compiler/rustc_borrowck/src/universal_regions.rs#L977 This PR fixes that function to use the *correct signature*, which properly considers the bound vars that come from deducing the signature of the closure, and which comes from the closure's args from the `type_of` query.
2025-07-30Rollup merge of #144268 - xizheyin:find-oldest-ancestor, r=jieyouxuStuart Cook-42/+58
Add method `find_ancestor_not_from_macro` and `find_ancestor_not_from_extern_macro` to supersede `find_oldest_ancestor_in_same_ctxt` As I was using it, I realized that the function is supposed to walk up to expand the chain? This seems to be the opposite of what I understood. r? `@jieyouxu`
2025-07-30const-eval: full support for pointer fragmentsRalf Jung-202/+230
2025-07-30Make sure to account for the right item universal regions in borrowckMichael Goulet-6/+21
2025-07-29Re-block SRoA on SIMD typesScott McMurray-1/+5
Fixes 144621
2025-07-30coverage: Re-land "Enlarge empty spans during MIR instrumentation"Zalathar-26/+40
This allows us to assume that coverage spans will only be discarded during codegen in very unusual situations.
2025-07-30Auto merge of #144577 - oli-obk:wrapping-niche, r=scottmcmbors-27/+74
Pick the largest niche even if the largest niche is wrapped around fixes rust-lang/rust#144388 r? `@scottmcm`
2025-07-29Rollup merge of #144640 - FractalFir:m68k_arch, r=UrgauJacob Pratt-0/+1
Add support for the m68k architecture in 'object_architecture' This is a tiny PR that adds the m68k architecture to `object_architecture`. This allows us to build rmeta files for that ISA(we use the object crate to pack metadata into object files).
2025-07-29Rollup merge of #144605 - LorrensP-2158466:cache-extern-prelude, r=petrochenkovJacob Pratt-12/+11
Resolve: cachify `ExternPreludeEntry.binding` through a `Cell` Provides interior mutability to the `binding` field of `ExternPreludeEntry` as this field behaves like a cache. Per [zulip thread](https://rust-lang.zulipchat.com/#narrow/channel/421156-gsoc/topic/Project.3A.20Parallel.20Macro.20Expansion/near/531390914). A little preparatory work for batched import resolution, which is part of [#gsoc > Project: Parallel Macro Expansion](https://rust-lang.zulipchat.com/#narrow/channel/421156-gsoc/topic/Project.3A.20Parallel.20Macro.20Expansion). r? `@petrochenkov`
2025-07-29Auto merge of #144557 - cjgillot:lower-more-span, r=compiler-errorsbors-16/+45
Complete span AST lowering. r? `@ghost`
2025-07-29Reuse `sign_extend` helperOli Scherer-3/+3
2025-07-29Pick the largest niche even if the largest niche is wrapped aroundOli Scherer-26/+73
2025-07-29Rollup merge of #144615 - cjgillot:fn-sig-rib, r=petrochenkovStuart Cook-75/+54
Make resolve_fn_signature responsible for its own rib. Small simplification in late resolver rib bookkeeping. r? `@petrochenkov`
2025-07-29Rollup merge of #144589 - compiler-errors:postfix-yield-after-cast, ↵Stuart Cook-1/+5
r=petrochenkov Account for `.yield` in illegal postfix operator message Fixes rust-lang/rust#144527
2025-07-29Rollup merge of #144587 - petrochenkov:optstdprel, r=nnethercoteStuart Cook-3/+1
expand: Micro-optimize prelude injection Use `splice` to avoid shifting the other items twice. Put `extern crate std;` first so it's already resolved when we resolve `::std::prelude::rust_20XX`.
2025-07-29Rollup merge of #144566 - scottmcm:align-of-slice, r=oli-obkStuart Cook-0/+31
Simplify `align_of_val::<[T]>(…)` → `align_of::<T>()` I spotted this while working on the inliner (rust-lang/rust#144561). In particular, if [`Layout::for_value`](https://doc.rust-lang.org/std/alloc/struct.Layout.html#method.for_value) inlines, then it can be pretty easy to end up with an `align_of_val::<[T]>` today (demo: <https://rust.godbolt.org/z/Tesnscj4a>) where we can save at least a block, if not more, by using the version that's an rvalue and not a call.
2025-07-29Rollup merge of #144560 - Zalathar:auto-derived, r=compiler-errorsStuart Cook-42/+36
coverage: Treat `#[automatically_derived]` as `#[coverage(off)]` One of the contributing factors behind https://github.com/rust-lang/rust/issues/141577#issuecomment-3120667286 was the presence of derive-macro-generated code containing nested closures. Coverage instrumentation already has a heuristic for skipping code marked with `#[automatically_derived]` (rust-lang/rust#120185), because derived code is usually not worth instrumenting, and also has a tendency to trigger vexing edge-case bugs in coverage instrumentation or coverage codegen. However, the existing heuristic only applied to the associated items directly within an auto-derived impl block, and had no effect on closures or nested items within those associated items. This PR therefore extends the search for `#[coverage(..)]` attributes to also treat `#[automatically_derived]` as an implied `#[coverage(off)]` for the purposes of coverage instrumentation. --- This change doesn’t rule out an entire category of bugs, because it only affects code that actually uses the auto-derived attribute. But it should reduce the overall chance of edge-case macro span bugs being observed in the wild.
2025-07-29"Cachify" `ExternPreludeEntry.binding` through a `Cell`.LorrensP-2158466-12/+11
2025-07-29Add support for the m68k architecture in 'object_architecture'FractalFir-0/+1
2025-07-29Rollup merge of #144626 - RalfJung:cc-pin-comment, r=lqdStuart Cook-4/+4
cc dependencies: clarify comment This caused confusion in https://github.com/rust-lang/rust/pull/144570 r? ``@jieyouxu``
2025-07-29Rollup merge of #144609 - Muscraft:right-align, r=compiler-errorsStuart Cook-44/+54
feat: Right align line numbers As part of my work on getting `annotate-snipptes` to be used as `rustc`'s renderer, I realized that `rustc` left-aligned line numbers, while `annotate-snippets` right-aligned them. This PR switches `rustc` to right-align the line numbers, matching `annotate-snippets`. In practice, this change isn't very noticeable in day-to-day output, as it only shows up when a diagnostic span contains line numbers with different lengths (9->10, 99->100, 999->1000, etc.). `rustc` ``` error[E0412]: cannot find type `F` in this scope --> $DIR/ui-testing-optout.rs:92:10 | 4 | type A = B; | ----------- similarly named type alias `A` defined here ... 92 | type E = F; | ^ help: a type alias with a similar name exists: `A` ``` `annotate-snippets` ``` error[E0412]: cannot find type `F` in this scope --> $DIR/ui-testing-optout.rs:92:10 | 4 | type A = B; | ----------- similarly named type alias `A` defined here ... 92 | type E = F; | ^ help: a type alias with a similar name exists: `A` ``` r? ``@compiler-errors``
2025-07-29Rollup merge of #144451 - ShoyuVanilla:loop-match-upvar, r=oli-obkStuart Cook-7/+14
fix: Reject upvar scrutinees for `loop_match` Fixes https://github.com/rust-lang/rust/issues/144051 I think we should reject upvars as they are not locals but somewhat like field access
2025-07-29Rollup merge of #144407 - godzie44:godzie44/fix_dwarf_inconsistency, ↵Stuart Cook-2/+2
r=wesleywiser fix(debuginfo): disable overflow check for recursive non-enum types Commit b10edb4 introduce an overflow check when generating debuginfo for expanding recursive types. While this check works correctly for enums, it can incorrectly prune valid debug information for structures. For example see rust-lang/rust#143241 (https://github.com/rust-lang/rust/issues/143241#issuecomment-3073721477). Furthermore, for structures such check does not make sense, since structures with recursively expanding types simply will not compile (there is a `hir_analysis_recursive_generic_parameter` for that). closes rust-lang/rust#143241
2025-07-29coverage: Treat `#[automatically_derived]` as `#[coverage(off)]`Zalathar-10/+9
2025-07-29coverage: Rename `CoverageStatus` to `CoverageAttrKind`Zalathar-32/+27
This patch also prepares the affected code in `coverage_attr_on` for some subsequent changes.
2025-07-29resuse eagerly resolved goal from previous iterationlcnr-13/+37
2025-07-29cc dependencies: clarify commentRalf Jung-4/+4
2025-07-29Create two methods to fix `find_oldest_ancestor_in_same_ctxt`xizheyin-42/+58
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn>
2025-07-28Simplify `align_of_val::<[T]>(…)` → `align_of::<T>()`Scott McMurray-0/+31
2025-07-29Rollup merge of #144578 - FractalFir:m68k_fix, r=compiler-errorsStuart Cook-0/+5
Ensure correct aligement of rustc_hir::Lifetime on platforms with lower default alignments. The compiler relies on `hir::Lifetime` being aligned to at least 4 bytes(for the purposes of pointer tagging). However, on some systems(like m68k) with lower alignment requirements(eg. usize / u32 aligned to 2 bytes),`hir::Lifetime` will be aligned to only 2 bytes. This causes the compilation to fail on those systems - a const assert in the compiler fails. This PR makes the aligement requriement of hir::Lifetime explict. This has no effect on platforms where that already is the case(repr align can only raise alignment), but ensures the alignment will stay correct no matter what.
2025-07-29Rollup merge of #144573 - BoxyUwU:patkind_constant_ptr_docs, r=lcnrStuart Cook-0/+2
Raw Pointers are Constant PatKinds too raw pointers can be matched on with a const pattern: ```rust const FOO: *const u8 = core::ptr::null(); fn foo(a: *const u8) { match a { FOO => (), _ => todo!(), } } ``` as far as I can tell this is represented with a `PatKind::Constant`: https://github.com/rust-lang/rust/blob/master/compiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs#L333-L337
2025-07-29Auto merge of #143289 - scottmcm:remove-array-chunks, r=jhprattbors-1/+1
Remove `[T]::array_chunks(_mut)` Since libs-api is proposing as much in https://github.com/rust-lang/rust/issues/74985#issuecomment-3024465102 Closes rust-lang/rust#74985 Closes rust-lang/rust#76354 try-job: dist-various-1 try-job: dist-various-2
2025-07-29Add the CRC instructions.Philip Woolford-1/+1
2025-07-29Make resolve_fn_signature responsible for its own rib.Camille GILLOT-75/+54
2025-07-29Enable features that are always available in a live system.Philip Woolford-1/+1
While some neon and crypto features may not be supported on the switch at boot (e.g. on the a53 cores), the features will _always_ be available if running as a sysmodule or homebrew application under Horizon/Atmosphere.
2025-07-28feat: Right align line numbersScott Schafer-44/+54
2025-07-28Allow `cargo fix` to partially apply `mismatched_lifetime_syntaxes`Kornel-24/+45
2025-07-28Auto merge of #144377 - camsteffen:simplify-impl-of-method, r=fee1-deadbors-60/+56
Rename impl_of_method and trait_of_item This PR used to tweak the implementation of impl_of_method, but that introduced a perf regression. Rename impl_of_method and trait_of_item to impl_of_assoc and trait_of_assoc respectively. This reflects how the two functions are closely related. And it reflects the behavior more accurately as the functions check whether the input is an associated item.
2025-07-28Account for .yield in illegal postfix operator messageMichael Goulet-1/+5
2025-07-28Tweak docsCameron Steffen-5/+4
2025-07-28Rename impl_of_method -> impl_of_assocCameron Steffen-18/+18
2025-07-28Rename trait_of_item -> trait_of_assocCameron Steffen-23/+23
2025-07-28Introduce assoc_parentCameron Steffen-14/+11
2025-07-28Remove TraitAlias from trait_of_itemCameron Steffen-1/+1
This is dead code.
2025-07-28expand: Micro-optimize prelude injectionVadim Petrochenkov-3/+1
Use `splice` to avoid shifting the other items twice. Put `extern crate std;` first so it's already resolved when we resolve `::std::prelude::rust_20XX`.
2025-07-28fix: Reject upvar scrutinees for `loop_match`Shoyu Vanilla-7/+14
2025-07-28Support multiple crate versions in --extern-html-root-urlKornel-0/+8
2025-07-28Save names of used extern cratesKornel-0/+20
Tracks association between `self.sess.opts.externs` (aliases in `--extern alias=rlib`) and resolved `CrateNum` Intended to allow Rustdoc match the aliases in `--extern-html-root-url` Force-injected extern crates aren't included, since they're meant for the linker only
2025-07-28Clarify update_extern_crateKornel-5/+27
2025-07-28Avoid redundant lookup in CrateLoader::existing_matchKornel-1/+1