summary refs log tree commit diff
path: root/compiler/rustc_abi/src/lib.rs
AgeCommit message (Collapse)AuthorLines
2025-04-09Remove redundant wordstimesince-1/+1
2025-03-29`BackendRepr::is_signed`: comment why this may panicsLieselotte-1/+2
2025-03-15Use {Decodable,Encodable}_NoContext in type_irMichael Goulet-7/+25
2025-03-13Auto merge of #137152 - saethlin:bss-const-allocs, r=wesleywiserbors-2/+2
Add a .bss-like scheme for encoded const allocs This check if all bytes are zero feel like it should be too slow, and instead we should have a flag that we track, but that seems hard. Let's see how this perfs first. Also we can probably stash the "it's all zero actually" flag inside one of the other struct members that's already not using an entire byte. This optimization doesn't fire all that often, so it's possible that by sticking it in the varint length field, this PR actually makes rmeta size worse.
2025-03-11Remove `#![warn(unreachable_pub)]` from all `compiler/` crates.Nicholas Nethercote-1/+0
It's no longer necessary now that `-Wunreachable_pub` is being passed.
2025-03-10Revert "Use workspace lints for crates in `compiler/` #138084"许杰友 Jieyou Xu (Joe)-0/+1
Revert <https://github.com/rust-lang/rust/pull/138084> to buy time to consider options that avoids breaking downstream usages of cargo on distributed `rustc-src` artifacts, where such cargo invocations fail due to inability to inherit `lints` from workspace root manifest's `workspace.lints` (this is only valid for the source rust-lang/rust workspace, but not really the distributed `rustc-src` artifacts). This breakage was reported in <https://github.com/rust-lang/rust/issues/138304>. This reverts commit 48caf81484b50dca5a5cebb614899a3df81ca898, reversing changes made to c6662879b27f5161e95f39395e3c9513a7b97028.
2025-03-09Rollup merge of #138158 - moulins:move-layout-to-rustc_abi, r=workingjubileeMatthias Krüger-42/+7
Move more layouting logic to `rustc_abi` Move all `LayoutData`-constructing code to `rustc_abi`: - Infaillible operations get a new `LayoutData` constructor method; - Faillible ones get a new method on `LayoutCalculator`.
2025-03-08Move SIMD layout logic to `rustc_abi`Moulins-0/+7
2025-03-08Remove most manual LayoutData creations and move them to `rustc_abi`Moulins-42/+0
...either as: - methods on LayoutCalculator, for faillible operations; - constructors on LayoutData, for infaillible ones.
2025-03-08Remove `#![warn(unreachable_pub)]` from all `compiler/` crates.Nicholas Nethercote-1/+0
(Except for `rustc_codegen_cranelift`.) It's no longer necessary now that `unreachable_pub` is in the workspace lints.
2025-03-06Rollup merge of #137805 - RalfJung:layout-debug-print, r=NoratriebMichael Goulet-1/+1
adjust Layout debug printing to match the internal field name The field got renamed a while ago, but the debug printing was not updated to match.
2025-02-28rename BackendRepr::Vector → SimdVectorRalf Jung-14/+14
2025-02-28adjust Layout debug printing to match the internal field namesRalf Jung-1/+1
2025-02-23Rollup merge of #137334 - compiler-errors:edition-2024-fresh-2, ↵Jacob Pratt-1/+1
r=saethlin,traviscross Greatly simplify lifetime captures in edition 2024 Remove most of the `+ Captures` and `+ '_` from the compiler, since they are now unnecessary with the new edition 2021 lifetime capture rules. Use some `+ 'tcx` and `+ 'static` rather than being overly verbose with precise capturing syntax.
2025-02-23Rollup merge of #137256 - workingjubilee:untangle-vector-abi-assumptions, ↵Matthias Krüger-44/+49
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-22Greatly simplify lifetime captures in edition 2024Michael Goulet-1/+1
2025-02-22Fix binding mode problemsMichael Goulet-9/+9
2025-02-20compiler: split vector_align into cabi and llvmlikeJubilee Young-9/+14
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: `BackendRepr::inherent_{size,align} -> scalar_{size,align}`Jubilee Young-26/+27
This pair of fn was introduced to perform invariant checks for scalars. Their current behavior doesn't mesh as well with checking SIMD types, so change the name of the fn to reflect their actual use-case and refactor the corresponding checks. Also simplify the returns from Option<AbiAndPrefAlign> to Option<Align>, because every site was mapping away the "preferred" alignment anyways.
2025-02-20compiler: Align::max_for_offset -> Align::max_aligned_factorJubilee Young-9/+8
No functional changes.
2025-02-20Adjust LayoutData::uninhabited doc comment.zachs18-2/+2
Co-authored-by: Jubilee <workingjubilee@gmail.com>
2025-02-20Remove `BackendRepr::Uninhabited`, replaced with an `uninhabited: bool` ↵Zachary S-19/+16
field in `LayoutData`. Also update comments that refered to BackendRepr::Uninhabited.
2025-02-19Add a .bss-like scheme for encoded const allocsBen Kimock-2/+2
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-3/+4
2025-02-11compiler: remove rustc_abi::lookup and AbiUnsupportedJubilee Young-5/+8
These can be entirely replaced by the FromStr implementation.
2025-02-11compiler: remove AbiDatasJubilee Young-8/+5
These were a way to ensure hashes were stable over time for ExternAbi, but simply hashing the strings is more stable in the face of changes. As a result, we can do away with them.
2025-02-11compiler: narrow scope of nightly cfg in rustc_abiJubilee Young-5/+1
2025-02-09compiler: gate `extern "{abi}"` in ast_loweringJubilee Young-3/+1
By moving this stability check into AST lowering, we effectively make it impossible to accidentally miss, as it must happen to generate HIR. Also, we put the ABI-stability code next to code that actually uses it! This allows code that wants to reason about backend ABI implementations to stop worrying about high-level concerns like syntax stability, while still leaving it as the authority on what ABIs actually exist. It also makes it easy to refactor things to have more consistent errors. For now, we only apply this to generalize the existing messages a bit.
2025-02-08Rustfmtbjorn3-4/+7
2025-01-10Foo<T> != Foo<U> under layout randomizationThe 8472-0/+39
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-30compiler: Add a statement-of-intent to `rustc_abi`Jubilee Young-0/+32
2024-12-18make no-variant types a dedicated Variants variantRalf Jung-4/+6
2024-12-18Variants::Single: do not use invalid VariantIdx for uninhabited enumsRalf Jung-4/+4
2024-12-01fix safe-transmute handling of enumsRalf Jung-1/+5
2024-11-30improve TagEncoding::Niche docs and sanity checkRalf Jung-5/+19
2024-11-22Auto merge of #130867 - michirakara:steps_between, r=dtolnaybors-1/+1
distinguish overflow and unimplemented in Step::steps_between
2024-11-21distinguish overflow and unimplemented in Step::steps_betweenmichirakara-1/+1
2024-11-08pointee_info_at: fix logic for recursing into enumsRalf Jung-4/+12
2024-10-30compiler: Lift `rustc_target::spec::abi::Abi` to `rustc_abi::ExternAbi`Jubilee Young-0/+8
2024-10-29compiler: `rustc_abi::Abi` => `BackendRepr`Jubilee Young-46/+66
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-28Rollup merge of #132255 - workingjubilee:layout-is-🏚️, r=compiler-errorsJubilee-0/+5
Add `LayoutS::is_uninhabited` and use it Use accessors for the things that accessors are good at: reducing everyone's need to be nosy and peek at the internals of every data structure.
2024-10-28compiler: Add `is_uninhabited` and use LayoutS accessorsJubilee Young-0/+5
This reduces the need of the compiler to peek on the fields of LayoutS.
2024-10-27compiler: Rename LayoutS to LayoutDataJubilee Young-7/+7
The last {UninternedType}S is in captivity. The galaxy is at peace.
2024-10-21Make rustc_abi compile on stable againLukas Wirth-4/+12
2024-10-11compiler: Wire `{TyAnd,}Layout` into `rustc_abi`Jubilee Young-1/+7
This finally unites TyAndLayout, Layout, and LayoutS into the same crate, as one might imagine they would be placed. No functional changes.
2024-09-22Reformat using the new identifier sorting from rustfmtMichael Goulet-7/+4
2024-09-21Auto merge of #127546 - workingjubilee:5-level-paging-exists, r=saethlinbors-6/+4
Correct outdated object size limit The comment here about 48 bit addresses being enough was written in 2016 but was made incorrect in 2019 by 5-level paging, and then persisted for another 5 years before being noticed and corrected. The bolding of the "exclusive" part is merely to call attention to something I missed when reading it and doublechecking the math. try-job: i686-msvc try-job: test-various
2024-09-21compiler: Precisely name units of object sizeJubilee-3/+3
Co-authored-by: Ralf Jung <post@ralfj.de>
2024-09-20compiler: reuse {un,}signed_fit in get_type_suggestion (nfc)Jubilee Young-0/+22
no need for a weird macro when a self-explanatory `match` will do.