about summary refs log tree commit diff
path: root/tests/ui/lint
diff options
context:
space:
mode:
authorKarol Zwolak <karolzwolak7@gmail.com>2025-04-28 09:21:10 +0200
committerKarol Zwolak <karolzwolak7@gmail.com>2025-08-19 21:27:10 +0200
commit9a29e1693d5122990dcd6c87a5a7b2b2b85f10da (patch)
treec432161cb7aaeb9df6c1661ed5b48810cef5a475 /tests/ui/lint
parent16ad385579cebb6f7d53367c552661b6b51a4a02 (diff)
downloadrust-9a29e1693d5122990dcd6c87a5a7b2b2b85f10da.tar.gz
rust-9a29e1693d5122990dcd6c87a5a7b2b2b85f10da.zip
mention lint group in default level lint note
Diffstat (limited to 'tests/ui/lint')
-rw-r--r--tests/ui/lint/mention-lint-group-in-default-level-lint-note-issue-65464.rs22
-rw-r--r--tests/ui/lint/mention-lint-group-in-default-level-lint-note-issue-65464.stderr23
2 files changed, 45 insertions, 0 deletions
diff --git a/tests/ui/lint/mention-lint-group-in-default-level-lint-note-issue-65464.rs b/tests/ui/lint/mention-lint-group-in-default-level-lint-note-issue-65464.rs
new file mode 100644
index 00000000000..5db7cc02baa
--- /dev/null
+++ b/tests/ui/lint/mention-lint-group-in-default-level-lint-note-issue-65464.rs
@@ -0,0 +1,22 @@
+//@ check-pass
+
+// Verify information about membership to builtin lint group is included in the lint message when
+// explaining lint level and source for builtin lints with default settings.
+//
+// Ideally, we'd like to use lints that are part of `unused` group as shown in the issue.
+// This is not possible in a ui test, because `unused` lints are enabled with `-A unused`
+// in such tests, and the we're testing a scenario with no modification to the default settings.
+
+fn main() {
+    // additional context is provided only if the level is not explicitly set
+    let WrongCase = 1;
+    //~^ WARN [non_snake_case]
+    //~| NOTE `#[warn(non_snake_case)]` (part of `#[warn(nonstandard_style)]`) on by default
+
+    // unchanged message if the level is explicitly set
+    // even if the level is the same as the default
+    #[warn(nonstandard_style)] //~ NOTE the lint level is defined here
+    let WrongCase = 2;
+    //~^ WARN [non_snake_case]
+    //~| NOTE `#[warn(non_snake_case)]` implied by `#[warn(nonstandard_style)]`
+}
diff --git a/tests/ui/lint/mention-lint-group-in-default-level-lint-note-issue-65464.stderr b/tests/ui/lint/mention-lint-group-in-default-level-lint-note-issue-65464.stderr
new file mode 100644
index 00000000000..86ec59220f0
--- /dev/null
+++ b/tests/ui/lint/mention-lint-group-in-default-level-lint-note-issue-65464.stderr
@@ -0,0 +1,23 @@
+warning: variable `WrongCase` should have a snake case name
+  --> $DIR/mention-lint-group-in-default-level-lint-note-issue-65464.rs:12:9
+   |
+LL |     let WrongCase = 1;
+   |         ^^^^^^^^^ help: convert the identifier to snake case: `wrong_case`
+   |
+   = note: `#[warn(non_snake_case)]` (part of `#[warn(nonstandard_style)]`) on by default
+
+warning: variable `WrongCase` should have a snake case name
+  --> $DIR/mention-lint-group-in-default-level-lint-note-issue-65464.rs:19:9
+   |
+LL |     let WrongCase = 2;
+   |         ^^^^^^^^^ help: convert the identifier to snake case: `wrong_case`
+   |
+note: the lint level is defined here
+  --> $DIR/mention-lint-group-in-default-level-lint-note-issue-65464.rs:18:12
+   |
+LL |     #[warn(nonstandard_style)]
+   |            ^^^^^^^^^^^^^^^^^
+   = note: `#[warn(non_snake_case)]` implied by `#[warn(nonstandard_style)]`
+
+warning: 2 warnings emitted
+