]> git.lizzy.rs Git - rust.git/commitdiff
Move stability lookup after cross-crate check
authorMaybe Waffle <waffle.lapkin@gmail.com>
Fri, 5 Aug 2022 14:13:22 +0000 (18:13 +0400)
committerMaybe Waffle <waffle.lapkin@gmail.com>
Fri, 5 Aug 2022 14:13:22 +0000 (18:13 +0400)
compiler/rustc_middle/src/middle/stability.rs

index 0d1223ed28965bab37e3a8aaae33943a6e720b01..7a9ad44d1d9ae86cec2b46303159c13950e95674 100644 (file)
@@ -421,6 +421,12 @@ pub fn eval_stability_allow_unstable(
             return EvalResult::Allow;
         }
 
+        // Only the cross-crate scenario matters when checking unstable APIs
+        let cross_crate = !def_id.is_local();
+        if !cross_crate {
+            return EvalResult::Allow;
+        }
+
         let stability = self.lookup_stability(def_id);
         debug!(
             "stability: \
@@ -428,12 +434,6 @@ pub fn eval_stability_allow_unstable(
             def_id, span, stability
         );
 
-        // Only the cross-crate scenario matters when checking unstable APIs
-        let cross_crate = !def_id.is_local();
-        if !cross_crate {
-            return EvalResult::Allow;
-        }
-
         // Issue #38412: private items lack stability markers.
         if skip_stability_check_due_to_privacy(self, def_id) {
             return EvalResult::Allow;
@@ -508,17 +508,17 @@ pub fn eval_default_body_stability(self, def_id: DefId, span: Span) -> EvalResul
             return EvalResult::Allow;
         }
 
-        let stability = self.lookup_default_body_stability(def_id);
-        debug!(
-            "body stability: inspecting def_id={def_id:?} span={span:?} of stability={stability:?}"
-        );
-
         // Only the cross-crate scenario matters when checking unstable APIs
         let cross_crate = !def_id.is_local();
         if !cross_crate {
             return EvalResult::Allow;
         }
 
+        let stability = self.lookup_default_body_stability(def_id);
+        debug!(
+            "body stability: inspecting def_id={def_id:?} span={span:?} of stability={stability:?}"
+        );
+
         // Issue #38412: private items lack stability markers.
         if skip_stability_check_due_to_privacy(self, def_id) {
             return EvalResult::Allow;