Combine identical alias arms

This commit is contained in:
Michael Goulet
2022-11-27 17:52:17 +00:00
parent 61adaf8187
commit 96cb18e864
29 changed files with 69 additions and 120 deletions

View File

@@ -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,