summary refs log tree commit diff
path: root/compiler/rustc_ty_utils/src
AgeCommit message (Collapse)AuthorLines
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
2023-07-07Move some logic into a method on `OpaqueTypeCollector`Oli Scherer-29/+33
2023-07-07Remove one layer of nested matching on the same thingOli Scherer-55/+39
2023-07-07liar liar find_taits_declared_in_body on fireOli Scherer-10/+10
2023-07-07We don't need to track binders if we aren't normalizingOli Scherer-20/+1
2023-07-07Remove normalization from `opaque_types_defined_by`Oli Scherer-41/+2
2023-07-07Require TAITs to be mentioned in the signatures of functions that register ↵Oli Scherer-30/+194
hidden types for them
2023-07-06get rid of a bit more calls to poly_selectMichael Goulet-1/+1
2023-07-06add helper methods for accessing struct tailLukas Markeffsky-10/+3
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-14/+16
2023-07-05Auto merge of #113210 - fee1-dead-contrib:effects-mvp, r=oli-obkbors-0/+2
Effects/keyword generics MVP This adds `feature(effects)`, which adds `const host: bool` to the generics of const functions, const traits and const impls. This will be used to replace the current logic around const traits. r? `@oli-obk`
2023-07-04include `host_effect_index` in `Generics`Deadbeef-0/+2
2023-07-04Replace `const_error` methods with `Const::new_error`Boxy-1/+1
2023-07-04Replace `mk_const` with `Const::new_x` methodsBoxy-13/+15
2023-07-04Auto merge of #113303 - compiler-errors:yeet-chalk, r=lcnrbors-117/+1
Remove chalk support from the compiler Removes chalk (`-Ztrait-solver=chalk`) from the compiler and prunes any dead code resulting from this, mainly: * Remove the chalk compatibility layer in `compiler/rustc_traits/src/chalk` * Remove the chalk flag `-Ztrait-solver=chalk` and its `TraitEngine` implementation * Remove `TypeWellFormedFromEnv` (and its many `bug!()` match arms) * Remove the chalk migration mode from compiletest * Remove the `chalkify` UI tests (do we want to keep any of these, but migrate them to `-Ztrait-solver=next`??) Fulfills rust-lang/types-team#93. r? `@jackh726`
2023-07-04Auto merge of #113215 - compiler-errors:rpitit-predicates-tweaks, r=spastorinobors-18/+1
Make RPITITs assume/require their parent method's predicates Removes a FIXME from the `param_env` query where we were manually adding the parent function's predicates to the RPITIT's assumptions. r? `@spastorino`
2023-07-03Remove chalk from the compilerMichael Goulet-117/+1
2023-07-03use `deeply_normalize` for `assumed_wf_types`lcnr-20/+56
2023-07-01Put `FnAbiError` behind reference to shrink resultNilstrieb-7/+10
The `FnAbi` is just a pointer, so the error type should not be bigger.
2023-07-01Put `LayoutError` behind reference to shrink resultNilstrieb-25/+42
`LayoutError` is 24 bytes, which is bigger than the `Ok` types, so let's shrink that.
2023-06-30RPITITs inherit method predicatesMichael Goulet-18/+1
2023-06-29Add bidirectional where clauses on RPITIT synthesized GATsSantiago Pastorino-12/+0
2023-06-29Do not remove previously added predicates in param_env, extend them insteadSantiago Pastorino-1/+3
2023-06-28Rollup merge of #112867 - compiler-errors:more-impl-source-nits, r=lcnrDylan DPC-3/+1
More `ImplSource` nits Even more clean-ups, I'll put this up in parallel with the `select_in_new_trait_solver` PR. r? ``@lcnr``
2023-06-27`thir`: Add `Become` expression kindMaybe Waffle-1/+3
2023-06-26TypeWellFormedInEnvMichael Goulet-10/+7
2023-06-26Migrate predicates_of and caller_bounds to ClauseMichael Goulet-10/+11
2023-06-23Auto merge of #112891 - oli-obk:impl_trait_in_assoc_tys_cleanup, ↵bors-49/+85
r=compiler-errors Various impl trait in assoc tys cleanups r? `@compiler-errors` All commits except for the last are pure refactorings. 274dab5bd658c97886a8987340bf50ae57900c39 allows struct fields to participate in deciding whether a function has an opaque in its signature. best reviewed commit by commit
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-22Only walk the identity substituted version of struct fieldsOli Scherer-1/+22
2023-06-22Handle weak type aliases by immediately resolving them to their aliased typeOli Scherer-9/+14
2023-06-22ICE on types that should not be defining opaque typesOli Scherer-1/+3
2023-06-22Document what is going on in `opaque_types_defined_by`Oli Scherer-0/+3
2023-06-22Move some field extraction logic onto a method on `Node`Oli Scherer-7/+3
2023-06-22Re-use error code for duplicate errorOli Scherer-1/+1
2023-06-22Treat opaque types failing the signature defining scope check as defining, ↵Oli Scherer-2/+3
as we already errored and can hide subsequent errors this way.
2023-06-22Stop failing eagerly, and collect all opaque types even if some are erroneous.Oli Scherer-12/+6
2023-06-22Point to argument/return type instead of the whole function headerOli Scherer-6/+30
2023-06-22Only create the opaque collector once and visit it many timesOli Scherer-20/+10
2023-06-22Move `opaque_type_origin_unchecked` onto `TyCtxt` and re-use it where it was ↵Oli Scherer-1/+1
open coded
2023-06-21Don't substitute a GAT that has mismatched generics in OpaqueTypeCollectorMichael Goulet-30/+50