Skip to content

Rollup of 3 pull requests #103118

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 13 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
link lint function with decorate function param to struct_lint_level
  • Loading branch information
WaffleLapkin committed Oct 12, 2022
commit c5de3ecec349f8269d35d00dd7d0c596dfc994e1
19 changes: 19 additions & 0 deletions compiler/rustc_lint/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,11 @@ pub trait LintContext: Sized {
fn sess(&self) -> &Session;
fn lints(&self) -> &LintStore;

/// Emit a lint at the appropriate level, with an optional associated span and an existing diagnostic.
///
/// Return value of the `decorate` closure is ignored, see [`struct_lint_level`] for a detailed explanation.
///
/// [`struct_lint_level`]: rustc_middle::lint::struct_lint_level#decorate-signature
fn lookup_with_diagnostics(
&self,
lint: &'static Lint,
Expand Down Expand Up @@ -872,6 +877,11 @@ pub trait LintContext: Sized {

// FIXME: These methods should not take an Into<MultiSpan> -- instead, callers should need to
// set the span in their `decorate` function (preferably using set_span).
/// Emit a lint at the appropriate level, with an optional associated span.
///
/// Return value of the `decorate` closure is ignored, see [`struct_lint_level`] for a detailed explanation.
///
/// [`struct_lint_level`]: rustc_middle::lint::struct_lint_level#decorate-signature
fn lookup<S: Into<MultiSpan>>(
&self,
lint: &'static Lint,
Expand All @@ -893,6 +903,11 @@ pub trait LintContext: Sized {
self.lookup(lint, Some(span), decorator.msg(), |diag| decorator.decorate_lint(diag));
}

/// Emit a lint at the appropriate level, with an associated span.
///
/// Return value of the `decorate` closure is ignored, see [`struct_lint_level`] for a detailed explanation.
///
/// [`struct_lint_level`]: rustc_middle::lint::struct_lint_level#decorate-signature
fn struct_span_lint<S: Into<MultiSpan>>(
&self,
lint: &'static Lint,
Expand All @@ -914,6 +929,10 @@ pub trait LintContext: Sized {
}

/// Emit a lint at the appropriate level, with no associated span.
///
/// Return value of the `decorate` closure is ignored, see [`struct_lint_level`] for a detailed explanation.
///
/// [`struct_lint_level`]: rustc_middle::lint::struct_lint_level#decorate-signature
fn lint(
&self,
lint: &'static Lint,
Expand Down
4 changes: 4 additions & 0 deletions compiler/rustc_lint/src/levels.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1069,6 +1069,10 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {

/// Used to emit a lint-related diagnostic based on the current state of
/// this lint context.
///
/// Return value of the `decorate` closure is ignored, see [`struct_lint_level`] for a detailed explanation.
///
/// [`struct_lint_level`]: rustc_middle::lint::struct_lint_level#decorate-signature
pub(crate) fn struct_lint(
&self,
lint: &'static Lint,
Expand Down
10 changes: 10 additions & 0 deletions compiler/rustc_middle/src/ty/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2826,6 +2826,11 @@ impl<'tcx> TyCtxt<'tcx> {
})
}

/// Emit a lint at the appropriate level for a hir node, with an associated span.
///
/// Return value of the `decorate` closure is ignored, see [`struct_lint_level`] for a detailed explanation.
///
/// [`struct_lint_level`]: rustc_middle::lint::struct_lint_level#decorate-signature
pub fn struct_span_lint_hir(
self,
lint: &'static Lint,
Expand All @@ -2851,6 +2856,11 @@ impl<'tcx> TyCtxt<'tcx> {
self.struct_lint_node(lint, id, decorator.msg(), |diag| decorator.decorate_lint(diag))
}

/// Emit a lint at the appropriate level for a hir node.
///
/// Return value of the `decorate` closure is ignored, see [`struct_lint_level`] for a detailed explanation.
///
/// [`struct_lint_level`]: rustc_middle::lint::struct_lint_level#decorate-signature
pub fn struct_lint_node(
self,
lint: &'static Lint,
Expand Down