mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 00:03:43 +00:00
Rollup merge of #85355 - hi-rustin:rustin-patch-issue-85255, r=varkor
More tests for issue-85255 Add more test for `pub(crate)`. r? ``@varkor``
This commit is contained in:
commit
8f9d1107b5
@ -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;
|
||||
}
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user