diff --git a/src/test/ui/lint/dead-code/issue-85255.rs b/src/test/ui/lint/dead-code/issue-85255.rs index 9a4d9fbad35..8c4aad66d47 100644 --- a/src/test/ui/lint/dead-code/issue-85255.rs +++ b/src/test/ui/lint/dead-code/issue-85255.rs @@ -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; } diff --git a/src/test/ui/lint/dead-code/issue-85255.stderr b/src/test/ui/lint/dead-code/issue-85255.stderr index 73646439295..736b1a20422 100644 --- a/src/test/ui/lint/dead-code/issue-85255.stderr +++ b/src/test/ui/lint/dead-code/issue-85255.stderr @@ -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