1
Fork 0

Introduce TyKind::Placeholder variant

This commit is contained in:
scalexm 2018-11-02 18:48:24 +01:00
parent 7401e3def5
commit 05995a8522
30 changed files with 46 additions and 13 deletions

View file

@ -687,6 +687,9 @@ for ty::TyKind<'gcx>
Bound(bound_ty) => { Bound(bound_ty) => {
bound_ty.hash_stable(hcx, hasher); bound_ty.hash_stable(hcx, hasher);
} }
ty::Placeholder(placeholder_ty) => {
placeholder_ty.hash_stable(hcx, hasher);
}
Foreign(def_id) => { Foreign(def_id) => {
def_id.hash_stable(hcx, hasher); def_id.hash_stable(hcx, hasher);
} }

View file

@ -380,6 +380,7 @@ impl<'cx, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for Canonicalizer<'cx, 'gcx, 'tcx>
| ty::Never | ty::Never
| ty::Tuple(..) | ty::Tuple(..)
| ty::Projection(..) | ty::Projection(..)
| ty::Placeholder(..)
| ty::UnnormalizedProjection(..) | ty::UnnormalizedProjection(..)
| ty::Foreign(..) | ty::Foreign(..)
| ty::Param(..) | ty::Param(..)

View file

@ -170,9 +170,6 @@ impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for TypeFreshener<'a, 'gcx, 'tcx> {
t t
} }
ty::Bound(..) =>
bug!("encountered bound ty during freshening"),
ty::Generator(..) | ty::Generator(..) |
ty::Bool | ty::Bool |
ty::Char | ty::Char |
@ -200,6 +197,9 @@ impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for TypeFreshener<'a, 'gcx, 'tcx> {
ty::Opaque(..) => { ty::Opaque(..) => {
t.super_fold_with(self) t.super_fold_with(self)
} }
ty::Placeholder(..) |
ty::Bound(..) => bug!("unexpected type {:?}", t),
} }
} }
} }

View file

@ -455,7 +455,7 @@ fn ty_is_local_constructor(ty: Ty<'_>, in_crate: InCrate) -> bool {
false false
} }
ty::Bound(..) | ty::Infer(..) => match in_crate { ty::Placeholder(..) | ty::Bound(..) | ty::Infer(..) => match in_crate {
InCrate::Local => false, InCrate::Local => false,
// The inference variable might be unified with a local // The inference variable might be unified with a local
// type in that remote crate. // type in that remote crate.

View file

@ -281,7 +281,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
ty::Generator(..) => Some(18), ty::Generator(..) => Some(18),
ty::Foreign(..) => Some(19), ty::Foreign(..) => Some(19),
ty::GeneratorWitness(..) => Some(20), 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"), ty::UnnormalizedProjection(..) => bug!("only used with chalk-engine"),
} }
} }

View file

@ -251,6 +251,7 @@ pub fn trivial_dropck_outlives<'tcx>(tcx: TyCtxt<'_, '_, 'tcx>, ty: Ty<'tcx>) ->
| ty::Projection(..) | ty::Projection(..)
| ty::Param(_) | ty::Param(_)
| ty::Opaque(..) | ty::Opaque(..)
| ty::Placeholder(..)
| ty::Infer(_) | ty::Infer(_)
| ty::Bound(..) | ty::Bound(..)
| ty::Generator(..) => false, | ty::Generator(..) => false,

View file

