Skip to content

Commit

Permalink
Rename struct_lint_level as lint_level.
Browse files Browse the repository at this point in the history
  • Loading branch information
nnethercote committed Jan 22, 2024
1 parent e164cf3 commit 15a4c4f
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 20 deletions.
8 changes: 4 additions & 4 deletions compiler/rustc_lint/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ pub trait LintContext {
/// Emit a lint at the appropriate level, with an optional associated span and an existing
/// diagnostic.
///
/// [`struct_lint_level`]: rustc_middle::lint::struct_lint_level#decorate-signature
/// [`lint_level`]: rustc_middle::lint::lint_level#decorate-signature
#[rustc_lint_diagnostics]
fn span_lint_with_diagnostics(
&self,
Expand All @@ -553,7 +553,7 @@ pub trait LintContext {
// set the span in their `decorate` function (preferably using set_span).
/// Emit a lint at the appropriate level, with an optional associated span.
///
/// [`struct_lint_level`]: rustc_middle::lint::struct_lint_level#decorate-signature
/// [`lint_level`]: rustc_middle::lint::lint_level#decorate-signature
#[rustc_lint_diagnostics]
fn opt_span_lint<S: Into<MultiSpan>>(
&self,
Expand All @@ -578,7 +578,7 @@ pub trait LintContext {

/// Emit a lint at the appropriate level, with an associated span.
///
/// [`struct_lint_level`]: rustc_middle::lint::struct_lint_level#decorate-signature
/// [`lint_level`]: rustc_middle::lint::lint_level#decorate-signature
#[rustc_lint_diagnostics]
fn span_lint<S: Into<MultiSpan>>(
&self,
Expand All @@ -600,7 +600,7 @@ pub trait LintContext {

/// Emit a lint at the appropriate level, with no associated span.
///
/// [`struct_lint_level`]: rustc_middle::lint::struct_lint_level#decorate-signature
/// [`lint_level`]: rustc_middle::lint::lint_level#decorate-signature
#[rustc_lint_diagnostics]
fn lint(
&self,
Expand Down
12 changes: 6 additions & 6 deletions compiler/rustc_lint/src/levels.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use rustc_hir::HirId;
use rustc_index::IndexVec;
use rustc_middle::hir::nested_filter;
use rustc_middle::lint::{
reveal_actual_level, struct_lint_level, LevelAndSource, LintExpectation, LintLevelSource,
lint_level, reveal_actual_level, LevelAndSource, LintExpectation, LintLevelSource,
ShallowLintLevelMap,
};
use rustc_middle::query::Providers;
Expand Down Expand Up @@ -1062,7 +1062,7 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
if self.lint_added_lints {
let lint = builtin::UNKNOWN_LINTS;
let (level, src) = self.lint_level(builtin::UNKNOWN_LINTS);
struct_lint_level(
lint_level(
self.sess,
lint,
level,
Expand Down Expand Up @@ -1096,7 +1096,7 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
/// Used to emit a lint-related diagnostic based on the current state of
/// this lint context.
///
/// [`struct_lint_level`]: rustc_middle::lint::struct_lint_level#decorate-signature
/// [`lint_level`]: rustc_middle::lint::lint_level#decorate-signature
#[rustc_lint_diagnostics]
#[track_caller]
pub(crate) fn opt_span_lint(
Expand All @@ -1107,7 +1107,7 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
decorate: impl for<'a, 'b> FnOnce(&'b mut DiagnosticBuilder<'a, ()>),
) {
let (level, src) = self.lint_level(lint);
struct_lint_level(self.sess, lint, level, src, span, msg, decorate)
lint_level(self.sess, lint, level, src, span, msg, decorate)
}

#[track_caller]
Expand All @@ -1118,15 +1118,15 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
decorate: impl for<'a> DecorateLint<'a, ()>,
) {
let (level, src) = self.lint_level(lint);
struct_lint_level(self.sess, lint, level, src, Some(span), decorate.msg(), |lint| {
lint_level(self.sess, lint, level, src, Some(span), decorate.msg(), |lint| {
decorate.decorate_lint(lint);
});
}

#[track_caller]
pub fn emit_lint(&self, lint: &'static Lint, decorate: impl for<'a> DecorateLint<'a, ()>) {
let (level, src) = self.lint_level(lint);
struct_lint_level(self.sess, lint, level, src, None, decorate.msg(), |lint| {
lint_level(self.sess, lint, level, src, None, decorate.msg(), |lint| {
decorate.decorate_lint(lint);
});
}
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_middle/src/lint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ pub fn explain_lint_level_source(
/// It is not intended to call `emit`/`cancel` on the `DiagnosticBuilder` passed
/// in the `decorate` callback.
#[track_caller]
pub fn struct_lint_level(
pub fn lint_level(
sess: &Session,
lint: &'static Lint,
level: Level,
Expand All @@ -270,7 +270,7 @@ pub fn struct_lint_level(
// Avoid codegen bloat from monomorphization by immediately doing dyn dispatch of `decorate` to
// the "real" work.
#[track_caller]
fn struct_lint_level_impl(
fn lint_level_impl(
sess: &Session,
lint: &'static Lint,
level: Level,
Expand Down Expand Up @@ -399,7 +399,7 @@ pub fn struct_lint_level(
explain_lint_level_source(lint, level, src, &mut *err);
err.emit()
}
struct_lint_level_impl(sess, lint, level, src, span, msg, Box::new(decorate))
lint_level_impl(sess, lint, level, src, span, msg, Box::new(decorate))
}

/// Returns whether `span` originates in a foreign crate's external macro.
Expand Down
12 changes: 6 additions & 6 deletions compiler/rustc_middle/src/ty/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ pub mod tls;
use crate::arena::Arena;
use crate::dep_graph::{DepGraph, DepKindStruct};
use crate::infer::canonical::{CanonicalParamEnvCache, CanonicalVarInfo, CanonicalVarInfos};
use crate::lint::struct_lint_level;
use crate::lint::lint_level;
use crate::metadata::ModChild;
use crate::middle::codegen_fn_attrs::CodegenFnAttrs;
use crate::middle::resolve_bound_vars;
Expand Down Expand Up @@ -2086,14 +2086,14 @@ impl<'tcx> TyCtxt<'tcx> {
) {
let msg = decorator.msg();
let (level, src) = self.lint_level_at_node(lint, hir_id);
struct_lint_level(self.sess, lint, level, src, Some(span.into()), msg, |diag| {
lint_level(self.sess, lint, level, src, Some(span.into()), msg, |diag| {
decorator.decorate_lint(diag);
})
}

/// Emit a lint at the appropriate level for a hir node, with an associated span.
///
/// [`struct_lint_level`]: rustc_middle::lint::struct_lint_level#decorate-signature
/// [`lint_level`]: rustc_middle::lint::lint_level#decorate-signature
#[rustc_lint_diagnostics]
#[track_caller]
pub fn node_span_lint(
Expand All @@ -2105,7 +2105,7 @@ impl<'tcx> TyCtxt<'tcx> {
decorate: impl for<'a, 'b> FnOnce(&'b mut DiagnosticBuilder<'a, ()>),
) {
let (level, src) = self.lint_level_at_node(lint, hir_id);
struct_lint_level(self.sess, lint, level, src, Some(span.into()), msg, decorate);
lint_level(self.sess, lint, level, src, Some(span.into()), msg, decorate);
}

/// Emit a lint from a lint struct (some type that implements `DecorateLint`, typically
Expand All @@ -2124,7 +2124,7 @@ impl<'tcx> TyCtxt<'tcx> {

/// Emit a lint at the appropriate level for a hir node.
///
/// [`struct_lint_level`]: rustc_middle::lint::struct_lint_level#decorate-signature
/// [`lint_level`]: rustc_middle::lint::lint_level#decorate-signature
#[rustc_lint_diagnostics]
#[track_caller]
pub fn node_lint(
Expand All @@ -2135,7 +2135,7 @@ impl<'tcx> TyCtxt<'tcx> {
decorate: impl for<'a, 'b> FnOnce(&'b mut DiagnosticBuilder<'a, ()>),
) {
let (level, src) = self.lint_level_at_node(lint, id);
struct_lint_level(self.sess, lint, level, src, None, msg, decorate);
lint_level(self.sess, lint, level, src, None, msg, decorate);
}

pub fn in_scope_traits(self, id: HirId) -> Option<&'tcx [TraitCandidate]> {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_session/src/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ pub fn feature_warn_issue(
let mut err = sess.parse_sess.dcx.struct_span_warn(span, explain);
add_feature_diagnostics_for_issue(&mut err, sess, feature, issue, false);

// Decorate this as a future-incompatibility lint as in rustc_middle::lint::struct_lint_level
// Decorate this as a future-incompatibility lint as in rustc_middle::lint::lint_level
let lint = UNSTABLE_SYNTAX_PRE_EXPANSION;
let future_incompatible = lint.future_incompatible.as_ref().unwrap();
err.is_lint(lint.name_lower(), /* has_future_breakage */ false);
Expand Down

0 comments on commit 15a4c4f

Please sign in to comment.