about summary refs log tree commit diff
path: root/compiler/rustc_middle/src
AgeCommit message (Collapse)AuthorLines
2025-02-16Move hashes from rustc_data_structure to rustc_hashes so they can be shared ↵Ben Kimock-3/+5
with rust-analyzer
2025-02-15Don't project into `NonNull` when dropping a `Box`Scott McMurray-5/+9
2025-02-15HIR analysis: Remove unnecessary abstraction over list of clausesLeón Orell Valerian Liehr-1/+1
2025-02-15Replace some u64 hashes with Hash64Ben Kimock-3/+3
2025-02-14Rollup merge of #137002 - chenyukang:fix-early-lint-check-desc, ↵Jubilee-1/+1
r=compiler-errors Fix early lint check desc in query When I debugging this issue: https://github.com/rust-lang/rust/pull/136906#discussion_r1954151036 I found early lint checking is performed after [macro expansion](https://github.com/chenyukang/rust/blob/37520e6d89eeea96b966ab281a7adf1775f7e207/compiler/rustc_interface/src/passes.rs#L267), but [prior to AST lowering](https://github.com/chenyukang/rust/blob/37520e6d89eeea96b966ab281a7adf1775f7e207/compiler/rustc_ast_lowering/src/lib.rs#L427). r? ``@cjgillot``
2025-02-14Move `MirPatch` from `rustc_middle` to `rustc_mir_transform`.Nicholas Nethercote-259/+0
Because it's only used in `rustc_mir_transform`. (Presumably it is currently in `rustc_middle` because lots of other MIR-related stuff is, but that's not a hard requirement.) And because `rustc_middle` is huge and it's always good to make it smaller.
2025-02-14Fix early lint check desc in queryyukang-1/+1
2025-02-13Auto merge of #136593 - lukas-code:ty-value-perf, r=oli-obkbors-80/+120
valtree performance tuning Summary: This PR makes type checking of code with many type-level constants faster. After https://github.com/rust-lang/rust/pull/136180 was merged, we observed a small perf regression (https://github.com/rust-lang/rust/pull/136318#issuecomment-2635562821). This happened because that PR introduced additional copies in the fast reject code path for consts, which is very hot for certain crates: https://github.com/rust-lang/rust/blob/6c1d960d88dd3755548b3818630acb63fa98187e/compiler/rustc_type_ir/src/fast_reject.rs#L486-L487 This PR improves the performance again by properly interning the valtrees so that copying and comparing them becomes faster. This will become especially useful with `feature(adt_const_params)`, so the fast reject code doesn't have to do a deep compare of the valtrees. Note that we can't just compare the interned consts themselves in the fast reject, because sometimes `'static` lifetimes in the type are be replaced with inference variables (due to canonicalization) on one side but not the other. A less invasive alternative that I considered is simply avoiding copies introduced by https://github.com/rust-lang/rust/pull/136180 and comparing the valtrees it in-place (see commit: https://github.com/rust-lang/rust/commit/9e91e50ac5920f0b9b4a3b1e0880c85336ba5c64 / perf results: https://github.com/rust-lang/rust/pull/136593#issuecomment-2642303245), however that was still measurably slower than interning. There are some minor regressions in secondary benchmarks: These happen due to changes in memory allocations and seem acceptable to me. The crates that make heavy use of valtrees show no significant changes in memory usage.
2025-02-13Implement and use BikeshedGuaranteedNoDrop for union/unsafe field validityMichael Goulet-0/+7
2025-02-13intern valtreesLukas Markeffsky-80/+120
2025-02-12Auto merge of #135994 - 1c3t3a:rename-unsafe-ptr, r=oli-obkbors-5/+5
Rename rustc_middle::Ty::is_unsafe_ptr to is_raw_ptr The wording unsafe pointer is less common and not mentioned in a lot of places, instead this is usually called a "raw pointer". For the sake of uniformity, we rename this method. This came up during the review of https://github.com/rust-lang/rust/pull/134424. r? `@Noratrieb`
2025-02-12Rollup merge of #136907 - workingjubilee:middle-errors-cleanup, ↵Guillaume Gomez-18/+10
r=compiler-errors compiler: Make middle errors `pub(crate)` and bury the dead code
2025-02-12Auto merge of #136905 - matthiaskrgr:rollup-8zwcgta, r=matthiaskrgrbors-4/+9
Rollup of 8 pull requests Successful merges: - #135549 (Document some safety constraints and use more safe wrappers) - #135965 (In "specify type" suggestion, skip type params that are already known) - #136193 (Implement pattern type ffi checks) - #136646 (Add a TyPat in the AST to reuse the generic arg lowering logic) - #136874 (Change the issue number for `likely_unlikely` and `cold_path`) - #136884 (Lower fn items as ZST valtrees and delay a bug) - #136885 (i686-linux-android: increase CPU baseline to Pentium 4 (without an actual change) - #136891 (Check sig for errors before checking for unconstrained anonymous lifetime) r? `@ghost` `@rustbot` modify labels: rollup
2025-02-11compiler: Make middle errors `pub(crate)` and bury some dead codeJubilee Young-18/+10
2025-02-12Rollup merge of #136884 - compiler-errors:fn-zst, r=BoxyUwUMatthias Krüger-4/+9
Lower fn items as ZST valtrees and delay a bug Lower it as a ZST instead of a const error, which we can handle mostly fine. Delay a bug so we don't accidentally support it tho. r? BoxyUwU Fixes #136855 Fixes #136853 Fixes #136854 Fixes #136337 Only added one test bc that's really the crux of the issue (fn item in array length position).
2025-02-12Auto merge of #136074 - compiler-errors:deeply-normalize-next-solver, r=lcnrbors-0/+10
Properly deeply normalize in the next solver Turn deep normalization into a `TypeOp`. In the old solver, just dispatch to the `Normalize` type op, but in the new solver call `deeply_normalize`. I chose to separate it into a different type op b/c some normalization is a no-op in the new solver, so this distinguishes just the normalization we need for correctness. Then use `DeeplyNormalize` in the callsites we used to be using a `CustomTypeOp` (for normalizing known type outlives obligations), and also use it to normalize function args and impl headers in the new solver. Finally, use it to normalize signatures for WF checks in the new solver as well. This addresses https://github.com/rust-lang/trait-system-refactor-initiative/issues/146.
2025-02-11Deeply normalize signature in new solverMichael Goulet-0/+3
2025-02-11Make DeeplyNormalize a real type opMichael Goulet-0/+7
2025-02-11Lower fn items as ZST valtrees and delay a bugMichael Goulet-4/+9
2025-02-11Rollup merge of #136847 - nnethercote:simplify-intra-crate-quals, r=oli-obkMatthias Krüger-46/+48
Simplify intra-crate qualifiers. The following is a weird pattern for a file within `rustc_middle`: ``` use rustc_middle::aaa; use crate::bbb; ``` More sensible and standard would be this: ``` use crate::{aaa, bbb}; ``` I.e. we generally prefer using `crate::` to using a crate's own name. (Exceptions are things like in macros where `crate::` doesn't work because the macro is used in multiple crates.) This commit fixes a bunch of these weird qualifiers. r? `@jieyouxu`
2025-02-11Rollup merge of #136833 - workingjubilee:let-the-impossible-be-impossible, ↵Matthias Krüger-11/+0
r=compiler-errors compiler: die immediately instead of handling unknown target codegen We cannot produce anything useful if asked to compile unknown targets. We should handle the error immediately at the point of discovery instead of propagating it upward, and preferably in the simplest way: Die. This allows cleaning up our "error-handling" spread across 5 crates.
2025-02-11Simplify intra-crate qualifiers.Nicholas Nethercote-46/+48
The following is a weird pattern for a file within `rustc_middle`: ``` use rustc_middle::aaa; use crate::bbb; ``` More sensible and standard would be this: ``` use crate::{aaa, bbb}; ``` I.e. we generally prefer using `crate::` to using a crate's own name. (Exceptions are things like in macros where `crate::` doesn't work because the macro is used in multiple crates.) This commit fixes a bunch of these weird qualifiers.
2025-02-10compiler: die immediately instead of handling unknown target codegenJubilee Young-11/+0
We cannot produce anything useful if asked to compile unknown targets. We should handle the error immediately at the point of discovery instead of propagating it upward, and preferably in the simplest way: Die. This allows cleaning up our "error-handling" spread across 5 crates.
2025-02-10Rollup merge of #136731 - safinaskar:parallel-2025-02-08-07-22, r=SparrowLiiMatthias Krüger-3/+0
rustc_middle: parallel: TyCtxt: remove "unsafe impl DynSend/DynSync" rustc_middle: parallel: TyCtxt: remove "unsafe impl DynSend/DynSync" We don't need to "short circuit trait resolution", because DynSend and DynSync are auto traits and thus coinductive cc "Parallel Rustc Front-end" https://github.com/rust-lang/rust/issues/113349 r? SparrowLii ``@rustbot`` label: +WG-compiler-parallel (rustbot sometimes ignores me and doesn't attach labels on my behalf. rustbot banned me?)
2025-02-10Extend the renaming to coerce_unsafe_ptrBastian Kersting-1/+1
2025-02-10Rename rustc_middle::Ty::is_unsafe_ptr to is_raw_ptrBastian Kersting-4/+4
The wording unsafe pointer is less common and not mentioned in a lot of places, instead this is usually called a "raw pointer". For the sake of uniformity, we rename this method. This came up during the review of https://github.com/rust-lang/rust/pull/134424.
2025-02-10Rollup merge of #136201 - davidv1992:eliminate-field-offset-alt, ↵Jubilee-3/+4
r=Mark-Simulacrum Removed dependency on the field-offset crate, alternate approach This is an alternate approach to reach the same goals as #136003. As it touches the core of the query system, this too probably should be evaluated for performance. r? ``@Mark-Simulacrum``
2025-02-10Rollup merge of #136053 - Zalathar:defer-counters, r=saethlinJubilee-81/+77
coverage: Defer part of counter-creation until codegen Follow-up to #135481 and #135873. One of the pleasant properties of the new counter-assignment algorithm is that we can stop partway through the process, store the intermediate state in MIR, and then resume the rest of the algorithm during codegen. This lets it take into account which parts of the control-flow graph were eliminated by MIR opts, resulting in fewer physical counters and simpler counter expressions. Those improvements end up completely obsoleting much larger chunks of code that were previously responsible for cleaning up the coverage metadata after MIR opts, while also doing a more thorough cleanup job. (That change also unlocks some further simplifications that I've kept out of this PR to limit its scope.)
2025-02-09Rollup merge of #136722 - kornelski:visit-spans, r=chenyukangMatthias Krüger-3/+6
Visit all debug info in MIR Visitor I've been experimenting with simplifying debug info in MIR inliner, and discovered that MIR Visitor doesn't reliably visit all spans. This PR adds the missing visitor calls.
2025-02-09Auto merge of #136751 - bjorn3:update_rustfmt, r=Mark-Simulacrumbors-49/+68
Update bootstrap compiler and rustfmt The rustfmt version we previously used formats things differently from what the latest nightly rustfmt does. This causes issues for subtrees that get formatted both in-tree and in their own repo. Updating the rustfmt used in-tree solves those issues. Also bumped the bootstrap compiler as the stage0 update command always updates both at the same time.
2025-02-08occured -> occurredMichael Goulet-1/+1
2025-02-08Rustfmtbjorn3-49/+68
2025-02-08Auto merge of #136728 - matthiaskrgr:rollup-x2qh9yt, r=matthiaskrgrbors-3/+1
Rollup of 6 pull requests Successful merges: - #136640 (Debuginfo for function ZSTs should have alignment of 8 bits, not 1 bit) - #136648 (Add a missing `//@ needs-symlink` to `tests/run-make/libs-through-symlinks`) - #136651 (Label mismatched parameters at the def site for foreign functions) - #136691 (Remove Linkage::Private and Linkage::Appending) - #136692 (add module level doc for bootstrap:utils:exec) - #136700 (i686-unknown-hurd-gnu: bump baseline CPU to Pentium 4) r? `@ghost` `@rustbot` modify labels: rollup
2025-02-08rustc_middle: parallel: TyCtxt: remove "unsafe impl DynSend/DynSync"Askar Safin-3/+0
We don't need to "short circuit trait resolution", because DynSend and DynSync are auto traits and thus coinductive
2025-02-08Rollup merge of #136691 - bjorn3:linkage_cleanup, r=jieyouxuMatthias Krüger-3/+1
Remove Linkage::Private and Linkage::Appending Neither of them has any use case. Neither known nor theoretical.
2025-02-08Auto merge of #136713 - matthiaskrgr:rollup-sy6py39, r=matthiaskrgrbors-0/+31
Rollup of 7 pull requests Successful merges: - #135179 (Make sure to use `Receiver` trait when extracting object method candidate) - #136554 (Add `opt_alias_variances` and use it in outlives code) - #136556 ([AIX] Update tests/ui/wait-forked-but-failed-child.rs to accomodate exiting and idle processes.) - #136589 (Enable "jump to def" feature on rustc docs) - #136615 (sys: net: Add UEFI stubs) - #136635 (Remove outdated `base_port` calculation in std net test) - #136682 (Move two windows process tests to tests/ui) r? `@ghost` `@rustbot` modify labels: rollup
2025-02-08Visit fn_span of calls in MIR VisitorKornel-2/+4
2025-02-08super_local_decl should visit source_info before copying itKornel-1/+2
Visiting source_info first makes it consistent with other visitors
2025-02-07Rollup merge of #136554 - compiler-errors:opt-alias-variances, r=lcnrMatthias Krüger-0/+31
Add `opt_alias_variances` and use it in outlives code ...so to fix some subtle outlives bugs with precise capturing in traits, and eventually make it easier to compute variances for "forced unconstrained" trait lifetimes. r? lcnr
2025-02-07Rollup merge of #136577 - dianne:simple-pat-migration-simplification, ↵Matthias Krüger-6/+20
r=Nadrieril Pattern Migration 2024: try to suggest eliding redundant binding modifiers This is based on #136475. Only the last commit is new. This is a simpler, more restrictive alternative to #136496, meant to partially address #136047. If a pattern can be migrated to Rust 2024 solely by removing redundant binding modifiers, this will make that suggestion; otherwise, it uses the old suggestion of making the pattern fully explicit. Relevant tracking issue: #131414 ``@rustbot`` label A-diagnostics A-patterns A-edition-2024 r? ``@Nadrieril``
2025-02-07Remove Linkage::Appendingbjorn3-1/+0
It can only be used for certain LLVM internal variables like llvm.global_ctors which users are not allowed to define.
2025-02-07Remove Linkage::Privatebjorn3-2/+1
This is the same as Linkage::Internal except that it doesn't emit any symbol. Some backends may not support it and it isn't all that useful anyway.
2025-02-06stabilize `feature(trait_upcasting)`Waffle Lapkin-1/+1
2025-02-06Auto merge of #136641 - matthiaskrgr:rollup-lajwje5, r=matthiaskrgrbors-65/+16
Rollup of 7 pull requests Successful merges: - #136073 (Always compute coroutine layout for eagerly emitting recursive layout errors) - #136235 (Pretty print pattern type values with transmute if they don't satisfy their pattern) - #136311 (Ensure that we never try to monomorphize the upcasting or vtable calls of impossible dyn types) - #136315 (Use short ty string for binop and unop errors) - #136393 (Fix accidentally not emitting overflowing literals lints anymore in patterns) - #136435 (Simplify some code for lowering THIR patterns) - #136630 (Change two std process tests to not output to std{out,err}, and fix test suite stat reset in bootstrap CI test rendering) r? `@ghost` `@rustbot` modify labels: rollup try-job: aarch64-gnu-debug
2025-02-06Add opt_alias_variances and use it in outlives codeMichael Goulet-0/+31
2025-02-06Rollup merge of #136435 - Zalathar:thir-pat-stuff, r=NadrierilMatthias Krüger-8/+9
Simplify some code for lowering THIR patterns I've been playing around with some radically different ways of storing THIR patterns, and while those experiments haven't yet produced a clear win, I have noticed various smaller things in the existing code that can be made a bit nicer. Some of the more significant changes: - With a little bit of extra effort (and thoughtful use of Arc), we can completely remove an entire layer of `'pat` lifetimes from the intermediate data structures used for match lowering. - In several places, lists of THIR patterns were being double-boxed for no apparent reason.
2025-02-06Rollup merge of #136235 - oli-obk:transmuty-pat-tys, r=RalfJungMatthias Krüger-1/+5
Pretty print pattern type values with transmute if they don't satisfy their pattern Instead of printing `0_u32 is 1..`, we now print the default fallback rendering that we also use for invalid bools, chars, ...: `{transmute(0x00000000): (u32) is 1..=}`. These cases can occur in mir dumps when const prop propagates a constant across a safety check that would prevent the actually UB value from existing. That's fine though, as it's dead code and we always need to allow UB in dead code. follow-up to https://github.com/rust-lang/rust/pull/136176 cc ``@compiler-errors`` ``@scottmcm`` r? ``@RalfJung`` because of the interpreter changes
2025-02-06Rollup merge of #136073 - compiler-errors:recursive-coro-always, r=oli-obkMatthias Krüger-56/+2
Always compute coroutine layout for eagerly emitting recursive layout errors Detect recursive coroutine layouts even if we don't detect opaque type recursion in the new solver. This is for two reasons: 1. It helps us detect (bad) recursive async function calls in the new solver, which due to its approach to normalization causes us to not detect this via a recursive RPIT (since the opaques are more eagerly revealed in the opaque body). * Fixes https://github.com/rust-lang/trait-system-refactor-initiative/issues/137. 2. It helps us detect (bad) recursive async functions behind AFITs. See the AFIT test that changed for the old solver too. 3. It also greatly simplifies the recursive impl trait check, since I can remove some jankness around how it handles coroutines.
2025-02-06Auto merge of #136471 - safinaskar:parallel, r=SparrowLiibors-24/+24
tree-wide: parallel: Fully removed all `Lrc`, replaced with `Arc` tree-wide: parallel: Fully removed all `Lrc`, replaced with `Arc` This is continuation of https://github.com/rust-lang/rust/pull/132282 . I'm pretty sure I did everything right. In particular, I searched all occurrences of `Lrc` in submodules and made sure that they don't need replacement. There are other possibilities, through. We can define `enum Lrc<T> { Rc(Rc<T>), Arc(Arc<T>) }`. Or we can make `Lrc` a union and on every clone we can read from special thread-local variable. Or we can add a generic parameter to `Lrc` and, yes, this parameter will be everywhere across all codebase. So, if you think we should take some alternative approach, then don't merge this PR. But if it is decided to stick with `Arc`, then, please, merge. cc "Parallel Rustc Front-end" ( https://github.com/rust-lang/rust/issues/113349 ) r? SparrowLii `@rustbot` label WG-compiler-parallel
2025-02-06coverage: Remove the old code for simplifying counters after MIR optsZalathar-31/+1