]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc_mir/borrow_check/diagnostics/region_errors.rs
introduce PredicateAtom
[rust.git] / src / librustc_mir / borrow_check / diagnostics / region_errors.rs
index 26c2aea41d5dc616b9fc4953966ee7061a14b4c1..a0d99ac33c04ee1a226b24fe7bb66100ae341f27 100644 (file)
@@ -19,7 +19,7 @@
     MirBorrowckCtxt,
 };
 
-use super::{OutlivesSuggestionBuilder, RegionName, RegionNameSource};
+use super::{OutlivesSuggestionBuilder, RegionName};
 
 impl ConstraintDescription for ConstraintCategory {
     fn description(&self) -> &'static str {
@@ -396,18 +396,8 @@ fn report_fnmut_error(
             diag.span_label(upvar_span, "variable captured here");
         }
 
-        match self.give_region_a_name(*outlived_fr).unwrap().source {
-            RegionNameSource::NamedEarlyBoundRegion(fr_span)
-            | RegionNameSource::NamedFreeRegion(fr_span)
-            | RegionNameSource::SynthesizedFreeEnvRegion(fr_span, _)
-            | RegionNameSource::CannotMatchHirTy(fr_span, _)
-            | RegionNameSource::MatchedHirTy(fr_span)
-            | RegionNameSource::MatchedAdtAndSegment(fr_span)
-            | RegionNameSource::AnonRegionFromUpvar(fr_span, _)
-            | RegionNameSource::AnonRegionFromOutput(fr_span, _, _) => {
-                diag.span_label(fr_span, "inferred to be a `FnMut` closure");
-            }
-            _ => {}
+        if let Some(fr_span) = self.give_region_a_name(*outlived_fr).unwrap().span() {
+            diag.span_label(fr_span, "inferred to be a `FnMut` closure");
         }
 
         diag.note(
@@ -599,10 +589,10 @@ fn add_static_impl_trait_suggestion(
 
                     let mut found = false;
                     for predicate in bounds.predicates {
-                        if let ty::PredicateKind::TypeOutlives(binder) = predicate.kind() {
-                            if let ty::OutlivesPredicate(_, ty::RegionKind::ReStatic) =
-                                binder.skip_binder()
-                            {
+                        if let ty::PredicateAtom::TypeOutlives(ty::OutlivesPredicate(_, r)) =
+                            predicate.skip_binders()
+                        {
+                            if let ty::RegionKind::ReStatic = r {
                                 found = true;
                                 break;
                             } else {