Skip to content

Commit

Permalink
Remove "override" terminology
Browse files Browse the repository at this point in the history
  • Loading branch information
semicoleon committed Jun 4, 2022
1 parent d03c411 commit d667a42
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 19 deletions.
27 changes: 13 additions & 14 deletions compiler/rustc_middle/src/middle/stability.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ use rustc_errors::{Applicability, Diagnostic};
use rustc_feature::GateIssue;
use rustc_hir::def::DefKind;
use rustc_hir::def_id::{DefId, LocalDefId};
use rustc_hir::{self as hir};
use rustc_hir::{self, HirId};
use rustc_hir::{self as hir, HirId};
use rustc_middle::ty::print::with_no_trimmed_paths;
use rustc_session::lint::builtin::{DEPRECATED, DEPRECATED_IN_FUTURE, SOFT_UNSTABLE};
use rustc_session::lint::{BuiltinLintDiagnostics, Level, Lint, LintBuffer};
Expand Down Expand Up @@ -331,7 +330,7 @@ impl<'tcx> TyCtxt<'tcx> {
span: Span,
method_span: Option<Span>,
) -> EvalResult {
self.eval_stability_override(def_id, id, span, method_span, AllowUnstable::No)
self.eval_stability_allow_unstable(def_id, id, span, method_span, AllowUnstable::No)
}

/// Evaluates the stability of an item.
Expand All @@ -344,14 +343,14 @@ impl<'tcx> TyCtxt<'tcx> {
/// deprecated. If the item is indeed deprecated, we will emit a deprecation lint attached to
/// `id`.
///
/// Pass `EvalOverride::AllowUnstable` to `eval_override` to force an unstable item to be allowed. Deprecation warnings will be emitted normally.
pub fn eval_stability_override(
/// Pass `AllowUnstable::Yes` to `allow_unstable` to force an unstable item to be allowed. Deprecation warnings will be emitted normally.
pub fn eval_stability_allow_unstable(
self,
def_id: DefId,
id: Option<HirId>,
span: Span,
method_span: Option<Span>,
eval_override: AllowUnstable,
allow_unstable: AllowUnstable,
) -> EvalResult {
// Deprecated attributes apply in-crate and cross-crate.
if let Some(id) = id {
Expand Down Expand Up @@ -449,7 +448,7 @@ impl<'tcx> TyCtxt<'tcx> {
}
}

if matches!(eval_override, AllowUnstable::Yes) {
if matches!(allow_unstable, AllowUnstable::Yes) {
return EvalResult::Allow;
}

Expand Down Expand Up @@ -479,7 +478,7 @@ impl<'tcx> TyCtxt<'tcx> {
span: Span,
method_span: Option<Span>,
) {
self.check_stability_override(def_id, id, span, method_span, AllowUnstable::No)
self.check_stability_allow_unstable(def_id, id, span, method_span, AllowUnstable::No)
}

/// Checks if an item is stable or error out.
Expand All @@ -490,21 +489,21 @@ impl<'tcx> TyCtxt<'tcx> {
/// This function will also check if the item is deprecated.
/// If so, and `id` is not `None`, a deprecated lint attached to `id` will be emitted.
///
/// Pass `EvalOverride::AllowUnstable` to `eval_override` to force an unstable item to be allowed. Deprecation warnings will be emitted normally.
pub fn check_stability_override(
/// Pass `AllowUnstable::Yes` to `allow_unstable` to force an unstable item to be allowed. Deprecation warnings will be emitted normally.
pub fn check_stability_allow_unstable(
self,
def_id: DefId,
id: Option<HirId>,
span: Span,
method_span: Option<Span>,
eval_override: AllowUnstable,
allow_unstable: AllowUnstable,
) {
self.check_optional_stability(
def_id,
id,
span,
method_span,
eval_override,
allow_unstable,
|span, def_id| {
// The API could be uncallable for other reasons, for example when a private module
// was referenced.
Expand All @@ -523,15 +522,15 @@ impl<'tcx> TyCtxt<'tcx> {
id: Option<HirId>,
span: Span,
method_span: Option<Span>,
eval_override: AllowUnstable,
allow_unstable: AllowUnstable,
unmarked: impl FnOnce(Span, DefId),
) {
let soft_handler = |lint, span, msg: &_| {
self.struct_span_lint_hir(lint, id.unwrap_or(hir::CRATE_HIR_ID), span, |lint| {
lint.build(msg).emit();
})
};
match self.eval_stability_override(def_id, id, span, method_span, eval_override) {
match self.eval_stability_allow_unstable(def_id, id, span, method_span, allow_unstable) {
EvalResult::Allow => {}
EvalResult::Deny { feature, reason, issue, suggestion, is_soft } => report_unstable(
self.sess,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_passes/src/stability.rs
Original file line number Diff line number Diff line change
Expand Up @@ -807,7 +807,7 @@ impl<'tcx> Visitor<'tcx> for Checker<'tcx> {
fn visit_path(&mut self, path: &'tcx hir::Path<'tcx>, id: hir::HirId) {
if let Some(def_id) = path.res.opt_def_id() {
let method_span = path.segments.last().map(|s| s.ident.span);
self.tcx.check_stability_override(
self.tcx.check_stability_allow_unstable(
def_id,
Some(id),
path.span,
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/stability-attribute/allow-unstable-reexport.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Allow an unstable re-export without requiring a feature gate.
// Allow an unstable re-export without requiring a feature gate.
// #94972

// aux-build:lint-stability.rs
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
error[E0658]: use of unstable library feature 'unstable_test_feature'
--> $DIR/allow-unstable-reexport.rs:21:9
--> $DIR/allow-unstable-reexport.rs:22:9
|
LL | pub use lint_stability::unstable as unstable2;
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: add `#![feature(unstable_test_feature)]` to the crate attributes to enable

error[E0658]: use of unstable library feature 'unstable_test_feature'
--> $DIR/allow-unstable-reexport.rs:27:5
--> $DIR/allow-unstable-reexport.rs:28:5
|
LL | unstable();
| ^^^^^^^^
|
= help: add `#![feature(unstable_test_feature)]` to the crate attributes to enable

error[E0658]: use of unstable library feature 'unstable_test_feature': text
--> $DIR/allow-unstable-reexport.rs:28:5
--> $DIR/allow-unstable-reexport.rs:29:5
|
LL | unstable_text();
| ^^^^^^^^^^^^^
Expand Down

0 comments on commit d667a42

Please sign in to comment.