@@ -31,11 +31,9 @@ use crate::diagnostics::{RegionErrorKind, RegionErrors, UniverseInfo};
3131use crate :: member_constraints:: { MemberConstraintSet , NllMemberConstraintIndex } ;
3232use crate :: nll:: PoloniusOutput ;
3333use crate :: region_infer:: reverse_sccs:: ReverseSccGraph ;
34- use crate :: region_infer:: values:: {
35- LivenessValues , PlaceholderIndices , RegionElement , RegionValues , ToElementIndex ,
36- } ;
37- use crate :: type_check:: Locations ;
34+ use crate :: region_infer:: values:: { LivenessValues , RegionElement , RegionValues , ToElementIndex } ;
3835use crate :: type_check:: free_region_relations:: UniversalRegionRelations ;
36+ use crate :: type_check:: { Locations , MirTypeckRegionConstraints } ;
3937use crate :: universal_regions:: UniversalRegions ;
4038
4139mod dump_mir;
@@ -395,22 +393,36 @@ impl<'tcx> RegionInferenceContext<'tcx> {
395393 pub ( crate ) fn new (
396394 infcx : & BorrowckInferCtxt < ' tcx > ,
397395 var_infos : VarInfos ,
398- placeholder_indices : PlaceholderIndices ,
396+ constraints : MirTypeckRegionConstraints < ' tcx > ,
399397 universal_region_relations : Frozen < UniversalRegionRelations < ' tcx > > ,
400- mut outlives_constraints : OutlivesConstraintSet < ' tcx > ,
401- member_constraints_in : MemberConstraintSet < ' tcx , RegionVid > ,
402- universe_causes : FxIndexMap < ty:: UniverseIndex , UniverseInfo < ' tcx > > ,
403- type_tests : Vec < TypeTest < ' tcx > > ,
404- liveness_constraints : LivenessValues ,
405398 elements : Rc < DenseLocationMap > ,
406399 ) -> Self {
407400 let universal_regions = & universal_region_relations. universal_regions ;
401+ let MirTypeckRegionConstraints {
402+ placeholder_indices,
403+ placeholder_index_to_region : _,
404+ liveness_constraints,
405+ mut outlives_constraints,
406+ mut member_constraints,
407+ universe_causes,
408+ type_tests,
409+ } = constraints;
408410
409411 debug ! ( "universal_regions: {:#?}" , universal_region_relations. universal_regions) ;
410412 debug ! ( "outlives constraints: {:#?}" , outlives_constraints) ;
411413 debug ! ( "placeholder_indices: {:#?}" , placeholder_indices) ;
412414 debug ! ( "type tests: {:#?}" , type_tests) ;
413415
416+ if let Some ( guar) = universal_region_relations. universal_regions . tainted_by_errors ( ) {
417+ // Suppress unhelpful extra errors in `infer_opaque_types` by clearing out all
418+ // outlives bounds that we may end up checking.
419+ outlives_constraints = Default :: default ( ) ;
420+ member_constraints = Default :: default ( ) ;
421+
422+ // Also taint the entire scope.
423+ infcx. set_tainted_by_errors ( guar) ;
424+ }
425+
414426 // Create a RegionDefinition for each inference variable.
415427 let definitions: IndexVec < _ , _ > = var_infos
416428 . iter ( )
@@ -435,7 +447,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
435447 }
436448
437449 let member_constraints =
438- Rc :: new ( member_constraints_in . into_mapped ( |r| constraint_sccs. scc ( r) ) ) ;
450+ Rc :: new ( member_constraints . into_mapped ( |r| constraint_sccs. scc ( r) ) ) ;
439451
440452 let mut result = Self {
441453 var_infos,
0 commit comments