about summary refs log tree commit diff
path: root/compiler/rustc_traits
AgeCommit message (Collapse)AuthorLines
2022-02-22chalk/db: use correct debrujin index when replacing opaque type.Dario Nieuwenhuis-15/+40
2022-02-21chalk/lowering: lower generator types.Dario Nieuwenhuis-1/+4
2022-02-21use `List<Ty<'tcx>>` for tupleslcnr-11/+8
2022-02-19Adopt let else in more placesest31-3/+3
2022-02-15Overhaul `Const`.Nicholas Nethercote-7/+7
Specifically, rename the `Const` struct as `ConstS` and re-introduce `Const` as this: ``` pub struct Const<'tcx>(&'tcx Interned<ConstS>); ``` This now matches `Ty` and `Predicate` more closely, including using pointer-based `eq` and `hash`. Notable changes: - `mk_const` now takes a `ConstS`. - `Const` was copy, despite being 48 bytes. Now `ConstS` is not, so need a we need separate arena for it, because we can't use the `Dropless` one any more. - Many `&'tcx Const<'tcx>`/`&Const<'tcx>` to `Const<'tcx>` changes - Many `ct.ty` to `ct.ty()` and `ct.val` to `ct.val()` changes. - Lots of tedious sigil fiddling.
2022-02-15Remove unnecessary `RegionKind::` quals.Nicholas Nethercote-22/+18
The variant names are exported, so we can use them directly (possibly with a `ty::` qualifier). Lots of places already do this, this commit just increases consistency.
2022-02-15Overhaul `RegionKind` and `Region`.Nicholas Nethercote-8/+8
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 `PredicateInner` and `Predicate`.Nicholas Nethercote-2/+2
Specifically, change `Ty` from this: ``` pub struct Predicate<'tcx> { inner: &'tcx PredicateInner<'tcx> } ``` to this: ``` pub struct Predicate<'tcx>(&'tcx Interned<PredicateS<'tcx>>) ``` where `PredicateInner` is renamed as `PredicateS`. This (plus a few other minor changes) makes the parallels with `Ty` and `TyS` much clearer, and makes the uniqueness more explicit.
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-02-11Reverse parameter to placeholder substitution in chalk resultsMatthew Jasper-10/+40
2022-02-11Fix more chalk lowering issuesMatthew Jasper-16/+22
- Implement lowering for subtype goals - Use correct lang item for Generator trait - Use `lower_into` for lowering `ty::Variance`
2022-02-11Stop using a placeholder for empty regions in ChalkMatthew Jasper-60/+14
2022-02-11Revert "Auto merge of #92007 - oli-obk:lazy_tait2, r=nikomatsakis"Oli Scherer-8/+0
This reverts commit e7cc3bddbe0d0e374d05e7003e662bba1742dbae, reversing changes made to 734368a200904ef9c21db86c595dc04263c87be0.
2022-02-09Avoid clone.Camille GILLOT-4/+4
2022-02-09Ensure that queries only return Copy types.Camille GILLOT-4/+4
2022-02-02Lazily resolve type-alias-impl-trait defining usesOli Scherer-0/+8
by using an opaque type obligation to bubble up comparisons between opaque types and other types Also uses proper obligation causes so that the body id works, because out of some reason nll uses body ids for logic instead of just diagnostics.
2022-01-28Remove generalization over projectionkadmin-1/+4
Instead, just use a term everywhere.
2022-01-19⬆ chalk to 0.76.0pierwill-3/+3
2022-01-18Auto merge of #87648 - JulianKnodt:const_eq_constrain, r=oli-obkbors-3/+17
allow eq constraints on associated constants Updates #70256 (cc `@varkor,` `@Centril)`
2022-01-18Rollup merge of #92640 - compiler-errors:array-deref-on-newtype, r=lcnrMatthias Krüger-4/+4
Fix ICEs related to `Deref<Target=[T; N]>` on newtypes 1. Stash a const infer's type into the canonical var during canonicalization, so we can recreate the fresh const infer with that same type. For example, given `[T; _]` we know `_` is a `usize`. If we go from infer => canonical => infer, we shouldn't forget that variable is a usize. Fixes #92626 Fixes #83704 2. Don't stash the autoderef'd slice type that we get from method lookup, but instead recreate it during method confirmation. We need to do this because the type we receive back after picking the method references a type variable that does not exist after probing is done. Fixes #92637 ... A better solution for the second issue would be to actually _properly_ implement `Deref` for `[T; N]` instead of fixing this autoderef hack to stop leaking inference variables. But I actually looked into this, and there are many complications with const impls.
2022-01-17Add term to ExistentialProjectionkadmin-1/+3
Also prevent ICE when adding a const in associated const equality.
2022-01-17Update term for use in more placeskadmin-2/+14
Replace use of `ty()` on term and use it in more places. This will allow more flexibility in the future, but slightly worried it allows items which are consts which only accept types.
2022-01-17Use Term in ProjectionPredicatekadmin-2/+2
ProjectionPredicate should be able to handle both associated types and consts so this adds the first step of that. It mainly just pipes types all the way down, not entirely sure how to handle consts, but hopefully that'll come with time.
2022-01-15initial revertEllen-13/+2
2022-01-12Canonicalize const variables correctlyMichael Goulet-4/+4
2022-01-07Add `trait_item_def_id` to `AssocItem`Matthew Jasper-13/+3
This allows avoiding some lookups by name
2021-12-31Auto merge of #91929 - ↵bors-10/+9
anuvratsingh:remove_in_band_lifetimes_compiler_rustc_traits, r=jackh726 Removed `in_band_lifetimes` from `rustc_traits` Issue: [#91867](https://github.com/rust-lang/rust/issues/91867)
2021-12-30Removed `in_band_lifetimes` from `rustc_traits`Anuvrat-10/+9
2021-12-23Auto merge of #92167 - pierwill:chalk-update, r=jackh726bors-84/+85
Update chalk to 0.75.0 - Compute flags in `intern_ty` - Remove `tracing-serde` from `PERMITTED_DEPENDENCIES` - Bump `tracing-tree` to 0.2.0 - Bump `tracing-subscriber` to 0.3.3
2021-12-22Update chalk to 0.75.0pierwill-84/+85
- Compute flags in `intern_ty` - Remove tracing-serde from PERMITTED_DEPENDENCIES - Disable `tracing-full` feature in `chalk-solve` - Bump tracing-tree to 0.2.0
2021-12-13get rid of normalize_generic_arg... queriesb-naber-18/+2
2021-12-13normalize_generic_arg_after in terms of try versionb-naber-34/+11
2021-12-02Reduce boilerplate around infallible foldersAlan Egerton-44/+35
2021-12-01implement version of normalize_erasing_regions that doesn't assume value is ↵b-naber-0/+40
normalizable
2021-11-26Unwrap the results of type foldersLeSeulArtichaut-21/+24
Co-authored-by: Alan Egerton <eggyal@gmail.com>
2021-11-26Adapt `TypeFolder` implementors to return a `Result`LeSeulArtichaut-14/+20
Co-authored-by: Alan Egerton <eggyal@gmail.com>
2021-11-08Make select_* methods return Vec for TraitEngineDeadbeef-3/+3
2021-10-15Move some outlives bounds things from rustc_trait_selection to rustc_typeckjackh726-1/+1
2021-10-15Move push_outlives_components to rustc_inferjackh726-2/+2
2021-10-08clippy::complexity fixesMatthias Krüger-1/+1
2021-09-27Improve cause information for NLL higher-ranked errorsAaron Hill-9/+4
This PR has several interconnected pieces: 1. In some of the NLL region error code, we now pass around an `ObligationCause`, instead of just a plain `Span`. This gets forwarded into `fulfill_cx.register_predicate_obligation` during error reporting. 2. The general InferCtxt error reporting code is extended to handle `ObligationCauseCode::BindingObligation` 3. A new enum variant `ConstraintCategory::Predicate` is added. We try to avoid using this as the 'best blame constraint' - instead, we use it to enhance the `ObligationCause` of the `BlameConstraint` that we do end up choosing. As a result, several NLL error messages now contain the same "the lifetime requirement is introduced here" message as non-NLL errors. Having an `ObligationCause` available will likely prove useful for future improvements to NLL error messages.
2021-09-24Rollup merge of #89001 - jackh726:binder-cleanup, r=nikomatsakisJubilee-2/+3
Be explicit about using Binder::dummy This is somewhat of a late followup to the binder refactor PR. It removes `ToPredicate` and `ToPolyTraitImpls` that hide the use of `Binder::dummy`. While this does make code a bit more verbose, it allows us be more careful about where we create binders. Another alternative here might be to add a new trait `ToBinder` or something with a `dummy()` fn. Which could still allow grepping but allows doing something like `trait_ref.dummy()` (but I also wonder if longer-term, it would be better to be even more explicit with a `bind_with_vars(ty::List::empty())` *but* that's not clear yet. r? ``@nikomatsakis``
2021-09-20Migrate to 2021Mark Rousskov-1/+1
2021-09-15Remove ToPredicate impls that use Binder::dummyjackh726-2/+3
2021-08-27Auto merge of #88371 - Manishearth:rollup-pkkjsme, r=Manishearthbors-15/+35
Rollup of 11 pull requests Successful merges: - #87832 (Fix debugger stepping behavior with `match` expressions) - #88123 (Make spans for tuple patterns in E0023 more precise) - #88215 (Reland #83738: "rustdoc: Don't load all extern crates unconditionally") - #88216 (Don't stabilize creation of TryReserveError instances) - #88270 (Handle type ascription type ops in NLL HRTB diagnostics) - #88289 (Fixes for LLVM change 0f45c16f2caa7c035e5c3edd40af9e0d51ad6ba7) - #88320 (type_implements_trait consider obligation failure on overflow) - #88332 (Add argument types tait tests) - #88340 (Add `c_size_t` and `c_ssize_t` to `std::os::raw`.) - #88346 (Revert "Add type of a let tait test impl trait straight in let") - #88348 (Add field types tait tests) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2021-08-26Rollup merge of #88270 - lqd:hrtb-type-ascription, r=nikomatsakisManish Goregaokar-15/+35
Handle type ascription type ops in NLL HRTB diagnostics Currently, there are still a few cases of the "higher-ranked subtype error" of yore, 4 of which are related to type ascription. This PR is a follow-up to #86700, adding support for type ascription type ops, and makes 3 of these tests output the same diagnostics in NLL mode as the migrate mode (and 1 is now much closer, especially if you ignore that it already outputs an additional error in NLL mode -- which could be a duplicate caused by a lack of normalization like [these comments point out](https://github.com/rust-lang/rust/blob/9583fd1bdd0127328e25e5b8c24dff575ec2c86b/compiler/rustc_traits/src/type_op.rs#L122-L157), or an imprecision in some parts of normalization as [described here](https://github.com/rust-lang/rust/pull/86700#discussion_r689086688)). Since we discussed these recently: - [here](https://github.com/rust-lang/rust/pull/86700#discussion_r689158868), cc ````@matthewjasper,```` - and [here](https://github.com/rust-lang/rust/issues/57374#issuecomment-901500856), cc ````@Aaron1011.```` It should only leave [this TAIT test](https://github.com/rust-lang/rust/blob/9583fd1bdd0127328e25e5b8c24dff575ec2c86b/src/test/ui/type-alias-impl-trait/issue-57611-trait-alias.rs) as still emitting [the terse error](https://github.com/rust-lang/rust/blob/9583fd1bdd0127328e25e5b8c24dff575ec2c86b/src/test/ui/type-alias-impl-trait/issue-57611-trait-alias.nll.stderr). r? ````@estebank```` (so that they shake their fist at NLL's general direction less often) or ````@nikomatsakis```` or matthew or aaron, the more the merrier.
2021-08-26make unevaluated const substs optionallcnr-4/+5
2021-08-26require a `tcx` for `TypeVisitor`lcnr-2/+12
2021-08-23handle ascription type op in NLL HRTB diagnosticsRémy Rakic-15/+35
Refactors the `type_op_ascribe_user_type` query into a version which accepts a span, and uses it in the nicer NLL HRTB bound region errors.
2021-08-22Fix typos “a”→“an”Frank Steffahn-1/+1