about summary refs log tree commit diff
path: root/compiler/rustc_ty_utils/src/layout.rs
AgeCommit message (Collapse)AuthorLines
2023-12-11Auto merge of #117116 - calebzulawski:repr-simd-packed, r=workingjubileebors-2/+16
Implement repr(packed) for repr(simd) This allows creating vectors with non-power-of-2 lengths that do not have padding. See rust-lang/portable-simd#319
2023-12-10remove redundant importssurechen-3/+1
detects redundant imports that can be eliminated. for #117772 : In order to facilitate review and modification, split the checking code and removing redundant imports code into two PR.
2023-12-02Implement repr(packed) for repr(simd)Caleb Zulawski-2/+16
2023-12-02Rename `HandlerInner::delay_span_bug` as `HandlerInner::span_delayed_bug`.Nicholas Nethercote-4/+4
Because the corresponding `Level` is `DelayedBug` and `span_delayed_bug` follows the pattern used everywhere else: `span_err`, `span_warning`, etc.
2023-11-21Fix `clippy::needless_borrow` in the compilerNilstrieb-2/+2
`x clippy compiler -Aclippy::all -Wclippy::needless_borrow --fix`. Then I had to remove a few unnecessary parens and muts that were exposed now.
2023-11-20Inline and remove `record_layout_for_printing`.Nicholas Nethercote-15/+5
It has a single call site.
2023-11-20Reduce exposure of some items.Nicholas Nethercote-1/+1
2023-11-13Compute layout with spans for better cycle errors in coroutinesMichael Goulet-5/+5
2023-10-20s/generator/coroutine/Oli Scherer-24/+24
2023-10-20s/Generator/Coroutine/Oli Scherer-14/+14
2023-10-13Format all the let chains in compilerMichael Goulet-21/+19
2023-10-02Implement Deref<LayoutS> for LayoutLukas Wirth-1/+1
2023-09-23Remove GeneratorWitness and rename GeneratorWitnessMIR.Camille GILLOT-5/+1
2023-09-18Explain `with_reveal_all_normalized` usageOli Scherer-0/+3
2023-09-11Disentangle `Debug` and `Display` for `Ty`.Nicholas Nethercote-1/+2
The `Debug` impl for `Ty` just calls the `Display` impl for `Ty`. This is surprising and annoying. In particular, it means `Debug` doesn't show as much information as `Debug` for `TyKind` does. And `Debug` is used in some user-facing error messages, which seems bad. This commit changes the `Debug` impl for `Ty` to call the `Debug` impl for `TyKind`. It also does a number of follow-up changes to preserve existing output, many of which involve inserting `with_no_trimmed_paths!` calls. It also adds `Display` impls for `UserType` and `Canonical`. Some tests have changes to expected output: - Those that use the `rustc_abi(debug)` attribute. - Those that use the `EMIT_MIR` annotation. In each case the output is slightly uglier than before. This isn't ideal, but it's pretty weird (particularly for the attribute) that the output is using `Debug` in the first place. They're fairly obscure attributes (I hadn't heard of them) so I'm not worried by this. For `async-is-unwindsafe.stderr`, there is one line that now lacks a full path. This is a consistency improvement, because all the other mentions of `Context` in this test lack a path.
2023-08-29some more is_zst that should be is_1zstRalf Jung-1/+1
2023-08-01Use upvar_tys in more places, make it a listMichael Goulet-2/+6
2023-07-27Don't attempt to compute layout of type referencing errorMichael Goulet-2/+13
2023-07-21Revert "Auto merge of #113166 - moulins:ref-niches-initial, r=oli-obk"David Tolnay-140/+112
This reverts commit 557359f92512ca88b62a602ebda291f17a953002, reversing changes made to 1e6c09a803fd543a98bfbe1624d697a55300a786.
2023-07-21Move `naive_layout_of` query provider in separate sibling moduleMoulins-229/+5
2023-07-21Add doc-comments for `NaiveLayout`Moulins-1/+1
2023-07-21Track ABI info. in `NaiveLayout`, and use it for `PointerLike` checksMoulins-55/+77
THis significantly complicates `NaiveLayout` logic, but is necessary to ensure that bounds like `NonNull<T>: PointerLike` hold in generic contexts. Also implement exact layout computation for structs.
2023-07-21Track exactness in `NaiveLayout` and use it for `SizeSkeleton` checksMoulins-32/+39
2023-07-21restrict the valid range of references if `-Z reference-niches` is setMoulins-11/+33
Note that this doesn't actually work at all, as many places in rustc assume that references only have the null niche.
2023-07-21add crate-local `-Z reference_niches` unstable flag (does nothing for now)Moulins-2/+9
2023-07-21properly handle arrays and wide pointers in `naive_layout_of`Moulins-80/+115
2023-07-21add `naive_layout_of` queryMoulins-19/+178
2023-07-15Auto merge of #112157 - erikdesjardins:align, r=nikicbors-0/+10
Resurrect: rustc_target: Add alignment to indirectly-passed by-value types, correcting the alignment of byval on x86 in the process. Same as #111551, which I [accidentally closed](https://github.com/rust-lang/rust/pull/111551#issuecomment-1571222612) :/ --- This resurrects PR #103830, which has sat idle for a while. Beyond #103830, this also: - fixes byval alignment for types containing vectors on Darwin (see `tests/codegen/align-byval-vector.rs`) - fixes byval alignment for overaligned types on x86 Windows (see `tests/codegen/align-byval.rs`) - fixes ABI for types with 128bit requested alignment on ARM64 Linux (see `tests/codegen/aarch64-struct-align-128.rs`) r? `@nikic` --- `@pcwalton's` original PR description is reproduced below: Commit 88e4d2c from five years ago removed support for alignment on indirectly-passed arguments because of problems with the `i686-pc-windows-msvc` target. Unfortunately, the `memcpy` optimizations I recently added to LLVM 16 depend on this to forward `memcpy`s. This commit attempts to fix the problems with `byval` parameters on that target and now correctly adds the `align` attribute. The problem is summarized in [this comment] by `@eddyb.` Briefly, 32-bit x86 has special alignment rules for `byval` parameters: for the most part, their alignment is forced to 4. This is not well-documented anywhere but in the Clang source. I looked at the logic in Clang `TargetInfo.cpp` and tried to replicate it here. The relevant methods in that file are `X86_32ABIInfo::getIndirectResult()` and `X86_32ABIInfo::getTypeStackAlignInBytes()`. The `align` parameter attribute for `byval` parameters in LLVM must match the platform ABI, or miscompilations will occur. Note that this doesn't use the approach suggested by eddyb, because I felt it was overkill to store the alignment in `on_stack` when special handling is really only needed for 32-bit x86. As a side effect, this should fix #80127, because it will make the `align` parameter attribute for `byval` parameters match the platform ABI on LLVM x86-64. [this comment]: #80822 (comment)
2023-07-14i686-windows: make requested alignment > 4 special case apply transitivelyErik Desjardins-5/+5
2023-07-14refactor(rustc_middle): Substs -> GenericArgMahdi Dibaiee-20/+20
2023-07-12Re-format let-else per rustfmt updateMark Rousskov-2/+7
2023-07-10aarch64-linux: properly handle 128bit aligned aggregatesErik Desjardins-0/+5
2023-07-10repr(align) <= 4 should still be byvalErik Desjardins-5/+5
2023-07-10move has_repr to layout, handle repr(transparent) properlyErik Desjardins-0/+5
2023-07-06add helper methods for accessing struct tailLukas Markeffsky-9/+2
2023-07-06sanity check field offsets in unsizeable structsLukas Markeffsky-0/+49
2023-07-06clean up struct layout codeLukas Markeffsky-32/+37
2023-07-05Move `TyCtxt::mk_x` to `Ty::new_x` where applicableBoxy-2/+2
2023-07-01Put `LayoutError` behind reference to shrink resultNilstrieb-24/+41
`LayoutError` is 24 bytes, which is bigger than the `Ok` types, so let's shrink that.
2023-06-23Rollup merge of #112810 - compiler-errors:dont-ice-on-bad-layout, r=wesleywiserMatthias Krüger-7/+28
Don't ICE on unnormalized struct tail in layout computation 1. We try to compute a `SizeSkeleton` even if a layout error occurs, but we really only need to do this if we get `LayoutError::Unknown`, since that means our type is too polymorphic to actually compute the full layout. If we have other errors, like `LayoutError::NormalizationError` or `LayoutError::Cycle`, then we can't really make any progress, since this represents an actual error. 2. Avoid using `normalize_erasing_regions` and `struct_tail_erasing_lifetimes` since those ICE on normalization errors, and since we may call `layout_of` in HIR typeck, we don't know for certain that we're on the happy path. Fixes #112736
2023-06-19Better error messageMichael Goulet-1/+16
2023-06-19Don't ICE on unnormalized struct tail in layout computationMichael Goulet-7/+13
2023-06-19Store generator field names in GeneratorLayout.Camille GILLOT-4/+5
2023-06-19Make closure_saved_names_of_captured_variables a query.Camille GILLOT-1/+1
2023-05-29EarlyBinder::new -> EarlyBinder::bindlcnr-1/+1
2023-05-28Replace EarlyBinder(x) with EarlyBinder::new(x)Kyle Matsuda-1/+1
2023-05-15Move expansion of query macros in rustc_middle to rustc_middle::queryJohn Kåre Alsaker-2/+3
2023-04-24Split `{Idx, IndexVec, IndexSlice}` into their own modulesMaybe Waffle-1/+1
2023-04-10Fix typos in compilerDaniPopes-1/+1
2023-04-08Update compiler/rustc_ty_utils/src/layout.rs matthewjasper-1/+1
Fix formatting that rustfmt can't handle currently. Co-authored-by: Michael Goulet <michael@errs.io>