|
3 | 3 | use crate::infer::canonical::Canonical;
|
4 | 4 | use crate::mir;
|
5 | 5 | use crate::traits;
|
| 6 | +use crate::traits::ChalkEnvironmentAndGoal; |
6 | 7 | use crate::ty::fast_reject::SimplifiedType;
|
7 | 8 | use crate::ty::subst::{GenericArg, SubstsRef};
|
8 | 9 | use crate::ty::{self, layout::TyAndLayout, Ty, TyCtxt};
|
| 10 | +use rustc_data_structures::remap::Remap; |
9 | 11 | use rustc_hir::def_id::{CrateNum, DefId, LocalDefId, LOCAL_CRATE};
|
10 | 12 | use rustc_hir::hir_id::{HirId, OwnerId};
|
| 13 | +pub use rustc_middle::traits::query::type_op; |
11 | 14 | use rustc_query_system::query::{DefaultCacheSelector, VecCacheSelector};
|
12 | 15 | use rustc_span::symbol::{Ident, Symbol};
|
13 | 16 | use rustc_span::{Span, DUMMY_SP};
|
14 | 17 |
|
15 | 18 | /// The `Key` trait controls what types can legally be used as the key
|
16 | 19 | /// for a query.
|
17 |
| -pub trait Key: Sized { |
| 20 | +pub trait Key: Sized + Remap { |
18 | 21 | // N.B. Most of the keys down below have `type CacheSelector = DefaultCacheSelector<Self>;`,
|
19 | 22 | // it would be reasonable to use associated type defaults, to remove the duplication...
|
20 | 23 | //
|
@@ -588,7 +591,7 @@ impl Key for Option<Symbol> {
|
588 | 591 |
|
589 | 592 | /// Canonical query goals correspond to abstract trait operations that
|
590 | 593 | /// are not tied to any crate in particular.
|
591 |
| -impl<'tcx, T> Key for Canonical<'tcx, T> { |
| 594 | +impl<'tcx, T: Remap> Key for Canonical<'tcx, T> { |
592 | 595 | type CacheSelector = DefaultCacheSelector<Self>;
|
593 | 596 |
|
594 | 597 | #[inline(always)]
|
@@ -696,3 +699,132 @@ impl Key for HirId {
|
696 | 699 | None
|
697 | 700 | }
|
698 | 701 | }
|
| 702 | + |
| 703 | +// Remap implementations |
| 704 | + |
| 705 | +impl<'tcx, T: Remap> Remap for ty::ParamEnvAnd<'tcx, T> { |
| 706 | + type Remap<'a> = ty::ParamEnvAnd<'a, T::Remap<'a>>; |
| 707 | +} |
| 708 | + |
| 709 | +impl<'tcx, T: Remap> Remap for ty::Binder<'tcx, T> { |
| 710 | + type Remap<'a> = ty::Binder<'a, T::Remap<'a>>; |
| 711 | +} |
| 712 | + |
| 713 | +impl<'tcx, T: Remap> Remap for Canonical<'tcx, T> { |
| 714 | + type Remap<'a> = Canonical<'a, T::Remap<'a>>; |
| 715 | +} |
| 716 | + |
| 717 | +impl<T: Remap> Remap for type_op::Normalize<T> { |
| 718 | + type Remap<'a> = type_op::Normalize<T::Remap<'a>>; |
| 719 | +} |
| 720 | + |
| 721 | +impl<'tcx> Remap for type_op::AscribeUserType<'tcx> { |
| 722 | + type Remap<'a> = type_op::AscribeUserType<'a>; |
| 723 | +} |
| 724 | + |
| 725 | +impl<'tcx> Remap for type_op::Subtype<'tcx> { |
| 726 | + type Remap<'a> = type_op::Subtype<'a>; |
| 727 | +} |
| 728 | + |
| 729 | +impl<'tcx> Remap for type_op::Eq<'tcx> { |
| 730 | + type Remap<'a> = type_op::Eq<'a>; |
| 731 | +} |
| 732 | + |
| 733 | +impl<'tcx> Remap for type_op::ProvePredicate<'tcx> { |
| 734 | + type Remap<'a> = type_op::ProvePredicate<'a>; |
| 735 | +} |
| 736 | + |
| 737 | +impl<'tcx> Remap for ty::FnSig<'tcx> { |
| 738 | + type Remap<'a> = ty::FnSig<'a>; |
| 739 | +} |
| 740 | + |
| 741 | +impl<'tcx> Remap for ty::AliasTy<'tcx> { |
| 742 | + type Remap<'a> = ty::AliasTy<'a>; |
| 743 | +} |
| 744 | + |
| 745 | +impl<'tcx> Remap for Ty<'tcx> { |
| 746 | + type Remap<'a> = Ty<'a>; |
| 747 | +} |
| 748 | + |
| 749 | +impl<'tcx> Remap for ty::Predicate<'tcx> { |
| 750 | + type Remap<'a> = ty::Predicate<'a>; |
| 751 | +} |
| 752 | + |
| 753 | +impl<'tcx> Remap for ChalkEnvironmentAndGoal<'tcx> { |
| 754 | + type Remap<'a> = ChalkEnvironmentAndGoal<'a>; |
| 755 | +} |
| 756 | + |
| 757 | +impl<'tcx> Remap for ty::Instance<'tcx> { |
| 758 | + type Remap<'a> = ty::Instance<'a>; |
| 759 | +} |
| 760 | + |
| 761 | +impl<'tcx> Remap for ty::InstanceDef<'tcx> { |
| 762 | + type Remap<'a> = ty::InstanceDef<'a>; |
| 763 | +} |
| 764 | + |
| 765 | +impl<T: Remap> Remap for ty::WithOptConstParam<T> { |
| 766 | + type Remap<'a> = ty::WithOptConstParam<T::Remap<'a>>; |
| 767 | +} |
| 768 | + |
| 769 | +impl Remap for SimplifiedType { |
| 770 | + type Remap<'a> = SimplifiedType; |
| 771 | +} |
| 772 | + |
| 773 | +impl<'tcx> Remap for mir::interpret::GlobalId<'tcx> { |
| 774 | + type Remap<'a> = mir::interpret::GlobalId<'a>; |
| 775 | +} |
| 776 | + |
| 777 | +impl<'tcx> Remap for mir::interpret::LitToConstInput<'tcx> { |
| 778 | + type Remap<'a> = mir::interpret::LitToConstInput<'a>; |
| 779 | +} |
| 780 | + |
| 781 | +impl<'tcx> Remap for mir::interpret::ConstAlloc<'tcx> { |
| 782 | + type Remap<'a> = mir::interpret::ConstAlloc<'a>; |
| 783 | +} |
| 784 | + |
| 785 | +impl<'tcx> Remap for mir::ConstantKind<'tcx> { |
| 786 | + type Remap<'a> = mir::ConstantKind<'a>; |
| 787 | +} |
| 788 | + |
| 789 | +impl Remap for mir::Field { |
| 790 | + type Remap<'a> = mir::Field; |
| 791 | +} |
| 792 | + |
| 793 | +impl<'tcx> Remap for ty::ValTree<'tcx> { |
| 794 | + type Remap<'a> = ty::ValTree<'a>; |
| 795 | +} |
| 796 | + |
| 797 | +impl<'tcx> Remap for ty::ParamEnv<'tcx> { |
| 798 | + type Remap<'a> = ty::ParamEnv<'a>; |
| 799 | +} |
| 800 | + |
| 801 | +impl<'tcx> Remap for ty::GenericArg<'tcx> { |
| 802 | + type Remap<'a> = ty::GenericArg<'a>; |
| 803 | +} |
| 804 | + |
| 805 | +impl<'tcx, T: Remap> Remap for &'tcx ty::List<T> |
| 806 | +where |
| 807 | + for<'a> <T as Remap>::Remap<'a>: 'a, |
| 808 | +{ |
| 809 | + type Remap<'a> = &'a ty::List<T::Remap<'a>>; |
| 810 | +} |
| 811 | + |
| 812 | +impl<'tcx> Remap for ty::ExistentialTraitRef<'tcx> { |
| 813 | + type Remap<'a> = ty::ExistentialTraitRef<'a>; |
| 814 | +} |
| 815 | + |
| 816 | +impl<'tcx> Remap for ty::Const<'tcx> { |
| 817 | + type Remap<'a> = ty::Const<'a>; |
| 818 | +} |
| 819 | + |
| 820 | +impl<'tcx> Remap for ty::TraitRef<'tcx> { |
| 821 | + type Remap<'a> = ty::TraitRef<'a>; |
| 822 | +} |
| 823 | + |
| 824 | +impl<'tcx> Remap for ty::UnevaluatedConst<'tcx> { |
| 825 | + type Remap<'a> = ty::UnevaluatedConst<'a>; |
| 826 | +} |
| 827 | + |
| 828 | +impl Remap for traits::WellFormedLoc { |
| 829 | + type Remap<'a> = traits::WellFormedLoc; |
| 830 | +} |
0 commit comments