about summary refs log tree commit diff
path: root/compiler/rustc_ty_utils
AgeCommit message (Collapse)AuthorLines
2022-06-14implement valtrees as the type-system representation for constant valuesb-naber-2/+0
2022-06-11Auto merge of #95880 - cjgillot:def-ident-span, r=petrochenkovbors-17/+0
Handle `def_ident_span` like `def_span`. `def_ident_span` had an ad-hoc status in the compiler. This PR refactors it to be a first-class citizen like `def_span`: - it gets encoded in the main metadata loop, instead of the visitor; - its implementation is updated to mirror the one of `def_span`. We do not remove the `Option` in the return type, since some items do not have an ident, AnonConsts for instance.
2022-06-10Implement def_ident_span in rustc_middle.Camille GILLOT-17/+0
2022-06-08Auto merge of #97860 - Dylan-DPC:rollup-t3vxos8, r=Dylan-DPCbors-5/+9
Rollup of 5 pull requests Successful merges: - #97595 (Remove unwrap from get_vtable) - #97597 (Preserve unused pointer to address casts) - #97819 (Recover `import` instead of `use` in item) - #97823 (Recover missing comma after match arm) - #97851 (Use repr(C) when depending on struct layout in ptr tests) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-06-08Rollup merge of #97595 - ouz-a:issue-97381, r=compiler-errorsDylan DPC-5/+9
Remove unwrap from get_vtable This avoids ICE on issue #97381 I think the bug is a bit deeper though, it compiles fine when `v` is `&v` which makes me think `Deref` is causing some issue with borrowck but it's fine I guess since this thing crashes since `nightly-2020-09-17` 😅
2022-06-08Folding revamp.Nicholas Nethercote-1/+3
This commit makes type folding more like the way chalk does it. Currently, `TypeFoldable` has `fold_with` and `super_fold_with` methods. - `fold_with` is the standard entry point, and defaults to calling `super_fold_with`. - `super_fold_with` does the actual work of traversing a type. - For a few types of interest (`Ty`, `Region`, etc.) `fold_with` instead calls into a `TypeFolder`, which can then call back into `super_fold_with`. With the new approach, `TypeFoldable` has `fold_with` and `TypeSuperFoldable` has `super_fold_with`. - `fold_with` is still the standard entry point, *and* it does the actual work of traversing a type, for all types except types of interest. - `super_fold_with` is only implemented for the types of interest. Benefits of the new model. - I find it easier to understand. The distinction between types of interest and other types is clearer, and `super_fold_with` doesn't exist for most types. - With the current model is easy to get confused and implement a `super_fold_with` method that should be left defaulted. (Some of the precursor commits fixed such cases.) - With the current model it's easy to call `super_fold_with` within `TypeFolder` impls where `fold_with` should be called. The new approach makes this mistake impossible, and this commit fixes a number of such cases. - It's potentially faster, because it avoids the `fold_with` -> `super_fold_with` call in all cases except types of interest. A lot of the time the compile would inline those away, but not necessarily always.
2022-06-05get_vtable returns opt instd of unwrppingouz-a-5/+9
2022-06-03Fully stabilize NLLJack Huey-1/+0
2022-05-30Auto merge of #96964 - oli-obk:const_trait_mvp, r=compiler-errorsbors-2/+2
Replace `#[default_method_body_is_const]` with `#[const_trait]` pulled out of #96077 related issues: #67792 and #92158 cc `@fee1-dead` This is groundwork to only allowing `impl const Trait` for traits that are marked with `#[const_trait]`. This is necessary to prevent adding a new default method from becoming a breaking change (as it could be a non-const fn).
2022-05-30Add a helper function for checking whether a default function in a trait can ↵Oli Scherer-2/+4
be treated as `const`
2022-05-30Remove `#[default..]` and add `#[const_trait]`Deadbeef-3/+1
2022-05-28Initial fixes on top of type interner commitMichael Goulet-0/+1
2022-05-28Move things to rustc_type_irWilco Kusee-1/+1
2022-05-17Auto merge of #97012 - oli-obk:🦀_intrinsics, r=davidtwcobors-7/+1
Add a query for checking whether a function is an intrinsic. work towards #93145 This will reduce churn when we add more ways to declare intrinsics r? `@scottmcm`
2022-05-16Add a query for checking whether a function is an intrinsic.Oli Scherer-7/+1
2022-05-14Auto merge of #96883 - jackh726:early-binder-2, r=oli-obkbors-6/+8
Add EarlyBinder Chalk has no concept of `Param` (https://github.com/rust-lang/chalk/blob/e0ade19d139bc784384acc6736cd960c91dd55a1/chalk-ir/src/lib.rs#L579) or `ReEarlyBound` (https://github.com/rust-lang/chalk/blob/e0ade19d139bc784384acc6736cd960c91dd55a1/chalk-ir/src/lib.rs#L1308). Everything is just "bound" - the equivalent of rustc's late-bound. It's not completely clear yet whether to move everything to the same time of binder in rustc or add `Param` and `ReEarlyBound` in Chalk. Either way, tracking when we have or haven't already substituted out these in rustc can be helpful. As a first step, I'm just adding a `EarlyBinder` newtype that is required to call `subst`. I also add a couple "transparent" `bound_*` wrappers around a couple query that are often immediately substituted. r? `@nikomatsakis`
2022-05-13Add bound_type_ofJack Huey-2/+2
2022-05-11Gracefully fail to resolve associated items instead of `delay_span_bug`.Camille GILLOT-1/+17
2022-05-10Introduce EarlyBinderJack Huey-6/+8
2022-04-10Avoid accessing HIR from MIR queries.Camille GILLOT-6/+1
2022-04-01Auto merge of #94883 - cjgillot:flat-metadata, r=oli-obkbors-10/+0
Encode even more metadata through tables instead of EntryKind This should move us closer to getting rid of `EntryKind`.
2022-03-31Merge impl_constness and is_const_fn_raw.Camille GILLOT-10/+0
2022-03-31Specialize suggestion for Option<T>Michael Goulet-23/+47
2022-03-21Rename `~const Drop` to `~const Destruct`Deadbeef-1/+1
2022-03-17Rollup merge of #94960 - codehorseman:master, r=oli-obkDylan DPC-3/+3
Fix many spelling mistakes Signed-off-by: codehorseman <cricis@yeah.net>
2022-03-16rustc_error: make ErrorReported impossible to constructmark-2/+2
There are a few places were we have to construct it, though, and a few places that are more invasive to change. To do this, we create a constructor with a long obvious name.
2022-03-16resolve the conflict in compiler/rustc_session/src/parse.rscodehorseman-3/+3
Signed-off-by: codehorseman <cricis@yeah.net>
2022-03-11Improve `AdtDef` interning.Nicholas Nethercote-21/+24
This commit makes `AdtDef` use `Interned`. Much the commit is tedious changes to introduce getter functions. The interesting changes are in `compiler/rustc_middle/src/ty/adt.rs`.
2022-03-02rename ErrorReported -> ErrorGuaranteedmark-7/+7
2022-02-24Restrict query recursion in `needs_significant_drop`Jakob Degen-19/+17
Overly aggressive use of the query system to improve caching lead to query cycles and consequently ICEs. This patch fixes this by restricting the use of the query system as a cache to those cases where it is definitely correct.
2022-02-21use `List<Ty<'tcx>>` for tupleslcnr-5/+5
2022-02-19Adopt let else in more placesest31-4/+2
2022-02-15Overhaul `RegionKind` and `Region`.Nicholas Nethercote-3/+3
Specifically, change `Region` from this: ``` pub type Region<'tcx> = &'tcx RegionKind; ``` to this: ``` pub struct Region<'tcx>(&'tcx Interned<RegionKind>); ``` This now matches `Ty` and `Predicate` more closely. Things to note - Regions have always been interned, but we haven't been using pointer-based `Eq` and `Hash`. This is now happening. - I chose to impl `Deref` for `Region` because it makes pattern matching a lot nicer, and `Region` can be viewed as just a smart wrapper for `RegionKind`. - Various methods are moved from `RegionKind` to `Region`. - There is a lot of tedious sigil changes. - A couple of types like `HighlightBuilder`, `RegionHighlightMode` now have a `'tcx` lifetime because they hold a `Ty<'tcx>`, so they can call `mk_region`. - A couple of test outputs change slightly, I'm not sure why, but the new outputs are a little better.
2022-02-15Overhaul `TyS` and `Ty`.Nicholas Nethercote-3/+3
Specifically, change `Ty` from this: ``` pub type Ty<'tcx> = &'tcx TyS<'tcx>; ``` to this ``` pub struct Ty<'tcx>(Interned<'tcx, TyS<'tcx>>); ``` There are two benefits to this. - It's now a first class type, so we can define methods on it. This means we can move a lot of methods away from `TyS`, leaving `TyS` as a barely-used type, which is appropriate given that it's not meant to be used directly. - The uniqueness requirement is now explicit, via the `Interned` type. E.g. the pointer-based `Eq` and `Hash` comes from `Interned`, rather than via `TyS`, which wasn't obvious at all. Much of this commit is boring churn. The interesting changes are in these files: - compiler/rustc_middle/src/arena.rs - compiler/rustc_middle/src/mir/visit.rs - compiler/rustc_middle/src/ty/context.rs - compiler/rustc_middle/src/ty/mod.rs Specifically: - Most mentions of `TyS` are removed. It's very much a dumb struct now; `Ty` has all the smarts. - `TyS` now has `crate` visibility instead of `pub`. - `TyS::make_for_test` is removed in favour of the static `BOOL_TY`, which just works better with the new structure. - The `Eq`/`Ord`/`Hash` impls are removed from `TyS`. `Interned`s impls of `Eq`/`Hash` now suffice. `Ord` is now partly on `Interned` (pointer-based, for the `Equal` case) and partly on `TyS` (contents-based, for the other cases). - There are many tedious sigil adjustments, i.e. adding or removing `*` or `&`. They seem to be unavoidable.
2022-02-01remove `TyS::same_type`lcnr-1/+1
it ignored regions and constants in adts, but didn't do so for references or any other types. This seemed quite weird
2022-01-31Rollup merge of #90277 - pierwill:fix-70258-inference-terms, r=jackh726Matthias Krüger-1/+1
Improve terminology around "after typeck" Closes #70258.
2022-01-19Store a `Symbol` instead of an `Ident` in `AssocItem`Aaron Hill-2/+2
This is the same idea as #92533, but for `AssocItem` instead of `VariantDef`/`FieldDef`. With this change, we no longer have any uses of `#[stable_hasher(project(...))]`
2022-01-16Auto merge of #92805 - BoxyUwU:revert-lazy-anon-const-substs, r=lcnrbors-16/+2
partially revertish `lazily "compute" anon const default substs` reverts #87280 except for some of the changes around `ty::Unevaluated` having a visitor and a generic for promoted why revert: <https://github.com/rust-lang/rust/pull/92805#issuecomment-1010736049> r? `@lcnr`
2022-01-15Reduce use of local_def_id_to_hir_id.Camille GILLOT-11/+3
2022-01-15Return a LocalDefId in get_parent_item.Camille GILLOT-2/+1
2022-01-15initial revertEllen-16/+2
2022-01-08Link impl items to corresponding trait items in late resolver.Camille GILLOT-104/+2
2022-01-07Add query to avoid name comparison in `leaf_def`Matthew Jasper-24/+28
2022-01-07Move associated_item* providers to their own moduleMatthew Jasper-225/+234
2022-01-07Add `trait_item_def_id` to `AssocItem`Matthew Jasper-1/+107
This allows avoiding some lookups by name
2021-12-17Use a const ParamEnv when in default_method_body_is_constDeadbeef-1/+7
2021-12-12Revert "Auto merge of #91491 - spastorino:revert-91354, r=oli-obk"Deadbeef-12/+73
This reverts commit ff2439b7b9bafcfdff86b7847128014699df8442, reversing changes made to 2a9e0831d6603d87220cedd1b1293e2eb82ef55c.
2021-12-07Store impl_trait_fn inside OpaqueTyOrigin.Camille GILLOT-2/+2
2021-12-03Revert "Auto merge of #91354 - fee1-dead:const_env, r=spastorino"Santiago Pastorino-73/+12
This reverts commit 18bb8c61a975fff6424cda831ace5b0404277145, reversing changes made to d9baa361902b172be716f96619b909f340802dea.
2021-12-03Rollup merge of #91462 - b-naber:use-try-normalize-erasing-regions, r=jackh726Matthias Krüger-2/+4
Use try_normalize_erasing_regions in needs_drop Fixes https://github.com/rust-lang/rust/issues/81199 r? ``@jackh726``