summary refs log tree commit diff
path: root/compiler/rustc_ty_utils/src/layout.rs
AgeCommit message (Collapse)AuthorLines
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-07compiler: Parse `p-` specs in datalayout string, allow definition of custom ↵Edoardo Marangoni-2/+2
default data address space
2025-07-01Remove support for dyn*Michael Goulet-8/+0
2025-06-17apply clippy::or_fun_callklensy-4/+3
2025-06-03Change `tag_field` to `FieldIdx` in `Variants::Multiple`Scott McMurray-1/+1
It was already available as a generic parameter anyway, and it's not like we'll ever put a tag in the 5-billionth field.
2025-05-11Return value of coroutine_layout fn changed to Result with LayoutErrorAndrew Zhogin-3/+1
2025-04-29Rollup merge of #139909 - oli-obk:or-patterns, r=BoxyUwUTrevor Gross-2/+84
implement or-patterns for pattern types These are necessary to represent `NonZeroI32`, as the range for that is `..0 | 1..`. The `rustc_scalar_layout_range_*` attributes avoided this by just implementing wraparound and having a single `1..=-1` range effectively. See https://rust-lang.zulipchat.com/#narrow/channel/481660-t-lang.2Fpattern-types/topic/.60or.20pattern.60.20representation.20in.20type.20system/with/504217694 for some background discussion cc https://github.com/rust-lang/rust/issues/123646 r? `@BoxyUwU`
2025-04-28AsyncDrop implementation using shim codegen of ↵Andrew Zhogin-2/+6
async_drop_in_place::{closure}, scoped async drop added.
2025-04-28Add or-patterns to pattern typesOli Scherer-2/+84
2025-04-13Initial `UnsafePinned`/`UnsafeUnpin` impl [Part 1: Libs]Sky-2/+5
2025-03-24Don't ICE when encountering placeholders in layout computationMichael Goulet-6/+2
2025-03-10Reject wrapping ranges of pattern typesOli Scherer-0/+28
2025-03-08Move coroutine layout logic to `rustc_abi`Moulins-334/+23
2025-03-08Refactor coroutine layout logic to precompute all sublayoutsMoulins-117/+118
Also properly attaches spans on layouts of non-promoted coroutine locals, which slightly improves the error messages for some coroutine tests.
2025-03-08Move SIMD layout logic to `rustc_abi`Moulins-61/+18
2025-03-08Remove most manual LayoutData creations and move them to `rustc_abi`Moulins-67/+25
...either as: - methods on LayoutCalculator, for faillible operations; - constructors on LayoutData, for infaillible ones.
2025-03-06Remove the `Option` part of range ends in the HIROli Scherer-7/+2
2025-03-06Avoid having to handle an `Option` in the type systemOli Scherer-14/+11
2025-03-06Prefer a two value enum over boolOli Scherer-2/+3
2025-03-02Remove layouting dead code for non-array SIMD types.Moulins-70/+19
These aren't supported anymore, and are already rejected in type checking.
2025-02-28rename BackendRepr::Vector → SimdVectorRalf Jung-1/+1
2025-02-23Rollup merge of #137256 - workingjubilee:untangle-vector-abi-assumptions, ↵Matthias Krüger-3/+6
r=bjorn3,RalfJung compiler: untangle SIMD alignment assumptions There were a number of puzzling assumptions being made about SIMD types and their layout that I have corrected in this diff. These are mostly no-op edits in actual fact, but they do subtly alter a pair of checks in our invariant-checking and union layout computation that rested on those peculiar assumptions. Those unfortunately stand in the way of any further actual fixes. I submit this for review, even though it's not clearly motivated without its followups, because it should still be possible to independently conclude whether this is correct.
2025-02-21layout_of: put back not-so-unreachable caseLukas Markeffsky-1/+14
2025-02-20compiler: split vector_align into cabi and llvmlikeJubilee Young-2/+5
Introduce a pair of functions that actually describe what they do, because it wasn't clear the alignment is sometimes a forgery.
2025-02-20compiler: Align::max_for_offset -> Align::max_aligned_factorJubilee Young-1/+1
No functional changes.
2025-02-20Remove `BackendRepr::Uninhabited`, replaced with an `uninhabited: bool` ↵Zachary S-12/+9
field in `LayoutData`. Also update comments that refered to BackendRepr::Uninhabited.
2025-02-18cosmetic changesLukas Markeffsky-18/+22
- change function parameter order to `cx, ty, ...` to match the other functions in this file - use `ct` identifier for `ty::Const` to match the majority of the compiler codebase - remove useless return - bring match arms in a more natural order
2025-02-18remove useless parameterLukas Markeffsky-36/+10
Remove the `repr` parameter from the wrappers around `calc.univariant`, because it's always defaulted. Only ADTs can have a repr and those call `calc.layout_of_struct_or_enum` and not `calc.univariant`.
2025-02-18remove redundant codeLukas Markeffsky-11/+9
- we normalize before calling `layout_of_uncached`, so we don't need to normalize again later - we check for type/const errors at the top of `layout_of_uncached`, so we don't need to check again later
2025-02-18remove unreachable casesLukas Markeffsky-15/+8
`ty::Placeholder` is used by the trait solver and computing its layout was necessary, because the `PointerLike` trait used to be automatically implemented for all types with pointer-like layout. Nowadays, `PointerLike` requires user-written impls and the trait solver no longer computes any layouts, so this can be removed. Unevaluated constants that aren't generic should have caused a const eval error earlier during normalization.
2025-02-16Move hashes from rustc_data_structure to rustc_hashes so they can be shared ↵Ben Kimock-1/+1
with rust-analyzer
2025-02-15Replace some u64 hashes with Hash64Ben Kimock-5/+8
2025-02-10Rename rustc_middle::Ty::is_unsafe_ptr to is_raw_ptrBastian Kersting-1/+1
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-08Rustfmtbjorn3-20/+35
2025-01-30introduce `ty::Value`Lukas Markeffsky-11/+8
Co-authored-by: FedericoBruzzone <federico.bruzzone.i@gmail.com>
2025-01-27Add `TooGeneric` variant to `LayoutError` and emit `Unknown` oneFedericoBruzzone-19/+50
- `check-pass` test for a MRE of #135020 - fail test for #135138 - switch to `TooGeneric` for checking CMSE fn signatures - switch to `TooGeneric` for compute `SizeSkeleton` (for transmute) - fix broken tests
2025-01-14Consider more erroneous layouts as LayoutError::ReferencesError to suppress ↵Michael Goulet-12/+20
spurious errors
2025-01-11rename `BitSet` to `DenseBitSet`Rémy Rakic-4/+4
This should make it clearer that this bitset is dense, with the advantages and disadvantages that it entails.
2025-01-10Foo<T> != Foo<U> under layout randomizationThe 8472-0/+10
previously field ordering was using the same seed for all instances of Foo, now we pass seed values through the layout tree so that not only the struct itself affects layout but also its fields
2024-12-22Begin to implement type system layer of unsafe bindersMichael Goulet-0/+5
2024-12-18make no-variant types a dedicated Variants variantRalf Jung-15/+11
2024-12-18Variants::Single: do not use invalid VariantIdx for uninhabited enumsRalf Jung-6/+8
2024-12-18Re-export more `rustc_span::symbol` things from `rustc_span`.Nicholas Nethercote-2/+1
`rustc_span::symbol` defines some things that are re-exported from `rustc_span`, such as `Symbol` and `sym`. But it doesn't re-export some closely related things such as `Ident` and `kw`. So you can do `use rustc_span::{Symbol, sym}` but you have to do `use rustc_span::symbol::{Ident, kw}`, which is inconsistent for no good reason. This commit re-exports `Ident`, `kw`, and `MacroRulesNormalizedIdent`, and changes many `rustc_span::symbol::` qualifiers in `compiler/` to `rustc_span::`. This is a 200+ net line of code reduction, mostly because many files with two `use rustc_span` items can be reduced to one.
2024-11-30report UB when the niche value refers to the untagged variantRalf Jung-1/+1
2024-11-23remove remaining references to `Reveal`lcnr-3/+3
2024-11-23no more Reveal :(lcnr-1/+1
2024-11-19move `fn is_item_raw` to `TypingEnv`lcnr-9/+5
2024-11-18use `TypingEnv` when no `infcx` is availablelcnr-20/+24
the behavior of the type system not only depends on the current assumptions, but also the currentnphase of the compiler. This is mostly necessary as we need to decide whether and how to reveal opaque types. We track this via the `TypingMode`.
2024-11-03compiler: Directly use rustc_abi in ty_utilsJubilee Young-4/+3
2024-10-29compiler: `rustc_abi::Abi` => `BackendRepr`Jubilee Young-19/+24
The initial naming of "Abi" was an awful mistake, conveying wrong ideas about how psABIs worked and even more about what the enum meant. It was only meant to represent the way the value would be described to a codegen backend as it was lowered to that intermediate representation. It was never meant to mean anything about the actual psABI handling! The conflation is because LLVM typically will associate a certain form with a certain ABI, but even that does not hold when the special cases that actually exist arise, plus the IR annotations that modify the ABI. Reframe `rustc_abi::Abi` as the `BackendRepr` of the type, and rename `BackendRepr::Aggregate` as `BackendRepr::Memory`. Unfortunately, due to the persistent misunderstandings, this too is now incorrect: - Scattered ABI-relevant code is entangled with BackendRepr - We do not always pre-compute a correct BackendRepr that reflects how we "actually" want this value to be handled, so we leave the backend interface to also inject various special-cases here - In some cases `BackendRepr::Memory` is a "real" aggregate, but in others it is in fact using memory, and in some cases it is a scalar! Our rustc-to-backend lowering code handles this sort of thing right now. That will eventually be addressed by lifting duplicated lowering code to either rustc_codegen_ssa or rustc_target as appropriate.