From d98384595f105179fef37960f37a636e562d6425 Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Wed, 14 Jul 2021 17:12:34 -0300 Subject: [PATCH] Removing unhandled region constraint error that is only for impl_trait_in_bindings --- .../src/borrow_check/member_constraints.rs | 5 --- .../src/borrow_check/region_infer/mod.rs | 34 +++---------------- 2 files changed, 5 insertions(+), 34 deletions(-) diff --git a/compiler/rustc_mir/src/borrow_check/member_constraints.rs b/compiler/rustc_mir/src/borrow_check/member_constraints.rs index baaf6f27ee8..2e2578df011 100644 --- a/compiler/rustc_mir/src/borrow_check/member_constraints.rs +++ b/compiler/rustc_mir/src/borrow_check/member_constraints.rs @@ -1,5 +1,4 @@ use rustc_data_structures::fx::FxHashMap; -use rustc_hir::def_id::DefId; use rustc_index::vec::IndexVec; use rustc_middle::infer::MemberConstraint; use rustc_middle::ty::{self, Ty}; @@ -32,9 +31,6 @@ where crate struct NllMemberConstraint<'tcx> { next_constraint: Option, - /// The opaque type whose hidden type is being inferred. (Used in error reporting.) - crate opaque_type_def_id: DefId, - /// The span where the hidden type was instantiated. crate definition_span: Span, @@ -91,7 +87,6 @@ impl<'tcx> MemberConstraintSet<'tcx, ty::RegionVid> { let constraint_index = self.constraints.push(NllMemberConstraint { next_constraint, member_region_vid, - opaque_type_def_id: m_c.opaque_type_def_id, definition_span: m_c.definition_span, hidden_ty: m_c.hidden_ty, start_index, diff --git a/compiler/rustc_mir/src/borrow_check/region_infer/mod.rs b/compiler/rustc_mir/src/borrow_check/region_infer/mod.rs index 0306782bfe4..c40e6bf1ec3 100644 --- a/compiler/rustc_mir/src/borrow_check/region_infer/mod.rs +++ b/compiler/rustc_mir/src/borrow_check/region_infer/mod.rs @@ -551,7 +551,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { polonius_output: Option>, ) -> (Option>, RegionErrors<'tcx>) { let mir_def_id = body.source.def_id(); - self.propagate_constraints(body, infcx.tcx); + self.propagate_constraints(body); let mut errors_buffer = RegionErrors::new(); @@ -599,7 +599,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { /// for each region variable until all the constraints are /// satisfied. Note that some values may grow **too** large to be /// feasible, but we check this later. - fn propagate_constraints(&mut self, _body: &Body<'tcx>, tcx: TyCtxt<'tcx>) { + fn propagate_constraints(&mut self, _body: &Body<'tcx>) { debug!("propagate_constraints()"); debug!("propagate_constraints: constraints={:#?}", { @@ -617,7 +617,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { // own. let constraint_sccs = self.constraint_sccs.clone(); for scc in constraint_sccs.all_sccs() { - self.compute_value_for_scc(scc, tcx); + self.compute_value_for_scc(scc); } // Sort the applied member constraints so we can binary search @@ -629,7 +629,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { /// computed, by unioning the values of its successors. /// Assumes that all successors have been computed already /// (which is assured by iterating over SCCs in dependency order). - fn compute_value_for_scc(&mut self, scc_a: ConstraintSccIndex, tcx: TyCtxt<'tcx>) { + fn compute_value_for_scc(&mut self, scc_a: ConstraintSccIndex) { let constraint_sccs = self.constraint_sccs.clone(); // Walk each SCC `B` such that `A: B`... @@ -652,12 +652,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { // Now take member constraints into account. let member_constraints = self.member_constraints.clone(); for m_c_i in member_constraints.indices(scc_a) { - self.apply_member_constraint( - tcx, - scc_a, - m_c_i, - member_constraints.choice_regions(m_c_i), - ); + self.apply_member_constraint(scc_a, m_c_i, member_constraints.choice_regions(m_c_i)); } debug!( @@ -680,31 +675,12 @@ impl<'tcx> RegionInferenceContext<'tcx> { /// If we make any changes, returns true, else false. fn apply_member_constraint( &mut self, - tcx: TyCtxt<'tcx>, scc: ConstraintSccIndex, member_constraint_index: NllMemberConstraintIndex, choice_regions: &[ty::RegionVid], ) -> bool { debug!("apply_member_constraint(scc={:?}, choice_regions={:#?})", scc, choice_regions,); - if let Some(uh_oh) = - choice_regions.iter().find(|&&r| !self.universal_regions.is_universal_region(r)) - { - // 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. - tcx.sess.delay_span_bug( - self.member_constraints[member_constraint_index].definition_span, - &format!( - "member constraint for `{:?}` has an option region `{:?}` \ - that is not a universal region", - self.member_constraints[member_constraint_index].opaque_type_def_id, uh_oh, - ), - ); - return false; - } - // Create a mutable vector of the options. We'll try to winnow // them down. let mut choice_regions: Vec = choice_regions.to_vec();