about summary refs log tree commit diff
path: root/compiler/rustc_middle/src/ty/mod.rs
AgeCommit message (Collapse)AuthorLines
2023-07-27Remove `constness` from `ParamEnv`Deadbeef-77/+8
2023-07-14refactor(rustc_middle): Substs -> GenericArgMahdi Dibaiee-27/+27
2023-07-14Enable potential_query_instability lint in rustc_hir_typeck.Michael Woerister-2/+1
Fix linting errors by using FxIndex(Map|Set) and Unord(Map|Set) as appropriate.
2023-07-12Re-format let-else per rustfmt updateMark Rousskov-2/+6
2023-07-12Flip cfg's for bootstrap bumpMark Rousskov-1/+1
2023-07-11Auto merge of #112984 - BoxyUwU:debug_with_infcx, r=compiler-errorsbors-0/+1
Introduce `trait DebugWithInfcx` to debug format types with universe info Seeing universes of infer vars is valuable for debugging but currently we have no way of easily debug formatting a type with the universes of all the infer vars shown. In the future I hope to augment the new solver's proof tree output with a `DebugWithInfcx` impl so that it can show universes but I left that out of this PR as it would be non trivial and this is already large and complex enough. The goal here is to make the various abstractions taking `T: Debug` able to use the codepath for printing out universes, that way we can do `debug!("{:?}", my_x)` and have `my_x` have universes shown, same for the `write!` macro. It's not possible to put the `Infcx: InferCtxtLike<I>` into the formatter argument to `Debug::fmt` so it has to go into the self ty. For this we introduce the type `OptWithInfcx<I: Interner, Infcx: InferCtxtLike<I>, T>` which has the data `T` optionally coupled with the infcx (more on why it's optional later). Because of coherence/orphan rules it's not possible to write the impl `Debug for OptWithInfcx<..., MyType>` when `OptWithInfcx` is in a upstream crate. This necessitates a blanket impl in the crate defining `OptWithInfcx` like so: `impl<T: DebugWithInfcx> Debug for OptWithInfcx<..., T>`. It is not intended for people to manually call `DebugWithInfcx::fmt`, the `Debug` impl for `OptWithInfcx` should be preferred. The infcx has to be optional in `OptWithInfcx` as otherwise we would end up with a large amount of code duplication. Almost all types that want to be used with `OptWithInfcx` do not themselves need access to the infcx so if we were to not optional we would end up with large `Debug` and `DebugWithInfcx` impls that were practically identical other than that when formatting their fields we wrap the field in `OptWithInfcx` instead of formatting it alone. The only types that need access to the infcx themselves are ty/const/region infer vars, everything else is implemented by having the `Debug` impl defer to `OptWithInfcx` with no infcx available. The `DebugWithInfcx` impl is pretty much just the standard `Debug` impl except that instead of recursively formatting fields with `write!(f, "{x:?}")` we must do `write!(f, "{:?}", opt_infcx.wrap(x))`. This is some pretty rough boilerplate but I could not think of an alternative unfortunately. `OptWithInfcx::wrap` is an eager `Option::map` because 99% of callsites were discarding the existing data in `OptWithInfcx` and did not need lazy evaluation. A trait `InferCtxtLike` was added instead of using `InferCtxt<'tcx>` as we need to implement `DebugWithInfcx` for types living in `rustc_type_ir` which are generic over an interner and do not have access to `InferCtxt` since it lives in `rustc_infer`. Additionally I suspect that adding universe info to new solver proof tree output will require an implementation of `InferCtxtLike` for something that is not an `InferCtxt` although this is not the primary motivaton. --- To summarize: - There is a type `OptWithInfcx` which bundles some data optionally with an infcx with allows us to pass an infcx into a `Debug` impl. It's optional instead of being there unconditionally so that we can share code for `Debug` and `DebugWithInfcx` impls that don't care about whether there is an infcx available but have fields that might care. - There is a trait `DebugWithInfcx` which allows downstream crates to add impls of the form `Debug for OptWithInfcx<...>` which would normally be forbidden by orphan rules/coherence. - There is a trait `InferCtxtLike` to allow us to implement `DebugWithInfcx` for types that live in `rustc_type_ir` This allows debug formatting various `ty::*` structures with universes shown by using the `Debug` impl for `OptWithInfcx::new(ty, infcx)` --- This PR does not add `DebugWithInfcx` impls to absolutely _everything_ that should realistically have them, for example you cannot use `OptWithInfcx<Obligation<Predicate>>`. I am leaving this to a future PR to do so as it would likely be a lot more work to do.
2023-07-08Replace RPITIT current impl with new strategy that lowers as a GATSantiago Pastorino-21/+3
2023-07-07Auto merge of #113245 - lukas-code:unsizing-sanity-check, r=the8472bors-0/+16
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-0/+16
2023-07-06Add a new trait to `Debug` things with an infcx availableBoxy-0/+1
2023-07-05Deal with falloutBoxy-0/+4
2023-07-05move `ConstKind` to typeir and move inherent impls to `Const`Boxy-2/+2
2023-07-03remove TypeWellFormedFromEnvMichael Goulet-13/+4
2023-06-26TypeWellFormedInEnvMichael Goulet-10/+10
2023-06-26Migrate predicates_of and caller_bounds to ClauseMichael Goulet-14/+36
2023-06-22migrate inferred_outlives_of to ClauseMichael Goulet-1/+8
2023-06-22Migrate item_bounds to ty::ClauseMichael Goulet-1/+26
2023-06-19docMichael Goulet-1/+11
2023-06-19Fully fledged Clause typeMichael Goulet-45/+68
2023-06-19s/Clause/ClauseKindMichael Goulet-60/+61
2023-06-18Rollup merge of #112734 - dswij:bounds-predicates-clause, r=compiler-errorsMatthias Krüger-0/+7
Make `Bound::predicates` use `Clause` Part of #107250 `Bound::predicates` returns an iterator over `Binder<_, Clause>` instead of `Predicate`. I tried updating `explicit_predicates_of` as well, but it seems that it needs a lot more change than I thought. Will do it in a separate PR instead.
2023-06-17Move ConstEvaluatable to ClauseMichael Goulet-9/+7
2023-06-17Move WF goal to clauseMichael Goulet-8/+8
2023-06-17`Bound::predicates` to return `Clause`dswij-0/+7
2023-06-15Make assumption functions in new solver take clauseMichael Goulet-0/+66
2023-05-30Rollup merge of #112060 - lcnr:early-binder, r=jackh726Nilstrieb-1/+1
`EarlyBinder::new` -> `EarlyBinder::bind` for consistency with `Binder::bind`. it may make sense to also add `EarlyBinder::dummy` in places where we know that no parameters exist, but I left that out of this PR. r? `@jackh726` `@kylematsuda`
2023-05-29Rollup merge of #111988 - BoxyUwU:make_tykind_debug_good, r=compiler-errorsMatthias Krüger-1/+1
Make `TyKind: Debug` have less verbose output Current `TyKind: Debug` impl is basically unusable for debugging, its too verbose even for verbose debugging :rofl: This PR replaces the debug logic for `TyKind` with a more manual debug impl instead of a hand expanded derived impl. This should help make #107084 more reasonable to land since the output of `Ty: Debug` will be better. This isn't a fully completed change to the `Debug` impl of `TyKind` as there's still logic from the derive macro for some variants. Some of the variants are also not consisten with the `-Zverbose` printing of `Ty`, ideally `-Zverbose` printing of `Ty` would also just defer to the debug impl instead of having lots of checks in pretty printing. I plan on fixing this in follow up PRs since it seems tricky to do in this one and its already a large PR :sweat_smile:
2023-05-29EarlyBinder::new -> EarlyBinder::bindlcnr-1/+1
2023-05-28Replace EarlyBinder(x) with EarlyBinder::new(x)Kyle Matsuda-1/+1
2023-05-27Add warn-by-default lint for local binding shadowing exported glob re-export ↵许杰友 Jieyou Xu (Joe)-1/+1
item
2023-05-26better `TyKind::Debug`Boxy-1/+1
2023-05-25Remove ExpnKind::Inlined.Camille GILLOT-3/+1
2023-05-25Pull out logic from #111131, plus some new logic in ↵Michael Goulet-10/+4
EvalCtxt::normalize_opaque_type Co-authored-by: lcnr <rust@lcnr.de>
2023-05-24Use `Option::is_some_and` and `Result::is_ok_and` in the compilerMaybe Waffle-3/+3
2023-05-22Check opaques for mismatch during writebackMichael Goulet-3/+15
2023-05-19Add extra debug assertions for equality for Adt/Variant/FieldDefMichael Goulet-2/+23
2023-05-17Finish move of query.rsJohn Kåre Alsaker-2/+0
2023-05-15Auto merge of #111221 - compiler-errors:yeet-generalizer, r=lcnrbors-0/+18
Combine three generalizer implementations Fixes #111092 Fixes #109505 This code is a bit delicate and there were subtle changes between them, so I'll leave inline comments where further inspection is needed. Regarding this comment from #109813 -- "add tests triggering all codepaths: at least the combine and the const generalizer", can't really do that now, and I don't really know how we'd get a higher-ranked const error since non-lifetime binders doesn't *really* support `for<const ..>` (it errors out when you try to use it). r? `@lcnr`
2023-05-15yeet ConstInferUnifierMichael Goulet-0/+18
2023-05-15Move expansion of query macros in rustc_middle to rustc_middle::queryJohn Kåre Alsaker-2/+4
2023-05-12Add a convenience functionOli Scherer-0/+12
2023-05-12Require `impl Trait` in associated types to appear in method signaturesOli Scherer-1/+1
2023-05-08Rollup merge of #109410 - fmease:iat-alias-kind-inherent, r=compiler-errorsMichael Goulet-1/+1
Introduce `AliasKind::Inherent` for inherent associated types Allows us to check (possibly generic) inherent associated types for well-formedness. Type inference now also works properly. Follow-up to #105961. Supersedes #108430. Fixes #106722. Fixes #108957. Fixes #109768. Fixes #109789. Fixes #109790. ~Not to be merged before #108860 (`AliasKind::Weak`).~ CC `@jackh726` r? `@compiler-errors` `@rustbot` label T-types F-inherent_associated_types
2023-05-07Use smaller ints for bitflagsNilstrieb-1/+1
2023-05-04IAT: Introduce AliasKind::InherentLeón Orell Valerian Liehr-1/+1
2023-05-04Auto merge of #110806 - WaffleLapkin:unmkI, r=lcnrbors-0/+18
Replace `tcx.mk_trait_ref` with `TraitRef::new` First step in implementing https://github.com/rust-lang/compiler-team/issues/616 r? `@lcnr`
2023-05-03Rollup merge of #111146 - petrochenkov:decident, r=compiler-errorsManish Goregaokar-4/+3
rustc_middle: Fix `opt_item_ident` for non-local def ids Noticed while working on https://github.com/rust-lang/rust/pull/110855.
2023-05-03rustc_middle: Fix `opt_item_ident` for non-local def idsVadim Petrochenkov-4/+3
2023-05-02resolve: One more attempt to simplify `module_children`Vadim Petrochenkov-2/+1