about summary refs log tree commit diff
path: root/compiler/rustc_mir_transform/src
AgeCommit message (Collapse)AuthorLines
2025-08-17Auto merge of #145284 - nnethercote:type_name-print-regions, r=lcnrbors-17/+28
Print regions in `type_name`. Currently they are skipped, which is a bit weird, and it sometimes causes malformed output like `Foo<>` and `dyn Bar<, A = u32>`. Most regions are erased by the time `type_name` does its work. So all regions are now printed as `'_` in non-optional places. Not perfect, but better than the status quo. `c_name` is updated to trim lifetimes from MIR pass names, so that the `PASS_NAMES` sanity check still works. It is also renamed as `simplify_pass_type_name` and made non-const, because it doesn't need to be const and the non-const implementation is much shorter. The commit also renames `should_print_region` as `should_print_optional_region`, which makes it clearer that it only applies to some regions. Fixes rust-lang/rust#145168. r? `@lcnr`
2025-08-15Rollup merge of #145392 - Zalathar:create-mappings, r=petrochenkovStuart Cook-77/+31
coverage: Remove intermediate data structures from mapping creation The data structures in `coverage::mappings` were historically very useful for isolating the details of mapping-extraction from the details of how coverage mappings are stored in MIR. But because of various changes that have taken place over time, they now provide little value, and cause difficulty for the coordinated changes that will be needed for introducing expansion mapping support. In the future, the pendulum might eventually swing back towards these being useful again, but we can always reintroduce suitable intermediate data structures if and when that happens. For now, the simplicity of not having this intermediate layer is a higher priority. There should be no changes to compiler output.
2025-08-14coverage: Remove intermediate data structures from mapping creationZalathar-77/+31
2025-08-14Print regions in `type_name`.Nicholas Nethercote-17/+28
Currently they are skipped, which is a bit weird, and it sometimes causes malformed output like `Foo<>` and `dyn Bar<, A = u32>`. Most regions are erased by the time `type_name` does its work. So all regions are now printed as `'_` in non-optional places. Not perfect, but better than the status quo. `c_name` is updated to trim lifetimes from MIR pass names, so that the `PASS_NAMES` sanity check still works. It is also renamed as `simplify_pass_type_name` and made non-const, because it doesn't need to be const and the non-const implementation is much shorter. The commit also renames `should_print_region` as `should_print_optional_region`, which makes it clearer that it only applies to some regions. Fixes #145168.
2025-08-13Cleanup assoc parent utilsCameron Steffen-4/+4
2025-08-12make no_mangle explicit on foreign itemsJana Dönszelmann-1/+1
2025-08-09Rollup merge of #144883 - scottmcm:remove-unneeded-drop_in_place, r=nnethercoteStuart Cook-7/+24
Remove unneeded `drop_in_place` calls Might as well pull this out from rust-lang/rust#144561 because this is still used in things like `Vec::truncate` where it'd be nice to allow it be removed if inlined enough to see that the type is `Copy`. So long as perf says it's ok, at least 🤞
2025-08-08coverage: Remove obsolete comment about hashing HIRZalathar-2/+5
This code does not hash HIR manually (and has not done so for some time); it merely obtains a hash returned as part of `hir_owner_nodes`.
2025-08-08coverage: Extract HIR-related helper code out of the main moduleZalathar-136/+139
2025-08-08Rollup merge of #145030 - cjgillot:gvn-no-flatten-index, r=saethlinStuart Cook-2/+13
GVN: Do not flatten derefs with ProjectionElem::Index. r? `@saethlin` This should fix the bug you found with https://github.com/rust-lang/rust/pull/131650
2025-08-08Rollup merge of #144999 - Zalathar:remove-mcdc, r=oli-obkStuart Cook-379/+5
coverage: Remove all unstable support for MC/DC instrumentation Preliminary support for a partial implementation of “Modified Condition/Decision Coverage” instrumentation was added behind the unstable flag `-Zcoverage-options=mcdc` in 2024. These are the most substantial PRs involved: - rust-lang/rust#123409 - rust-lang/rust#126733 At the time, I accepted these PRs with relatively modest scrutiny, because I did not want to stand in the way of independent work on MC/DC instrumentation. My hope was that ongoing work by interested contributors would lead to the code becoming clearer and more maintainable over time. --- However, that MC/DC code has proven itself to be a major burden on overall maintenance of coverage instrumentation, and a major obstacle to other planned improvements, such as internal changes needed for proper support of macro expansion regions. I have also become reluctant to accept any further MC/DC-related changes that would increase this burden. That tension has resulted in an unhappy impasse. On one hand, the present MC/DC implementation is not yet complete, and shows little sign of being complete at an acceptable level of code quality in the foreseeable future. On the other hand, the continued existence of this partial MC/DC implementation is imposing serious maintenance burdens on every other aspect of coverage instrumentation, and is preventing some of the very improvements that would make it easier to accept expanded MC/DC support in the future. While I know this will be disappointing to some, I think the healthy way forward is accept that I made the wrong call in accepting the current implementation, and to remove it entirely from the compiler.
2025-08-07Do not flatten derefs with ProjectionElem::Index.Camille Gillot-2/+13
2025-08-06Rollup merge of #144996 - dianqk:simplifycfg-collapse_goto_chain-changed, ↵Guillaume Gomez-0/+1
r=cjgillot simplifycfg: Mark as changed when start is modified in collapse goto chain Split from rust-lang/rust#142771. r? cjgillot
2025-08-06coverage: Remove all unstable support for MC/DC instrumentationZalathar-379/+5
2025-08-06simplifycfg: Mark as changed when start is modified in collapse goto chaindianqk-0/+1
2025-08-04Let `RemoveUnneededDrops` also remove `drop_in_place`Scott McMurray-7/+24
2025-08-04coverage: Push async special case down into `extract_refined_covspans`Zalathar-14/+16
2025-08-04coverage: Remove `-Zcoverage-options=no-mir-spans`Zalathar-5/+1
This flag turned out to be less useful than anticipated, and interferes with work towards expansion support.
2025-08-02Rollup merge of #144756 - WaffleLapkin:inf-rec-etc-ctfe, r=lqdSamuel Tardieu-1/+1
detect infinite recursion with tail calls in ctfe fixes rust-lang/rust#144753
2025-08-02Rollup merge of #132748 - ↵Samuel Tardieu-0/+4
lolbinarycat:rustdoc-intra-doc-link-warn-more-54191, r=GuillaumeGomez get rid of some false negatives in rustdoc::broken_intra_doc_links rustdoc will not try to do intra-doc linking if the "path" of a link looks too much like a "real url". however, only inline links (`[text](url)`) can actually contain a url, other types of links (reference links, shortcut links) contain a *reference* which is later resolved to an actual url. the "path" in this case cannot be a url, and therefore it should not be skipped due to looking like a url. fixes https://github.com/rust-lang/rust/issues/54191 to minimize the number of false positives that will be introduced, the following heuristic is used: If there's no backticks, be lenient revert to old behavior. This is to prevent churn by linting on stuff that isn't meant to be a link. only shortcut links have simple enough syntax that they are likely to be written accidentlly, collapsed and reference links need 4 metachars, and reference links will not usually use backticks in the reference name. therefore, only shortcut syntax gets the lenient behavior. here's a truth table for how link kinds that cannot be urls are handled: | | is shortcut link | not shortcut link | |--------------|--------------------|-------------------| | has backtick | never ignore | never ignore | | no backtick | ignore if url-like | never ignore |
2025-07-31detect infinite recursion with tail calls in ctfeWaffle Lapkin-1/+1
2025-07-31remove rustc_attr_data_structuresJana Dönszelmann-5/+6
2025-07-31Auto merge of #144723 - Zalathar:rollup-f9e0rfo, r=Zalatharbors-1/+5
Rollup of 3 pull requests Successful merges: - rust-lang/rust#144657 (fix: Only "close the window" when its the last annotated file) - rust-lang/rust#144665 (Re-block SRoA on SIMD types) - rust-lang/rust#144713 (`rustc_middle::ty` cleanups) r? `@ghost` `@rustbot` modify labels: rollup
2025-07-31Rollup merge of #144663 - Zalathar:empty-span, r=petrochenkovStuart Cook-2/+36
coverage: Re-land "Enlarge empty spans during MIR instrumentation" This allows us to assume that coverage spans will only be discarded during codegen in very unusual situations. --- This seemingly-simple change has a rather messy history: - rust-lang/rust#140847 - rust-lang/rust#141650 - rust-lang/rust#144298 - rust-lang/rust#144480 Since then, a number of related changes have landed that should make it reasonable to try again: - rust-lang/rust#144530 - rust-lang/rust#144560 - rust-lang/rust#144616 In particular, we have multiple fixes/mitigations, and a confirmed regression test for the original bug that is not triggered by re-landing the changes in this PR.
2025-07-31Rollup merge of #143672 - beepster4096:box_drop_flags_again, r=oli-obkStuart Cook-26/+28
Fix Box allocator drop elaboration New version of rust-lang/rust#131146. Clearing Box's drop flag after running its destructor can cause it to skip dropping its allocator, so just don't. Its cleared by the drop ladder code afterwards already. Unlike the last PR this also handles other types with destructors properly, in the event that we can have open drops on them in the future (by partial initialization or DerefMove or something). Finally, I also added tests for the interaction with async drop here but I discovered rust-lang/rust#143658, so one of the tests has a `knownbug` annotation. Not sure if it should be in this PR at all though. Fixes rust-lang/rust#131082 r? wesleywiser - prev. reviewer
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-2/+36
This allows us to assume that coverage spans will only be discarded during codegen in very unusual situations.
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-29coverage: Treat `#[automatically_derived]` as `#[coverage(off)]`Zalathar-10/+9
2025-07-29coverage: Rename `CoverageStatus` to `CoverageAttrKind`Zalathar-13/+16
This patch also prepares the affected code in `coverage_attr_on` for some subsequent changes.
2025-07-28Simplify `align_of_val::<[T]>(…)` → `align_of::<T>()`Scott McMurray-0/+31
2025-07-28Auto merge of #144377 - camsteffen:simplify-impl-of-method, r=fee1-deadbors-5/+5
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-28Rename impl_of_method -> impl_of_assocCameron Steffen-3/+3
2025-07-28Rename trait_of_item -> trait_of_assocCameron Steffen-2/+2
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-28Auto merge of #144469 - Kivooeo:chains-cleanup, r=SparrowLiibors-31/+28
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-28use let chains in mir, resolve, targetKivooeo-27/+24
2025-07-28use let chains in hir, lint, mirKivooeo-4/+4
2025-07-27Allow more MIR SROAScott McMurray-28/+8
2025-07-26Revert "coverage: Enlarge empty spans during MIR instrumentation, not codegen"Zalathar-36/+2
This reverts commit f877aa7d14916f71a2f88c6d4c009e7ded7684c4.
2025-07-25span_bug instead of handling currently impossible drop casebeepster4096-7/+8
2025-07-25fix box destructor generationbeepster4096-27/+28
2025-07-24fix up issues with internal compiler docs revealed by stricter lintbinarycat-0/+4
2025-07-23Remove useless lifetime parameter.Camille GILLOT-1/+1
2025-07-23Auto merge of #144233 - cjgillot:unsat-mir, r=oli-obkbors-8/+17
Consider parent predicates in ImpossiblePredicates pass. This pass is double edged. It avoids some ICEs (yay!) but also degrades diagnostics from constant evaluation. Fixes rust-lang/rust#121363 Fixes rust-lang/rust#131507 Fixes rust-lang/rust#140100 Fixes rust-lang/rust#140365
2025-07-23Rollup merge of #144298 - Zalathar:empty-span, r=wesleywiserMatthias Krüger-2/+36
coverage: Enlarge empty spans during MIR instrumentation, not codegen This re-lands the part of rust-lang/rust#140847 that was (hopefully) not responsible for the coverage-instrumentation regressions that caused that PR to be reverted. --- Enlarging empty spans was historically performed during MIR instrumentation, but had to be moved to codegen as part of larger changes in rust-lang/rust#134497, leading to the status quo. But now there should be no reason not to move that step back to its more logical home in instrumentaion.
2025-07-22Rename `tests/codegen` into `tests/codegen-llvm`Guillaume Gomez-1/+1
2025-07-22coverage: Enlarge empty spans during MIR instrumentation, not codegenZalathar-2/+36
This allows us to assume that coverage spans will only be discarded during codegen in very unusual situations.
2025-07-22Keep elaborating predicates.Camille GILLOT-12/+9
2025-07-22Rollup merge of #144212 - bjorn3:remove_unique_lang_item, r=oli-obk许杰友 Jieyou Xu (Joe)-2/+0
Remove the ptr_unique lang item Miri no longer uses it since https://github.com/rust-lang/miri/pull/4307.