@ -2470,6 +2470,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
ty::Infer(ty::TyVar(_)) => Ambiguous, ty::Infer(ty::TyVar(_)) => Ambiguous,
ty::UnnormalizedProjection(..) ty::UnnormalizedProjection(..)
| ty::Placeholder(..)
| ty::Bound(_) | ty::Bound(_)
| ty::Infer(ty::FreshTy(_)) | ty::Infer(ty::FreshTy(_))
| ty::Infer(ty::FreshIntTy(_)) | ty::Infer(ty::FreshIntTy(_))
@ -2555,6 +2556,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
} }
ty::UnnormalizedProjection(..) ty::UnnormalizedProjection(..)
| ty::Placeholder(..)
| ty::Bound(_) | ty::Bound(_)
| ty::Infer(ty::FreshTy(_)) | ty::Infer(ty::FreshTy(_))
| ty::Infer(ty::FreshIntTy(_)) | ty::Infer(ty::FreshIntTy(_))
@ -2594,6 +2596,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
| ty::Char => Vec::new(), | ty::Char => Vec::new(),
ty::UnnormalizedProjection(..) ty::UnnormalizedProjection(..)
| ty::Placeholder(..)
| ty::Dynamic(..) | ty::Dynamic(..)
| ty::Param(..) | ty::Param(..)
| ty::Foreign(..) | ty::Foreign(..)

View file

@ -2250,7 +2250,7 @@ impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> {
pub fn print_debug_stats(self) { pub fn print_debug_stats(self) {
sty_debug_print!( sty_debug_print!(
self, self,
Adt, Array, Slice, RawPtr, Ref, FnDef, FnPtr, Adt, Array, Slice, RawPtr, Ref, FnDef, FnPtr, Placeholder,
Generator, GeneratorWitness, Dynamic, Closure, Tuple, Bound, Generator, GeneratorWitness, Dynamic, Closure, Tuple, Bound,
Param, Infer, UnnormalizedProjection, Projection, Opaque, Foreign); Param, Infer, UnnormalizedProjection, Projection, Opaque, Foreign);

View file

@ -212,6 +212,7 @@ impl<'a, 'gcx, 'lcx, 'tcx> ty::TyS<'tcx> {
ty::Infer(ty::TyVar(_)) => "inferred type".into(), ty::Infer(ty::TyVar(_)) => "inferred type".into(),
ty::Infer(ty::IntVar(_)) => "integral variable".into(), ty::Infer(ty::IntVar(_)) => "integral variable".into(),
ty::Infer(ty::FloatVar(_)) => "floating-point variable".into(), ty::Infer(ty::FloatVar(_)) => "floating-point variable".into(),
ty::Placeholder(..) => "placeholder type".into(),
ty::Bound(_) | ty::Bound(_) |
ty::Infer(ty::FreshTy(_)) => "fresh type".into(), ty::Infer(ty::FreshTy(_)) => "fresh type".into(),
ty::Infer(ty::FreshIntTy(_)) => "fresh integral type".into(), ty::Infer(ty::FreshIntTy(_)) => "fresh integral type".into(),

View file

@ -122,7 +122,7 @@ pub fn simplify_type<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>,
ty::Foreign(def_id) => { ty::Foreign(def_id) => {
Some(ForeignSimplifiedType(def_id)) Some(ForeignSimplifiedType(def_id))
} }
ty::Bound(..) | ty::Infer(_) | ty::Error => None, ty::Placeholder(..) | ty::Bound(..) | ty::Infer(_) | ty::Error => None,
} }
} }

View file

@ -74,6 +74,7 @@ impl FlagComputation {
&ty::Uint(_) | &ty::Uint(_) |
&ty::Never | &ty::Never |
&ty::Str | &ty::Str |
&ty::Placeholder(..) |
&ty::Foreign(..) => { &ty::Foreign(..) => {
} }

View file

@ -515,6 +515,7 @@ pub fn characteristic_def_id_of_type(ty: Ty<'_>) -> Option<DefId> {
ty::Str | ty::Str |
ty::FnPtr(_) | ty::FnPtr(_) |
ty::Projection(_) | ty::Projection(_) |
ty::Placeholder(..) |
ty::UnnormalizedProjection(..) | ty::UnnormalizedProjection(..) |
ty::Param(_) | ty::Param(_) |
ty::Opaque(..) | ty::Opaque(..) |

View file

@ -1159,6 +1159,7 @@ impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> {
} }
ty::Bound(..) | ty::Bound(..) |
ty::Placeholder(..) |
ty::UnnormalizedProjection(..) | ty::UnnormalizedProjection(..) |
ty::GeneratorWitness(..) | ty::GeneratorWitness(..) |
ty::Infer(_) => { ty::Infer(_) => {
@ -1743,7 +1744,8 @@ impl<'a, 'tcx, C> TyLayoutMethods<'tcx, C> for Ty<'tcx>
} }
ty::Projection(_) | ty::UnnormalizedProjection(..) | ty::Bound(..) | 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) bug!("TyLayout::field_type: unexpected type `{}`", this.ty)
} }
}) })

