Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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