Skip to content

Commit 8f9d110

Browse files
authored
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``
2 parents 8a1403a + 2cb1ba3 commit 8f9d110

File tree

2 files changed

+82
-5
lines changed

2 files changed

+82
-5
lines changed

src/test/ui/lint/dead-code/issue-85255.rs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// check-pass
33

44
#![warn(dead_code)]
5+
#![feature(crate_visibility_modifier)]
56

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

19+
pub(crate) struct Foo1 {
20+
a: i32, //~ WARNING: field is never read
21+
pub b: i32, //~ WARNING: field is never read
22+
}
23+
24+
pub(crate) struct Bar1;
25+
26+
impl Bar1 {
27+
fn a(&self) -> i32 { 5 } //~ WARNING: associated function is never used
28+
pub fn b(&self) -> i32 { 6 } //~ WARNING: associated function is never used
29+
}
30+
31+
crate struct Foo2 {
32+
a: i32, //~ WARNING: field is never read
33+
pub b: i32, //~ WARNING: field is never read
34+
}
35+
36+
crate struct Bar2;
37+
38+
impl Bar2 {
39+
fn a(&self) -> i32 { 5 } //~ WARNING: associated function is never used
40+
pub fn b(&self) -> i32 { 6 } //~ WARNING: associated function is never used
41+
}
42+
1843

1944
fn main() {
2045
let _ = Foo { a: 1, b: 2 };
2146
let _ = Bar;
47+
let _ = Foo1 { a: 1, b: 2 };
48+
let _ = Bar1;
49+
let _ = Foo2 { a: 1, b: 2 };
50+
let _ = Bar2;
2251
}
Lines changed: 53 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
warning: field is never read: `a`
2-
--> $DIR/issue-85255.rs:7:5
2+
--> $DIR/issue-85255.rs:8:5
33
|
44
LL | a: i32,
55
| ^^^^^^
@@ -11,22 +11,70 @@ LL | #![warn(dead_code)]
1111
| ^^^^^^^^^
1212

1313
warning: field is never read: `b`
14-
--> $DIR/issue-85255.rs:8:5
14+
--> $DIR/issue-85255.rs:9:5
15+
|
16+
LL | pub b: i32,
17+
| ^^^^^^^^^^
18+
19+
warning: associated function is never used: `a`
20+
--> $DIR/issue-85255.rs:15:8
21+
|
22+
LL | fn a(&self) -> i32 { 5 }
23+
| ^
24+
25+
warning: associated function is never used: `b`
26+
--> $DIR/issue-85255.rs:16:12
27+
|
28+
LL | pub fn b(&self) -> i32 { 6 }
29+
| ^
30+
31+
warning: field is never read: `a`
32+
--> $DIR/issue-85255.rs:20:5
33+
|
34+
LL | a: i32,
35+
| ^^^^^^
36+
37+
warning: field is never read: `b`
38+
--> $DIR/issue-85255.rs:21:5
39+
|
40+
LL | pub b: i32,
41+
| ^^^^^^^^^^
42+
43+
warning: associated function is never used: `a`
44+
--> $DIR/issue-85255.rs:27:8
45+
|
46+
LL | fn a(&self) -> i32 { 5 }
47+
| ^
48+
49+
warning: associated function is never used: `b`
50+
--> $DIR/issue-85255.rs:28:12
51+
|
52+
LL | pub fn b(&self) -> i32 { 6 }
53+
| ^
54+
55+
warning: field is never read: `a`
56+
--> $DIR/issue-85255.rs:32:5
57+
|
58+
LL | a: i32,
59+
| ^^^^^^
60+
61+
warning: field is never read: `b`
62+
--> $DIR/issue-85255.rs:33:5
1563
|
1664
LL | pub b: i32,
1765
| ^^^^^^^^^^
1866

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

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

31-
warning: 4 warnings emitted
79+
warning: 12 warnings emitted
3280

0 commit comments

Comments
 (0)