View file

@ -2445,6 +2445,7 @@ impl<'a, 'gcx, 'tcx> AdtDef {
} }
} }
Placeholder(..) |
Bound(..) | Bound(..) |
Infer(..) => { Infer(..) => {
bug!("unexpected type `{:?}` in sized_constraint_for_ty", bug!("unexpected type `{:?}` in sized_constraint_for_ty",

View file

@ -155,6 +155,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
ty::FnDef(..) | // OutlivesFunction (*) ty::FnDef(..) | // OutlivesFunction (*)
ty::FnPtr(_) | // OutlivesFunction (*) ty::FnPtr(_) | // OutlivesFunction (*)
ty::Dynamic(..) | // OutlivesObject, OutlivesFragment (*) ty::Dynamic(..) | // OutlivesObject, OutlivesFragment (*)
ty::Placeholder(..) |
ty::Bound(..) | ty::Bound(..) |
ty::Error => { ty::Error => {
// (*) Bare functions and traits are both binders. In the // (*) Bare functions and traits are both binders. In the

View file

@ -746,6 +746,7 @@ impl<'tcx> TypeFoldable<'tcx> for Ty<'tcx> {
ty::Infer(_) | ty::Infer(_) |
ty::Param(..) | ty::Param(..) |
ty::Bound(..) | ty::Bound(..) |
ty::Placeholder(..) |
ty::Never | ty::Never |
ty::Foreign(..) => return self ty::Foreign(..) => return self
}; };
@ -792,6 +793,7 @@ impl<'tcx> TypeFoldable<'tcx> for Ty<'tcx> {
ty::Error | ty::Error |
ty::Infer(_) | ty::Infer(_) |
ty::Bound(..) | ty::Bound(..) |
ty::Placeholder(..) |
ty::Param(..) | ty::Param(..) |
ty::Never | ty::Never |
ty::Foreign(..) => false, ty::Foreign(..) => false,

View file

@ -203,6 +203,9 @@ pub enum TyKind<'tcx> {
/// Bound type variable, used only when preparing a trait query. /// Bound type variable, used only when preparing a trait query.
Bound(BoundTy), Bound(BoundTy),
/// A placeholder type - universally quantified higher-ranked type.
Placeholder(ty::PlaceholderType),
/// A type variable used during type checking. /// A type variable used during type checking.
Infer(InferTy), Infer(InferTy),
@ -1890,6 +1893,7 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> {
Foreign(..) | Foreign(..) |
Param(_) | Param(_) |
Bound(..) | Bound(..) |
Placeholder(..) |
Infer(_) | Infer(_) |
Error => {} Error => {}
} }
@ -1954,6 +1958,7 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> {
ty::Infer(ty::TyVar(_)) => false, ty::Infer(ty::TyVar(_)) => false,
ty::Bound(_) | ty::Bound(_) |
ty::Placeholder(..) |
ty::Infer(ty::FreshTy(_)) | ty::Infer(ty::FreshTy(_)) |
ty::Infer(ty::FreshIntTy(_)) | ty::Infer(ty::FreshIntTy(_)) |
ty::Infer(ty::FreshFloatTy(_)) => ty::Infer(ty::FreshFloatTy(_)) =>

View file

@ -952,7 +952,7 @@ fn needs_drop_raw<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
// Can refer to a type which may drop. // Can refer to a type which may drop.
// FIXME(eddyb) check this against a ParamEnv. // FIXME(eddyb) check this against a ParamEnv.
ty::Dynamic(..) | ty::Projection(..) | ty::Param(_) | ty::Bound(..) | 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"), ty::UnnormalizedProjection(..) => bug!("only used with chalk-engine"),

View file

@ -82,7 +82,7 @@ fn push_subtypes<'tcx>(stack: &mut TypeWalkerStack<'tcx>, parent_ty: Ty<'tcx>) {
match parent_ty.sty { match parent_ty.sty {
ty::Bool | ty::Char | ty::Int(_) | ty::Uint(_) | ty::Float(_) | ty::Bool | ty::Char | ty::Int(_) | ty::Uint(_) | ty::Float(_) |
ty::Str | ty::Infer(_) | ty::Param(_) | ty::Never | ty::Error | ty::Str | ty::Infer(_) | ty::Param(_) | ty::Never | ty::Error |
ty::Bound(..) | ty::Foreign(..) => { ty::Placeholder(..) | ty::Bound(..) | ty::Foreign(..) => {
} }
ty::Array(ty, len) => { ty::Array(ty, len) => {
push_const(stack, len); push_const(stack, len);

View file

@ -259,6 +259,7 @@ impl<'a, 'gcx, 'tcx> WfPredicates<'a, 'gcx, 'tcx> {
ty::Never | ty::Never |
ty::Param(_) | ty::Param(_) |
ty::Bound(..) | ty::Bound(..) |
ty::Placeholder(..) |
ty::Foreign(..) => { ty::Foreign(..) => {
// WfScalar, WfParameter, etc // WfScalar, WfParameter, etc
} }

View file

@ -18,7 +18,7 @@ use ty::{Bool, Char, Adt};
use ty::{Error, Str, Array, Slice, Float, FnDef, FnPtr}; use ty::{Error, Str, Array, Slice, Float, FnDef, FnPtr};
use ty::{Param, Bound, RawPtr, Ref, Never, Tuple}; use ty::{Param, Bound, RawPtr, Ref, Never, Tuple};
use ty::{Closure, Generator, GeneratorWitness, Foreign, Projection, Opaque}; 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 ty::{self, RegionVid, Ty, TyCtxt, TypeFoldable, GenericParamCount, GenericParamDefKind};
use util::nodemap::FxHashSet; use util::nodemap::FxHashSet;
@ -1144,6 +1144,9 @@ define_print! {
data.print(f, cx)?; data.print(f, cx)?;
write!(f, ")") write!(f, ")")
} }
Placeholder(placeholder) => {
write!(f, "Placeholder({:?})", placeholder)
}
Opaque(def_id, substs) => { Opaque(def_id, substs) => {
if cx.is_verbose { if cx.is_verbose {
return write!(f, "Opaque({:?}, {:?})", def_id, substs); return write!(f, "Opaque({:?}, {:?})", def_id, substs);

View file

@ -172,6 +172,7 @@ pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
} }
ty::Error | ty::Error |
ty::Infer(_) | ty::Infer(_) |
ty::Placeholder(..) |
ty::UnnormalizedProjection(..) | ty::UnnormalizedProjection(..) |
ty::Projection(..) | ty::Projection(..) |
ty::Bound(..) | ty::Bound(..) |

View file

@ -727,6 +727,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
ty::Closure(..) | ty::Closure(..) |
ty::Generator(..) | ty::Generator(..) |
ty::GeneratorWitness(..) | ty::GeneratorWitness(..) |
ty::Placeholder(..) |
ty::UnnormalizedProjection(..) | ty::UnnormalizedProjection(..) |
ty::Projection(..) | ty::Projection(..) |
ty::Opaque(..) | ty::Opaque(..) |

View file

@ -378,6 +378,7 @@ impl<'a, 'tcx> DefPathBasedNames<'a, 'tcx> {
ty::Error | ty::Error |
ty::Bound(..) | ty::Bound(..) |
ty::Infer(_) | ty::Infer(_) |
ty::Placeholder(..) |
ty::UnnormalizedProjection(..) | ty::UnnormalizedProjection(..) |
ty::Projection(..) | ty::Projection(..) |
ty::Param(_) | ty::Param(_) |

View file

@ -418,6 +418,7 @@ impl ChalkInferenceContext<'cx, 'gcx, 'tcx> {
} }
ty::GeneratorWitness(..) | ty::GeneratorWitness(..) |
ty::Placeholder(..) |
ty::UnnormalizedProjection(..) | ty::UnnormalizedProjection(..) |
ty::Infer(..) | ty::Infer(..) |
ty::Bound(..) | ty::Bound(..) |

View file

@ -274,7 +274,7 @@ fn dtorck_constraint_for_ty<'a, 'gcx, 'tcx>(
ty::UnnormalizedProjection(..) => bug!("only used with chalk-engine"), 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 // By the time this code runs, all type variables ought to
// be fully resolved. // be fully resolved.
Err(NoSolution) Err(NoSolution)

View file

@ -114,6 +114,7 @@ impl ClauseVisitor<'set, 'a, 'tcx> {
ty::Tuple(..) | ty::Tuple(..) |
ty::Never | ty::Never |
ty::Infer(..) | ty::Infer(..) |
ty::Placeholder(..) |
ty::Bound(..) => (), ty::Bound(..) => (),
ty::GeneratorWitness(..) | ty::GeneratorWitness(..) |

View file

@ -128,7 +128,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
ty::Opaque(def_id, substs) => Some(PointerKind::OfOpaque(def_id, substs)), ty::Opaque(def_id, substs) => Some(PointerKind::OfOpaque(def_id, substs)),
ty::Param(ref p) => Some(PointerKind::OfParam(p)), ty::Param(ref p) => Some(PointerKind::OfParam(p)),
// Insufficient type information. // Insufficient type information.
ty::Bound(..) | ty::Infer(_) => None, ty::Placeholder(..) | ty::Bound(..) | ty::Infer(_) => None,
ty::Bool | ty::Char | ty::Int(..) | ty::Uint(..) | ty::Bool | ty::Char | ty::Int(..) | ty::Uint(..) |
ty::Float(_) | ty::Array(..) | ty::GeneratorWitness(..) | ty::Float(_) | ty::Array(..) | ty::GeneratorWitness(..) |

View file

@ -336,6 +336,7 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> {
// types, where we use Error as the Self type // types, where we use Error as the Self type
} }
ty::Placeholder(..) |
ty::UnnormalizedProjection(..) | ty::UnnormalizedProjection(..) |
ty::GeneratorWitness(..) | ty::GeneratorWitness(..) |
ty::Bound(..) | ty::Bound(..) |

View file

@ -2744,6 +2744,7 @@ impl<'tcx> Clean<Type> for Ty<'tcx> {
ty::Closure(..) | ty::Generator(..) => Tuple(vec![]), // FIXME(pcwalton) ty::Closure(..) | ty::Generator(..) => Tuple(vec![]), // FIXME(pcwalton)
ty::Bound(..) => panic!("Bound"), ty::Bound(..) => panic!("Bound"),
ty::Placeholder(..) => panic!("Placeholder"),
ty::UnnormalizedProjection(..) => panic!("UnnormalizedProjection"), ty::UnnormalizedProjection(..) => panic!("UnnormalizedProjection"),
ty::GeneratorWitness(..) => panic!("GeneratorWitness"), ty::GeneratorWitness(..) => panic!("GeneratorWitness"),
ty::Infer(..) => panic!("Infer"), ty::Infer(..) => panic!("Infer"),