diff options
| author | Niko Matsakis <niko@alum.mit.edu> | 2018-09-17 13:03:34 -0400 |
|---|---|---|
| committer | Niko Matsakis <niko@alum.mit.edu> | 2018-09-26 09:38:26 -0400 |
| commit | db0e62692eed43a5efb7024a69e36c6288fff859 (patch) | |
| tree | 770c805e26c1439f0d9777e1d1350d0e9ce3c3d9 /src | |
| parent | 9b63dcc7731e1023c525e795ba36472a3e4bd21b (diff) | |
| download | rust-db0e62692eed43a5efb7024a69e36c6288fff859.tar.gz rust-db0e62692eed43a5efb7024a69e36c6288fff859.zip | |
introduce a "comparison fn" instead of always use `==`
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustc/infer/outlives/verify.rs | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/src/librustc/infer/outlives/verify.rs b/src/librustc/infer/outlives/verify.rs index cd4f3c3e5dc..a4fd4d4b880 100644 --- a/src/librustc/infer/outlives/verify.rs +++ b/src/librustc/infer/outlives/verify.rs @@ -153,7 +153,10 @@ impl<'cx, 'gcx, 'tcx> VerifyBoundCx<'cx, 'gcx, 'tcx> { // like `<T as Foo<'a>>::Item`. let generic_ty = generic.to_ty(tcx); let c_b = self.param_env.caller_bounds; - let mut param_bounds = self.collect_outlives_from_predicate_list(generic_ty, c_b); + let mut param_bounds = self.collect_outlives_from_predicate_list( + |ty| ty == generic_ty, + c_b, + ); // Next, collect regions we scraped from the well-formedness // constraints in the fn signature. To do that, we walk the list @@ -241,7 +244,7 @@ impl<'cx, 'gcx, 'tcx> VerifyBoundCx<'cx, 'gcx, 'tcx> { let identity_substs = Substs::identity_for_item(tcx, assoc_item_def_id); let identity_proj = tcx.mk_projection(assoc_item_def_id, identity_substs); self.collect_outlives_from_predicate_list( - identity_proj, + |ty| ty == identity_proj, traits::elaborate_predicates(tcx, trait_predicates.predicates), ) } @@ -252,20 +255,16 @@ impl<'cx, 'gcx, 'tcx> VerifyBoundCx<'cx, 'gcx, 'tcx> { /// when comparing `ty` for equality, so `ty` must be something /// that does not involve inference variables and where you /// otherwise want a precise match. - fn collect_outlives_from_predicate_list<I, P>( + fn collect_outlives_from_predicate_list( &self, - ty: Ty<'tcx>, - predicates: I, - ) -> Vec<ty::Region<'tcx>> - where - I: IntoIterator<Item = P>, - P: AsRef<ty::Predicate<'tcx>>, - { + compare_ty: impl Fn(Ty<'tcx>) -> bool, + predicates: impl IntoIterator<Item = impl AsRef<ty::Predicate<'tcx>>>, + ) -> Vec<ty::Region<'tcx>> { predicates .into_iter() .filter_map(|p| p.as_ref().to_opt_type_outlives()) .filter_map(|p| p.no_late_bound_regions()) - .filter(|p| p.0 == ty) + .filter(|p| compare_ty(p.0)) .map(|p| p.1) .collect() } |
