Inline and remove generic_args_may_unify.

It has a single callsite.
This commit is contained in:
Nicholas Nethercote 2023-03-07 16:02:01 +11:00
parent 47225e8700
commit 9fa69473fd

View File

@ -193,26 +193,19 @@ impl DeepRejectCtxt {
obligation_substs: SubstsRef<'tcx>, obligation_substs: SubstsRef<'tcx>,
impl_substs: SubstsRef<'tcx>, impl_substs: SubstsRef<'tcx>,
) -> bool { ) -> bool {
iter::zip(obligation_substs, impl_substs) iter::zip(obligation_substs, impl_substs).all(|(obl, imp)| {
.all(|(obl, imp)| self.generic_args_may_unify(obl, imp)) match (obl.unpack(), imp.unpack()) {
} // We don't fast reject based on regions for now.
(GenericArgKind::Lifetime(_), GenericArgKind::Lifetime(_)) => true,
pub fn generic_args_may_unify<'tcx>( (GenericArgKind::Type(obl), GenericArgKind::Type(imp)) => {
self, self.types_may_unify(obl, imp)
obligation_arg: ty::GenericArg<'tcx>, }
impl_arg: ty::GenericArg<'tcx>, (GenericArgKind::Const(obl), GenericArgKind::Const(imp)) => {
) -> bool { self.consts_may_unify(obl, imp)
match (obligation_arg.unpack(), impl_arg.unpack()) { }
// We don't fast reject based on regions for now. _ => bug!("kind mismatch: {obl} {imp}"),
(GenericArgKind::Lifetime(_), GenericArgKind::Lifetime(_)) => true,
(GenericArgKind::Type(obl), GenericArgKind::Type(imp)) => {
self.types_may_unify(obl, imp)
} }
(GenericArgKind::Const(obl), GenericArgKind::Const(imp)) => { })
self.consts_may_unify(obl, imp)
}
_ => bug!("kind mismatch: {obligation_arg} {impl_arg}"),
}
} }
pub fn types_may_unify<'tcx>(self, obligation_ty: Ty<'tcx>, impl_ty: Ty<'tcx>) -> bool { pub fn types_may_unify<'tcx>(self, obligation_ty: Ty<'tcx>, impl_ty: Ty<'tcx>) -> bool {