Skip to content

Commit c5de3ec

Browse files
committed
link lint function with decorate function param to struct_lint_level
1 parent b1c3e78 commit c5de3ec

File tree

3 files changed

+33
-0
lines changed

3 files changed

+33
-0
lines changed

compiler/rustc_lint/src/context.rs

+19
Original file line numberDiff line numberDiff line change
@@ -574,6 +574,11 @@ pub trait LintContext: Sized {
574574
fn sess(&self) -> &Session;
575575
fn lints(&self) -> &LintStore;
576576

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

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

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

916931
/// Emit a lint at the appropriate level, with no associated span.
932+
///
933+
/// Return value of the `decorate` closure is ignored, see [`struct_lint_level`] for a detailed explanation.
934+
///
935+
/// [`struct_lint_level`]: rustc_middle::lint::struct_lint_level#decorate-signature
917936
fn lint(
918937
&self,
919938
lint: &'static Lint,

compiler/rustc_lint/src/levels.rs

+4
Original file line numberDiff line numberDiff line change
@@ -1069,6 +1069,10 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
10691069

10701070
/// Used to emit a lint-related diagnostic based on the current state of
10711071
/// this lint context.
1072+
///
1073+
/// Return value of the `decorate` closure is ignored, see [`struct_lint_level`] for a detailed explanation.
1074+
///
1075+
/// [`struct_lint_level`]: rustc_middle::lint::struct_lint_level#decorate-signature
10721076
pub(crate) fn struct_lint(
10731077
&self,
10741078
lint: &'static Lint,

compiler/rustc_middle/src/ty/context.rs

+10
Original file line numberDiff line numberDiff line change
@@ -2826,6 +2826,11 @@ impl<'tcx> TyCtxt<'tcx> {
28262826
})
28272827
}
28282828

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

2859+
/// Emit a lint at the appropriate level for a hir node.
2860+
///
2861+
/// Return value of the `decorate` closure is ignored, see [`struct_lint_level`] for a detailed explanation.
2862+
///
2863+
/// [`struct_lint_level`]: rustc_middle::lint::struct_lint_level#decorate-signature
28542864
pub fn struct_lint_node(
28552865
self,
28562866
lint: &'static Lint,

0 commit comments

Comments
 (0)