Combine identical alias arms
This commit is contained in:
parent
61adaf8187
commit
96cb18e864
29 changed files with 69 additions and 120 deletions
|
@ -349,7 +349,7 @@ impl<'tcx> SizeSkeleton<'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
ty::Alias(ty::Projection, _) | ty::Alias(ty::Opaque, ..) => {
|
||||
ty::Alias(..) => {
|
||||
let normalized = tcx.normalize_erasing_regions(param_env, ty);
|
||||
if ty == normalized {
|
||||
Err(err)
|
||||
|
@ -757,10 +757,9 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
ty::Alias(ty::Projection, _)
|
||||
ty::Alias(..)
|
||||
| ty::Bound(..)
|
||||
| ty::Placeholder(..)
|
||||
| ty::Alias(ty::Opaque, ..)
|
||||
| ty::Param(_)
|
||||
| ty::Infer(_)
|
||||
| ty::Error(_) => bug!("TyAndLayout::field: unexpected type `{}`", this.ty),
|
||||
|
|
|
@ -275,10 +275,9 @@ fn characteristic_def_id_of_type_cached<'a>(
|
|||
| ty::Uint(_)
|
||||
| ty::Str
|
||||
| ty::FnPtr(_)
|
||||
| ty::Alias(ty::Projection, _)
|
||||
| ty::Alias(..)
|
||||
| ty::Placeholder(..)
|
||||
| ty::Param(_)
|
||||
| ty::Alias(ty::Opaque, ..)
|
||||
| ty::Infer(_)
|
||||
| ty::Bound(..)
|
||||
| ty::Error(_)
|
||||
|
|
|
@ -651,12 +651,7 @@ impl<'tcx> TypeSuperFoldable<'tcx> for Ty<'tcx> {
|
|||
}
|
||||
ty::GeneratorWitness(types) => ty::GeneratorWitness(types.try_fold_with(folder)?),
|
||||
ty::Closure(did, substs) => ty::Closure(did, substs.try_fold_with(folder)?),
|
||||
ty::Alias(ty::Projection, data) => {
|
||||
ty::Alias(ty::Projection, data.try_fold_with(folder)?)
|
||||
}
|
||||
ty::Alias(ty::Opaque, ty::AliasTy { def_id, substs }) => {
|
||||
ty::Alias(ty::Opaque, ty::AliasTy { def_id, substs: substs.try_fold_with(folder)? })
|
||||
}
|
||||
ty::Alias(kind, data) => ty::Alias(kind, data.try_fold_with(folder)?),
|
||||
|
||||
ty::Bool
|
||||
| ty::Char
|
||||
|
@ -701,10 +696,7 @@ impl<'tcx> TypeSuperVisitable<'tcx> for Ty<'tcx> {
|
|||
ty::Generator(_did, ref substs, _) => substs.visit_with(visitor),
|
||||
ty::GeneratorWitness(ref types) => types.visit_with(visitor),
|
||||
ty::Closure(_did, ref substs) => substs.visit_with(visitor),
|
||||
ty::Alias(ty::Projection, ref data) => data.visit_with(visitor),
|
||||
ty::Alias(ty::Opaque, ty::AliasTy { def_id: _, ref substs }) => {
|
||||
substs.visit_with(visitor)
|
||||
}
|
||||
ty::Alias(_, ref data) => data.visit_with(visitor),
|
||||
|
||||
ty::Bool
|
||||
| ty::Char
|
||||
|
|
|
@ -2047,10 +2047,7 @@ impl<'tcx> Ty<'tcx> {
|
|||
ty::Adt(adt, _) if adt.is_enum() => adt.repr().discr_type().to_ty(tcx),
|
||||
ty::Generator(_, substs, _) => substs.as_generator().discr_ty(tcx),
|
||||
|
||||
ty::Param(_)
|
||||
| ty::Alias(ty::Projection, _)
|
||||
| ty::Alias(ty::Opaque, ..)
|
||||
| ty::Infer(ty::TyVar(_)) => {
|
||||
ty::Param(_) | ty::Alias(..) | ty::Infer(ty::TyVar(_)) => {
|
||||
let assoc_items = tcx.associated_item_def_ids(
|
||||
tcx.require_lang_item(hir::LangItem::DiscriminantKind, None),
|
||||
);
|
||||
|
@ -2130,7 +2127,7 @@ impl<'tcx> Ty<'tcx> {
|
|||
|
||||
// type parameters only have unit metadata if they're sized, so return true
|
||||
// to make sure we double check this during confirmation
|
||||
ty::Param(_) | ty::Alias(ty::Projection, _) | ty::Alias(ty::Opaque, ..) => (tcx.types.unit, true),
|
||||
ty::Param(_) | ty::Alias(..) => (tcx.types.unit, true),
|
||||
|
||||
ty::Infer(ty::TyVar(_))
|
||||
| ty::Bound(..)
|
||||
|
@ -2206,7 +2203,7 @@ impl<'tcx> Ty<'tcx> {
|
|||
|
||||
ty::Adt(def, _substs) => def.sized_constraint(tcx).0.is_empty(),
|
||||
|
||||
ty::Alias(ty::Projection, _) | ty::Param(_) | ty::Alias(ty::Opaque, ..) => false,
|
||||
ty::Alias(..) | ty::Param(_) => false,
|
||||
|
||||
ty::Infer(ty::TyVar(_)) => false,
|
||||
|
||||
|
@ -2262,9 +2259,12 @@ impl<'tcx> Ty<'tcx> {
|
|||
ty::Generator(..) | ty::GeneratorWitness(..) => false,
|
||||
|
||||
// Might be, but not "trivial" so just giving the safe answer.
|
||||
ty::Adt(..) | ty::Closure(..) | ty::Alias(ty::Opaque, ..) => false,
|
||||
ty::Adt(..) | ty::Closure(..) => false,
|
||||
|
||||
ty::Alias(ty::Projection, ..) | ty::Param(..) | ty::Infer(..) | ty::Error(..) => false,
|
||||
// Needs normalization or revealing to determine, so no is the safe answer.
|
||||
ty::Alias(..) => false,
|
||||
|
||||
ty::Param(..) | ty::Infer(..) | ty::Error(..) => false,
|
||||
|
||||
ty::Bound(..) | ty::Placeholder(..) => {
|
||||
bug!("`is_trivially_pure_clone_copy` applied to unexpected type: {:?}", self);
|
||||
|
|
|
@ -259,7 +259,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
|
||||
ty::Tuple(_) => break,
|
||||
|
||||
ty::Alias(ty::Projection, _) | ty::Alias(ty::Opaque, ..) => {
|
||||
ty::Alias(..) => {
|
||||
let normalized = normalize(ty);
|
||||
if ty == normalized {
|
||||
return ty;
|
||||
|
@ -332,8 +332,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
break;
|
||||
}
|
||||
}
|
||||
(ty::Alias(ty::Projection, _) | ty::Alias(ty::Opaque, ..), _)
|
||||
| (_, ty::Alias(ty::Projection, _) | ty::Alias(ty::Opaque, ..)) => {
|
||||
(ty::Alias(..), _) | (_, ty::Alias(..)) => {
|
||||
// If either side is a projection, attempt to
|
||||
// progress via normalization. (Should be safe to
|
||||
// apply to both sides as normalization is
|
||||
|
@ -938,10 +937,9 @@ impl<'tcx> Ty<'tcx> {
|
|||
| ty::Generator(..)
|
||||
| ty::GeneratorWitness(_)
|
||||
| ty::Infer(_)
|
||||
| ty::Alias(ty::Opaque, ..)
|
||||
| ty::Alias(..)
|
||||
| ty::Param(_)
|
||||
| ty::Placeholder(_)
|
||||
| ty::Alias(ty::Projection, _) => false,
|
||||
| ty::Placeholder(_) => false,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -978,10 +976,9 @@ impl<'tcx> Ty<'tcx> {
|
|||
| ty::Generator(..)
|
||||
| ty::GeneratorWitness(_)
|
||||
| ty::Infer(_)
|
||||
| ty::Alias(ty::Opaque, ..)
|
||||
| ty::Alias(..)
|
||||
| ty::Param(_)
|
||||
| ty::Placeholder(_)
|
||||
| ty::Alias(ty::Projection, _) => false,
|
||||
| ty::Placeholder(_) => false,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1101,12 +1098,9 @@ impl<'tcx> Ty<'tcx> {
|
|||
//
|
||||
// FIXME(ecstaticmorse): Maybe we should `bug` here? This should probably only be
|
||||
// called for known, fully-monomorphized types.
|
||||
ty::Alias(ty::Projection, _)
|
||||
| ty::Alias(ty::Opaque, ..)
|
||||
| ty::Param(_)
|
||||
| ty::Bound(..)
|
||||
| ty::Placeholder(_)
|
||||
| ty::Infer(_) => false,
|
||||
ty::Alias(..) | ty::Param(_) | ty::Bound(..) | ty::Placeholder(_) | ty::Infer(_) => {
|
||||
false
|
||||
}
|
||||
|
||||
ty::Foreign(_) | ty::GeneratorWitness(..) | ty::Error(_) => false,
|
||||
}
|
||||
|
@ -1237,11 +1231,10 @@ pub fn needs_drop_components<'tcx>(
|
|||
|
||||
// These require checking for `Copy` bounds or `Adt` destructors.
|
||||
ty::Adt(..)
|
||||
| ty::Alias(ty::Projection, ..)
|
||||
| ty::Alias(..)
|
||||
| ty::Param(_)
|
||||
| ty::Bound(..)
|
||||
| ty::Placeholder(..)
|
||||
| ty::Alias(ty::Opaque, ..)
|
||||
| ty::Infer(_)
|
||||
| ty::Closure(..)
|
||||
| ty::Generator(..) => Ok(smallvec![ty]),
|
||||
|
@ -1265,13 +1258,12 @@ pub fn is_trivially_const_drop<'tcx>(ty: Ty<'tcx>) -> bool {
|
|||
| ty::Never
|
||||
| ty::Foreign(_) => true,
|
||||
|
||||
ty::Alias(ty::Opaque, ..)
|
||||
ty::Alias(..)
|
||||
| ty::Dynamic(..)
|
||||
| ty::Error(_)
|
||||
| ty::Bound(..)
|
||||
| ty::Param(_)
|
||||
| ty::Placeholder(_)
|
||||
| ty::Alias(ty::Projection, _)
|
||||
| ty::Infer(_) => false,
|
||||
|
||||
// Not trivial because they have components, and instead of looking inside,
|
||||
|
|
|
@ -654,7 +654,7 @@ impl<'tcx> TypeVisitor<'tcx> for LateBoundRegionsCollector {
|
|||
// ignore the inputs to a projection, as they may not appear
|
||||
// in the normalized form
|
||||
if self.just_constrained {
|
||||
if let ty::Alias(ty::Projection, ..) | ty::Alias(ty::Opaque, ..) = t.kind() {
|
||||
if let ty::Alias(..) = t.kind() {
|
||||
return ControlFlow::CONTINUE;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -165,7 +165,7 @@ fn push_inner<'tcx>(stack: &mut TypeWalkerStack<'tcx>, parent: GenericArg<'tcx>)
|
|||
stack.push(ty.into());
|
||||
stack.push(lt.into());
|
||||
}
|
||||
ty::Alias(ty::Projection, data) => {
|
||||
ty::Alias(_, data) => {
|
||||
stack.extend(data.substs.iter().rev());
|
||||
}
|
||||
ty::Dynamic(obj, lt, _) => {
|
||||
|
@ -188,7 +188,6 @@ fn push_inner<'tcx>(stack: &mut TypeWalkerStack<'tcx>, parent: GenericArg<'tcx>)
|
|||
}));
|
||||
}
|
||||
ty::Adt(_, substs)
|
||||
| ty::Alias(ty::Opaque, ty::AliasTy { def_id: _, substs })
|
||||
| ty::Closure(_, substs)
|
||||
| ty::Generator(_, substs, _)
|
||||
| ty::FnDef(_, substs) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue