Skip to content

Commit 95bf0fb

Browse files
committed
Move stability lookup after cross-crate check
1 parent 963e402 commit 95bf0fb

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

compiler/rustc_middle/src/middle/stability.rs

+11-11
Original file line numberDiff line numberDiff line change
@@ -421,19 +421,19 @@ impl<'tcx> TyCtxt<'tcx> {
421421
return EvalResult::Allow;
422422
}
423423

424+
// Only the cross-crate scenario matters when checking unstable APIs
425+
let cross_crate = !def_id.is_local();
426+
if !cross_crate {
427+
return EvalResult::Allow;
428+
}
429+
424430
let stability = self.lookup_stability(def_id);
425431
debug!(
426432
"stability: \
427433
inspecting def_id={:?} span={:?} of stability={:?}",
428434
def_id, span, stability
429435
);
430436

431-
// Only the cross-crate scenario matters when checking unstable APIs
432-
let cross_crate = !def_id.is_local();
433-
if !cross_crate {
434-
return EvalResult::Allow;
435-
}
436-
437437
// Issue #38412: private items lack stability markers.
438438
if skip_stability_check_due_to_privacy(self, def_id) {
439439
return EvalResult::Allow;
@@ -508,17 +508,17 @@ impl<'tcx> TyCtxt<'tcx> {
508508
return EvalResult::Allow;
509509
}
510510

511-
let stability = self.lookup_default_body_stability(def_id);
512-
debug!(
513-
"body stability: inspecting def_id={def_id:?} span={span:?} of stability={stability:?}"
514-
);
515-
516511
// Only the cross-crate scenario matters when checking unstable APIs
517512
let cross_crate = !def_id.is_local();
518513
if !cross_crate {
519514
return EvalResult::Allow;
520515
}
521516

517+
let stability = self.lookup_default_body_stability(def_id);
518+
debug!(
519+
"body stability: inspecting def_id={def_id:?} span={span:?} of stability={stability:?}"
520+
);
521+
522522
// Issue #38412: private items lack stability markers.
523523
if skip_stability_check_due_to_privacy(self, def_id) {
524524
return EvalResult::Allow;

0 commit comments

Comments
 (0)