Skip to content

Commit

Permalink
Rollup merge of #85355 - hi-rustin:rustin-patch-issue-85255, r=varkor
Browse files Browse the repository at this point in the history
More tests for issue-85255

Add more test for `pub(crate)`.

r? ``@varkor``
  • Loading branch information
RalfJung authored May 17, 2021
2 parents 8a1403a + 2cb1ba3 commit 8f9d110
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 5 deletions.
29 changes: 29 additions & 0 deletions src/test/ui/lint/dead-code/issue-85255.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// check-pass

#![warn(dead_code)]
#![feature(crate_visibility_modifier)]

struct Foo {
a: i32, //~ WARNING: field is never read
Expand All @@ -15,8 +16,36 @@ impl Bar {
pub fn b(&self) -> i32 { 6 } //~ WARNING: associated function is never used
}

pub(crate) struct Foo1 {
a: i32, //~ WARNING: field is never read
pub b: i32, //~ WARNING: field is never read
}

pub(crate) struct Bar1;

impl Bar1 {
fn a(&self) -> i32 { 5 } //~ WARNING: associated function is never used
pub fn b(&self) -> i32 { 6 } //~ WARNING: associated function is never used
}

crate struct Foo2 {
a: i32, //~ WARNING: field is never read
pub b: i32, //~ WARNING: field is never read
}

crate struct Bar2;

impl Bar2 {
fn a(&self) -> i32 { 5 } //~ WARNING: associated function is never used
pub fn b(&self) -> i32 { 6 } //~ WARNING: associated function is never used
}


fn main() {
let _ = Foo { a: 1, b: 2 };
let _ = Bar;
let _ = Foo1 { a: 1, b: 2 };
let _ = Bar1;
let _ = Foo2 { a: 1, b: 2 };
let _ = Bar2;
}
58 changes: 53 additions & 5 deletions src/test/ui/lint/dead-code/issue-85255.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
warning: field is never read: `a`
--> $DIR/issue-85255.rs:7:5
--> $DIR/issue-85255.rs:8:5
|
LL | a: i32,
| ^^^^^^
Expand All @@ -11,22 +11,70 @@ LL | #![warn(dead_code)]
| ^^^^^^^^^

warning: field is never read: `b`
--> $DIR/issue-85255.rs:8:5
--> $DIR/issue-85255.rs:9:5
|
LL | pub b: i32,
| ^^^^^^^^^^

warning: associated function is never used: `a`
--> $DIR/issue-85255.rs:15:8
|
LL | fn a(&self) -> i32 { 5 }
| ^

warning: associated function is never used: `b`
--> $DIR/issue-85255.rs:16:12
|
LL | pub fn b(&self) -> i32 { 6 }
| ^

warning: field is never read: `a`
--> $DIR/issue-85255.rs:20:5
|
LL | a: i32,
| ^^^^^^

warning: field is never read: `b`
--> $DIR/issue-85255.rs:21:5
|
LL | pub b: i32,
| ^^^^^^^^^^

warning: associated function is never used: `a`
--> $DIR/issue-85255.rs:27:8
|
LL | fn a(&self) -> i32 { 5 }
| ^

warning: associated function is never used: `b`
--> $DIR/issue-85255.rs:28:12
|
LL | pub fn b(&self) -> i32 { 6 }
| ^

warning: field is never read: `a`
--> $DIR/issue-85255.rs:32:5
|
LL | a: i32,
| ^^^^^^

warning: field is never read: `b`
--> $DIR/issue-85255.rs:33:5
|
LL | pub b: i32,
| ^^^^^^^^^^

warning: associated function is never used: `a`
--> $DIR/issue-85255.rs:14:8
--> $DIR/issue-85255.rs:39:8
|
LL | fn a(&self) -> i32 { 5 }
| ^

warning: associated function is never used: `b`
--> $DIR/issue-85255.rs:15:12
--> $DIR/issue-85255.rs:40:12
|
LL | pub fn b(&self) -> i32 { 6 }
| ^

warning: 4 warnings emitted
warning: 12 warnings emitted

0 comments on commit 8f9d110

Please sign in to comment.