summary refs log tree commit diff
path: root/src/tools/clippy/tests
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2024-05-27 08:44:12 +0000
committerbors <bors@rust-lang.org>2024-05-27 08:44:12 +0000
commitb582f807fae230b22ac126ff1d8a13262bb099ba (patch)
tree861b8cb9ffe0461d39a824e74a44cc36c2ffa5c2 /src/tools/clippy/tests
parentfec98b3bbc94b54a0b3085d004708aabcc48081a (diff)
parent37bf2d2dabdbdce9473b0fed1708fcbf31ba9c1a (diff)
downloadrust-b582f807fae230b22ac126ff1d8a13262bb099ba.tar.gz
rust-b582f807fae230b22ac126ff1d8a13262bb099ba.zip
Auto merge of #125410 - fmease:adj-lint-diag-api, r=nnethercote
[perf] Delay the construction of early lint diag structs

Attacks some of the perf regressions from https://github.com/rust-lang/rust/pull/124417#issuecomment-2123700666.

See individual commits for details. The first three commits are not strictly necessary.
However, the 2nd one (06bc4fc67145e3a7be9b5a2cf2b5968cef36e587, *Remove `LintDiagnostic::msg`*) makes the main change way nicer to implement.
It's also pretty sweet on its own if I may say so myself.
Diffstat (limited to 'src/tools/clippy/tests')
-rw-r--r--src/tools/clippy/tests/ui-internal/disallow_span_lint.rs4
-rw-r--r--src/tools/clippy/tests/ui-internal/disallow_span_lint.stderr8
2 files changed, 6 insertions, 6 deletions
diff --git a/src/tools/clippy/tests/ui-internal/disallow_span_lint.rs b/src/tools/clippy/tests/ui-internal/disallow_span_lint.rs
index 5a2a868ed3e..b91a83308b5 100644
--- a/src/tools/clippy/tests/ui-internal/disallow_span_lint.rs
+++ b/src/tools/clippy/tests/ui-internal/disallow_span_lint.rs
@@ -11,11 +11,11 @@ use rustc_lint::{Lint, LintContext};
 use rustc_middle::ty::TyCtxt;
 
 pub fn a(cx: impl LintContext, lint: &'static Lint, span: impl Into<MultiSpan>, msg: impl Into<DiagMessage>) {
-    cx.span_lint(lint, span, msg, |_| {});
+    cx.span_lint(lint, span, |lint| { lint.primary_message(msg); });
 }
 
 pub fn b(tcx: TyCtxt<'_>, lint: &'static Lint, hir_id: HirId, span: impl Into<MultiSpan>, msg: impl Into<DiagMessage>) {
-    tcx.node_span_lint(lint, hir_id, span, msg, |_| {});
+    tcx.node_span_lint(lint, hir_id, span, |lint| { lint.primary_message(msg); });
 }
 
 fn main() {}
diff --git a/src/tools/clippy/tests/ui-internal/disallow_span_lint.stderr b/src/tools/clippy/tests/ui-internal/disallow_span_lint.stderr
index cfc590bed36..1cfbc8efc8e 100644
--- a/src/tools/clippy/tests/ui-internal/disallow_span_lint.stderr
+++ b/src/tools/clippy/tests/ui-internal/disallow_span_lint.stderr
@@ -1,8 +1,8 @@
 error: use of a disallowed method `rustc_lint::context::LintContext::span_lint`
   --> tests/ui-internal/disallow_span_lint.rs:14:5
    |
-LL |     cx.span_lint(lint, span, msg, |_| {});
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+LL |     cx.span_lint(lint, span, |lint| { lint.primary_message(msg); });
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: this function does not add a link to our documentation, please use the `clippy_utils::diagnostics::span_lint*` functions instead (from clippy.toml)
    = note: `-D clippy::disallowed-methods` implied by `-D warnings`
@@ -11,8 +11,8 @@ LL |     cx.span_lint(lint, span, msg, |_| {});
 error: use of a disallowed method `rustc_middle::ty::context::TyCtxt::node_span_lint`
   --> tests/ui-internal/disallow_span_lint.rs:18:5
    |
-LL |     tcx.node_span_lint(lint, hir_id, span, msg, |_| {});
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+LL |     tcx.node_span_lint(lint, hir_id, span, |lint| { lint.primary_message(msg); });
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: this function does not add a link to our documentation, please use the `clippy_utils::diagnostics::span_lint_hir*` functions instead (from clippy.toml)