about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorCamille GILLOT <gillot.camille@gmail.com>2022-06-19 18:52:06 +0200
committerCamille GILLOT <gillot.camille@gmail.com>2022-06-22 20:48:18 +0200
commit02a42ff83d17ccb76ddf6dbaf1a0a56d91edd69c (patch)
treea48237af9964b934358823caf147f1d8344db5c7 /src
parenta319f3c992e8c77103b3c542bd9b20be63999205 (diff)
downloadrust-02a42ff83d17ccb76ddf6dbaf1a0a56d91edd69c.tar.gz
rust-02a42ff83d17ccb76ddf6dbaf1a0a56d91edd69c.zip
Rewrite dead-code pass to avoid fetching HIR.
Diffstat (limited to 'src')
-rw-r--r--src/test/ui/lint/dead-code/issue-85255.stderr40
-rw-r--r--src/test/ui/lint/dead-code/lint-dead-code-3.rs11
-rw-r--r--src/test/ui/lint/dead-code/lint-dead-code-3.stderr26
-rw-r--r--src/test/ui/lint/dead-code/lint-dead-code-4.stderr6
4 files changed, 53 insertions, 30 deletions
diff --git a/src/test/ui/lint/dead-code/issue-85255.stderr b/src/test/ui/lint/dead-code/issue-85255.stderr
index cff572e1b55..3497b952fdd 100644
--- a/src/test/ui/lint/dead-code/issue-85255.stderr
+++ b/src/test/ui/lint/dead-code/issue-85255.stderr
@@ -14,6 +14,26 @@ note: the lint level is defined here
 LL | #![warn(dead_code)]
    |         ^^^^^^^^^
 
+warning: fields `a` and `b` are never read
+  --> $DIR/issue-85255.rs:19:5
+   |
+LL | pub(crate) struct Foo1 {
+   |                   ---- fields in this struct
+LL |     a: i32,
+   |     ^
+LL |     pub b: i32,
+   |         ^
+
+warning: fields `a` and `b` are never read
+  --> $DIR/issue-85255.rs:31:5
+   |
+LL | pub(crate) struct Foo2 {
+   |                   ---- fields in this struct
+LL |     a: i32,
+   |     ^
+LL |     pub b: i32,
+   |         ^
+
 warning: associated function `a` is never used
   --> $DIR/issue-85255.rs:14:8
    |
@@ -26,16 +46,6 @@ warning: associated function `b` is never used
 LL |     pub fn b(&self) -> i32 { 6 }
    |            ^
 
-warning: fields `a` and `b` are never read
-  --> $DIR/issue-85255.rs:19:5
-   |
-LL | pub(crate) struct Foo1 {
-   |                   ---- fields in this struct
-LL |     a: i32,
-   |     ^
-LL |     pub b: i32,
-   |         ^
-
 warning: associated function `a` is never used
   --> $DIR/issue-85255.rs:26:8
    |
@@ -48,16 +58,6 @@ warning: associated function `b` is never used
 LL |     pub fn b(&self) -> i32 { 6 }
    |            ^
 
-warning: fields `a` and `b` are never read
-  --> $DIR/issue-85255.rs:31:5
-   |
-LL | pub(crate) struct Foo2 {
-   |                   ---- fields in this struct
-LL |     a: i32,
-   |     ^
-LL |     pub b: i32,
-   |         ^
-
 warning: associated function `a` is never used
   --> $DIR/issue-85255.rs:38:8
    |
diff --git a/src/test/ui/lint/dead-code/lint-dead-code-3.rs b/src/test/ui/lint/dead-code/lint-dead-code-3.rs
index c3e56063dc3..293fcdbc5ee 100644
--- a/src/test/ui/lint/dead-code/lint-dead-code-3.rs
+++ b/src/test/ui/lint/dead-code/lint-dead-code-3.rs
@@ -73,7 +73,18 @@ mod inner {
     fn f() {}
 }
 
+fn anon_const() -> [(); {
+    fn blah() {} //~ ERROR: function `blah` is never used
+    1
+}] {
+    [(); {
+        fn blah() {} //~ ERROR: function `blah` is never used
+        1
+    }]
+}
+
 pub fn foo() {
     let a: &dyn inner::Trait = &1_isize;
     a.f();
+    anon_const();
 }
diff --git a/src/test/ui/lint/dead-code/lint-dead-code-3.stderr b/src/test/ui/lint/dead-code/lint-dead-code-3.stderr
index 38578929848..26fc13bae08 100644
--- a/src/test/ui/lint/dead-code/lint-dead-code-3.stderr
+++ b/src/test/ui/lint/dead-code/lint-dead-code-3.stderr
@@ -10,12 +10,6 @@ note: the lint level is defined here
 LL | #![deny(dead_code)]
    |         ^^^^^^^^^
 
-error: associated function `foo` is never used
-  --> $DIR/lint-dead-code-3.rs:16:8
-   |
-LL |     fn foo(&self) {
-   |        ^^^
-
 error: function `bar` is never used
   --> $DIR/lint-dead-code-3.rs:21:4
    |
@@ -28,11 +22,29 @@ error: enum `c_void` is never used
 LL | enum c_void {}
    |      ^^^^^^
 
+error: function `blah` is never used
+  --> $DIR/lint-dead-code-3.rs:77:8
+   |
+LL |     fn blah() {}
+   |        ^^^^
+
+error: function `blah` is never used
+  --> $DIR/lint-dead-code-3.rs:81:12
+   |
+LL |         fn blah() {}
+   |            ^^^^
+
+error: associated function `foo` is never used
+  --> $DIR/lint-dead-code-3.rs:16:8
+   |
+LL |     fn foo(&self) {
+   |        ^^^
+
 error: function `free` is never used
   --> $DIR/lint-dead-code-3.rs:62:8
    |
 LL |     fn free(p: *const c_void);
    |        ^^^^
 
-error: aborting due to 5 previous errors
+error: aborting due to 7 previous errors
 
diff --git a/src/test/ui/lint/dead-code/lint-dead-code-4.stderr b/src/test/ui/lint/dead-code/lint-dead-code-4.stderr
index 8cb4621d543..668c1dacf95 100644
--- a/src/test/ui/lint/dead-code/lint-dead-code-4.stderr
+++ b/src/test/ui/lint/dead-code/lint-dead-code-4.stderr
@@ -32,9 +32,9 @@ LL | enum ABC {
 error: fields `b` and `c` are never read
   --> $DIR/lint-dead-code-4.rs:39:9
    |
-LL | enum IJK {
-   |      --- fields in this enum
-...
+LL |     J {
+   |     - fields in this variant
+LL |         a: String,
 LL |         b: i32,
    |         ^
 LL |         c: i32,