Apply nits, make some bounds into supertraits on inherent traits
This commit is contained in:
parent
f368527802
commit
b55d8a3b49
@ -30,6 +30,8 @@ pub struct Predicate<'tcx>(
|
|||||||
pub(super) Interned<'tcx, WithCachedTypeInfo<ty::Binder<'tcx, PredicateKind<'tcx>>>>,
|
pub(super) Interned<'tcx, WithCachedTypeInfo<ty::Binder<'tcx, PredicateKind<'tcx>>>>,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
impl<'tcx> rustc_type_ir::inherent::Predicate<TyCtxt<'tcx>> for Predicate<'tcx> {}
|
||||||
|
|
||||||
impl<'tcx> rustc_type_ir::visit::Flags for Predicate<'tcx> {
|
impl<'tcx> rustc_type_ir::visit::Flags for Predicate<'tcx> {
|
||||||
fn flags(&self) -> TypeFlags {
|
fn flags(&self) -> TypeFlags {
|
||||||
self.0.flags
|
self.0.flags
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
use rustc_middle::query::Providers;
|
use rustc_middle::query::Providers;
|
||||||
use rustc_middle::traits::query::NoSolution;
|
use rustc_middle::traits::query::NoSolution;
|
||||||
use rustc_middle::ty::{Clause, ParamEnvAnd};
|
use rustc_middle::ty::{Clause, ParamEnvAnd};
|
||||||
use rustc_middle::ty::{FnSig, Lift, PolyFnSig, Ty, TyCtxt, TypeFoldable};
|
use rustc_middle::ty::{FnSig, PolyFnSig, Ty, TyCtxt, TypeFoldable};
|
||||||
use rustc_trait_selection::infer::InferCtxtBuilderExt;
|
use rustc_trait_selection::infer::InferCtxtBuilderExt;
|
||||||
use rustc_trait_selection::traits::query::normalize::QueryNormalizeExt;
|
use rustc_trait_selection::traits::query::normalize::QueryNormalizeExt;
|
||||||
use rustc_trait_selection::traits::query::type_op::ascribe_user_type::{
|
use rustc_trait_selection::traits::query::type_op::ascribe_user_type::{
|
||||||
|
@ -1,33 +1,69 @@
|
|||||||
use crate::{BoundVar, DebruijnIndex, Interner, UniverseIndex};
|
use std::fmt::Debug;
|
||||||
|
use std::hash::Hash;
|
||||||
|
|
||||||
pub trait Ty<I: Interner<Ty = Self>> {
|
use crate::fold::TypeSuperFoldable;
|
||||||
|
use crate::visit::{Flags, TypeSuperVisitable};
|
||||||
|
use crate::{
|
||||||
|
BoundVar, ConstKind, DebruijnIndex, DebugWithInfcx, Interner, RegionKind, TyKind, UniverseIndex,
|
||||||
|
};
|
||||||
|
|
||||||
|
pub trait Ty<I: Interner<Ty = Self>>:
|
||||||
|
Copy
|
||||||
|
+ DebugWithInfcx<I>
|
||||||
|
+ Hash
|
||||||
|
+ Eq
|
||||||
|
+ Into<I::GenericArg>
|
||||||
|
+ IntoKind<Kind = TyKind<I>>
|
||||||
|
+ TypeSuperVisitable<I>
|
||||||
|
+ TypeSuperFoldable<I>
|
||||||
|
+ Flags
|
||||||
|
{
|
||||||
fn new_anon_bound(interner: I, debruijn: DebruijnIndex, var: BoundVar) -> Self;
|
fn new_anon_bound(interner: I, debruijn: DebruijnIndex, var: BoundVar) -> Self;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait Region<I: Interner<Region = Self>> {
|
pub trait Region<I: Interner<Region = Self>>:
|
||||||
|
Copy + DebugWithInfcx<I> + Hash + Eq + Into<I::GenericArg> + IntoKind<Kind = RegionKind<I>> + Flags
|
||||||
|
{
|
||||||
fn new_anon_bound(interner: I, debruijn: DebruijnIndex, var: BoundVar) -> Self;
|
fn new_anon_bound(interner: I, debruijn: DebruijnIndex, var: BoundVar) -> Self;
|
||||||
|
|
||||||
fn new_static(interner: I) -> Self;
|
fn new_static(interner: I) -> Self;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait Const<I: Interner<Const = Self>> {
|
pub trait Const<I: Interner<Const = Self>>:
|
||||||
|
Copy
|
||||||
|
+ DebugWithInfcx<I>
|
||||||
|
+ Hash
|
||||||
|
+ Eq
|
||||||
|
+ Into<I::GenericArg>
|
||||||
|
+ IntoKind<Kind = ConstKind<I>>
|
||||||
|
+ TypeSuperVisitable<I>
|
||||||
|
+ TypeSuperFoldable<I>
|
||||||
|
+ Flags
|
||||||
|
{
|
||||||
fn new_anon_bound(interner: I, debruijn: DebruijnIndex, var: BoundVar, ty: I::Ty) -> Self;
|
fn new_anon_bound(interner: I, debruijn: DebruijnIndex, var: BoundVar, ty: I::Ty) -> Self;
|
||||||
|
|
||||||
fn ty(self) -> I::Ty;
|
fn ty(self) -> I::Ty;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait GenericsOf<I: Interner> {
|
pub trait GenericsOf<I: Interner<GenericsOf = Self>> {
|
||||||
fn count(&self) -> usize;
|
fn count(&self) -> usize;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait GenericArgs<I: Interner> {
|
pub trait GenericArgs<I: Interner<GenericArgs = Self>>:
|
||||||
|
Copy + DebugWithInfcx<I> + Hash + Eq + IntoIterator<Item = I::GenericArg>
|
||||||
|
{
|
||||||
fn type_at(self, i: usize) -> I::Ty;
|
fn type_at(self, i: usize) -> I::Ty;
|
||||||
|
|
||||||
fn identity_for_item(interner: I, def_id: I::DefId) -> I::GenericArgs;
|
fn identity_for_item(interner: I, def_id: I::DefId) -> I::GenericArgs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub trait Predicate<I: Interner<Predicate = Self>>:
|
||||||
|
Copy + Debug + Hash + Eq + TypeSuperVisitable<I> + TypeSuperFoldable<I> + Flags
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
/// Common capabilities of placeholder kinds
|
/// Common capabilities of placeholder kinds
|
||||||
pub trait PlaceholderLike {
|
pub trait PlaceholderLike: Copy + Debug + Hash + Eq {
|
||||||
fn universe(self) -> UniverseIndex;
|
fn universe(self) -> UniverseIndex;
|
||||||
fn var(self) -> BoundVar;
|
fn var(self) -> BoundVar;
|
||||||
|
|
||||||
|
@ -2,23 +2,17 @@
|
|||||||
use std::fmt::Debug;
|
use std::fmt::Debug;
|
||||||
use std::hash::Hash;
|
use std::hash::Hash;
|
||||||
|
|
||||||
use crate::fold::TypeSuperFoldable;
|
|
||||||
use crate::inherent::*;
|
use crate::inherent::*;
|
||||||
use crate::ir_print::IrPrint;
|
use crate::ir_print::IrPrint;
|
||||||
use crate::visit::{Flags, TypeSuperVisitable, TypeVisitable};
|
use crate::visit::{Flags, TypeSuperVisitable, TypeVisitable};
|
||||||
use crate::{CanonicalVarInfo, ConstKind, DebugWithInfcx, RegionKind, TraitRef, TyKind};
|
use crate::{CanonicalVarInfo, DebugWithInfcx, TraitRef};
|
||||||
|
|
||||||
pub trait Interner: Sized + Copy + IrPrint<TraitRef<Self>> {
|
pub trait Interner: Sized + Copy + IrPrint<TraitRef<Self>> {
|
||||||
type DefId: Copy + Debug + Hash + Eq;
|
type DefId: Copy + Debug + Hash + Eq;
|
||||||
type DefiningOpaqueTypes: Copy + Debug + Hash + Default + Eq + TypeVisitable<Self>;
|
type DefiningOpaqueTypes: Copy + Debug + Hash + Default + Eq + TypeVisitable<Self>;
|
||||||
type AdtDef: Copy + Debug + Hash + Eq;
|
type AdtDef: Copy + Debug + Hash + Eq;
|
||||||
|
|
||||||
type GenericArgs: Copy
|
type GenericArgs: GenericArgs<Self>;
|
||||||
+ DebugWithInfcx<Self>
|
|
||||||
+ Hash
|
|
||||||
+ Eq
|
|
||||||
+ IntoIterator<Item = Self::GenericArg>
|
|
||||||
+ GenericArgs<Self>;
|
|
||||||
type GenericArg: Copy + DebugWithInfcx<Self> + Hash + Eq;
|
type GenericArg: Copy + DebugWithInfcx<Self> + Hash + Eq;
|
||||||
type Term: Copy + Debug + Hash + Eq;
|
type Term: Copy + Debug + Hash + Eq;
|
||||||
|
|
||||||
@ -29,21 +23,12 @@ pub trait Interner: Sized + Copy + IrPrint<TraitRef<Self>> {
|
|||||||
type CanonicalVars: Copy + Debug + Hash + Eq + IntoIterator<Item = CanonicalVarInfo<Self>>;
|
type CanonicalVars: Copy + Debug + Hash + Eq + IntoIterator<Item = CanonicalVarInfo<Self>>;
|
||||||
|
|
||||||
// Kinds of tys
|
// Kinds of tys
|
||||||
type Ty: Copy
|
type Ty: Ty<Self>;
|
||||||
+ DebugWithInfcx<Self>
|
|
||||||
+ Hash
|
|
||||||
+ Eq
|
|
||||||
+ Into<Self::GenericArg>
|
|
||||||
+ IntoKind<Kind = TyKind<Self>>
|
|
||||||
+ TypeSuperVisitable<Self>
|
|
||||||
+ TypeSuperFoldable<Self>
|
|
||||||
+ Flags
|
|
||||||
+ Ty<Self>;
|
|
||||||
type Tys: Copy + Debug + Hash + Eq + IntoIterator<Item = Self::Ty>;
|
type Tys: Copy + Debug + Hash + Eq + IntoIterator<Item = Self::Ty>;
|
||||||
type AliasTy: Copy + DebugWithInfcx<Self> + Hash + Eq;
|
type AliasTy: Copy + DebugWithInfcx<Self> + Hash + Eq;
|
||||||
type ParamTy: Copy + Debug + Hash + Eq;
|
type ParamTy: Copy + Debug + Hash + Eq;
|
||||||
type BoundTy: Copy + Debug + Hash + Eq;
|
type BoundTy: Copy + Debug + Hash + Eq;
|
||||||
type PlaceholderTy: Copy + Debug + Hash + Eq + PlaceholderLike;
|
type PlaceholderTy: PlaceholderLike;
|
||||||
|
|
||||||
// Things stored inside of tys
|
// Things stored inside of tys
|
||||||
type ErrorGuaranteed: Copy + Debug + Hash + Eq;
|
type ErrorGuaranteed: Copy + Debug + Hash + Eq;
|
||||||
@ -53,46 +38,24 @@ pub trait Interner: Sized + Copy + IrPrint<TraitRef<Self>> {
|
|||||||
type Pat: Copy + Debug + Hash + Eq + DebugWithInfcx<Self>;
|
type Pat: Copy + Debug + Hash + Eq + DebugWithInfcx<Self>;
|
||||||
|
|
||||||
// Kinds of consts
|
// Kinds of consts
|
||||||
type Const: Copy
|
type Const: Const<Self>;
|
||||||
+ DebugWithInfcx<Self>
|
|
||||||
+ Hash
|
|
||||||
+ Eq
|
|
||||||
+ Into<Self::GenericArg>
|
|
||||||
+ IntoKind<Kind = ConstKind<Self>>
|
|
||||||
+ TypeSuperVisitable<Self>
|
|
||||||
+ TypeSuperFoldable<Self>
|
|
||||||
+ Flags
|
|
||||||
+ Const<Self>;
|
|
||||||
type AliasConst: Copy + DebugWithInfcx<Self> + Hash + Eq;
|
type AliasConst: Copy + DebugWithInfcx<Self> + Hash + Eq;
|
||||||
type PlaceholderConst: Copy + Debug + Hash + Eq + PlaceholderLike;
|
type PlaceholderConst: PlaceholderLike;
|
||||||
type ParamConst: Copy + Debug + Hash + Eq;
|
type ParamConst: Copy + Debug + Hash + Eq;
|
||||||
type BoundConst: Copy + Debug + Hash + Eq;
|
type BoundConst: Copy + Debug + Hash + Eq;
|
||||||
type ValueConst: Copy + Debug + Hash + Eq;
|
type ValueConst: Copy + Debug + Hash + Eq;
|
||||||
type ExprConst: Copy + DebugWithInfcx<Self> + Hash + Eq;
|
type ExprConst: Copy + DebugWithInfcx<Self> + Hash + Eq;
|
||||||
|
|
||||||
// Kinds of regions
|
// Kinds of regions
|
||||||
type Region: Copy
|
type Region: Region<Self>;
|
||||||
+ DebugWithInfcx<Self>
|
|
||||||
+ Hash
|
|
||||||
+ Eq
|
|
||||||
+ Into<Self::GenericArg>
|
|
||||||
+ IntoKind<Kind = RegionKind<Self>>
|
|
||||||
+ Flags
|
|
||||||
+ Region<Self>;
|
|
||||||
type EarlyParamRegion: Copy + Debug + Hash + Eq;
|
type EarlyParamRegion: Copy + Debug + Hash + Eq;
|
||||||
type LateParamRegion: Copy + Debug + Hash + Eq;
|
type LateParamRegion: Copy + Debug + Hash + Eq;
|
||||||
type BoundRegion: Copy + Debug + Hash + Eq;
|
type BoundRegion: Copy + Debug + Hash + Eq;
|
||||||
type InferRegion: Copy + DebugWithInfcx<Self> + Hash + Eq;
|
type InferRegion: Copy + DebugWithInfcx<Self> + Hash + Eq;
|
||||||
type PlaceholderRegion: Copy + Debug + Hash + Eq + PlaceholderLike;
|
type PlaceholderRegion: PlaceholderLike;
|
||||||
|
|
||||||
// Predicates
|
// Predicates
|
||||||
type Predicate: Copy
|
type Predicate: Predicate<Self>;
|
||||||
+ Debug
|
|
||||||
+ Hash
|
|
||||||
+ Eq
|
|
||||||
+ TypeSuperVisitable<Self>
|
|
||||||
+ TypeSuperFoldable<Self>
|
|
||||||
+ Flags;
|
|
||||||
type TraitPredicate: Copy + Debug + Hash + Eq;
|
type TraitPredicate: Copy + Debug + Hash + Eq;
|
||||||
type RegionOutlivesPredicate: Copy + Debug + Hash + Eq;
|
type RegionOutlivesPredicate: Copy + Debug + Hash + Eq;
|
||||||
type TypeOutlivesPredicate: Copy + Debug + Hash + Eq;
|
type TypeOutlivesPredicate: Copy + Debug + Hash + Eq;
|
||||||
|
@ -8,7 +8,7 @@ pub trait IrPrint<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! define_display_via_print {
|
macro_rules! define_display_via_print {
|
||||||
($($ty:ident,)*) => {
|
($($ty:ident),+ $(,)?) => {
|
||||||
$(
|
$(
|
||||||
impl<I: Interner> fmt::Display for $ty<I> {
|
impl<I: Interner> fmt::Display for $ty<I> {
|
||||||
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
|
@ -31,7 +31,7 @@ pub struct TraitRef<I: Interner> {
|
|||||||
pub args: I::GenericArgs,
|
pub args: I::GenericArgs,
|
||||||
/// This field exists to prevent the creation of `TraitRef` without
|
/// This field exists to prevent the creation of `TraitRef` without
|
||||||
/// calling [`TraitRef::new`].
|
/// calling [`TraitRef::new`].
|
||||||
pub(super) _use_trait_ref_new_instead: (),
|
_use_trait_ref_new_instead: (),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<I: Interner> TraitRef<I> {
|
impl<I: Interner> TraitRef<I> {
|
||||||
|
Loading…
Reference in New Issue
Block a user