More tests for issue-85255

This commit is contained in:
hi-rustin 2021-05-16 10:18:28 +08:00
parent d565c74887
commit 2cb1ba3671
2 changed files with 82 additions and 5 deletions

View file

@ -2,6 +2,7 @@
// check-pass
#![warn(dead_code)]
#![feature(crate_visibility_modifier)]
struct Foo {
a: i32, //~ WARNING: field is never read
@ -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;
}

View file

@ -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,
| ^^^^^^
@ -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:14:8
--> $DIR/issue-85255.rs:15:8
|
LL | fn a(&self) -> i32 { 5 }
| ^
warning: associated function is never used: `b`
--> $DIR/issue-85255.rs:15:12
--> $DIR/issue-85255.rs:16:12
|
LL | pub fn b(&self) -> i32 { 6 }
| ^
warning: 4 warnings emitted
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:39:8
|
LL | fn a(&self) -> i32 { 5 }
| ^
warning: associated function is never used: `b`
--> $DIR/issue-85255.rs:40:12
|
LL | pub fn b(&self) -> i32 { 6 }
| ^
warning: 12 warnings emitted