about summary refs log tree commit diff
path: root/compiler/rustc_ty_utils
AgeCommit message (Collapse)AuthorLines
2023-08-01Convert adt_sized_constraint to early-binder, use listMichael Goulet-4/+7
2023-07-31Rollup merge of #114267 - compiler-errors:rpitit-opaque-bounds, r=spastorinoMatthias Krüger-2/+4
Map RPITIT's opaque type bounds back from projections to opaques An RPITIT in a program's AST is eventually translated into both a projection GAT and an opaque. The opaque is used for default trait methods, like: ``` trait Foo { fn bar() -> impl Sized { 0i32 } } ``` The item bounds for both the projection and opaque are identical, and both have a *projection* self ty. This is mostly okay, since we can normalize this projection within the default trait method body to the opaque, but it does two things: 1. it leads to bugs in places where we don't normalize item bounds, like `deduce_future_output_from_obligations` 2. it leads to extra match arms that are both suspicious looking and also easy to miss This PR maps the opaque type bounds of the RPITIT's *opaque* back to the opaque's self type to avoid this quirk. Then we can fix the UI test for #108304 (1.) and also remove a bunch of match arms (2.). Fixes #108304 r? `@spastorino`
2023-07-31We don't need impl_trait_in_trait_parent_fn anymoreMichael Goulet-2/+4
2023-07-30Don't install default projection bound for RPITITsMichael Goulet-1/+3
2023-07-29some nits, bless testMichael Goulet-5/+27
2023-07-29Implement assumed_wf_types for RPITITs' implementationsMichael Goulet-33/+58
2023-07-29Take RPITITs inherit the assumed_wf_types of their parent fnMichael Goulet-0/+38
2023-07-29Rollup merge of #113773 - compiler-errors:err-layout-bail, r=cjgillotMatthias Krüger-2/+13
Don't attempt to compute layout of type referencing error Leads to more ICEs and strange diagnostics than are worth it. Fixes #113760
2023-07-28Rollup merge of #114146 - compiler-errors:dont-report-rpitit-name, r=spastorinoMatthias Krüger-2/+10
Skip reporting item name when checking RPITIT GAT's associated type bounds hold Doesn't really make sense to label an item that has a name that users can't really mention. Fixes #114145. Also fixes #113794. r? `@spastorino`
2023-07-27tighten span slightly for synthetic itemMichael Goulet-2/+10
2023-07-27Don't attempt to compute layout of type referencing errorMichael Goulet-2/+13
2023-07-27Remove `constness` from `ParamEnv`Deadbeef-77/+1
2023-07-25inline format!() args from rustc_codegen_llvm to the end (4)Matthias Krüger-1/+1
r? @WaffleLapkin
2023-07-25Make everything builtin!Michael Goulet-8/+11
2023-07-25Restore tuple unsizing feature gateMichael Goulet-1/+3
2023-07-23fix some clippy::style findingsMatthias Krüger-1/+1
comparison_to_empty iter_nth_zero for_kv_map manual_next_back redundant_pattern
2023-07-21Revert "Auto merge of #113166 - moulins:ref-niches-initial, r=oli-obk"David Tolnay-470/+113
This reverts commit 557359f92512ca88b62a602ebda291f17a953002, reversing changes made to 1e6c09a803fd543a98bfbe1624d697a55300a786.
2023-07-21Track (partial) niche information in `NaiveLayout`Moulins-33/+115
Still more complexity, but this allows computing exact `NaiveLayout`s for null-optimized enums, and thus allows calls like `transmute::<Option<&T>, &U>()` to work in generic contexts.
2023-07-21Move `naive_layout_of` query provider in separate sibling moduleMoulins-230/+253
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-18Rollup merge of #113824 - lcnr:exhaustive-match, r=wesleywiserMatthias Krüger-3/+27
a small `fn needs_drop` refactor I am generally a fan of exhaustively matching on `TyKind` once we care about more than 1 variant
2023-07-18some additional refactorlcnr-3/+3
also, treat placeholders equal to params
2023-07-17Rename arg_iter to iter_instantiatedMichael Goulet-2/+2
2023-07-17exhaustive matches are goodlcnr-1/+25
2023-07-17Auto merge of #113772 - nnethercote:streamline-size-estimates-2, r=wesleywiserbors-17/+0
Streamline size estimates (take 2) This was merged in #113684 but then [something happened](https://github.com/rust-lang/rust/pull/113684#issuecomment-1636811985): > There has been a bors issue that lead to the merge commit of this PR getting purged from master. > You'll have to make a new PR to reapply it. So this is exactly the same changes. `@bors` r=wesleywiser
2023-07-17Remove `instance_def_size_estimate` query.Nicholas Nethercote-17/+0
It doesn't seem worthwhile now that `MonoItem::size_estimate` is called much less often.
2023-07-17Rollup merge of #113539 - agnarrarendelle:master, r=workingjubileeMatthias Krüger-1/+1
fixed typo Hi, I have fixed a few typos in commands. Please review my pr.
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-143/+141
2023-07-12Re-format let-else per rustfmt updateMark Rousskov-7/+16
2023-07-12fixed typosagnarrarendelle-1/+1
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-08Replace RPITIT current impl with new strategy that lowers as a GATSantiago Pastorino-72/+48
2023-07-08Auto merge of #113376 - ↵bors-2/+2
Nilstrieb:pointer-coercions-are-not-casts-because-that-sounds-way-to-general-aaaa, r=oli-obk Rename `adjustment::PointerCast` and variants using it to `PointerCoercion` It makes it sounds like the `ExprKind` and `Rvalue` are supposed to represent all pointer related casts, when in reality their just used to share a little enum variants. Make it clear there these are only coercions and that people who see this and think "why are so many pointer related casts not in these variants" aren't insane. This enum was added in #59987. I'm not sure whether the variant sharing is actually worth it, but this at least makes it less confusing. r? oli-obk
2023-07-08Auto merge of #112652 - oli-obk:tait_only_in_sig, r=compiler-errorsbors-35/+117
Require TAITs to be mentioned in the signatures of functions that register hidden types for them r? `@lcnr` `@compiler-errors` This implements the lang team decision from [the TAIT design meeting](https://rust-lang.zulipchat.com/#narrow/stream/213817-t-lang/topic/design.20meeting.202023-05-31.20TAITs/near/362518164).
2023-07-07Rename `adjustment::PointerCast` and variants using it to `PointerCoercion`Nilstrieb-2/+2
It makes it sound like the `ExprKind` and `Rvalue` are supposed to represent all pointer related casts, when in reality their just used to share a some enum variants. Make it clear there these are only coercion to make it clear why only some pointer related "casts" are in the enum.
2023-07-07Auto merge of #113245 - lukas-code:unsizing-sanity-check, r=the8472bors-28/+75
sanity check field offsets in unsizeable structs As promised in https://github.com/rust-lang/rust/pull/112062#issuecomment-1567494994, this PR extends the layout sanity checks to ensure that structs fields don't move around when unsizing and prevent issues like https://github.com/rust-lang/rust/issues/112048 in the future. Like most other layout sanity checks, this only runs on compilers with debug assertions enabled. Here is how it looks when it fails: ```text error: internal compiler error: compiler/rustc_ty_utils/src/layout.rs:533:21: unsizing GcNode<std::boxed::Box<i32>> changed field order! Layout { size: Size(32 bytes), align: AbiAndPrefAlign { abi: Align(8 bytes), pref: Align(8 bytes) }, abi: Aggregate { sized: true }, fields: Arbitrary { offsets: [Size(0 bytes), Size(8 bytes), Size(24 bytes)], memory_index: [0, 1, 2] }, largest_niche: Some(Niche { offset: Size(24 bytes), value: Pointer(AddressSpace(0)), valid_range: 1..=18446744073709551615 }), variants: Single { index: 0 } } Layout { size: Size(24 bytes), align: AbiAndPrefAlign { abi: Align(8 bytes), pref: Align(8 bytes) }, abi: Aggregate { sized: false }, fields: Arbitrary { offsets: [Size(16 bytes), Size(0 bytes), Size(24 bytes)], memory_index: [1, 0, 2] }, largest_niche: None, variants: Single { index: 0 } } ``` r? `@the8472`
2023-07-07Treat closures as part of their parentOli Scherer-10/+10
2023-07-07Fix one layer of closures not being able to constrain opaque typesOli Scherer-1/+4
2023-07-07Only match on the `DefKind` once.Oli Scherer-29/+19
2023-07-07Collect nested items immediately instead of collecting them into an ↵Oli Scherer-15/+10
intermediate `Vec` first