about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorTakayuki Maeda <takoyaki0316@gmail.com>2022-06-08 16:34:58 +0900
committerTakayuki Maeda <takoyaki0316@gmail.com>2022-06-19 18:32:56 +0900
commitda27551f3ab25b395fa96709c7a559d04748d718 (patch)
tree7cf0b40a5498041d4023fddbde4ddac3c6478fdb /src
parent5fb8a3926619a18a2e31627e4cdf05f16530b0eb (diff)
downloadrust-da27551f3ab25b395fa96709c7a559d04748d718.tar.gz
rust-da27551f3ab25b395fa96709c7a559d04748d718.zip
emit only one note per unused struct field
Diffstat (limited to 'src')
-rw-r--r--src/test/ui/derives/clone-debug-dead-code-in-the-same-struct.rs12
-rw-r--r--src/test/ui/derives/clone-debug-dead-code-in-the-same-struct.stderr33
2 files changed, 45 insertions, 0 deletions
diff --git a/src/test/ui/derives/clone-debug-dead-code-in-the-same-struct.rs b/src/test/ui/derives/clone-debug-dead-code-in-the-same-struct.rs
new file mode 100644
index 00000000000..f5cff8ae9e5
--- /dev/null
+++ b/src/test/ui/derives/clone-debug-dead-code-in-the-same-struct.rs
@@ -0,0 +1,12 @@
+#![forbid(dead_code)]
+
+#[derive(Debug)]
+pub struct Whatever {
+    pub field0: (),
+    field1: (), //~ERROR field is never read: `field1
+    field2: (), //~ERROR field is never read: `field2
+    field3: (), //~ERROR field is never read: `field3
+    field4: (), //~ERROR field is never read: `field4
+}
+
+fn main() {}
diff --git a/src/test/ui/derives/clone-debug-dead-code-in-the-same-struct.stderr b/src/test/ui/derives/clone-debug-dead-code-in-the-same-struct.stderr
new file mode 100644
index 00000000000..2190a0307bf
--- /dev/null
+++ b/src/test/ui/derives/clone-debug-dead-code-in-the-same-struct.stderr
@@ -0,0 +1,33 @@
+error: field is never read: `field1`
+  --> $DIR/clone-debug-dead-code-in-the-same-struct.rs:6:5
+   |
+LL |     field1: (),
+   |     ^^^^^^^^^^
+   |
+note: the lint level is defined here
+  --> $DIR/clone-debug-dead-code-in-the-same-struct.rs:1:11
+   |
+LL | #![forbid(dead_code)]
+   |           ^^^^^^^^^
+   = note: `Whatever` has a derived impl for the trait `Debug`, but this is intentionally ignored during dead code analysis
+
+error: field is never read: `field2`
+  --> $DIR/clone-debug-dead-code-in-the-same-struct.rs:7:5
+   |
+LL |     field2: (),
+   |     ^^^^^^^^^^
+
+error: field is never read: `field3`
+  --> $DIR/clone-debug-dead-code-in-the-same-struct.rs:8:5
+   |
+LL |     field3: (),
+   |     ^^^^^^^^^^
+
+error: field is never read: `field4`
+  --> $DIR/clone-debug-dead-code-in-the-same-struct.rs:9:5
+   |
+LL |     field4: (),
+   |     ^^^^^^^^^^
+
+error: aborting due to 4 previous errors
+