Skip to content

Commit ef83742

Browse files
committed
Delay bug for non-universal regions in member constraints
1 parent 6f9a8a7 commit ef83742

File tree

1 file changed

+19
-10
lines changed
  • compiler/rustc_mir/src/borrow_check/region_infer

1 file changed

+19
-10
lines changed

compiler/rustc_mir/src/borrow_check/region_infer/mod.rs

+19-10
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
551551
mir_def_id: DefId,
552552
polonius_output: Option<Rc<PoloniusOutput>>,
553553
) -> (Option<ClosureRegionRequirements<'tcx>>, RegionErrors<'tcx>) {
554-
self.propagate_constraints(body);
554+
self.propagate_constraints(body, infcx.tcx);
555555

556556
let mut errors_buffer = RegionErrors::new();
557557

@@ -599,7 +599,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
599599
/// for each region variable until all the constraints are
600600
/// satisfied. Note that some values may grow **too** large to be
601601
/// feasible, but we check this later.
602-
fn propagate_constraints(&mut self, _body: &Body<'tcx>) {
602+
fn propagate_constraints(&mut self, _body: &Body<'tcx>, tcx: TyCtxt<'tcx>) {
603603
debug!("propagate_constraints()");
604604

605605
debug!("propagate_constraints: constraints={:#?}", {
@@ -617,7 +617,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
617617
// own.
618618
let constraint_sccs = self.constraint_sccs.clone();
619619
for scc in constraint_sccs.all_sccs() {
620-
self.compute_value_for_scc(scc);
620+
self.compute_value_for_scc(scc, tcx);
621621
}
622622

623623
// Sort the applied member constraints so we can binary search
@@ -629,7 +629,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
629629
/// computed, by unioning the values of its successors.
630630
/// Assumes that all successors have been computed already
631631
/// (which is assured by iterating over SCCs in dependency order).
632-
fn compute_value_for_scc(&mut self, scc_a: ConstraintSccIndex) {
632+
fn compute_value_for_scc(&mut self, scc_a: ConstraintSccIndex, tcx: TyCtxt<'tcx>) {
633633
let constraint_sccs = self.constraint_sccs.clone();
634634

635635
// Walk each SCC `B` such that `A: B`...
@@ -652,7 +652,12 @@ impl<'tcx> RegionInferenceContext<'tcx> {
652652
// Now take member constraints into account.
653653
let member_constraints = self.member_constraints.clone();
654654
for m_c_i in member_constraints.indices(scc_a) {
655-
self.apply_member_constraint(scc_a, m_c_i, member_constraints.choice_regions(m_c_i));
655+
self.apply_member_constraint(
656+
tcx,
657+
scc_a,
658+
m_c_i,
659+
member_constraints.choice_regions(m_c_i),
660+
);
656661
}
657662

658663
debug!(
@@ -675,6 +680,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
675680
/// If we make any changes, returns true, else false.
676681
fn apply_member_constraint(
677682
&mut self,
683+
tcx: TyCtxt<'tcx>,
678684
scc: ConstraintSccIndex,
679685
member_constraint_index: NllMemberConstraintIndex,
680686
choice_regions: &[ty::RegionVid],
@@ -688,12 +694,15 @@ impl<'tcx> RegionInferenceContext<'tcx> {
688694
// `impl_trait_in_bindings`, I believe, and we are just
689695
// opting not to handle it for now. See #61773 for
690696
// details.
691-
bug!(
692-
"member constraint for `{:?}` has an option region `{:?}` \
693-
that is not a universal region",
694-
self.member_constraints[member_constraint_index].opaque_type_def_id,
695-
uh_oh,
697+
tcx.sess.delay_span_bug(
698+
self.member_constraints[member_constraint_index].definition_span,
699+
&format!(
700+
"member constraint for `{:?}` has an option region `{:?}` \
701+
that is not a universal region",
702+
self.member_constraints[member_constraint_index].opaque_type_def_id, uh_oh,
703+
),
696704
);
705+
return false;
697706
}
698707

699708
// Create a mutable vector of the options. We'll try to winnow

0 commit comments

Comments
 (0)