summary refs log tree commit diff
path: root/compiler/rustc_ty_utils/src/ty.rs
AgeCommit message (Collapse)AuthorLines
2022-10-20Note discrepancies in constness calculationMichael Goulet-0/+5
2022-10-20Revert "Unify tcx.constness and param env constness checks"Michael Goulet-1/+68
This reverts commit bef8681a1837790f2745c1f6a7f8214af2fd7f5d. This reverts commit c646c4d403d8c88cd3450f859fbdc34ec26d5bb5.
2022-10-12Rollup merge of #102830 - compiler-errors:constness-parity, r=fee1-deadDylan DPC-68/+1
Unify `tcx.constness` query and param env constness checks The checks that we do in the `constness` query seem inconsistent with the checks that we do to determine if an item's param-env is const, so I merged them into the `constness` query and call that from the `param_env` query. I'm not sure if this totally makes sense -- is there a case where `tcx.param_env()` would return a const param-env for an item whose `tcx.constness()` is `Constness::NotConst`? Because if not, it seems a bit dangerous that these two differ. Luckily, not many places actually use `tcx.constness()`, and the checks in `tcx.param_env()` seem stricter than the checks in `tcx.constness()` (at least for the types of items we type-check). Also, due to the way that `tcx.param_env()` is implemented, it _never_ used to return a const param-env for a item coming from a different crate, which also seems dangerous (though also probably not weaponizable currently, because we seldom actually compute the param-env for a non-local item).
2022-10-12Unify tcx.constness and param env constness checksMichael Goulet-68/+1
2022-10-10Check representability in adt_sized_constraintCameron Steffen-4/+8
2022-10-09ImplItemKind::TyAlias => ImplItemKind::TypeMichael Goulet-1/+1
2022-09-19remove the `Subst` trait, always use `EarlyBinder`lcnr-1/+0
2022-09-12Plumb dyn trait representation through ty::DynamicEric Holk-1/+1
2022-09-01tracing::instrument cleanupOli Scherer-2/+0
2022-08-26Replace `Body::basic_blocks()` with field accessTomasz Miąsko-1/+1
2022-08-03Add bound_impl_subject and bound_return_tyJack Huey-3/+1
2022-08-03Change sized_constraints to return EarlyBinderJack Huey-1/+2
2022-08-01Store associated item defaultness in impl_defaultness.Camille GILLOT-5/+7
2022-07-29Rename local_did to def_idMiguel Guarniz-4/+8
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-07-29Change maybe_body_owned_by to take local def idMiguel Guarniz-3/+4
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-07-13Rename `debugging_opts` to `unstable_opts`Joshua Nelson-1/+1
This is no longer used only for debugging options (e.g. `-Zoutput-width`, `-Zallow-features`). Rename it to be more clear.
2022-07-04remove an unused `DefId`lcnr-1/+1
2022-06-10Implement def_ident_span in rustc_middle.Camille GILLOT-17/+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-28Move things to rustc_type_irWilco Kusee-1/+1
2022-05-13Add bound_type_ofJack Huey-1/+1
2022-05-10Introduce EarlyBinderJack Huey-3/+5
2022-04-10Avoid accessing HIR from MIR queries.Camille GILLOT-6/+1
2022-03-31Merge impl_constness and is_const_fn_raw.Camille GILLOT-10/+0
2022-03-11Improve `AdtDef` interning.Nicholas Nethercote-4/+4
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-02-21use `List<Ty<'tcx>>` for tupleslcnr-3/+3
2022-02-19Adopt let else in more placesest31-4/+1
2022-02-15Overhaul `RegionKind` and `Region`.Nicholas Nethercote-1/+1
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-1/+1
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-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-16Auto merge of #92805 - BoxyUwU:revert-lazy-anon-const-substs, r=lcnrbors-12/+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-5/+2
2022-01-15initial revertEllen-12/+2
2022-01-07Move associated_item* providers to their own moduleMatthew Jasper-225/+2
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-02Auto merge of #91354 - fee1-dead:const_env, r=spastorinobors-12/+73
Cleanup: Eliminate ConstnessAnd This is almost a behaviour-free change and purely a refactoring. "almost" because we appear to be using the wrong ParamEnv somewhere already, and this is now exposed by failing a test using the unstable `~const` feature. We most definitely need to review all `without_const` and at some point should probably get rid of many of them by using `TraitPredicate` instead of `TraitRef`. This is a continuation of https://github.com/rust-lang/rust/pull/90274. r? `@oli-obk` cc `@spastorino` `@ecstatic-morse`
2021-12-01FormatDeadbeef-6/+26
2021-11-29`ParamEnv` should be const when `ImplItem` is within a const impl.Deadbeef-1/+37
2021-11-29Completely remove ConstnessAndOli Scherer-3/+1
2021-11-29Re-use `constness_for_typeck` instead of rolling it ourselvesOli Scherer-11/+1
2021-11-29Add constness to ParamEnvOli Scherer-10/+27
This now causes a lot of queries to be executed twice, as reveal_all forces NotConst
2021-11-28Take a LocalDefId in expect_*item.Camille GILLOT-7/+4
2021-11-06Improve terminology around "after typeck"pierwill-1/+1
2021-10-25expose default substs in param_envb-naber-0/+12