Skip to content

Commit b07ed6a

Browse files
committed
stability: remove skip_stability_check_due_to_privacy
1 parent a8e75c5 commit b07ed6a

File tree

3 files changed

+7
-34
lines changed

3 files changed

+7
-34
lines changed

compiler/rustc_middle/src/middle/stability.rs

+1-28
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ use rustc_attr::{
1010
use rustc_data_structures::unord::UnordMap;
1111
use rustc_errors::{Applicability, Diag, EmissionGuarantee};
1212
use rustc_feature::GateIssue;
13-
use rustc_hir::def::DefKind;
1413
use rustc_hir::def_id::{DefId, LocalDefId, LocalDefIdMap};
1514
use rustc_hir::{self as hir, HirId};
1615
use rustc_macros::{Decodable, Encodable, HashStable, Subdiagnostic};
@@ -24,7 +23,7 @@ use rustc_span::symbol::{Symbol, sym};
2423
use tracing::debug;
2524

2625
pub use self::StabilityLevel::*;
27-
use crate::ty::{self, TyCtxt};
26+
use crate::ty::TyCtxt;
2827

2928
#[derive(PartialEq, Clone, Copy, Debug)]
3029
pub enum StabilityLevel {
@@ -273,22 +272,6 @@ pub enum EvalResult {
273272
Unmarked,
274273
}
275274

276-
// See issue #38412.
277-
fn skip_stability_check_due_to_privacy(tcx: TyCtxt<'_>, def_id: DefId) -> bool {
278-
if tcx.def_kind(def_id) == DefKind::TyParam {
279-
// Have no visibility, considered public for the purpose of this check.
280-
return false;
281-
}
282-
match tcx.visibility(def_id) {
283-
// Must check stability for `pub` items.
284-
ty::Visibility::Public => false,
285-
286-
// These are not visible outside crate; therefore
287-
// stability markers are irrelevant, if even present.
288-
ty::Visibility::Restricted(..) => true,
289-
}
290-
}
291-
292275
// See issue #83250.
293276
fn suggestion_for_allocator_api(
294277
tcx: TyCtxt<'_>,
@@ -407,11 +390,6 @@ impl<'tcx> TyCtxt<'tcx> {
407390
def_id, span, stability
408391
);
409392

410-
// Issue #38412: private items lack stability markers.
411-
if skip_stability_check_due_to_privacy(self, def_id) {
412-
return EvalResult::Allow;
413-
}
414-
415393
match stability {
416394
Some(Stability {
417395
level: attr::Unstable { reason, issue, is_soft, implied_by },
@@ -495,11 +473,6 @@ impl<'tcx> TyCtxt<'tcx> {
495473
"body stability: inspecting def_id={def_id:?} span={span:?} of stability={stability:?}"
496474
);
497475

498-
// Issue #38412: private items lack stability markers.
499-
if skip_stability_check_due_to_privacy(self, def_id) {
500-
return EvalResult::Allow;
501-
}
502-
503476
match stability {
504477
Some(DefaultBodyStability {
505478
level: attr::Unstable { reason, issue, is_soft, .. },

tests/ui/auxiliary/pub-and-stability.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
// The basic stability pattern in this file has four cases:
66
// 1. no stability attribute at all
77
// 2. a stable attribute (feature "unit_test")
8-
// 3. an unstable attribute that unit test declares (feature "unstable_declared")
9-
// 4. an unstable attribute that unit test fails to declare (feature "unstable_undeclared")
8+
// 3. an unstable attribute that unit test enables (feature "unstable_declared")
9+
// 4. an unstable attribute that unit test fails to enable (feature "unstable_undeclared")
1010
//
1111
// This file also covers four kinds of visibility: private,
1212
// pub(module), pub(crate), and pub.

tests/ui/explore-issue-38412.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
//@ aux-build:pub-and-stability.rs
22

3-
// A big point of this test is that we *declare* `unstable_declared`,
4-
// but do *not* declare `unstable_undeclared`. This way we can check
5-
// that the compiler is letting in uses of declared feature-gated
6-
// stuff but still rejecting uses of undeclared feature-gated stuff.
3+
// A big point of this test is that we *enable* `unstable_declared`,
4+
// but do *not* enable `unstable_undeclared`. This way we can check
5+
// that the compiler is letting in uses of enabled feature-gated
6+
// stuff but still rejecting uses of disabled feature-gated stuff.
77
#![feature(unstable_declared)]
88

99
extern crate pub_and_stability;

0 commit comments

Comments
 (0)