about summary refs log tree commit diff
path: root/compiler/rustc_ty_utils/src/layout.rs
AgeCommit message (Collapse)AuthorLines
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.
2024-10-27compiler: Rename LayoutS to LayoutDataJubilee Young-16/+16
The last {UninternedType}S is in captivity. The galaxy is at peace.
2024-10-21Auto merge of #130950 - compiler-errors:yeet-eval, r=BoxyUwUbors-3/+3
Continue to get rid of `ty::Const::{try_}eval*` This PR mostly does: * Removes all of the `try_eval_*` and `eval_*` helpers from `ty::Const`, and replace their usages with `try_to_*`. * Remove `ty::Const::eval`. * Rename `ty::Const::normalize` to `ty::Const::normalize_internal`. This function is still used in the normalization code itself. * Fix some weirdness around the `TransmuteFrom` goal. I'm happy to split it out further; for example, I could probably land the first part which removes the helpers, or the changes to codegen which are more obvious than the changes to tools. r? BoxyUwU Part of https://github.com/rust-lang/rust/issues/130704
2024-10-20compiler: Reject impossible reprs during enum layoutJubilee Young-0/+5
2024-10-20compiler: pre-move code for fixing enum layout ICEsJubilee Young-2/+3
2024-10-19Get rid of const eval_* and try_eval_* helpersMichael Goulet-3/+3
2024-10-08compiler: Factor rustc_target::abi::* out of ty_utilsJubilee Young-7/+13
2024-09-22Reformat using the new identifier sorting from rustfmtMichael Goulet-36/+21
2024-09-17get rid of an old hackLukas Markeffsky-36/+5
For structs that cannot be unsized, the layout algorithm sometimes moves unsized fields to the end of the struct, which circumvented the error for unexpected unsized fields and returned an unsized layout anyway. This commit makes it so that the unexpected unsized error is always returned for structs that cannot be unsized, allowing us to remove an old hack and fixing some old ICE.
2024-09-17assert that unexpectedly unsized fields are sized in the param envLukas Markeffsky-26/+26
2024-09-16layout computation: eagerly error for unexpected unsized fieldsLukas Markeffsky-34/+64
2024-09-16make `LayoutCx` not genericLukas Markeffsky-10/+7
2024-08-20supress niches in coroutinesRalf Jung-1/+7
2024-08-14Auto merge of #128812 - nnethercote:shrink-TyKind-FnPtr, r=compiler-errorsbors-1/+1
Shrink `TyKind::FnPtr`. By splitting the `FnSig` within `TyKind::FnPtr` into `FnSigTys` and `FnHeader`, which can be packed more efficiently. This reduces the size of the hot `TyKind` type from 32 bytes to 24 bytes on 64-bit platforms. This reduces peak memory usage by a few percent on some benchmarks. It also reduces cache misses and page faults similarly, though this doesn't translate to clear cycles or wall-time improvements on CI. r? `@compiler-errors`
2024-08-11Remove struct_tail_no_normalizationMichael Goulet-1/+5
2024-08-09Shrink `TyKind::FnPtr`.Nicholas Nethercote-1/+1
By splitting the `FnSig` within `TyKind::FnPtr` into `FnSigTys` and `FnHeader`, which can be packed more efficiently. This reduces the size of the hot `TyKind` type from 32 bytes to 24 bytes on 64-bit platforms. This reduces peak memory usage by a few percent on some benchmarks. It also reduces cache misses and page faults similarly, though this doesn't translate to clear cycles or wall-time improvements on CI.
2024-08-08Rename struct_tail_erasing_lifetimes to struct_tail_for_codegenMichael Goulet-1/+1
2024-07-30Auto merge of #128083 - Mark-Simulacrum:bump-bootstrap, r=albertlarsan68bors-3/+1
Bump bootstrap compiler to new beta https://forge.rust-lang.org/release/process.html#master-bootstrap-update-t-2-day-tuesday
2024-07-29Reformat `use` declarations.Nicholas Nethercote-3/+3
The previous commit updated `rustfmt.toml` appropriately. This commit is the outcome of running `x fmt --all` with the new formatting options.
2024-07-28step cfg(bootstrap)Mark Rousskov-3/+1
2024-06-01Uplift TypeRelation and RelateMichael Goulet-1/+2
2024-05-23Remove `#[macro_use] extern crate tracing` from `rustc_ty_utils`.Nicholas Nethercote-0/+1
2024-05-13Remove `extern crate rustc_middle` from `rustc_ty_utils`.Nicholas Nethercote-0/+1
2024-05-06Refactor float `Primitive`s to a separate `Float` typebeetrees-7/+2
2024-04-09Handle const generic pattern typesSantiago Pastorino-2/+6
2024-04-08Actually create ranged int types in the type system.Oli Scherer-0/+33
2024-04-04Rollup merge of #123464 - fmease:rn-has-proj-to-has-aliases, r=compiler-errorsJacob Pratt-2/+2
Cleanup: Rename `HAS_PROJECTIONS` to `HAS_ALIASES` etc. The name of the bitflag `HAS_PROJECTIONS` and of its corresponding method `has_projections` is quite historical dating back to a time when projections were the only kind of alias type. I think it's time to update it to clear up any potential confusion for newcomers and to reduce unnecessary friction during contributor onboarding. r? types
2024-04-04Rename HAS_PROJECTIONS to HAS_ALIASES etc.León Orell Valerian Liehr-2/+2
2024-04-04Rollup merge of #121546 - gurry:121473-ice-sizeof-mir-op, r=oli-obkMatthias Krüger-1/+37
Error out of layout calculation if a non-last struct field is unsized Fixes #121473 Fixes #123152
2024-04-04Error out of layout calculation if a non-last struct field is unsizedGurinder Singh-1/+37
Fixes an ICE that occurs when a struct with an unsized field at a non-last position is const evaluated.
2024-04-03rustc_index: Add a `ZERO` constant to index typesVadim Petrochenkov-1/+1
It is commonly used.
2024-03-24Require coroutine kind type to be passed to TyCtxt::coroutine_layoutMichael Goulet-2/+2
2024-03-24Always use tcx.coroutine_layout over calling optimized_mir directlyMichael Goulet-1/+1
2024-03-22-Zprint-type-sizes: print the types of awaitees and unnamed coroutine locals.Kevin Reid-1/+9
This should assist comprehending the size of coroutines. In particular, whenever a future is suspended while awaiting another future, the latter is given the special name `__awaitee`, and now the type of the awaited future will be printed, allowing identifying caller/callee — er, I mean, poller/pollee — relationships. It would be possible to include the type name in more cases, but I thought that that might be overly verbose (`print-type-sizes` is already a lot of text) and ordinary named fields or variables are easier for readers to discover the types of.
2024-03-22Programmatically convert some of the pat ctorsMichael Goulet-1/+1
2024-02-28Add `f16` and `f128` to `rustc_type_ir::FloatTy` and `rustc_abi::Primitive`Trevor Gross-0/+2
Make changes necessary to support these types in the compiler.