about summary refs log tree commit diff
path: root/compiler/rustc_middle/src/ty
AgeCommit message (Collapse)AuthorLines
2025-10-02Auto merge of #147138 - jackh726:split-canonical-bound, r=lcnrbors-25/+130
Split Bound index into Canonical and Bound See [#t-types/trait-system-refactor > perf `async-closures/post-mono-higher-ranked-hang.rs`](https://rust-lang.zulipchat.com/#narrow/channel/364551-t-types.2Ftrait-system-refactor/topic/perf.20.60async-closures.2Fpost-mono-higher-ranked-hang.2Ers.60/with/541535613) for context Things compile and tests pass, but not sure if this actually solves the perf issue (edit: it does). Opening up this to do a perf (and maybe crater) run. r? lcnr
2025-09-30Split Bound into Canonical and Boundjackh726-25/+130
2025-09-30Rollup merge of #147109 - BoxyUwU:rename_concrete_opaques, r=lcnrStuart Cook-2/+2
Rename various "concrete opaque type" things to say "hidden type" r? lcnr I've found "concrete opaque type" terminology to be somewhat confusing as in conversation and when explaining opaque type stuff to people I always just talk about things in terms of hidden types. Also the hidden types of opaques are very much not *concrete* in the same sense that a type without any generic parameters is concrete which is an unfortunate overlap in terminology. I've tried to update comments to also stop referring to things as concrete opaque types but this is mostly best effort as it difficult to find all such cases amongst the massive amounts of uses of "concrete" or "hidden" across the whole compiler.
2025-09-28remove explicit deref of AbiAlign for most methodsJubilee Young-1/+1
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-28Rollup merge of #144197 - KMJ-007:type-tree, r=ZuseZ4Matthias Krüger-1/+224
TypeTree support in autodiff # TypeTrees for Autodiff ## What are TypeTrees? Memory layout descriptors for Enzyme. Tell Enzyme exactly how types are structured in memory so it can compute derivatives efficiently. ## Structure ```rust TypeTree(Vec<Type>) Type { offset: isize, // byte offset (-1 = everywhere) size: usize, // size in bytes kind: Kind, // Float, Integer, Pointer, etc. child: TypeTree // nested structure } ``` ## Example: `fn compute(x: &f32, data: &[f32]) -> f32` **Input 0: `x: &f32`** ```rust TypeTree(vec![Type { offset: -1, size: 8, kind: Pointer, child: TypeTree(vec![Type { offset: -1, size: 4, kind: Float, child: TypeTree::new() }]) }]) ``` **Input 1: `data: &[f32]`** ```rust TypeTree(vec![Type { offset: -1, size: 8, kind: Pointer, child: TypeTree(vec![Type { offset: -1, size: 4, kind: Float, // -1 = all elements child: TypeTree::new() }]) }]) ``` **Output: `f32`** ```rust TypeTree(vec![Type { offset: -1, size: 4, kind: Float, child: TypeTree::new() }]) ``` ## Why Needed? - Enzyme can't deduce complex type layouts from LLVM IR - Prevents slow memory pattern analysis - Enables correct derivative computation for nested structures - Tells Enzyme which bytes are differentiable vs metadata ## What Enzyme Does With This Information: Without TypeTrees (current state): ```llvm ; Enzyme sees generic LLVM IR: define float ``@distance(ptr*`` %p1, ptr* %p2) { ; Has to guess what these pointers point to ; Slow analysis of all memory operations ; May miss optimization opportunities } ``` With TypeTrees (our implementation): ```llvm define "enzyme_type"="{[]:Float@float}" float ``@distance(`` ptr "enzyme_type"="{[]:Pointer}" %p1, ptr "enzyme_type"="{[]:Pointer}" %p2 ) { ; Enzyme knows exact type layout ; Can generate efficient derivative code directly } ``` # TypeTrees - Offset and -1 Explained ## Type Structure ```rust Type { offset: isize, // WHERE this type starts size: usize, // HOW BIG this type is kind: Kind, // WHAT KIND of data (Float, Int, Pointer) child: TypeTree // WHAT'S INSIDE (for pointers/containers) } ``` ## Offset Values ### Regular Offset (0, 4, 8, etc.) **Specific byte position within a structure** ```rust struct Point { x: f32, // offset 0, size 4 y: f32, // offset 4, size 4 id: i32, // offset 8, size 4 } ``` TypeTree for `&Point` (internal representation): ```rust TypeTree(vec![ Type { offset: 0, size: 4, kind: Float }, // x at byte 0 Type { offset: 4, size: 4, kind: Float }, // y at byte 4 Type { offset: 8, size: 4, kind: Integer } // id at byte 8 ]) ``` Generates LLVM: ```llvm "enzyme_type"="{[]:Float@float}" ``` ### Offset -1 (Special: "Everywhere") **Means "this pattern repeats for ALL elements"** #### Example 1: Array `[f32; 100]` ```rust TypeTree(vec![Type { offset: -1, // ALL positions size: 4, // each f32 is 4 bytes kind: Float, // every element is float }]) ``` Instead of listing 100 separate Types with offsets `0,4,8,12...396` #### Example 2: Slice `&[i32]` ```rust // Pointer to slice data TypeTree(vec![Type { offset: -1, size: 8, kind: Pointer, child: TypeTree(vec![Type { offset: -1, // ALL slice elements size: 4, // each i32 is 4 bytes kind: Integer }]) }]) ``` #### Example 3: Mixed Structure ```rust struct Container { header: i64, // offset 0 data: [f32; 1000], // offset 8, but elements use -1 } ``` ```rust TypeTree(vec![ Type { offset: 0, size: 8, kind: Integer }, // header Type { offset: 8, size: 4000, kind: Pointer, child: TypeTree(vec![Type { offset: -1, size: 4, kind: Float // ALL array elements }]) } ]) ```
2025-09-27Rename various "concrete opaque type" terminology to say "hidden type"Boxy Uwu-2/+2
2025-09-27Rollup merge of #147075 - Lysxia:no-panic-def-path-hash, r=petrochenkovMatthias Krüger-1/+1
Make `def_path_hash_to_def_id` not panic when passed an invalid hash I'm using this function in a third-party application (Creusot) to access private items (by reverse engineering their hash). This works in the happy path, but it panics when an item does not exist. There is no way to hack it downstream because the hook `def_path_hash_to_def_id_extern` must always return a `DefId` and its implementation uses `def_path_hash_to_def_index` which is internal and which is where the panic happens.
2025-09-26Make `def_path_hash_to_def_id` not panic when passed an invalid hashLi-yao Xia-1/+1
2025-09-26predefined opaques to `method_autoderef_steps`lcnr-1/+10
2025-09-26predefined opaques use `List`lcnr-6/+5
2025-09-25Auto merge of #147019 - Zalathar:rollup-boxzbmo, r=Zalatharbors-0/+26
Rollup of 14 pull requests Successful merges: - rust-lang/rust#145067 (RawVecInner: add missing `unsafe` to unsafe fns) - rust-lang/rust#145277 (Do not materialise X in [X; 0] when X is unsizing a const) - rust-lang/rust#145973 (Add `std` support for `armv7a-vex-v5`) - rust-lang/rust#146667 (Add an attribute to check the number of lanes in a SIMD vector after monomorphization) - rust-lang/rust#146735 (unstably constify float mul_add methods) - rust-lang/rust#146737 (f16_f128: enable some more tests in Miri) - rust-lang/rust#146766 (Add attributes for #[global_allocator] functions) - rust-lang/rust#146905 (llvm: update remarks support on LLVM 22) - rust-lang/rust#146982 (Remove erroneous normalization step in `tests/run-make/linker-warning`) - rust-lang/rust#147005 (Small string formatting cleanup) - rust-lang/rust#147007 (Explicitly note `&[SocketAddr]` impl of `ToSocketAddrs`) - rust-lang/rust#147008 (bootstrap.py: Respect build.jobs while building bootstrap tool) - rust-lang/rust#147013 (rustdoc: Fix documentation for `--doctest-build-arg`) - rust-lang/rust#147015 (Use `LLVMDisposeTargetMachine`) r? `@ghost` `@rustbot` modify labels: rollup
2025-09-25Rollup merge of #146667 - calebzulawski:simd-mono-lane-limit, r=lcnr,RalfJungStuart Cook-0/+26
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-25Auto merge of #147003 - matthiaskrgr:rollup-b5z9uiz, r=matthiaskrgrbors-2/+1
Rollup of 7 pull requests Successful merges: - rust-lang/rust#146556 (Fix duration_since panic on unix when std is built with integer overflow checks) - rust-lang/rust#146679 (Clarify Display for error should not include source) - rust-lang/rust#146753 (Improve the pretty print of UnstableFeature clause) - rust-lang/rust#146894 (Improve derive suggestion of const param) - rust-lang/rust#146950 (core: simplify `CStr::default()`) - rust-lang/rust#146958 (Fix infinite recursion in Path::eq with String) - rust-lang/rust#146971 (fix ICE in writeback due to bound regions) r? `@ghost` `@rustbot` modify labels: rollup
2025-09-24Rollup merge of #146753 - tiif:unsatisfiable-unstable-feature, r=BoxyUwUMatthias Krüger-2/+1
Improve the pretty print of UnstableFeature clause As per https://github.com/rust-lang/rust/pull/145095#discussion_r2349439492, we could make the diagnostic for unsatisfiable ``UnstableFeature`` clause better. r? `@BoxyUwU`
2025-09-24Rollup merge of #146857 - tnuha:revert_self_has_no_region_infer, r=lcnrMatthias Krüger-1/+10
revert change removing `has_infer` check. Commit conservatively patch… …es for now, but more development proceeding. Hotfix for rust-lang/rust#146852.
2025-09-24Improve the pretty print of UnstableFeature clausetiif-2/+1
2025-09-23Add an attribute to check the number of lanes in a SIMD vector after ↵Caleb Zulawski-0/+26
monomorphization Unify zero-length and oversized SIMD errors
2025-09-23revert change removing `has_infer` check. Commit conservatively patches for ↵ash-1/+10
now, but more development proceeding. Also contains a more concise test
2025-09-21Add panic=immediate-abortBen Kimock-4/+4
2025-09-19autodiff: typetree recursive depth query from enzyme with fallbackKaran Janthe-14/+7
Signed-off-by: Karan Janthe <karanjanthe@gmail.com>
2025-09-19autodiff: recurion added for typetreeKaran Janthe-8/+68
2025-09-19autodiff: fixed test to be more precise for type tree checkingKaran Janthe-27/+9
2025-09-19autodiff: struct support in typetreeKaran Janthe-0/+32
2025-09-19autodiff: tuple support in typetreeKaran Janthe-0/+36
2025-09-19autodiff: slice support in typetreeKaran Janthe-0/+7
2025-09-19autodiff: add TypeTree support for arraysKaran Janthe-1/+41
2025-09-19added typetree support for memcpyKaran Janthe-2/+2
2025-09-19Add TypeTree metadata attachment for autodiffKaran Janthe-13/+6
- Add F128 support to TypeTree Kind enum - Implement TypeTree FFI bindings and conversion functions - Add typetree.rs module for metadata attachment to LLVM functions - Integrate TypeTree generation with autodiff intrinsic pipeline - Support scalar types: f32, f64, integers, f16, f128 - Attach enzyme_type attributes as LLVM string metadata for Enzyme Signed-off-by: Karan Janthe <karanjanthe@gmail.com>
2025-09-19autodiff: Add basic TypeTree with NoTT flagKaran Janthe-0/+80
Signed-off-by: Karan Janthe <karanjanthe@gmail.com>
2025-09-18Rollup merge of #146597 - modhanami:add-struct-tail-recursion-limit-span, ↵Matthias Krüger-5/+17
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-18Rollup merge of #146694 - camsteffen:impl-subject, r=compiler-errorsStuart Cook-30/+0
Remove ImplSubject It only has one usage in rustdoc.
2025-09-18Rollup merge of #146664 - fmease:clean-up-dyn, r=jdonszelmannStuart Cook-25/+19
Clean up `ty::Dynamic` 1. As a follow-up to PR rust-lang/rust#143036, remove `DynKind` entirely. 2. Inside HIR ty lowering, consolidate modules `dyn_compatibility` and `lint` into `dyn_trait` * `dyn_compatibility` wasn't about dyn compatibility itself, it's about lowering trait object types * `lint` contained dyn-Trait-specific diagnostics+lints only
2025-09-17Remove ImplSubjectCameron Steffen-30/+0
2025-09-17Remove `DynKind`León Orell Valerian Liehr-25/+19
2025-09-16Add span for struct tail recursion limit errorTawan Muadmuenwai-5/+17
2025-09-15remove FIXME from `has_significant_drop`, replaced with checking ↵ash-8/+1
non_region_infer
2025-09-12Don't store defaultness for inherent impl itemsCameron Steffen-1/+4
2025-09-12Split AssocContainer::{InherentImpl,TraitImpl}Cameron Steffen-47/+59
2025-09-12Introduce hir::ImplItemImplKindCameron Steffen-16/+10
2025-09-12Rename AssocItemContainer -> AssocContainerCameron Steffen-12/+12
2025-09-12Introduce trait_item_ofCameron Steffen-0/+9
2025-09-12Auto merge of #146329 - lcnr:opaque-type-infer-alias-candidates, r=BoxyUwUbors-1/+5
consider item bounds for non-yet-defined opaque types Based on rust-lang/rust#140405. fixes https://github.com/rust-lang/trait-system-refactor-initiative/issues/182 fixes https://github.com/rust-lang/trait-system-refactor-initiative/issues/196 fixes https://github.com/rust-lang/trait-system-refactor-initiative/issues/205 there's some jank here, see https://github.com/rust-lang/trait-system-refactor-initiative/issues/229 ## Design If the self type is an inference variable which has been sub-unified with am opaque type, we need to incompletely guide inference to avoid breakage. In this case, we - look at the item bounds of all sub-unified opaque types, and - blanket impls which do not constrain the self type Even if there are applicable candidates, we always force their certainty to be `Maybe`, so they will always have to be reproven once we've constrained the inference variable. This is a bit iffy, see the added tests. r? `@BoxyUwU`
2025-09-12Auto merge of #146328 - zetanumbers:fix-141951, r=lcnrbors-4/+1
Skip typeck for items w/o their own typeck context Skip items which forward typeck to their ancestor. Should remove some potential but unnecessary typeck query waits, hence might improve performance for the parallel frontend. Thanks to `@ywxt` for a fix suggestion Fixes rust-lang/rust#141951
2025-09-11incompletely prefer opaque type bounds when self type bottoms out in inferMichael Goulet-1/+5
2025-09-09Auto merge of #145717 - BoxyUwU:erase_regions_rename, r=lcnrbors-28/+32
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-09Driveby fixesBoxy-3/+2
2025-09-09erase_regions to erase_and_anonymize_regionsBoxy-27/+32
2025-09-08fixup limit handling codeJana Dönszelmann-4/+6
2025-09-08Rollup merge of #146313 - nnethercote:rustc_middle-ty-cleanups-2, r=lcnrMatthias Krüger-81/+3
Some `rustc_middle` cleanups Minor improvements I found while looking through this code. r? `@BoxyUwU`
2025-09-08Rollup merge of #146111 - ChayimFriedman2:more-ns-specific-defid, r=lcnrMatthias Krüger-1/+27
Migrate more things in the new solver to specific `DefId`s Continuation of https://github.com/rust-lang/rust/pull/145377. I migrated the rest of the types, except aliases. Aliases are problematic because opaques and associated types share the same type in the new solver. `@jackh726,` `@lcnr,` `@ShoyuVanilla` I'd like to hear ideas here. Anyway, even if we do nothing with them we already got a substantial improvement. r? types