1
Fork 0

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

@ -142,12 +142,11 @@ pub(crate) fn const_to_valtree_inner<'tcx>(
| ty::Foreign(..)
| ty::Infer(ty::FreshIntTy(_))
| ty::Infer(ty::FreshFloatTy(_))
| ty::Alias(ty::Projection, ..)
// FIXME(oli-obk): we could look behind opaque types
| ty::Alias(..)
| ty::Param(_)
| ty::Bound(..)
| ty::Placeholder(..)
// FIXME(oli-obk): we could look behind opaque types
| ty::Alias(ty::Opaque, ..)
| ty::Infer(_)
// FIXME(oli-obk): we can probably encode closures just like structs
| ty::Closure(..)
@ -307,11 +306,10 @@ pub fn valtree_to_const_value<'tcx>(
| ty::Foreign(..)
| ty::Infer(ty::FreshIntTy(_))
| ty::Infer(ty::FreshFloatTy(_))
| ty::Alias(ty::Projection, ..)
| ty::Alias(..)
| ty::Param(_)
| ty::Bound(..)
| ty::Placeholder(..)
| ty::Alias(ty::Opaque, ..)
| ty::Infer(_)
| ty::Closure(..)
| ty::Generator(..)

View file

@ -82,11 +82,9 @@ pub(crate) fn eval_nullary_intrinsic<'tcx>(
ty::Adt(ref adt, _) => {
ConstValue::from_machine_usize(adt.variants().len() as u64, &tcx)
}
ty::Alias(ty::Projection, _)
| ty::Alias(ty::Opaque, ty::AliasTy { def_id: _, substs: _ })
| ty::Param(_)
| ty::Placeholder(_)
| ty::Infer(_) => throw_inval!(TooGeneric),
ty::Alias(..) | ty::Param(_) | ty::Placeholder(_) | ty::Infer(_) => {
throw_inval!(TooGeneric)
}
ty::Bound(_, _) => bug!("bound ty during ctfe"),
ty::Bool
| ty::Char

View file

@ -601,8 +601,7 @@ impl<'rt, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> ValidityVisitor<'rt, 'mir, '
| ty::Placeholder(..)
| ty::Bound(..)
| ty::Param(..)
| ty::Alias(ty::Opaque, ..)
| ty::Alias(ty::Projection, ..)
| ty::Alias(..)
| ty::GeneratorWitness(..) => bug!("Encountered invalid type {:?}", ty),
}
}

View file

@ -58,8 +58,7 @@ impl<'tcx> Printer<'tcx> for AbsolutePathPrinter<'tcx> {
// Types with identity (print the module path).
ty::Adt(ty::AdtDef(Interned(&ty::AdtDefData { did: def_id, .. }, _)), substs)
| ty::FnDef(def_id, substs)
| ty::Alias(ty::Opaque, ty::AliasTy { def_id, substs })
| ty::Alias(ty::Projection, ty::AliasTy { def_id, substs })
| ty::Alias(_, ty::AliasTy { def_id, substs })
| ty::Closure(def_id, substs)
| ty::Generator(def_id, substs, _) => self.print_def_path(def_id, substs),
ty::Foreign(def_id) => self.print_def_path(def_id, &[]),