about summary refs log tree commit diff
diff options
context:
space:
mode:
authorOli Scherer <git-spam-no-reply9815368754983@oli-obk.de>2021-09-24 17:32:58 +0000
committerOli Scherer <git-spam-no-reply9815368754983@oli-obk.de>2021-10-15 17:50:33 +0000
commit07b8bbb1f6ecbdcd30f6fb0fdf9b29e169a19451 (patch)
treec617ba47b3791d43da190703d68a4a64c2dca891
parent6f71cab3b0d5c1fb88f5850642bb036677e3484e (diff)
downloadrust-07b8bbb1f6ecbdcd30f6fb0fdf9b29e169a19451.tar.gz
rust-07b8bbb1f6ecbdcd30f6fb0fdf9b29e169a19451.zip
Equality of regions is not just on identity, but if both regions outlive each other
-rw-r--r--compiler/rustc_infer/src/infer/lexical_region_resolve/mod.rs10
1 files changed, 9 insertions, 1 deletions
diff --git a/compiler/rustc_infer/src/infer/lexical_region_resolve/mod.rs b/compiler/rustc_infer/src/infer/lexical_region_resolve/mod.rs
index 2fa69083b8d..2f545ef66ac 100644
--- a/compiler/rustc_infer/src/infer/lexical_region_resolve/mod.rs
+++ b/compiler/rustc_infer/src/infer/lexical_region_resolve/mod.rs
@@ -637,7 +637,15 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
                 .choice_regions
                 .iter()
                 .map(|&choice_region| var_data.normalize(self.tcx(), choice_region));
-            if !choice_regions.clone().any(|choice_region| member_region == choice_region) {
+            let fr = &self.region_rels.free_regions;
+            let sub = |a, b| {
+                fr.is_free_or_static(a)
+                    && fr.is_free_or_static(b)
+                    && fr.sub_free_regions(self.tcx(), a, b)
+            };
+            if !choice_regions.clone().any(|choice_region| {
+                sub(member_region, choice_region) && sub(choice_region, member_region)
+            }) {
                 let span = self.tcx().def_span(member_constraint.opaque_type_def_id);
                 errors.push(RegionResolutionError::MemberConstraintFailure {
                     span,