-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Don't pass lint back out of lint decorator #118727
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -574,7 +574,6 @@ fn emit_implied_wf_lint<'tcx>( | |
Applicability::MaybeIncorrect, | ||
); | ||
} | ||
lint | ||
}, | ||
); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,7 +45,7 @@ fn check_unused_traits(tcx: TyCtxt<'_>, (): ()) { | |
item.hir_id(), | ||
path.span, | ||
msg, | ||
|lint| lint, | ||
|_| {}, | ||
); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -912,8 +912,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { | |
Applicability::HasPlaceholders | ||
); | ||
} | ||
|
||
lint | ||
}, | ||
); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -520,19 +520,14 @@ pub trait LintContext { | |
/// 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 | ||
#[rustc_lint_diagnostics] | ||
fn lookup_with_diagnostics( | ||
&self, | ||
lint: &'static Lint, | ||
span: Option<impl Into<MultiSpan>>, | ||
msg: impl Into<DiagnosticMessage>, | ||
decorate: impl for<'a, 'b> FnOnce( | ||
&'b mut DiagnosticBuilder<'a, ()>, | ||
) -> &'b mut DiagnosticBuilder<'a, ()>, | ||
decorate: impl for<'a, 'b> FnOnce(&'b mut DiagnosticBuilder<'a, ()>), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is a comment at the top of this method that points to a long comment on Though I will say that I wonder if the comment is correct, because as written the change seems like an improvement, shortening the code a little. And any function of the form There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, well, I guess I missed that. I'm not necessarily convinced by either of the arguments, but yeah, I'll leave it up to waffle to weigh in. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The shortening comment refers to is the I don't personally find There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes |
||
diagnostic: BuiltinLintDiagnostics, | ||
) { | ||
// We first generate a blank diagnostic. | ||
|
@@ -986,18 +981,14 @@ 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. | ||
/// | ||
/// 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 | ||
#[rustc_lint_diagnostics] | ||
fn lookup<S: Into<MultiSpan>>( | ||
&self, | ||
lint: &'static Lint, | ||
span: Option<S>, | ||
msg: impl Into<DiagnosticMessage>, | ||
decorate: impl for<'a, 'b> FnOnce( | ||
&'b mut DiagnosticBuilder<'a, ()>, | ||
) -> &'b mut DiagnosticBuilder<'a, ()>, | ||
decorate: impl for<'a, 'b> FnOnce(&'b mut DiagnosticBuilder<'a, ()>), | ||
); | ||
|
||
/// Emit a lint at `span` from a lint struct (some type that implements `DecorateLint`, | ||
|
@@ -1008,23 +999,21 @@ pub trait LintContext { | |
span: S, | ||
decorator: impl for<'a> DecorateLint<'a, ()>, | ||
) { | ||
self.lookup(lint, Some(span), decorator.msg(), |diag| decorator.decorate_lint(diag)); | ||
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 | ||
#[rustc_lint_diagnostics] | ||
fn struct_span_lint<S: Into<MultiSpan>>( | ||
&self, | ||
lint: &'static Lint, | ||
span: S, | ||
msg: impl Into<DiagnosticMessage>, | ||
decorate: impl for<'a, 'b> FnOnce( | ||
&'b mut DiagnosticBuilder<'a, ()>, | ||
) -> &'b mut DiagnosticBuilder<'a, ()>, | ||
decorate: impl for<'a, 'b> FnOnce(&'b mut DiagnosticBuilder<'a, ()>), | ||
) { | ||
self.lookup(lint, Some(span), msg, decorate); | ||
} | ||
|
@@ -1033,23 +1022,19 @@ pub trait LintContext { | |
/// generated by `#[derive(LintDiagnostic)]`). | ||
fn emit_lint(&self, lint: &'static Lint, decorator: impl for<'a> DecorateLint<'a, ()>) { | ||
self.lookup(lint, None as Option<Span>, decorator.msg(), |diag| { | ||
decorator.decorate_lint(diag) | ||
decorator.decorate_lint(diag); | ||
}); | ||
} | ||
|
||
/// 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 | ||
#[rustc_lint_diagnostics] | ||
fn lint( | ||
&self, | ||
lint: &'static Lint, | ||
msg: impl Into<DiagnosticMessage>, | ||
decorate: impl for<'a, 'b> FnOnce( | ||
&'b mut DiagnosticBuilder<'a, ()>, | ||
) -> &'b mut DiagnosticBuilder<'a, ()>, | ||
decorate: impl for<'a, 'b> FnOnce(&'b mut DiagnosticBuilder<'a, ()>), | ||
) { | ||
self.lookup(lint, None as Option<Span>, msg, decorate); | ||
} | ||
|
@@ -1113,9 +1098,7 @@ impl<'tcx> LintContext for LateContext<'tcx> { | |
lint: &'static Lint, | ||
span: Option<S>, | ||
msg: impl Into<DiagnosticMessage>, | ||
decorate: impl for<'a, 'b> FnOnce( | ||
&'b mut DiagnosticBuilder<'a, ()>, | ||
) -> &'b mut DiagnosticBuilder<'a, ()>, | ||
decorate: impl for<'a, 'b> FnOnce(&'b mut DiagnosticBuilder<'a, ()>), | ||
) { | ||
let hir_id = self.last_node_with_lint_attrs; | ||
|
||
|
@@ -1142,9 +1125,7 @@ impl LintContext for EarlyContext<'_> { | |
lint: &'static Lint, | ||
span: Option<S>, | ||
msg: impl Into<DiagnosticMessage>, | ||
decorate: impl for<'a, 'b> FnOnce( | ||
&'b mut DiagnosticBuilder<'a, ()>, | ||
) -> &'b mut DiagnosticBuilder<'a, ()>, | ||
decorate: impl for<'a, 'b> FnOnce(&'b mut DiagnosticBuilder<'a, ()>), | ||
) { | ||
self.builder.struct_lint(lint, span.map(|s| s.into()), msg, decorate) | ||
} | ||
|
Uh oh!
There was an error while loading. Please reload this page.