Skip to content

Commit 6fb0fa0

Browse files
committed
add and update tests
1 parent 9c1e14e commit 6fb0fa0

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

tests/ui/pub_underscore_fields.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
#![allow(unused)]
22
#![warn(clippy::pub_underscore_fields)]
33

4+
use std::marker::PhantomData;
5+
46
mod inner {
7+
use std::marker;
8+
59
pub struct PubSuper {
610
pub(super) a: usize,
711
pub(super) _b: u8,
812
_c: i32,
13+
pub _mark: marker::PhantomData<u8>,
914
}
1015

1116
mod inner2 {
@@ -26,6 +31,7 @@ fn main() {
2631
a: u8,
2732
_b: usize,
2833
pub _c: i64,
34+
#[doc(hidden)]
2935
pub d: String,
3036
pub _e: Option<u8>,
3137
}
@@ -47,5 +53,6 @@ fn main() {
4753
pub struct NamedPub {
4854
r#pub: bool,
4955
_pub: String,
56+
pub(crate) _mark: PhantomData<u8>,
5057
}
5158
}

tests/ui/pub_underscore_fields.stderr

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: field marked as public but also inferred as unused because it's prefixed with `_`
2-
--> $DIR/pub_underscore_fields.rs:7:9
2+
--> $DIR/pub_underscore_fields.rs:11:9
33
|
44
LL | pub(super) _b: u8,
55
| ^^^^^^^^^^^^^
@@ -9,39 +9,39 @@ LL | pub(super) _b: u8,
99
= help: to override `-D warnings` add `#[allow(clippy::pub_underscore_fields)]`
1010

1111
error: field marked as public but also inferred as unused because it's prefixed with `_`
12-
--> $DIR/pub_underscore_fields.rs:14:13
12+
--> $DIR/pub_underscore_fields.rs:19:13
1313
|
1414
LL | pub(in crate::inner) _f: Option<()>,
1515
| ^^^^^^^^^^^^^^^^^^^^^^^
1616
|
1717
= help: consider removing the underscore, or making the field private
1818

1919
error: field marked as public but also inferred as unused because it's prefixed with `_`
20-
--> $DIR/pub_underscore_fields.rs:21:9
20+
--> $DIR/pub_underscore_fields.rs:26:9
2121
|
2222
LL | pub _a: usize,
2323
| ^^^^^^
2424
|
2525
= help: consider removing the underscore, or making the field private
2626

2727
error: field marked as public but also inferred as unused because it's prefixed with `_`
28-
--> $DIR/pub_underscore_fields.rs:28:9
28+
--> $DIR/pub_underscore_fields.rs:33:9
2929
|
3030
LL | pub _c: i64,
3131
| ^^^^^^
3232
|
3333
= help: consider removing the underscore, or making the field private
3434

3535
error: field marked as public but also inferred as unused because it's prefixed with `_`
36-
--> $DIR/pub_underscore_fields.rs:30:9
36+
--> $DIR/pub_underscore_fields.rs:36:9
3737
|
3838
LL | pub _e: Option<u8>,
3939
| ^^^^^^
4040
|
4141
= help: consider removing the underscore, or making the field private
4242

4343
error: field marked as public but also inferred as unused because it's prefixed with `_`
44-
--> $DIR/pub_underscore_fields.rs:43:9
44+
--> $DIR/pub_underscore_fields.rs:49:9
4545
|
4646
LL | pub(crate) _b: Option<String>,
4747
| ^^^^^^^^^^^^^

0 commit comments

Comments
 (0)