about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorNiko Matsakis <niko@alum.mit.edu>2019-06-12 11:16:59 -0400
committerNiko Matsakis <niko@alum.mit.edu>2019-07-02 12:15:21 -0400
commit4de99600b0ca8dafd5310f900def87bbcbf0aae6 (patch)
tree6c24c1bdb43372637d6da1c6905107a4e41104e5 /src
parent2057136326bfac61b29b7fac87289728f105ffe3 (diff)
downloadrust-4de99600b0ca8dafd5310f900def87bbcbf0aae6.tar.gz
rust-4de99600b0ca8dafd5310f900def87bbcbf0aae6.zip
add a FIXME related to the non-free-region case
I don't think it would actually be harmful to just ignore such cases
but I'm inclined not to take chances.
Diffstat (limited to 'src')
-rw-r--r--src/librustc_mir/borrow_check/nll/region_infer/mod.rs19
-rw-r--r--src/test/ui/impl-trait/multiple-lifetimes/ordinary-bounds-pick-original-elided.rs27
2 files changed, 43 insertions, 3 deletions
diff --git a/src/librustc_mir/borrow_check/nll/region_infer/mod.rs b/src/librustc_mir/borrow_check/nll/region_infer/mod.rs
index 39818de2310..822c7b76b8f 100644
--- a/src/librustc_mir/borrow_check/nll/region_infer/mod.rs
+++ b/src/librustc_mir/borrow_check/nll/region_infer/mod.rs
@@ -550,7 +550,11 @@ impl<'tcx> RegionInferenceContext<'tcx> {
         // Now take pick constraints into account
         let pick_constraints = self.pick_constraints.clone();
         for p_c_i in pick_constraints.indices(scc_a) {
-            self.apply_pick_constraint(scc_a, pick_constraints.option_regions(p_c_i));
+            self.apply_pick_constraint(
+                scc_a,
+                pick_constraints[p_c_i].opaque_type_def_id,
+                pick_constraints.option_regions(p_c_i),
+            );
         }
 
         debug!(
@@ -574,6 +578,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
     fn apply_pick_constraint(
         &mut self,
         scc: ConstraintSccIndex,
+        opaque_type_def_id: DefId,
         option_regions: &[ty::RegionVid],
     ) -> bool {
         debug!("apply_pick_constraint(scc={:?}, option_regions={:#?})", scc, option_regions,);
@@ -581,8 +586,16 @@ impl<'tcx> RegionInferenceContext<'tcx> {
         if let Some(uh_oh) =
             option_regions.iter().find(|&&r| !self.universal_regions.is_universal_region(r))
         {
-            debug!("apply_pick_constraint: option region `{:?}` is not a universal region", uh_oh);
-            return false;
+            // FIXME(#61773): This case can only occur with
+            // `impl_trait_in_bindings`, I believe, and we are just
+            // opting not to handle it for now. See #61773 for
+            // details.
+            bug!(
+                "pick constraint for `{:?}` has an option region `{:?}` \
+                 that is not a universal region",
+                opaque_type_def_id,
+                uh_oh,
+            );
         }
 
         // Create a mutable vector of the options. We'll try to winnow
diff --git a/src/test/ui/impl-trait/multiple-lifetimes/ordinary-bounds-pick-original-elided.rs b/src/test/ui/impl-trait/multiple-lifetimes/ordinary-bounds-pick-original-elided.rs
new file mode 100644
index 00000000000..23981d92562
--- /dev/null
+++ b/src/test/ui/impl-trait/multiple-lifetimes/ordinary-bounds-pick-original-elided.rs
@@ -0,0 +1,27 @@
+// edition:2018
+// run-pass
+// revisions: migrate mir
+//[mir]compile-flags: -Z borrowck=mir
+
+trait Trait<'a, 'b> { }
+impl<T> Trait<'_, '_> for T { }
+
+// Test case where we have elision in the impl trait and we have to
+// pick the right region.
+
+// Ultimately `Trait<'x, 'static>`.
+fn upper_bounds1(a: &u8) -> impl Trait<'_, 'static> {
+    (a, a)
+}
+
+// Ultimately `Trait<'x, 'x>`, so not really multiple bounds.
+fn upper_bounds2(a: &u8) -> impl Trait<'_, '_> {
+    (a, a)
+}
+
+// Kind of a weird annoying case.
+fn upper_bounds3<'b>(a: &u8) -> impl Trait<'_, 'b> {
+    (a, a)
+}
+
+fn main() { }