summary refs log tree commit diff
path: root/compiler
AgeCommit message (Collapse)AuthorLines
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-29Make resolve_fn_signature responsible for its own rib.Camille GILLOT-75/+54
2025-07-28feat: Right align line numbersScott Schafer-44/+54
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
2025-07-28Auto merge of #144543 - scottmcm:more-sroa, r=cjgillotbors-28/+8
Allow more MIR SROA This removes some guards on SROA that are no longer needed: - With https://github.com/rust-lang/compiler-team/issues/838 it no longer needs to check for SIMD - With https://github.com/rust-lang/compiler-team/issues/807 it no longer needs to check for niches - This means that `Wrapper(char)` and `Pin<&mut T>` can get SRoA'd now, where previously they weren't because the check was banning SRaA for anything with a niche -- not just things with `#[rustc_layout_scalar_valid_range_*]`. - Technically rust-lang/rust#133652 isn't complete yet, but `NonZero` and `NonNull` have already moved over, so this is fine. At worst this will mean that LLVM gets less `!range` metadata on something that wasn't already fixed by rust-lang/rust#133651 or rust-lang/rust#135236, but that's still sound, and unblocking general SRoA is worth that tradeoff.
2025-07-28Raw Pointers are Constant PatKinds tooBoxy-0/+2
2025-07-28Auto merge of #144562 - matthiaskrgr:rollup-mlvn7qo, r=matthiaskrgrbors-219/+69
Rollup of 7 pull requests Successful merges: - rust-lang/rust#144072 (update `Atomic*::from_ptr` and `Atomic*::as_ptr` docs) - rust-lang/rust#144151 (`tests/ui/issues/`: The Issues Strike Back [1/N]) - rust-lang/rust#144300 (Clippy fixes for miropt-test-tools) - rust-lang/rust#144399 (Add a ratchet for moving all standard library tests to separate packages) - rust-lang/rust#144472 (str: Mark unstable `round_char_boundary` feature functions as const) - rust-lang/rust#144503 (Various refactors to the codegen coordinator code (part 3)) - rust-lang/rust#144530 (coverage: Infer `instances_used` from `pgo_func_name_var_map`) r? `@ghost` `@rustbot` modify labels: rollup
2025-07-28Rollup merge of #144530 - Zalathar:instances-used, r=lqdMatthias Krüger-22/+28
coverage: Infer `instances_used` from `pgo_func_name_var_map` In obscure circumstances involving macro-expanded spans, we would sometimes emit a covfun record for a function with no physical coverage counters, and therefore no corresponding entry in the “PGO names” section of the binary. The absence of that name entry causes `llvm-cov` to fail with the cryptic error message: ```text malformed instrumentation profile data: function name is empty ``` We can eliminate this mismatch by removing `instances_used` entirely, and instead inferring its contents from the keys of `pgo_func_name_var_map`. This makes it impossible for a "used" function to lack a PGO name entry. --- This is an attempt to eliminate the cause of rust-lang/rust#141577 when re-landing changes like rust-lang/rust#144298 in the future. I haven't been able to reproduce the underlying issue in an in-tree test, because the only known repro involves a non-trivial derive proc-macro that relies on `syn` and `proc-macro2`. But I have manually verified in a separate branch that this change would have prevented the reoccurrence of https://github.com/rust-lang/rust/issues/141577#issuecomment-3120667286.
2025-07-28Rollup merge of #144503 - bjorn3:lto_refactors3, r=petrochenkovMatthias Krüger-197/+41
Various refactors to the codegen coordinator code (part 3) Continuing from https://github.com/rust-lang/rust/pull/144062 this removes an option without any known users, uses the object crate in favor of LLVM for getting the LTO bitcode and improves the coordinator channel handling.
2025-07-27Remove `[T]::array_chunks(_mut)`Scott McMurray-1/+1
2025-07-28Auto merge of #144469 - Kivooeo:chains-cleanup, r=SparrowLiibors-1203/+1109
Some `let chains` clean-up Not sure if this kind of clean-up is welcoming because of size, but I decided to try out one r? compiler
2025-07-28Auto merge of #144556 - matthiaskrgr:rollup-aayo3h5, r=matthiaskrgrbors-224/+271
Rollup of 6 pull requests Successful merges: - rust-lang/rust#143607 (Port the proc macro attributes to the new attribute parsing infrastructure) - rust-lang/rust#144471 (Remove `compiler-builtins-{no-asm,mangled-names}`) - rust-lang/rust#144495 (bump cargo_metadata) - rust-lang/rust#144523 (rustdoc: save target modifiers) - rust-lang/rust#144534 (check_static_item: explain should_check_for_sync choices) - rust-lang/rust#144535 (miri: for ABI mismatch errors, say which argument is the problem) Failed merges: - rust-lang/rust#144536 (miri subtree update) r? `@ghost` `@rustbot` modify labels: rollup
2025-07-28use let chains in mir, resolve, targetKivooeo-450/+417
2025-07-28use let chains in hir, lint, mirKivooeo-308/+279
2025-07-28use let chains in ast, borrowck, codegen, const_evalKivooeo-445/+413
2025-07-28Complete span lowering.Camille GILLOT-16/+45
2025-07-28Rollup merge of #144535 - RalfJung:abi-mismatch-err, r=compiler-errorsMatthias Krüger-13/+26
miri: for ABI mismatch errors, say which argument is the problem
2025-07-28Rollup merge of #144534 - RalfJung:should_check_for_sync, r=compiler-errorsMatthias Krüger-3/+9
check_static_item: explain should_check_for_sync choices Follow-up to https://github.com/rust-lang/rust/pull/144226. r? ``@oli-obk``