diff options
| author | TennyZhuang <zty0826@gmail.com> | 2022-10-16 16:02:23 +0800 |
|---|---|---|
| committer | TennyZhuang <zty0826@gmail.com> | 2022-10-16 16:03:50 +0800 |
| commit | 7ac97b69fc81fcd5cbd2a7c862187f6a6c6ea354 (patch) | |
| tree | cbb596de635702a984233c4ede7e2aba31a2fc6e /src | |
| parent | ff33d6e712ebf1068e8d6109e56f2f5d1e82054c (diff) | |
| download | rust-7ac97b69fc81fcd5cbd2a7c862187f6a6c6ea354.tar.gz rust-7ac97b69fc81fcd5cbd2a7c862187f6a6c6ea354.zip | |
Add new lint `partial_pub_fields`
Signed-off-by: TennyZhuang <zty0826@gmail.com>
Diffstat (limited to 'src')
| -rw-r--r-- | src/docs.rs | 1 | ||||
| -rw-r--r-- | src/docs/partial_pub_fields.txt | 27 |
2 files changed, 28 insertions, 0 deletions
diff --git a/src/docs.rs b/src/docs.rs index 41c31f91bca..b8b4286b488 100644 --- a/src/docs.rs +++ b/src/docs.rs @@ -395,6 +395,7 @@ docs! { "panic", "panic_in_result_fn", "panicking_unwrap", + "partial_pub_fields", "partialeq_ne_impl", "partialeq_to_none", "path_buf_push_overwrite", diff --git a/src/docs/partial_pub_fields.txt b/src/docs/partial_pub_fields.txt new file mode 100644 index 00000000000..a332ec8c28a --- /dev/null +++ b/src/docs/partial_pub_fields.txt @@ -0,0 +1,27 @@ +### What it does +Checks whether partial fields of a struct are public. + +Either make all fields of a type public, or make none of them public + +### Why is this bad? +Most types should either be: +* Abstract data types: complex objects with opaque implementation which guard +interior invariants and expose intentionally limited API to the outside world. +* Data: relatively simple objects which group a bunch of related attributes together. + +### Example +``` +pub struct Color { + pub r, + pub g, + b, +} +``` +Use instead: +``` +pub struct Color { + pub r, + pub g, + pub b, +} +``` \ No newline at end of file |
