Skip to content

Commit 4de9960

Browse files
committed
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.
1 parent 2057136 commit 4de9960

File tree

2 files changed

+43
-3
lines changed

2 files changed

+43
-3
lines changed

src/librustc_mir/borrow_check/nll/region_infer/mod.rs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,11 @@ impl<'tcx> RegionInferenceContext<'tcx> {
550550
// Now take pick constraints into account
551551
let pick_constraints = self.pick_constraints.clone();
552552
for p_c_i in pick_constraints.indices(scc_a) {
553-
self.apply_pick_constraint(scc_a, pick_constraints.option_regions(p_c_i));
553+
self.apply_pick_constraint(
554+
scc_a,
555+
pick_constraints[p_c_i].opaque_type_def_id,
556+
pick_constraints.option_regions(p_c_i),
557+
);
554558
}
555559

556560
debug!(
@@ -574,15 +578,24 @@ impl<'tcx> RegionInferenceContext<'tcx> {
574578
fn apply_pick_constraint(
575579
&mut self,
576580
scc: ConstraintSccIndex,
581+
opaque_type_def_id: DefId,
577582
option_regions: &[ty::RegionVid],
578583
) -> bool {
579584
debug!("apply_pick_constraint(scc={:?}, option_regions={:#?})", scc, option_regions,);
580585

581586
if let Some(uh_oh) =
582587
option_regions.iter().find(|&&r| !self.universal_regions.is_universal_region(r))
583588
{
584-
debug!("apply_pick_constraint: option region `{:?}` is not a universal region", uh_oh);
585-
return false;
589+
// FIXME(#61773): This case can only occur with
590+
// `impl_trait_in_bindings`, I believe, and we are just
591+
// opting not to handle it for now. See #61773 for
592+
// details.
593+
bug!(
594+
"pick constraint for `{:?}` has an option region `{:?}` \
595+
that is not a universal region",
596+
opaque_type_def_id,
597+
uh_oh,
598+
);
586599
}
587600

588601
// Create a mutable vector of the options. We'll try to winnow
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// edition:2018
2+
// run-pass
3+
// revisions: migrate mir
4+
//[mir]compile-flags: -Z borrowck=mir
5+
6+
trait Trait<'a, 'b> { }
7+
impl<T> Trait<'_, '_> for T { }
8+
9+
// Test case where we have elision in the impl trait and we have to
10+
// pick the right region.
11+
12+
// Ultimately `Trait<'x, 'static>`.
13+
fn upper_bounds1(a: &u8) -> impl Trait<'_, 'static> {
14+
(a, a)
15+
}
16+
17+
// Ultimately `Trait<'x, 'x>`, so not really multiple bounds.
18+
fn upper_bounds2(a: &u8) -> impl Trait<'_, '_> {
19+
(a, a)
20+
}
21+
22+
// Kind of a weird annoying case.
23+
fn upper_bounds3<'b>(a: &u8) -> impl Trait<'_, 'b> {
24+
(a, a)
25+
}
26+
27+
fn main() { }

0 commit comments

Comments
 (0)