summary refs log tree commit diff
diff options
context:
space:
mode:
authorRalf Jung <post@ralfj.de>2024-11-18 08:05:30 +0100
committerRalf Jung <post@ralfj.de>2024-11-18 08:07:46 +0100
commitb07ed6ab164bf58a0fcfe7a365d5341c0e7b7e7d (patch)
tree4a7cf70ad64cb6ebf0b96a3b2ecdb71d7854d704
parenta8e75c53d0036b5d012cbc0ee5de17f8991fe60c (diff)
downloadrust-b07ed6ab164bf58a0fcfe7a365d5341c0e7b7e7d.tar.gz
rust-b07ed6ab164bf58a0fcfe7a365d5341c0e7b7e7d.zip
stability: remove skip_stability_check_due_to_privacy
-rw-r--r--compiler/rustc_middle/src/middle/stability.rs29
-rw-r--r--tests/ui/auxiliary/pub-and-stability.rs4
-rw-r--r--tests/ui/explore-issue-38412.rs8
3 files changed, 7 insertions, 34 deletions
diff --git a/compiler/rustc_middle/src/middle/stability.rs b/compiler/rustc_middle/src/middle/stability.rs
index e6b36299d7f..94d13021612 100644
--- a/compiler/rustc_middle/src/middle/stability.rs
+++ b/compiler/rustc_middle/src/middle/stability.rs
@@ -10,7 +10,6 @@ use rustc_attr::{
 use rustc_data_structures::unord::UnordMap;
 use rustc_errors::{Applicability, Diag, EmissionGuarantee};
 use rustc_feature::GateIssue;
-use rustc_hir::def::DefKind;
 use rustc_hir::def_id::{DefId, LocalDefId, LocalDefIdMap};
 use rustc_hir::{self as hir, HirId};
 use rustc_macros::{Decodable, Encodable, HashStable, Subdiagnostic};
@@ -24,7 +23,7 @@ use rustc_span::symbol::{Symbol, sym};
 use tracing::debug;
 
 pub use self::StabilityLevel::*;
-use crate::ty::{self, TyCtxt};
+use crate::ty::TyCtxt;
 
 #[derive(PartialEq, Clone, Copy, Debug)]
 pub enum StabilityLevel {
@@ -273,22 +272,6 @@ pub enum EvalResult {
     Unmarked,
 }
 
-// See issue #38412.
-fn skip_stability_check_due_to_privacy(tcx: TyCtxt<'_>, def_id: DefId) -> bool {
-    if tcx.def_kind(def_id) == DefKind::TyParam {
-        // Have no visibility, considered public for the purpose of this check.
-        return false;
-    }
-    match tcx.visibility(def_id) {
-        // Must check stability for `pub` items.
-        ty::Visibility::Public => false,
-
-        // These are not visible outside crate; therefore
-        // stability markers are irrelevant, if even present.
-        ty::Visibility::Restricted(..) => true,
-    }
-}
-
 // See issue #83250.
 fn suggestion_for_allocator_api(
     tcx: TyCtxt<'_>,
@@ -407,11 +390,6 @@ impl<'tcx> TyCtxt<'tcx> {
             def_id, span, stability
         );
 
-        // Issue #38412: private items lack stability markers.
-        if skip_stability_check_due_to_privacy(self, def_id) {
-            return EvalResult::Allow;
-        }
-
         match stability {
             Some(Stability {
                 level: attr::Unstable { reason, issue, is_soft, implied_by },
@@ -495,11 +473,6 @@ impl<'tcx> TyCtxt<'tcx> {
             "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;
-        }
-
         match stability {
             Some(DefaultBodyStability {
                 level: attr::Unstable { reason, issue, is_soft, .. },
diff --git a/tests/ui/auxiliary/pub-and-stability.rs b/tests/ui/auxiliary/pub-and-stability.rs
index ee05a07dbb2..d2d07f99398 100644
--- a/tests/ui/auxiliary/pub-and-stability.rs
+++ b/tests/ui/auxiliary/pub-and-stability.rs
@@ -5,8 +5,8 @@
 // The basic stability pattern in this file has four cases:
 // 1. no stability attribute at all
 // 2. a stable attribute (feature "unit_test")
-// 3. an unstable attribute that unit test declares (feature "unstable_declared")
-// 4. an unstable attribute that unit test fails to declare (feature "unstable_undeclared")
+// 3. an unstable attribute that unit test enables (feature "unstable_declared")
+// 4. an unstable attribute that unit test fails to enable (feature "unstable_undeclared")
 //
 // This file also covers four kinds of visibility: private,
 // pub(module), pub(crate), and pub.
diff --git a/tests/ui/explore-issue-38412.rs b/tests/ui/explore-issue-38412.rs
index e1295a96ba5..2008b120faa 100644
--- a/tests/ui/explore-issue-38412.rs
+++ b/tests/ui/explore-issue-38412.rs
@@ -1,9 +1,9 @@
 //@ aux-build:pub-and-stability.rs
 
-// A big point of this test is that we *declare* `unstable_declared`,
-// but do *not* declare `unstable_undeclared`. This way we can check
-// that the compiler is letting in uses of declared feature-gated
-// stuff but still rejecting uses of undeclared feature-gated stuff.
+// A big point of this test is that we *enable* `unstable_declared`,
+// but do *not* enable `unstable_undeclared`. This way we can check
+// that the compiler is letting in uses of enabled feature-gated
+// stuff but still rejecting uses of disabled feature-gated stuff.
 #![feature(unstable_declared)]
 
 extern crate pub_and_stability;