add many tests

Signed-off-by: TennyZhuang <zty0826@gmail.com>
This commit is contained in:
TennyZhuang 2022-10-16 16:57:31 +08:00
parent b10882ab91
commit abd5db3321
2 changed files with 41 additions and 5 deletions

View File

@ -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,
}
}

View File

@ -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<u32, String>,
| ^^^
@ -8,12 +8,28 @@ LL | pub paths: HashMap<u32, String>,
= 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