|
1 | 1 | use crate::mir::Mutability;
|
2 | 2 | use crate::ty::subst::GenericArgKind;
|
3 |
| -use crate::ty::{self, Ty, TyCtxt, TypeVisitableExt}; |
| 3 | +use crate::ty::{self, SubstsRef, Ty, TyCtxt, TypeVisitableExt}; |
4 | 4 | use rustc_hir::def_id::DefId;
|
5 | 5 | use std::fmt::Debug;
|
6 | 6 | use std::hash::Hash;
|
@@ -188,6 +188,15 @@ pub struct DeepRejectCtxt {
|
188 | 188 | }
|
189 | 189 |
|
190 | 190 | impl DeepRejectCtxt {
|
| 191 | + pub fn substs_refs_may_unify<'tcx>( |
| 192 | + self, |
| 193 | + obligation_substs: SubstsRef<'tcx>, |
| 194 | + impl_substs: SubstsRef<'tcx>, |
| 195 | + ) -> bool { |
| 196 | + iter::zip(obligation_substs, impl_substs) |
| 197 | + .all(|(obl, imp)| self.generic_args_may_unify(obl, imp)) |
| 198 | + } |
| 199 | + |
191 | 200 | pub fn generic_args_may_unify<'tcx>(
|
192 | 201 | self,
|
193 | 202 | obligation_arg: ty::GenericArg<'tcx>,
|
@@ -258,9 +267,7 @@ impl DeepRejectCtxt {
|
258 | 267 | },
|
259 | 268 | ty::Adt(obl_def, obl_substs) => match k {
|
260 | 269 | &ty::Adt(impl_def, impl_substs) => {
|
261 |
| - obl_def == impl_def |
262 |
| - && iter::zip(obl_substs, impl_substs) |
263 |
| - .all(|(obl, imp)| self.generic_args_may_unify(obl, imp)) |
| 270 | + obl_def == impl_def && self.substs_refs_may_unify(obl_substs, impl_substs) |
264 | 271 | }
|
265 | 272 | _ => false,
|
266 | 273 | },
|
|
0 commit comments