Skip to content

Commit 811adb5

Browse files
committed
Remove private methods from TyCtxt impl block: rustc::middle::stability.
1 parent 47256b8 commit 811adb5

File tree

1 file changed

+23
-25
lines changed

1 file changed

+23
-25
lines changed

src/librustc/middle/stability.rs

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -245,35 +245,35 @@ pub enum EvalResult {
245245
Unmarked,
246246
}
247247

248-
impl<'tcx> TyCtxt<'tcx> {
249-
// See issue #38412.
250-
fn skip_stability_check_due_to_privacy(self, mut def_id: DefId) -> bool {
251-
// Check if `def_id` is a trait method.
252-
match self.def_kind(def_id) {
253-
Some(DefKind::Method) | Some(DefKind::AssocTy) | Some(DefKind::AssocConst) => {
254-
if let ty::TraitContainer(trait_def_id) = self.associated_item(def_id).container {
255-
// Trait methods do not declare visibility (even
256-
// for visibility info in cstore). Use containing
257-
// trait instead, so methods of `pub` traits are
258-
// themselves considered `pub`.
259-
def_id = trait_def_id;
260-
}
248+
// See issue #38412.
249+
fn skip_stability_check_due_to_privacy(tcx: TyCtxt<'_>, mut def_id: DefId) -> bool {
250+
// Check if `def_id` is a trait method.
251+
match tcx.def_kind(def_id) {
252+
Some(DefKind::Method) | Some(DefKind::AssocTy) | Some(DefKind::AssocConst) => {
253+
if let ty::TraitContainer(trait_def_id) = tcx.associated_item(def_id).container {
254+
// Trait methods do not declare visibility (even
255+
// for visibility info in cstore). Use containing
256+
// trait instead, so methods of `pub` traits are
257+
// themselves considered `pub`.
258+
def_id = trait_def_id;
261259
}
262-
_ => {}
263260
}
261+
_ => {}
262+
}
264263

265-
let visibility = self.visibility(def_id);
264+
let visibility = tcx.visibility(def_id);
266265

267-
match visibility {
268-
// Must check stability for `pub` items.
269-
ty::Visibility::Public => false,
266+
match visibility {
267+
// Must check stability for `pub` items.
268+
ty::Visibility::Public => false,
270269

271-
// These are not visible outside crate; therefore
272-
// stability markers are irrelevant, if even present.
273-
ty::Visibility::Restricted(..) | ty::Visibility::Invisible => true,
274-
}
270+
// These are not visible outside crate; therefore
271+
// stability markers are irrelevant, if even present.
272+
ty::Visibility::Restricted(..) | ty::Visibility::Invisible => true,
275273
}
274+
}
276275

276+
impl<'tcx> TyCtxt<'tcx> {
277277
/// Evaluates the stability of an item.
278278
///
279279
/// Returns `EvalResult::Allow` if the item is stable, or unstable but the corresponding
@@ -338,7 +338,7 @@ impl<'tcx> TyCtxt<'tcx> {
338338
}
339339

340340
// Issue #38412: private items lack stability markers.
341-
if self.skip_stability_check_due_to_privacy(def_id) {
341+
if skip_stability_check_due_to_privacy(self, def_id) {
342342
return EvalResult::Allow;
343343
}
344344

@@ -402,9 +402,7 @@ impl<'tcx> TyCtxt<'tcx> {
402402
}
403403
}
404404
}
405-
}
406405

407-
impl<'tcx> TyCtxt<'tcx> {
408406
pub fn lookup_deprecation(self, id: DefId) -> Option<Deprecation> {
409407
self.lookup_deprecation_entry(id).map(|depr| depr.attr)
410408
}

0 commit comments

Comments
 (0)