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>>>>,
|
||||
);
|
||||
|
||||
impl<'tcx> rustc_type_ir::inherent::Predicate<TyCtxt<'tcx>> for Predicate<'tcx> {}
|
||||
|
||||
impl<'tcx> rustc_type_ir::visit::Flags for Predicate<'tcx> {
|
||||
fn flags(&self) -> TypeFlags {
|
||||
self.0.flags
|
||||
|
@ -3,7 +3,7 @@
|
||||
use rustc_middle::query::Providers;
|
||||
use rustc_middle::traits::query::NoSolution;
|
||||
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::traits::query::normalize::QueryNormalizeExt;
|
||||
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;
|
||||
}
|
||||
|
||||
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_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 ty(self) -> I::Ty;
|
||||
}
|
||||
|
||||
pub trait GenericsOf<I: Interner> {
|
||||
pub trait GenericsOf<I: Interner<GenericsOf = Self>> {
|
||||
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 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
|
||||
pub trait PlaceholderLike {
|
||||
pub trait PlaceholderLike: Copy + Debug + Hash + Eq {
|
||||
fn universe(self) -> UniverseIndex;
|
||||
fn var(self) -> BoundVar;
|
||||
|
||||
|
@ -2,23 +2,17 @@
|
||||
use std::fmt::Debug;
|
||||
use std::hash::Hash;
|
||||
|
||||
use crate::fold::TypeSuperFoldable;
|
||||
use crate::inherent::*;
|
||||
use crate::ir_print::IrPrint;
|
||||
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>> {
|
||||
type DefId: Copy + Debug + Hash + Eq;
|
||||
type DefiningOpaqueTypes: Copy + Debug + Hash + Default + Eq + TypeVisitable<Self>;
|
||||
type AdtDef: Copy + Debug + Hash + Eq;
|
||||
|
||||
type GenericArgs: Copy
|
||||
+ DebugWithInfcx<Self>
|
||||
+ Hash
|
||||
+ Eq
|
||||
+ IntoIterator<Item = Self::GenericArg>
|
||||
+ GenericArgs<Self>;
|
||||
type GenericArgs: GenericArgs<Self>;
|
||||
type GenericArg: Copy + DebugWithInfcx<Self> + 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>>;
|
||||
|
||||
// Kinds of tys
|
||||
type Ty: Copy
|
||||
+ DebugWithInfcx<Self>
|
||||
+ Hash
|
||||
+ Eq
|
||||
+ Into<Self::GenericArg>
|
||||
+ IntoKind<Kind = TyKind<Self>>
|
||||
+ TypeSuperVisitable<Self>
|
||||
+ TypeSuperFoldable<Self>
|
||||
+ Flags
|
||||
+ Ty<Self>;
|
||||
type Ty: Ty<Self>;
|
||||
type Tys: Copy + Debug + Hash + Eq + IntoIterator<Item = Self::Ty>;
|
||||
type AliasTy: Copy + DebugWithInfcx<Self> + Hash + Eq;
|
||||
type ParamTy: 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
|
||||
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>;
|
||||
|
||||
// Kinds of consts
|
||||
type Const: Copy
|
||||
+ DebugWithInfcx<Self>
|
||||
+ Hash
|
||||
+ Eq
|
||||
+ Into<Self::GenericArg>
|
||||
+ IntoKind<Kind = ConstKind<Self>>
|
||||
+ TypeSuperVisitable<Self>
|
||||
+ TypeSuperFoldable<Self>
|
||||
+ Flags
|
||||
+ Const<Self>;
|
||||
type Const: Const<Self>;
|
||||
type AliasConst: Copy + DebugWithInfcx<Self> + Hash + Eq;
|
||||
type PlaceholderConst: Copy + Debug + Hash + Eq + PlaceholderLike;
|
||||
type PlaceholderConst: PlaceholderLike;
|
||||
type ParamConst: Copy + Debug + Hash + Eq;
|
||||
type BoundConst: Copy + Debug + Hash + Eq;
|
||||
type ValueConst: Copy + Debug + Hash + Eq;
|
||||
type ExprConst: Copy + DebugWithInfcx<Self> + Hash + Eq;
|
||||
|
||||
// Kinds of regions
|
||||
type Region: Copy
|
||||
+ DebugWithInfcx<Self>
|
||||
+ Hash
|
||||
+ Eq
|
||||
+ Into<Self::GenericArg>
|
||||
+ IntoKind<Kind = RegionKind<Self>>
|
||||
+ Flags
|
||||
+ Region<Self>;
|
||||
type Region: Region<Self>;
|
||||
type EarlyParamRegion: Copy + Debug + Hash + Eq;
|
||||
type LateParamRegion: Copy + Debug + Hash + Eq;
|
||||
type BoundRegion: Copy + Debug + Hash + Eq;
|
||||
type InferRegion: Copy + DebugWithInfcx<Self> + Hash + Eq;
|
||||
type PlaceholderRegion: Copy + Debug + Hash + Eq + PlaceholderLike;
|
||||
type PlaceholderRegion: PlaceholderLike;
|
||||
|
||||
// Predicates
|
||||
type Predicate: Copy
|
||||
+ Debug
|
||||
+ Hash
|
||||
+ Eq
|
||||
+ TypeSuperVisitable<Self>
|
||||
+ TypeSuperFoldable<Self>
|
||||
+ Flags;
|
||||
type Predicate: Predicate<Self>;
|
||||
type TraitPredicate: Copy + Debug + Hash + Eq;
|
||||
type RegionOutlivesPredicate: Copy + Debug + Hash + Eq;
|
||||
type TypeOutlivesPredicate: Copy + Debug + Hash + Eq;
|
||||
|
@ -8,7 +8,7 @@ pub trait IrPrint<T> {
|
||||
}
|
||||
|
||||
macro_rules! define_display_via_print {
|
||||
($($ty:ident,)*) => {
|
||||
($($ty:ident),+ $(,)?) => {
|
||||
$(
|
||||
impl<I: Interner> fmt::Display for $ty<I> {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
|
@ -31,7 +31,7 @@ pub struct TraitRef<I: Interner> {
|
||||
pub args: I::GenericArgs,
|
||||
/// This field exists to prevent the creation of `TraitRef` without
|
||||
/// calling [`TraitRef::new`].
|
||||
pub(super) _use_trait_ref_new_instead: (),
|
||||
_use_trait_ref_new_instead: (),
|
||||
}
|
||||
|
||||
impl<I: Interner> TraitRef<I> {
|
||||
|
Loading…
Reference in New Issue
Block a user