about summary refs log tree commit diff
path: root/compiler/rustc_ty_utils
AgeCommit message (Collapse)AuthorLines
2025-09-28remove explicit deref of AbiAlign for most methodsJubilee Young-8/+8
Much of the compiler calls functions on Align projected from AbiAlign. AbiAlign impls Deref to its inner Align, so we can simplify these away. Also, it will minimize disruption when AbiAlign is removed. For now, preserve usages that might resolve to PartialOrd or PartialEq, as those have odd inference.
2025-09-25Rollup merge of #146667 - calebzulawski:simd-mono-lane-limit, r=lcnr,RalfJungStuart Cook-17/+22
Add an attribute to check the number of lanes in a SIMD vector after monomorphization Allows std::simd to drop the `LaneCount<N>: SupportedLaneCount` trait and maintain good error messages. Also, extends rust-lang/rust#145967 by including spans in layout errors for all ADTs. r? ``@RalfJung`` cc ``@workingjubilee`` ``@programmerjake``
2025-09-23Add an attribute to check the number of lanes in a SIMD vector after ↵Caleb Zulawski-17/+22
monomorphization Unify zero-length and oversized SIMD errors
2025-09-18Rollup merge of #146597 - modhanami:add-struct-tail-recursion-limit-span, ↵Matthias Krüger-22/+25
r=oli-obk Add span for struct tail recursion limit error Fixes rust-lang/rust#135629 Changes 1. Add span to RecursionLimitReached 2. Add ObligationCause parameter to struct_tail_raw 4. Update call sites to pass nearby ObligationCause or create one 5. Update affected .stderr
2025-09-17Remove `DynKind`León Orell Valerian Liehr-3/+3
2025-09-16Add span for struct tail recursion limit errorTawan Muadmuenwai-22/+25
2025-09-12Don't store defaultness for inherent impl itemsCameron Steffen-4/+0
2025-09-12Split AssocContainer::{InherentImpl,TraitImpl}Cameron Steffen-20/+11
2025-09-12Introduce hir::ImplItemImplKindCameron Steffen-4/+17
2025-09-12Rename AssocItemContainer -> AssocContainerCameron Steffen-5/+5
2025-09-12Introduce trait_item_ofCameron Steffen-1/+1
2025-09-09Auto merge of #145717 - BoxyUwU:erase_regions_rename, r=lcnrbors-4/+4
rename erase_regions to erase_and_anonymize_regions I find it consistently confusing that `erase_regions` does more than replacing regions with `'erased`. it also makes some code look real goofy to be writing manual folders to erase regions with a comment saying "we cant use erase regions" :> or code that re-calls erase_regions on types with regions already erased just to anonymize all the bound regions. r? lcnr idk how i feel about the name being almost twice as long now
2025-09-09erase_regions to erase_and_anonymize_regionsBoxy-4/+4
2025-09-08fixup limit handling codeJana Dönszelmann-1/+1
2025-09-02Revert introduction of `[workspace.dependencies]`.Nicholas Nethercote-2/+2
This was done in #145740 and #145947. It is causing problems for people using r-a on anything that uses the rustc-dev rustup package, e.g. Miri, clippy. This repository has lots of submodules and subtrees and various different projects are carved out of pieces of it. It seems like `[workspace.dependencies]` will just be more trouble than it's worth.
2025-09-01Auto merge of #145925 - lcnr:revealing-use-closures-2, r=BoxyUwUbors-1/+3
`-Znext-solver`: support non-defining uses in closures Cleaned up version of rust-lang/rust#139587, finishing the implementation of https://github.com/rust-lang/types-team/issues/129. This does not affect stable. The reasoning for why this is the case is subtle however. ## What does it do We split `do_mir_borrowck` into `borrowck_collect_region_constraints` and `borrowck_check_region_constraints`, where `borrowck_collect_region_constraints` returns an enormous `CollectRegionConstraintsResult` struct which contains all the relevant data to actually handle opaque type uses and to check the region constraints later on. `query mir_borrowck` now simply calls `BorrowCheckRootCtxt::do_mir_borrowck` which starts by iterating over all nested bodies of the current function - visiting nested bodies before their parents - and computing their `CollectRegionConstraintsResult`. After we've collected all constraints it's time to actually compute the concrete types for the opaques defined by this function. With this PR we now compute the concrete types of opaques for each body before using them to check the non-defining uses of any of them. After we've computed the concrete types by using all bodies, we use `apply_computed_concrete_opaque_types` for each body to constrain non-defining uses, before finally finishing with `borrowck_check_region_constraints`. We always visit nested bodies before their parents when doing this. ## `ClosureRegionRequirements` As we only call `borrowck_collect_region_constraints` for nested bodies before type checking the parent, we can't simply use the final `ClosureRegionRequirements` of the nested body during MIR type check. We instead track that we need to apply these requirements in `deferred_closure_requirements`. We now manually apply the final closure requirements to each body after handling opaque types. This works, except that we may need the region constraints of nested bodies to successfully define an opaque type in the parent. This is handled by using a new `fn compute_closure_requirements_modulo_opaques` which duplicates region checking - while ignoring any errors - before we've added the constraints from `apply_computed_concrete_opaque_types`. This is necessary for a lot of async tests, as pretty much the entire function is inside of an async block while the opaque type gets defined in the parent. As an performance optimization we only use `fn compute_closure_requirements_modulo_opaques` in case the nested body actually depends on any opaque types. Otherwise we eagerly call `borrowck_check_region_constraints` and apply the final closure region requirements right away. ## Impact on stable code Handling the opaque type uses in the parent function now only uses the closure requirements *modulo opaques*, while it previously also considered member constraints from nested bodies. `External` regions are never valid choice regions. Also, member constraints will never constrain a member region if it is required to be outlived by an external region, as that fails the upper-bound check. https://github.com/rust-lang/rust/blob/564ee219127b796d56f74767366fd359758b97de/compiler/rustc_borrowck/src/region_infer/opaque_types/member_constraints.rs#L90-L96 Member constraints therefore never add constraints for external regions :> r? `@BoxyUwU`
2025-08-27change order of `nested_bodies_within`lcnr-1/+3
2025-08-27Add `itertools` to `[workspace.dependencies]`.Nicholas Nethercote-1/+1
2025-08-27Add `tracing` to `[workspace.dependencies]`.Nicholas Nethercote-1/+1
2025-08-20Tell LLVM about read-only capturesNikita Popov-0/+1
`&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-11Propagate TraitImplHeader to hirCameron Steffen-7/+13
2025-08-10Rollup merge of #145147 - fee1-dead-contrib:push-mxxpmlpmzmsz, r=compiler-errorsStuart Cook-2/+2
rename `TraitRef::from_method` to `from_assoc` also add a note to `GenericArgs::truncate_to`
2025-08-09rename `TraitRef::from_method` to `from_assoc`Deadbeef-2/+2
also add a note to `GenericArgs::truncate_to`
2025-08-06Fix ICEbjorn3-3/+6
2025-08-06Avoid using unadjusted ABI for the thread-local shimbjorn3-1/+1
This restricts the uses of the unadjusted ABI to LLVM intrinsics. The Rust ABI works fine for the thread-local shim as it always returns pointers directly like the backend expects.
2025-08-06Change adjust_for_rust_scalar into arg_attrs_for_rust_scalarbjorn3-16/+9
Directly creating the ArgAttributes rather than adjusting one is a bit clearer.
2025-07-31Extract borrowck coroutine drop-liveness hackMichael Goulet-17/+26
2025-07-28Rename trait_of_item -> trait_of_assocCameron Steffen-1/+1
2025-07-28Auto merge of #144469 - Kivooeo:chains-cleanup, r=SparrowLiibors-9/+9
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-9/+9
2025-07-26Rollup merge of #144448 - camsteffen:defaultness-impl-trait-only, ↵Matthias Krüger-2/+5
r=compiler-errors Limit defaultness query to impl of trait I separated this out from https://github.com/rust-lang/rust/pull/144386.
2025-07-25Limit defaultness to impl of traitCameron Steffen-2/+5
2025-07-24Remove dead code and extend test coverage and diagnostics around itOli Scherer-8/+0
We lost the following comment during refactorings: The current code for niche-filling relies on variant indices instead of actual discriminants, so enums with explicit discriminants (RFC 2363) would misbehave.
2025-07-17Rollup merge of #143793 - fmease:lta-opaq-inf-recur, r=oli-obkMatthias Krüger-4/+7
Opaque type collection: Guard against endlessly recursing free alias types See test description for technical details. Fixes https://github.com/rust-lang/rust/issues/131994. r? oli-obk (sry, your queue is large, so no rush & feel free to reassign)
2025-07-13Retire hir::*ItemRef.Camille GILLOT-7/+7
2025-07-13Remove hir::AssocItemKind.Camille GILLOT-2/+2
2025-07-13Move trait_item_def_id from ImplItemRef to ImplItem.Camille GILLOT-62/+51
2025-07-13Remove usused depth.Camille GILLOT-4/+1
2025-07-12Clean up implementation of RPITIT assoc item loweringMichael Goulet-115/+75
2025-07-13query RPITIT in a trait or implbohan-112/+104
2025-07-13compute all rpitit of a traitbohan-56/+56
2025-07-11Opaque type collection: Guard against endlessly recursing free alias typesLeón Orell Valerian Liehr-4/+7
2025-07-08Rollup merge of #143570 - bvanjoi:issue-143560, r=compiler-errorsMatthias Krüger-10/+24
consider nested cases for duplicate RPITIT Fixes rust-lang/rust#143560 r? `@compiler-errors` cc `@Zoxc`
2025-07-07Auto merge of #143182 - xdoardo:more-addrspace, r=workingjubileebors-2/+2
Allow custom default address spaces and parse `p-` specifications in the datalayout string Some targets, such as CHERI, use as default an address space different from the "normal" default address space `0` (in the case of CHERI, [200 is used](https://www.cl.cam.ac.uk/techreports/UCAM-CL-TR-877.pdf)). Currently, `rustc` does not allow to specify custom address spaces and does not take into consideration [`p-` specifications in the datalayout string](https://llvm.org/docs/LangRef.html#langref-datalayout). This patch tries to mitigate these problems by allowing targets to define a custom default address space (while keeping the default value to address space `0`) and adding the code to parse the `p-` specifications in `rustc_abi`. The main changes are that `TargetDataLayout` now uses functions to refer to pointer-related informations, instead of having specific fields for the size and alignment of pointers in the default address space; furthermore, the two `pointer_size` and `pointer_align` fields in `TargetDataLayout` are replaced with an `FxHashMap` that holds info for all the possible address spaces, as parsed by the `p-` specifications. The potential performance drawbacks of not having ad-hoc fields for the default address space will be tested in this PR's CI run. r? workingjubilee
2025-07-07consider nested cases for duplicate RPITITbohan-10/+24
2025-07-07compiler: Parse `p-` specs in datalayout string, allow definition of custom ↵Edoardo Marangoni-2/+2
default data address space
2025-07-06Rollup merge of #143484 - bvanjoi:issue-140796, r=compiler-errorsMatthias Krüger-2/+29
distinguish the duplicate item of rpitit Fixes rust-lang/rust#140796 r? compiler cc `@Zoxc`
2025-07-06distinguish the duplicate item of rpititbohan-2/+29
2025-07-05use `is_multiple_of` instead of manual moduloFolkert de Vries-1/+1
2025-07-03Rollup merge of #134006 - klensy:typos, r=nnethercoteJana Dönszelmann-1/+1
setup typos check in CI This allows to check typos in CI, currently for compiler only (to reduce commit size with fixes). With current setup, exclude list is quite short, so it worth trying? Also includes commits with actual typo fixes. MCP: https://github.com/rust-lang/compiler-team/issues/817 typos check currently turned for: * ./compiler * ./library * ./src/bootstrap * ./src/librustdoc After merging, PRs which enables checks for other crates (tools) can be implemented too. Found typos will **not break** other jobs immediately: (tests, building compiler for perf run). Job will be marked as red on completion in ~ 20 secs, so you will not forget to fix it whenever you want, before merging pr. Check typos: `python x.py test tidy --extra-checks=spellcheck` Apply typo fixes: `python x.py test tidy --extra-checks=spellcheck:fix` (in case if there only 1 suggestion of each typo) Current fail in this pr is expected and shows how typo errors emitted. Commit with error will be removed after r+.