Introduce TyKind::Placeholder
variant
This commit is contained in:
parent
7401e3def5
commit
05995a8522
30 changed files with 46 additions and 13 deletions
|
@ -687,6 +687,9 @@ for ty::TyKind<'gcx>
|
|||
Bound(bound_ty) => {
|
||||
bound_ty.hash_stable(hcx, hasher);
|
||||
}
|
||||
ty::Placeholder(placeholder_ty) => {
|
||||
placeholder_ty.hash_stable(hcx, hasher);
|
||||
}
|
||||
Foreign(def_id) => {
|
||||
def_id.hash_stable(hcx, hasher);
|
||||
}
|
||||
|
|
|
@ -380,6 +380,7 @@ impl<'cx, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for Canonicalizer<'cx, 'gcx, 'tcx>
|
|||
| ty::Never
|
||||
| ty::Tuple(..)
|
||||
| ty::Projection(..)
|
||||
| ty::Placeholder(..)
|
||||
| ty::UnnormalizedProjection(..)
|
||||
| ty::Foreign(..)
|
||||
| ty::Param(..)
|
||||
|
|
|
@ -170,9 +170,6 @@ impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for TypeFreshener<'a, 'gcx, 'tcx> {
|
|||
t
|
||||
}
|
||||
|
||||
ty::Bound(..) =>
|
||||
bug!("encountered bound ty during freshening"),
|
||||
|
||||
ty::Generator(..) |
|
||||
ty::Bool |
|
||||
ty::Char |
|
||||
|
@ -200,6 +197,9 @@ impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for TypeFreshener<'a, 'gcx, 'tcx> {
|
|||
ty::Opaque(..) => {
|
||||
t.super_fold_with(self)
|
||||
}
|
||||
|
||||
ty::Placeholder(..) |
|
||||
ty::Bound(..) => bug!("unexpected type {:?}", t),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -455,7 +455,7 @@ fn ty_is_local_constructor(ty: Ty<'_>, in_crate: InCrate) -> bool {
|
|||
false
|
||||
}
|
||||
|
||||
ty::Bound(..) | ty::Infer(..) => match in_crate {
|
||||
ty::Placeholder(..) | ty::Bound(..) | ty::Infer(..) => match in_crate {
|
||||
InCrate::Local => false,
|
||||
// The inference variable might be unified with a local
|
||||
// type in that remote crate.
|
||||
|
|
|
@ -281,7 +281,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
|||
ty::Generator(..) => Some(18),
|
||||
ty::Foreign(..) => Some(19),
|
||||
ty::GeneratorWitness(..) => Some(20),
|
||||
ty::Bound(..) | ty::Infer(..) | ty::Error => None,
|
||||
ty::Placeholder(..) | ty::Bound(..) | ty::Infer(..) | ty::Error => None,
|
||||
ty::UnnormalizedProjection(..) => bug!("only used with chalk-engine"),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -251,6 +251,7 @@ pub fn trivial_dropck_outlives<'tcx>(tcx: TyCtxt<'_, '_, 'tcx>, ty: Ty<'tcx>) ->
|
|||
| ty::Projection(..)
|
||||
| ty::Param(_)
|
||||
| ty::Opaque(..)
|
||||
| ty::Placeholder(..)
|
||||
| ty::Infer(_)
|
||||
| ty::Bound(..)
|
||||
| ty::Generator(..) => false,
|
||||
|
|
|
@ -2470,6 +2470,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
|
|||
ty::Infer(ty::TyVar(_)) => Ambiguous,
|
||||
|
||||
ty::UnnormalizedProjection(..)
|
||||
| ty::Placeholder(..)
|
||||
| ty::Bound(_)
|
||||
| ty::Infer(ty::FreshTy(_))
|
||||
| ty::Infer(ty::FreshIntTy(_))
|
||||
|
@ -2555,6 +2556,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
|
|||
}
|
||||
|
||||
ty::UnnormalizedProjection(..)
|
||||
| ty::Placeholder(..)
|
||||
| ty::Bound(_)
|
||||
| ty::Infer(ty::FreshTy(_))
|
||||
| ty::Infer(ty::FreshIntTy(_))
|
||||
|
@ -2594,6 +2596,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
|
|||
| ty::Char => Vec::new(),
|
||||
|
||||
ty::UnnormalizedProjection(..)
|
||||
| ty::Placeholder(..)
|
||||
| ty::Dynamic(..)
|
||||
| ty::Param(..)
|
||||
| ty::Foreign(..)
|
||||
|
|
|
@ -2250,7 +2250,7 @@ impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> {
|
|||
pub fn print_debug_stats(self) {
|
||||
sty_debug_print!(
|
||||
self,
|
||||
Adt, Array, Slice, RawPtr, Ref, FnDef, FnPtr,
|
||||
Adt, Array, Slice, RawPtr, Ref, FnDef, FnPtr, Placeholder,
|
||||
Generator, GeneratorWitness, Dynamic, Closure, Tuple, Bound,
|
||||
Param, Infer, UnnormalizedProjection, Projection, Opaque, Foreign);
|
||||
|
||||
|
|
|
@ -212,6 +212,7 @@ impl<'a, 'gcx, 'lcx, 'tcx> ty::TyS<'tcx> {
|
|||
ty::Infer(ty::TyVar(_)) => "inferred type".into(),
|
||||
ty::Infer(ty::IntVar(_)) => "integral variable".into(),
|
||||
ty::Infer(ty::FloatVar(_)) => "floating-point variable".into(),
|
||||
ty::Placeholder(..) => "placeholder type".into(),
|
||||
ty::Bound(_) |
|
||||
ty::Infer(ty::FreshTy(_)) => "fresh type".into(),
|
||||
ty::Infer(ty::FreshIntTy(_)) => "fresh integral type".into(),
|
||||
|
|
|
@ -122,7 +122,7 @@ pub fn simplify_type<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>,
|
|||
ty::Foreign(def_id) => {
|
||||
Some(ForeignSimplifiedType(def_id))
|
||||
}
|
||||
ty::Bound(..) | ty::Infer(_) | ty::Error => None,
|
||||
ty::Placeholder(..) | ty::Bound(..) | ty::Infer(_) | ty::Error => None,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -74,6 +74,7 @@ impl FlagComputation {
|
|||
&ty::Uint(_) |
|
||||
&ty::Never |
|
||||
&ty::Str |
|
||||
&ty::Placeholder(..) |
|
||||
&ty::Foreign(..) => {
|
||||
}
|
||||
|
||||
|
|
|
@ -515,6 +515,7 @@ pub fn characteristic_def_id_of_type(ty: Ty<'_>) -> Option<DefId> {
|
|||
ty::Str |
|
||||
ty::FnPtr(_) |
|
||||
ty::Projection(_) |
|
||||
ty::Placeholder(..) |
|
||||
ty::UnnormalizedProjection(..) |
|
||||
ty::Param(_) |
|
||||
ty::Opaque(..) |
|
||||
|
|
|
@ -1159,6 +1159,7 @@ impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> {
|
|||
}
|
||||
|
||||
ty::Bound(..) |
|
||||
ty::Placeholder(..) |
|
||||
ty::UnnormalizedProjection(..) |
|
||||
ty::GeneratorWitness(..) |
|
||||
ty::Infer(_) => {
|
||||
|
@ -1743,7 +1744,8 @@ impl<'a, 'tcx, C> TyLayoutMethods<'tcx, C> for Ty<'tcx>
|
|||
}
|
||||
|
||||
ty::Projection(_) | ty::UnnormalizedProjection(..) | ty::Bound(..) |
|
||||
ty::Opaque(..) | ty::Param(_) | ty::Infer(_) | ty::Error => {
|
||||
ty::Placeholder(..) | ty::Opaque(..) | ty::Param(_) | ty::Infer(_) |
|
||||
ty::Error => {
|
||||
bug!("TyLayout::field_type: unexpected type `{}`", this.ty)
|
||||
}
|
||||
})
|
||||
|
|
|
@ -2445,6 +2445,7 @@ impl<'a, 'gcx, 'tcx> AdtDef {
|
|||
}
|
||||
}
|
||||
|
||||
Placeholder(..) |
|
||||
Bound(..) |
|
||||
Infer(..) => {
|
||||
bug!("unexpected type `{:?}` in sized_constraint_for_ty",
|
||||
|
|
|
@ -155,6 +155,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
|||
ty::FnDef(..) | // OutlivesFunction (*)
|
||||
ty::FnPtr(_) | // OutlivesFunction (*)
|
||||
ty::Dynamic(..) | // OutlivesObject, OutlivesFragment (*)
|
||||
ty::Placeholder(..) |
|
||||
ty::Bound(..) |
|
||||
ty::Error => {
|
||||
// (*) Bare functions and traits are both binders. In the
|
||||
|
|
|
@ -746,6 +746,7 @@ impl<'tcx> TypeFoldable<'tcx> for Ty<'tcx> {
|
|||
ty::Infer(_) |
|
||||
ty::Param(..) |
|
||||
ty::Bound(..) |
|
||||
ty::Placeholder(..) |
|
||||
ty::Never |
|
||||
ty::Foreign(..) => return self
|
||||
};
|
||||
|
@ -792,6 +793,7 @@ impl<'tcx> TypeFoldable<'tcx> for Ty<'tcx> {
|
|||
ty::Error |
|
||||
ty::Infer(_) |
|
||||
ty::Bound(..) |
|
||||
ty::Placeholder(..) |
|
||||
ty::Param(..) |
|
||||
ty::Never |
|
||||
ty::Foreign(..) => false,
|
||||
|
|
|
@ -203,6 +203,9 @@ pub enum TyKind<'tcx> {
|
|||
/// Bound type variable, used only when preparing a trait query.
|
||||
Bound(BoundTy),
|
||||
|
||||
/// A placeholder type - universally quantified higher-ranked type.
|
||||
Placeholder(ty::PlaceholderType),
|
||||
|
||||
/// A type variable used during type checking.
|
||||
Infer(InferTy),
|
||||
|
||||
|
@ -1890,6 +1893,7 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> {
|
|||
Foreign(..) |
|
||||
Param(_) |
|
||||
Bound(..) |
|
||||
Placeholder(..) |
|
||||
Infer(_) |
|
||||
Error => {}
|
||||
}
|
||||
|
@ -1954,6 +1958,7 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> {
|
|||
ty::Infer(ty::TyVar(_)) => false,
|
||||
|
||||
ty::Bound(_) |
|
||||
ty::Placeholder(..) |
|
||||
ty::Infer(ty::FreshTy(_)) |
|
||||
ty::Infer(ty::FreshIntTy(_)) |
|
||||
ty::Infer(ty::FreshFloatTy(_)) =>
|
||||
|
|
|
@ -952,7 +952,7 @@ fn needs_drop_raw<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
|||
// Can refer to a type which may drop.
|
||||
// FIXME(eddyb) check this against a ParamEnv.
|
||||
ty::Dynamic(..) | ty::Projection(..) | ty::Param(_) | ty::Bound(..) |
|
||||
ty::Opaque(..) | ty::Infer(_) | ty::Error => true,
|
||||
ty::Placeholder(..) | ty::Opaque(..) | ty::Infer(_) | ty::Error => true,
|
||||
|
||||
ty::UnnormalizedProjection(..) => bug!("only used with chalk-engine"),
|
||||
|
||||
|
|
|
@ -82,7 +82,7 @@ fn push_subtypes<'tcx>(stack: &mut TypeWalkerStack<'tcx>, parent_ty: Ty<'tcx>) {
|
|||
match parent_ty.sty {
|
||||
ty::Bool | ty::Char | ty::Int(_) | ty::Uint(_) | ty::Float(_) |
|
||||
ty::Str | ty::Infer(_) | ty::Param(_) | ty::Never | ty::Error |
|
||||
ty::Bound(..) | ty::Foreign(..) => {
|
||||
ty::Placeholder(..) | ty::Bound(..) | ty::Foreign(..) => {
|
||||
}
|
||||
ty::Array(ty, len) => {
|
||||
push_const(stack, len);
|
||||
|
|
|
@ -259,6 +259,7 @@ impl<'a, 'gcx, 'tcx> WfPredicates<'a, 'gcx, 'tcx> {
|
|||
ty::Never |
|
||||
ty::Param(_) |
|
||||
ty::Bound(..) |
|
||||
ty::Placeholder(..) |
|
||||
ty::Foreign(..) => {
|
||||
// WfScalar, WfParameter, etc
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ use ty::{Bool, Char, Adt};
|
|||
use ty::{Error, Str, Array, Slice, Float, FnDef, FnPtr};
|
||||
use ty::{Param, Bound, RawPtr, Ref, Never, Tuple};
|
||||
use ty::{Closure, Generator, GeneratorWitness, Foreign, Projection, Opaque};
|
||||
use ty::{UnnormalizedProjection, Dynamic, Int, Uint, Infer};
|
||||
use ty::{Placeholder, UnnormalizedProjection, Dynamic, Int, Uint, Infer};
|
||||
use ty::{self, RegionVid, Ty, TyCtxt, TypeFoldable, GenericParamCount, GenericParamDefKind};
|
||||
use util::nodemap::FxHashSet;
|
||||
|
||||
|
@ -1144,6 +1144,9 @@ define_print! {
|
|||
data.print(f, cx)?;
|
||||
write!(f, ")")
|
||||
}
|
||||
Placeholder(placeholder) => {
|
||||
write!(f, "Placeholder({:?})", placeholder)
|
||||
}
|
||||
Opaque(def_id, substs) => {
|
||||
if cx.is_verbose {
|
||||
return write!(f, "Opaque({:?}, {:?})", def_id, substs);
|
||||
|
|
|
@ -172,6 +172,7 @@ pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
|
|||
}
|
||||
ty::Error |
|
||||
ty::Infer(_) |
|
||||
ty::Placeholder(..) |
|
||||
ty::UnnormalizedProjection(..) |
|
||||
ty::Projection(..) |
|
||||
ty::Bound(..) |
|
||||
|
|
|
@ -727,6 +727,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
|
|||
ty::Closure(..) |
|
||||
ty::Generator(..) |
|
||||
ty::GeneratorWitness(..) |
|
||||
ty::Placeholder(..) |
|
||||
ty::UnnormalizedProjection(..) |
|
||||
ty::Projection(..) |
|
||||
ty::Opaque(..) |
|
||||
|
|
|
@ -378,6 +378,7 @@ impl<'a, 'tcx> DefPathBasedNames<'a, 'tcx> {
|
|||
ty::Error |
|
||||
ty::Bound(..) |
|
||||
ty::Infer(_) |
|
||||
ty::Placeholder(..) |
|
||||
ty::UnnormalizedProjection(..) |
|
||||
ty::Projection(..) |
|
||||
ty::Param(_) |
|
||||
|
|
|
@ -418,6 +418,7 @@ impl ChalkInferenceContext<'cx, 'gcx, 'tcx> {
|
|||
}
|
||||
|
||||
ty::GeneratorWitness(..) |
|
||||
ty::Placeholder(..) |
|
||||
ty::UnnormalizedProjection(..) |
|
||||
ty::Infer(..) |
|
||||
ty::Bound(..) |
|
||||
|
|
|
@ -274,7 +274,7 @@ fn dtorck_constraint_for_ty<'a, 'gcx, 'tcx>(
|
|||
|
||||
ty::UnnormalizedProjection(..) => bug!("only used with chalk-engine"),
|
||||
|
||||
ty::Bound(..) | ty::Infer(..) | ty::Error => {
|
||||
ty::Placeholder(..) | ty::Bound(..) | ty::Infer(..) | ty::Error => {
|
||||
// By the time this code runs, all type variables ought to
|
||||
// be fully resolved.
|
||||
Err(NoSolution)
|
||||
|
|
|
@ -114,6 +114,7 @@ impl ClauseVisitor<'set, 'a, 'tcx> {
|
|||
ty::Tuple(..) |
|
||||
ty::Never |
|
||||
ty::Infer(..) |
|
||||
ty::Placeholder(..) |
|
||||
ty::Bound(..) => (),
|
||||
|
||||
ty::GeneratorWitness(..) |
|
||||
|
|
|
@ -128,7 +128,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
|||
ty::Opaque(def_id, substs) => Some(PointerKind::OfOpaque(def_id, substs)),
|
||||
ty::Param(ref p) => Some(PointerKind::OfParam(p)),
|
||||
// Insufficient type information.
|
||||
ty::Bound(..) | ty::Infer(_) => None,
|
||||
ty::Placeholder(..) | ty::Bound(..) | ty::Infer(_) => None,
|
||||
|
||||
ty::Bool | ty::Char | ty::Int(..) | ty::Uint(..) |
|
||||
ty::Float(_) | ty::Array(..) | ty::GeneratorWitness(..) |
|
||||
|
|
|
@ -336,6 +336,7 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> {
|
|||
// types, where we use Error as the Self type
|
||||
}
|
||||
|
||||
ty::Placeholder(..) |
|
||||
ty::UnnormalizedProjection(..) |
|
||||
ty::GeneratorWitness(..) |
|
||||
ty::Bound(..) |
|
||||
|
|
|
@ -2744,6 +2744,7 @@ impl<'tcx> Clean<Type> for Ty<'tcx> {
|
|||
ty::Closure(..) | ty::Generator(..) => Tuple(vec![]), // FIXME(pcwalton)
|
||||
|
||||
ty::Bound(..) => panic!("Bound"),
|
||||
ty::Placeholder(..) => panic!("Placeholder"),
|
||||
ty::UnnormalizedProjection(..) => panic!("UnnormalizedProjection"),
|
||||
ty::GeneratorWitness(..) => panic!("GeneratorWitness"),
|
||||
ty::Infer(..) => panic!("Infer"),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue