diff --git a/tests/ui/partial_pub_fields.rs b/tests/ui/partial_pub_fields.rs index e1a4b482799..668545da844 100644 --- a/tests/ui/partial_pub_fields.rs +++ b/tests/ui/partial_pub_fields.rs @@ -2,8 +2,6 @@ #![warn(clippy::partial_pub_fields)] fn main() { - // test code goes here - use std::collections::HashMap; #[derive(Default)] @@ -17,4 +15,26 @@ pub struct Color { pub g: u8, b: u8, } + + pub struct Point(i32, pub i32); + + pub struct Visibility { + r#pub: bool, + pub pos: u32, + } + + // Don't lint on empty structs; + pub struct Empty1; + pub struct Empty2(); + pub struct Empty3 {}; + + // Don't lint on structs with one field. + pub struct Single1(i32); + pub struct Single2(pub i32); + pub struct Single3 { + v1: i32, + } + pub struct Single4 { + pub v1: i32, + } } diff --git a/tests/ui/partial_pub_fields.stderr b/tests/ui/partial_pub_fields.stderr index f7f23c85a67..84cfc1a9194 100644 --- a/tests/ui/partial_pub_fields.stderr +++ b/tests/ui/partial_pub_fields.stderr @@ -1,5 +1,5 @@ error: mixed usage of pub and non-pub fields - --> $DIR/partial_pub_fields.rs:12:9 + --> $DIR/partial_pub_fields.rs:10:9 | LL | pub paths: HashMap, | ^^^ @@ -8,12 +8,28 @@ LL | pub paths: HashMap, = note: `-D clippy::partial-pub-fields` implied by `-D warnings` error: mixed usage of pub and non-pub fields - --> $DIR/partial_pub_fields.rs:18:9 + --> $DIR/partial_pub_fields.rs:16:9 | LL | b: u8, | ^ | = help: consider using public field here -error: aborting due to 2 previous errors +error: mixed usage of pub and non-pub fields + --> $DIR/partial_pub_fields.rs:19:27 + | +LL | pub struct Point(i32, pub i32); + | ^^^ + | + = help: consider using private field here + +error: mixed usage of pub and non-pub fields + --> $DIR/partial_pub_fields.rs:23:9 + | +LL | pub pos: u32, + | ^^^ + | + = help: consider using private field here + +error: aborting due to 4 previous errors