Skip to content

Commit 252d99a

Browse files
Fix comments
1 parent 7f565ed commit 252d99a

File tree

4 files changed

+3
-37
lines changed

4 files changed

+3
-37
lines changed

compiler/rustc_lint/src/context.rs

-9
Original file line numberDiff line numberDiff line change
@@ -520,9 +520,6 @@ pub trait LintContext {
520520
/// Emit a lint at the appropriate level, with an optional associated span and an existing
521521
/// diagnostic.
522522
///
523-
/// Return value of the `decorate` closure is ignored, see [`struct_lint_level`] for a detailed
524-
/// explanation.
525-
///
526523
/// [`struct_lint_level`]: rustc_middle::lint::struct_lint_level#decorate-signature
527524
#[rustc_lint_diagnostics]
528525
fn lookup_with_diagnostics(
@@ -984,8 +981,6 @@ pub trait LintContext {
984981
// set the span in their `decorate` function (preferably using set_span).
985982
/// Emit a lint at the appropriate level, with an optional associated span.
986983
///
987-
/// Return value of the `decorate` closure is ignored, see [`struct_lint_level`] for a detailed explanation.
988-
///
989984
/// [`struct_lint_level`]: rustc_middle::lint::struct_lint_level#decorate-signature
990985
#[rustc_lint_diagnostics]
991986
fn lookup<S: Into<MultiSpan>>(
@@ -1011,8 +1006,6 @@ pub trait LintContext {
10111006

10121007
/// Emit a lint at the appropriate level, with an associated span.
10131008
///
1014-
/// Return value of the `decorate` closure is ignored, see [`struct_lint_level`] for a detailed explanation.
1015-
///
10161009
/// [`struct_lint_level`]: rustc_middle::lint::struct_lint_level#decorate-signature
10171010
#[rustc_lint_diagnostics]
10181011
fn struct_span_lint<S: Into<MultiSpan>>(
@@ -1035,8 +1028,6 @@ pub trait LintContext {
10351028

10361029
/// Emit a lint at the appropriate level, with no associated span.
10371030
///
1038-
/// Return value of the `decorate` closure is ignored, see [`struct_lint_level`] for a detailed explanation.
1039-
///
10401031
/// [`struct_lint_level`]: rustc_middle::lint::struct_lint_level#decorate-signature
10411032
#[rustc_lint_diagnostics]
10421033
fn lint(

compiler/rustc_lint/src/levels.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1093,8 +1093,6 @@ impl<'s, P: LintLevelsProvider> LintLevelsBuilder<'s, P> {
10931093
/// Used to emit a lint-related diagnostic based on the current state of
10941094
/// this lint context.
10951095
///
1096-
/// Return value of the `decorate` closure is ignored, see [`struct_lint_level`] for a detailed explanation.
1097-
///
10981096
/// [`struct_lint_level`]: rustc_middle::lint::struct_lint_level#decorate-signature
10991097
#[rustc_lint_diagnostics]
11001098
#[track_caller]

compiler/rustc_middle/src/lint.rs

+3-22
Original file line numberDiff line numberDiff line change
@@ -253,29 +253,10 @@ pub fn explain_lint_level_source(
253253
/// - [`TyCtxt::struct_lint_node`]
254254
/// - `LintContext::lookup`
255255
///
256-
/// ## `decorate` signature
256+
/// ## `decorate`
257257
///
258-
/// The return value of `decorate` is ignored by this function. So what is the
259-
/// point of returning `&'b mut DiagnosticBuilder<'a, ()>`?
260-
///
261-
/// There are 2 reasons for this signature.
262-
///
263-
/// First of all, it prevents accidental use of `.emit()` -- it's clear that the
264-
/// builder will be later used and shouldn't be emitted right away (this is
265-
/// especially important because the old API expected you to call `.emit()` in
266-
/// the closure).
267-
///
268-
/// Second of all, it makes the most common case of adding just a single label
269-
/// /suggestion much nicer, since [`DiagnosticBuilder`] methods return
270-
/// `&mut DiagnosticBuilder`, you can just chain methods, without needed
271-
/// awkward `{ ...; }`:
272-
/// ```ignore pseudo-code
273-
/// struct_lint_level(
274-
/// ...,
275-
/// |lint| lint.span_label(sp, "lbl")
276-
/// // ^^^^^^^^^^^^^^^^^^^^^ returns `&mut DiagnosticBuilder` by default
277-
/// )
278-
/// ```
258+
/// It is not intended to call `emit`/`cancel` on the `DiagnosticBuilder` passed
259+
/// in the `decorate` callback.
279260
#[track_caller]
280261
pub fn struct_lint_level(
281262
sess: &Session,

compiler/rustc_middle/src/ty/context.rs

-4
Original file line numberDiff line numberDiff line change
@@ -2036,8 +2036,6 @@ impl<'tcx> TyCtxt<'tcx> {
20362036

20372037
/// Emit a lint at the appropriate level for a hir node, with an associated span.
20382038
///
2039-
/// Return value of the `decorate` closure is ignored, see [`struct_lint_level`] for a detailed explanation.
2040-
///
20412039
/// [`struct_lint_level`]: rustc_middle::lint::struct_lint_level#decorate-signature
20422040
#[rustc_lint_diagnostics]
20432041
#[track_caller]
@@ -2069,8 +2067,6 @@ impl<'tcx> TyCtxt<'tcx> {
20692067

20702068
/// Emit a lint at the appropriate level for a hir node.
20712069
///
2072-
/// Return value of the `decorate` closure is ignored, see [`struct_lint_level`] for a detailed explanation.
2073-
///
20742070
/// [`struct_lint_level`]: rustc_middle::lint::struct_lint_level#decorate-signature
20752071
#[rustc_lint_diagnostics]
20762072
#[track_caller]

0 commit comments

Comments
 (0)