summary refs log tree commit diff
path: root/compiler/rustc_middle/src/ty
AgeCommit message (Collapse)AuthorLines
2023-07-08Auto merge of #113376 - ↵bors-3/+3
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-07Rollup merge of #113467 - nbdd0121:unwind, r=compiler-errorsMichael Goulet-11/+5
Fix comment of `fn_can_unwind` Reopen of #113213
2023-07-07Rename `adjustment::PointerCast` and variants using it to `PointerCoercion`Nilstrieb-3/+3
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-2/+18
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-06Separate select calls that don't need a binderMichael Goulet-0/+7
2023-07-06add helper methods for accessing struct tailLukas Markeffsky-2/+18
2023-07-06Auto merge of #113377 - BoxyUwU:move_ty_ctors_to_ty, r=compiler-errorsbors-447/+489
Move `TyCtxt::mk_x` to `Ty::new_x` where applicable Part of rust-lang/compiler-team#616 turns out there's a lot of places we construct `Ty` this is a ridiculously huge PR :S r? `@oli-obk`
2023-07-06Fix up doc linksOli Scherer-2/+2
2023-07-06Auto merge of #113291 - oli-obk:pretty_print_mir_const, r=RalfJungbors-26/+15
Specialize `try_destructure_mir_constant` for its sole user (pretty printing) We can't remove the query, as we need to invoke it from rustc_middle, but can only implement it in mir interpretation/const eval. r? `@RalfJung` for a first round. While we could move all the logic into pretty printing, that would end up duplicating a bit of code with const eval, which doesn't seem great either.
2023-07-05Change comment on `TyCtxt::mk_ty_from_kind`Michael Goulet-1/+1
2023-07-05Move `TyCtxt::mk_x` to `Ty::new_x` where applicableBoxy-445/+487
2023-07-05Auto merge of #113370 - compiler-errors:rollup-8gvyy8e, r=compiler-errorsbors-235/+203
Rollup of 8 pull requests Successful merges: - #113010 (rust-installer & rls: remove exclusion from rustfmt & tidy ) - #113317 ( -Ztrait-solver=next: stop depending on old solver) - #113319 (`TypeParameterDefinition` always require a `DefId`) - #113320 (Add some extra information to opaque type cycle errors) - #113321 (Move `ty::ConstKind` to `rustc_type_ir`) - #113337 (Winnow specialized impls during selection in new solver) - #113355 (Move most coverage code out of `rustc_codegen_ssa`) - #113356 (Add support for NetBSD/riscv64 aka. riscv64gc-unknown-netbsd.) r? `@ghost` `@rustbot` modify labels: rollup
2023-07-05Document magic booleanOli Scherer-1/+3
2023-07-05Remove a function argument that is always passed with the same value.Oli Scherer-26/+13
2023-07-05Rollup merge of #113337 - compiler-errors:next-solver-winnow-specializing, ↵Michael Goulet-2/+2
r=lcnr Winnow specialized impls during selection in new solver We need to be able to winnow impls that are specialized by more specific impls in order for codegen to be able to proceed. r? ``@lcnr``
2023-07-05Auto merge of #113210 - fee1-dead-contrib:effects-mvp, r=oli-obkbors-0/+18
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-05Deal with falloutBoxy-14/+35
2023-07-05move `ConstKind` to typeir and move inherent impls to `Const`Boxy-220/+167
2023-07-05Winnow specializing implsMichael Goulet-2/+2
2023-07-04include `host_effect_index` in `Generics`Deadbeef-0/+3
2023-07-04Replace `const_error` methods with `Const::new_error`Boxy-35/+41
2023-07-04Replace `mk_const` with `Const::new_x` methodsBoxy-35/+106
2023-07-04enforce context effects in typeckDeadbeef-0/+15
2023-07-03remove TypeWellFormedFromEnvMichael Goulet-22/+4
2023-07-03fix structurally relate for weak aliaseslcnr-11/+15
2023-07-01Put `FnAbiError` behind reference to shrink resultNilstrieb-14/+6
The `FnAbi` is just a pointer, so the error type should not be bigger.
2023-07-01Put `LayoutError` behind reference to shrink resultNilstrieb-11/+21
`LayoutError` is 24 bytes, which is bigger than the `Ok` types, so let's shrink that.
2023-06-30Fix comment of `fn_can_unwind`Gary Guo-11/+5
2023-06-28Auto merge of #112708 - flip1995:clippy-freezing-pc-with-ice, r=oli-obkbors-5/+10
Avoid calling queries during query stack printing This has the side effect, that when Clippy should ICE (during an EarlyPass?) it will fill up the RAM with 2 GB/s and then freezes my Laptop. This is blocking the Clippy sync and might give some people really bad experiences, so this should be merged ASAP. r? `@cjgillot` cc `@Zoxc` I only commented this on [Zulip](https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/.60try_print_query_stack.60.20has.20.60ImplicitCtx.60.20during.20.60EarlyPass.60/near/363926180). I should've left a comment on the PR as well. My bad.
2023-06-28Rustdoc nit: refer to macro from docsOli Scherer-1/+1
2023-06-27Rollup merge of #113103 - cjgillot:normalize-inhabited, r=compiler-errorsMatthias Krüger-1/+12
Normalize types when applying uninhabited predicate. Fixes https://github.com/rust-lang/rust/issues/112997
2023-06-27Normalize types when applying uninhabited predicate.Camille GILLOT-1/+12
2023-06-27Avoid calling queries during query stack printingOli Scherer-4/+9
2023-06-26TypeWellFormedInEnvMichael Goulet-17/+17
2023-06-26Migrate predicates_of and caller_bounds to ClauseMichael Goulet-80/+74
2023-06-23Auto merge of #112891 - oli-obk:impl_trait_in_assoc_tys_cleanup, ↵bors-0/+6
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 #112870 - compiler-errors:clause-2, r=oli-obkMatthias Krüger-17/+86
Migrate `item_bounds` to `ty::Clause` Should be simpler than the next PR that's coming up. Last three commits are the relevant ones. r? ``@oli-obk`` or ``@lcnr``
2023-06-23Rollup merge of #112810 - compiler-errors:dont-ice-on-bad-layout, r=wesleywiserMatthias Krüger-1/+7
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-22migrate inferred_outlives_of to ClauseMichael Goulet-11/+8
2023-06-22Expect clause moreMichael Goulet-5/+2
2023-06-22Migrate item_bounds to ty::ClauseMichael Goulet-9/+84
2023-06-22Move `opaque_type_origin_unchecked` onto `TyCtxt` and re-use it where it was ↵Oli Scherer-0/+6
open coded
2023-06-21Print def_id on EarlyBoundRegion debugSantiago Pastorino-1/+1
2023-06-21Rollup merge of #112772 - compiler-errors:clauses-1, r=lcnrNilstrieb-119/+183
Add a fully fledged `Clause` type, rename old `Clause` to `ClauseKind` Does two basic things before I put up a more delicate set of PRs (along the lines of #112714, but hopefully much cleaner) that migrate existing usages of `ty::Predicate` to `ty::Clause` (`predicates_of`/`item_bounds`/`ParamEnv::caller_bounds`). 1. Rename `Clause` to `ClauseKind`, so it's parallel with `PredicateKind`. 2. Add a new `Clause` type which is parallel to `Predicate`. * This type exposes `Clause::kind(self) -> Binder<'tcx, ClauseKind<'tcx>>` which is parallel to `Predicate::kind` 😸 The new `Clause` type essentially acts as a newtype wrapper around `Predicate` that asserts that it is specifically a `PredicateKind::Clause`. Turns out from experimentation[^1] that this is not negative performance-wise, which is wonderful, since this a much simpler design than something that requires encoding the discriminant into the alignment bits of a predicate kind, or something else like that... r? ``@lcnr`` or ``@oli-obk`` [^1]: https://github.com/rust-lang/rust/pull/112714#issuecomment-1595653910
2023-06-21Rollup merge of #112759 - cjgillot:closure-names, r=oli-obkNilstrieb-76/+0
Make closure_saved_names_of_captured_variables a query. As we will start removing debuginfo during MIR optimizations, we need to keep them somewhere.
2023-06-21Auto merge of #112119 - zirconium-n:issue-113072-merge-borrow-kind, r=lcnrbors-0/+2
Merge `BorrowKind::Unique` into `BorrowKind::Mut` Fixes #112072 Might have conflict with #112070 r? `@lcnr` I'm not sure what's the suitable change in a couple places.
2023-06-20address most easy commentsZiru Niu-0/+2
2023-06-20Rollup merge of #112786 - lcnr:early-binder, r=NilstriebGuillaume Gomez-55/+60
change binders from tuple structs to named fields
2023-06-20Auto merge of #112320 - compiler-errors:do-not-impl-via-obj, r=lcnrbors-0/+10
Add `implement_via_object` to `rustc_deny_explicit_impl` to control object candidate assembly Some built-in traits are special, since they are used to prove facts about the program that are important for later phases of compilation such as codegen and CTFE. For example, the `Unsize` trait is used to assert to the compiler that we are able to unsize a type into another type. It doesn't have any methods because it doesn't actually *instruct* the compiler how to do this unsizing, but this is later used (alongside an exhaustive match of combinations of unsizeable types) during codegen to generate unsize coercion code. Due to this, these built-in traits are incompatible with the type erasure provided by object types. For example, the existence of `dyn Unsize<T>` does not mean that the compiler is able to unsize `Box<dyn Unsize<T>>` into `Box<T>`, since `Unsize` is a *witness* to the fact that a type can be unsized, and it doesn't actually encode that unsizing operation in its vtable as mentioned above. The old trait solver gets around this fact by having complex control flow that never considers object bounds for certain built-in traits: https://github.com/rust-lang/rust/blob/2f896da247e0ee8f0bef7cd7c54cfbea255b9f68/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs#L61-L132 However, candidate assembly in the new solver is much more lovely, and I'd hate to add this list of opt-out cases into the new solver. Instead of maintaining this complex and hard-coded control flow, instead we can make this a property of the trait via a built-in attribute. We already have such a build attribute that's applied to every single trait that we care about: `rustc_deny_explicit_impl`. This PR adds `implement_via_object` as a meta-item to that attribute that allows us to opt a trait out of object-bound candidate assembly as well. r? `@lcnr`
2023-06-20Merge attrs, better validationMichael Goulet-4/+6