From 4810db7721a36a4f147e653a82905a8e3980723e Mon Sep 17 00:00:00 2001 From: U9G Date: Fri, 24 Nov 2023 23:44:23 -0500 Subject: [PATCH 01/15] implement struct_now_doc_hidden lint --- src/lints/struct_now_doc_hidden.ron | 50 +++++++++++++++++++ src/query.rs | 1 + .../struct_now_doc_hidden/new/Cargo.toml | 7 +++ .../struct_now_doc_hidden/new/src/lib.rs | 4 ++ .../struct_now_doc_hidden/old/Cargo.toml | 7 +++ .../struct_now_doc_hidden/old/src/lib.rs | 3 ++ test_outputs/struct_now_doc_hidden.output.ron | 46 +++++++++++++++++ 7 files changed, 118 insertions(+) create mode 100644 src/lints/struct_now_doc_hidden.ron create mode 100644 test_crates/struct_now_doc_hidden/new/Cargo.toml create mode 100644 test_crates/struct_now_doc_hidden/new/src/lib.rs create mode 100644 test_crates/struct_now_doc_hidden/old/Cargo.toml create mode 100644 test_crates/struct_now_doc_hidden/old/src/lib.rs create mode 100644 test_outputs/struct_now_doc_hidden.output.ron diff --git a/src/lints/struct_now_doc_hidden.ron b/src/lints/struct_now_doc_hidden.ron new file mode 100644 index 00000000..bd64f091 --- /dev/null +++ b/src/lints/struct_now_doc_hidden.ron @@ -0,0 +1,50 @@ +SemverQuery( + id: "struct_now_doc_hidden", + human_readable_name: "pub struct is now #[doc(hidden)]", + description: "A pub struct is now hidden from documentation effectively removing it from the crate's public api.", + required_update: Major, + reference_link: Some("https://doc.rust-lang.org/rustdoc/write-documentation/the-doc-attribute.html#hidden"), + query: r#" + { + CrateDiff { + baseline { + item { + ... on Struct { + visibility_limit @filter(op: "=", value: ["$public"]) + struct_type @output @tag + + importable_path { + path @output @tag + public_api @filter(op: "=", value: ["$true"]) + } + } + } + } + current { + item { + ... on Struct { + visibility_limit @filter(op: "=", value: ["$public"]) + struct_name: name @output + struct_type @filter(op: "=", value: ["%struct_type"]) + + importable_path { + path @filter(op: "=", value: ["%path"]) + public_api @filter(op: "!=", value: ["$true"]) + } + + span_: span @optional { + filename @output + begin_line @output + } + } + } + } + } + }"#, + arguments: { + "public": "public", + "true": true, + }, + error_message: "A publicly visible struct is now hidden via #[doc(hidden)].", + per_result_error_template: Some("Struct {{struct_name}} in file {{span_filename}}:{{span_begin_line}}"), +) diff --git a/src/query.rs b/src/query.rs index 2a45dd0e..c35e8ed0 100644 --- a/src/query.rs +++ b/src/query.rs @@ -495,6 +495,7 @@ add_lints!( struct_marked_non_exhaustive, struct_missing, struct_must_use_added, + struct_now_doc_hidden, struct_pub_field_missing, struct_repr_c_removed, struct_repr_transparent_removed, diff --git a/test_crates/struct_now_doc_hidden/new/Cargo.toml b/test_crates/struct_now_doc_hidden/new/Cargo.toml new file mode 100644 index 00000000..9e827d01 --- /dev/null +++ b/test_crates/struct_now_doc_hidden/new/Cargo.toml @@ -0,0 +1,7 @@ +[package] +publish = false +name = "struct_now_doc_hidden" +version = "0.1.0" +edition = "2021" + +[dependencies] diff --git a/test_crates/struct_now_doc_hidden/new/src/lib.rs b/test_crates/struct_now_doc_hidden/new/src/lib.rs new file mode 100644 index 00000000..a66ae2b5 --- /dev/null +++ b/test_crates/struct_now_doc_hidden/new/src/lib.rs @@ -0,0 +1,4 @@ +struct StayingKnown; + +#[doc(hidden)] +pub struct Example; diff --git a/test_crates/struct_now_doc_hidden/old/Cargo.toml b/test_crates/struct_now_doc_hidden/old/Cargo.toml new file mode 100644 index 00000000..9e827d01 --- /dev/null +++ b/test_crates/struct_now_doc_hidden/old/Cargo.toml @@ -0,0 +1,7 @@ +[package] +publish = false +name = "struct_now_doc_hidden" +version = "0.1.0" +edition = "2021" + +[dependencies] diff --git a/test_crates/struct_now_doc_hidden/old/src/lib.rs b/test_crates/struct_now_doc_hidden/old/src/lib.rs new file mode 100644 index 00000000..6b944506 --- /dev/null +++ b/test_crates/struct_now_doc_hidden/old/src/lib.rs @@ -0,0 +1,3 @@ +struct StayingKnown; + +pub struct Example; diff --git a/test_outputs/struct_now_doc_hidden.output.ron b/test_outputs/struct_now_doc_hidden.output.ron new file mode 100644 index 00000000..1f267683 --- /dev/null +++ b/test_outputs/struct_now_doc_hidden.output.ron @@ -0,0 +1,46 @@ +{ + "./test_crates/struct_now_doc_hidden/": [ + { + "path": List([ + String("struct_now_doc_hidden"), + String("Example"), + ]), + "span_begin_line": Uint64(4), + "span_filename": String("src/lib.rs"), + "struct_name": String("Example"), + "struct_type": String("unit"), + }, + ], + "./test_crates/type_hidden_from_public_api/": [ + { + "path": List([ + String("type_hidden_from_public_api"), + String("ExamplePlainStruct"), + ]), + "span_begin_line": Uint64(2), + "span_filename": String("src/lib.rs"), + "struct_name": String("ExamplePlainStruct"), + "struct_type": String("plain"), + }, + { + "path": List([ + String("type_hidden_from_public_api"), + String("ExampleTupleStruct"), + ]), + "span_begin_line": Uint64(7), + "span_filename": String("src/lib.rs"), + "struct_name": String("ExampleTupleStruct"), + "struct_type": String("tuple"), + }, + { + "path": List([ + String("type_hidden_from_public_api"), + String("ExampleUnitStruct"), + ]), + "span_begin_line": Uint64(10), + "span_filename": String("src/lib.rs"), + "struct_name": String("ExampleUnitStruct"), + "struct_type": String("unit"), + }, + ], +} \ No newline at end of file From 56a3791263590313dfa7f0b9fca59ada83bd951b Mon Sep 17 00:00:00 2001 From: u9g Date: Sat, 25 Nov 2023 12:14:08 -0500 Subject: [PATCH 02/15] Update src/lints/struct_now_doc_hidden.ron Co-authored-by: Predrag Gruevski <2348618+obi1kenobi@users.noreply.github.com> --- src/lints/struct_now_doc_hidden.ron | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lints/struct_now_doc_hidden.ron b/src/lints/struct_now_doc_hidden.ron index bd64f091..f05b362c 100644 --- a/src/lints/struct_now_doc_hidden.ron +++ b/src/lints/struct_now_doc_hidden.ron @@ -1,7 +1,7 @@ SemverQuery( id: "struct_now_doc_hidden", human_readable_name: "pub struct is now #[doc(hidden)]", - description: "A pub struct is now hidden from documentation effectively removing it from the crate's public api.", + description: "A pub struct is now marked #[doc(hidden)] and is thus no longer part of the public API.", required_update: Major, reference_link: Some("https://doc.rust-lang.org/rustdoc/write-documentation/the-doc-attribute.html#hidden"), query: r#" From a8d279c9df55005b035999b070eaa9990c97caac Mon Sep 17 00:00:00 2001 From: U9G Date: Mon, 27 Nov 2023 23:06:03 -0500 Subject: [PATCH 03/15] no need to filter on struct type --- src/lints/struct_now_doc_hidden.ron | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/lints/struct_now_doc_hidden.ron b/src/lints/struct_now_doc_hidden.ron index f05b362c..dd65c048 100644 --- a/src/lints/struct_now_doc_hidden.ron +++ b/src/lints/struct_now_doc_hidden.ron @@ -11,7 +11,6 @@ SemverQuery( item { ... on Struct { visibility_limit @filter(op: "=", value: ["$public"]) - struct_type @output @tag importable_path { path @output @tag @@ -25,7 +24,6 @@ SemverQuery( ... on Struct { visibility_limit @filter(op: "=", value: ["$public"]) struct_name: name @output - struct_type @filter(op: "=", value: ["%struct_type"]) importable_path { path @filter(op: "=", value: ["%path"]) From 35897c8e114c43ec1dd4cd45ee453fd29a68b0de Mon Sep 17 00:00:00 2001 From: u9g Date: Mon, 27 Nov 2023 23:06:56 -0500 Subject: [PATCH 04/15] Update src/lints/struct_now_doc_hidden.ron Co-authored-by: Predrag Gruevski <2348618+obi1kenobi@users.noreply.github.com> --- src/lints/struct_now_doc_hidden.ron | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lints/struct_now_doc_hidden.ron b/src/lints/struct_now_doc_hidden.ron index dd65c048..4cfef5f5 100644 --- a/src/lints/struct_now_doc_hidden.ron +++ b/src/lints/struct_now_doc_hidden.ron @@ -44,5 +44,5 @@ SemverQuery( "true": true, }, error_message: "A publicly visible struct is now hidden via #[doc(hidden)].", - per_result_error_template: Some("Struct {{struct_name}} in file {{span_filename}}:{{span_begin_line}}"), + per_result_error_template: Some("struct {{struct_name}} in file {{span_filename}}:{{span_begin_line}}"), ) From b3c3e45991441400abf5b5bfc404c1348625025f Mon Sep 17 00:00:00 2001 From: u9g Date: Mon, 27 Nov 2023 23:08:27 -0500 Subject: [PATCH 05/15] Update src/lints/struct_now_doc_hidden.ron Co-authored-by: Predrag Gruevski <2348618+obi1kenobi@users.noreply.github.com> --- src/lints/struct_now_doc_hidden.ron | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lints/struct_now_doc_hidden.ron b/src/lints/struct_now_doc_hidden.ron index 4cfef5f5..088cf369 100644 --- a/src/lints/struct_now_doc_hidden.ron +++ b/src/lints/struct_now_doc_hidden.ron @@ -43,6 +43,6 @@ SemverQuery( "public": "public", "true": true, }, - error_message: "A publicly visible struct is now hidden via #[doc(hidden)].", + error_message: "A pub struct is now #[doc(hidden)], removing it from the crate's public API.", per_result_error_template: Some("struct {{struct_name}} in file {{span_filename}}:{{span_begin_line}}"), ) From ded09b03ee5cd7b561e5504653ea442f6951b15d Mon Sep 17 00:00:00 2001 From: U9G Date: Mon, 27 Nov 2023 23:09:31 -0500 Subject: [PATCH 06/15] fix no end new line --- test_outputs/struct_now_doc_hidden.output.ron | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test_outputs/struct_now_doc_hidden.output.ron b/test_outputs/struct_now_doc_hidden.output.ron index 1f267683..021371c6 100644 --- a/test_outputs/struct_now_doc_hidden.output.ron +++ b/test_outputs/struct_now_doc_hidden.output.ron @@ -43,4 +43,4 @@ "struct_type": String("unit"), }, ], -} \ No newline at end of file +} From 17ca63702ada42ec02ffe725a9ff0b65fd406c09 Mon Sep 17 00:00:00 2001 From: U9G Date: Mon, 27 Nov 2023 23:17:38 -0500 Subject: [PATCH 07/15] remove struct_type from expected output --- test_outputs/struct_now_doc_hidden.output.ron | 4 ---- 1 file changed, 4 deletions(-) diff --git a/test_outputs/struct_now_doc_hidden.output.ron b/test_outputs/struct_now_doc_hidden.output.ron index 021371c6..5074e80b 100644 --- a/test_outputs/struct_now_doc_hidden.output.ron +++ b/test_outputs/struct_now_doc_hidden.output.ron @@ -8,7 +8,6 @@ "span_begin_line": Uint64(4), "span_filename": String("src/lib.rs"), "struct_name": String("Example"), - "struct_type": String("unit"), }, ], "./test_crates/type_hidden_from_public_api/": [ @@ -20,7 +19,6 @@ "span_begin_line": Uint64(2), "span_filename": String("src/lib.rs"), "struct_name": String("ExamplePlainStruct"), - "struct_type": String("plain"), }, { "path": List([ @@ -30,7 +28,6 @@ "span_begin_line": Uint64(7), "span_filename": String("src/lib.rs"), "struct_name": String("ExampleTupleStruct"), - "struct_type": String("tuple"), }, { "path": List([ @@ -40,7 +37,6 @@ "span_begin_line": Uint64(10), "span_filename": String("src/lib.rs"), "struct_name": String("ExampleUnitStruct"), - "struct_type": String("unit"), }, ], } From 88ced54ea60803c128cd7f9164d8735464967cf5 Mon Sep 17 00:00:00 2001 From: U9G Date: Mon, 27 Nov 2023 23:40:15 -0500 Subject: [PATCH 08/15] add struct-in-mod tests --- test_crates/struct_now_doc_hidden/new/src/lib.rs | 15 ++++++++++++++- test_crates/struct_now_doc_hidden/old/src/lib.rs | 8 +++++++- test_outputs/struct_now_doc_hidden.output.ron | 12 +++++++++++- 3 files changed, 32 insertions(+), 3 deletions(-) diff --git a/test_crates/struct_now_doc_hidden/new/src/lib.rs b/test_crates/struct_now_doc_hidden/new/src/lib.rs index a66ae2b5..cd416154 100644 --- a/test_crates/struct_now_doc_hidden/new/src/lib.rs +++ b/test_crates/struct_now_doc_hidden/new/src/lib.rs @@ -1,4 +1,17 @@ -struct StayingKnown; +mod MyNonPublicMod { + // despite adding #[doc(hidden)], this struct is in a + // private mod, so it isn't part of the crate's public + // api + #[doc(hidden)] + pub struct MyStruct; +} + +pub mod MyPublicMod { + // added #[doc(hidden)], however this struct is in a + // public mod, so it is part of the crate's public api + #[doc(hidden)] + pub struct MyStruct; +} #[doc(hidden)] pub struct Example; diff --git a/test_crates/struct_now_doc_hidden/old/src/lib.rs b/test_crates/struct_now_doc_hidden/old/src/lib.rs index 6b944506..5cc0a0d7 100644 --- a/test_crates/struct_now_doc_hidden/old/src/lib.rs +++ b/test_crates/struct_now_doc_hidden/old/src/lib.rs @@ -1,3 +1,9 @@ -struct StayingKnown; +mod MyNonPublicMod { + pub struct MyStruct; +} + +pub mod MyPublicMod { + pub struct MyStruct; +} pub struct Example; diff --git a/test_outputs/struct_now_doc_hidden.output.ron b/test_outputs/struct_now_doc_hidden.output.ron index 5074e80b..e438c972 100644 --- a/test_outputs/struct_now_doc_hidden.output.ron +++ b/test_outputs/struct_now_doc_hidden.output.ron @@ -1,11 +1,21 @@ { "./test_crates/struct_now_doc_hidden/": [ + { + "path": List([ + String("struct_now_doc_hidden"), + String("MyPublicMod"), + String("MyStruct"), + ]), + "span_begin_line": Uint64(13), + "span_filename": String("src/lib.rs"), + "struct_name": String("MyStruct"), + }, { "path": List([ String("struct_now_doc_hidden"), String("Example"), ]), - "span_begin_line": Uint64(4), + "span_begin_line": Uint64(17), "span_filename": String("src/lib.rs"), "struct_name": String("Example"), }, From 38115fda680c2470c8d5fa8a5b246f87f3cbefa4 Mon Sep 17 00:00:00 2001 From: U9G Date: Mon, 27 Nov 2023 23:46:13 -0500 Subject: [PATCH 09/15] add even more nested mods --- .../struct_now_doc_hidden/new/src/lib.rs | 19 +++++++++++++++++++ .../struct_now_doc_hidden/old/src/lib.rs | 12 ++++++++++++ test_outputs/struct_now_doc_hidden.output.ron | 13 ++++++++++++- 3 files changed, 43 insertions(+), 1 deletion(-) diff --git a/test_crates/struct_now_doc_hidden/new/src/lib.rs b/test_crates/struct_now_doc_hidden/new/src/lib.rs index cd416154..60e973d9 100644 --- a/test_crates/struct_now_doc_hidden/new/src/lib.rs +++ b/test_crates/struct_now_doc_hidden/new/src/lib.rs @@ -13,5 +13,24 @@ pub mod MyPublicMod { pub struct MyStruct; } +mod MyNestedNonPublicMod { + pub mod PublicInnerStruct { + // despite adding #[doc(hidden)], this struct is in a + // private outer mod, so it isn't part of the crate's public + // api + #[doc(hidden)] + pub struct MyStruct; + } +} + +pub mod MyNestedPublicMod { + pub mod PublicInnerStruct { + // added #[doc(hidden)], however this struct is in a + // public mod, so it is part of the crate's public api + #[doc(hidden)] + pub struct MyStruct; + } +} + #[doc(hidden)] pub struct Example; diff --git a/test_crates/struct_now_doc_hidden/old/src/lib.rs b/test_crates/struct_now_doc_hidden/old/src/lib.rs index 5cc0a0d7..268efb1c 100644 --- a/test_crates/struct_now_doc_hidden/old/src/lib.rs +++ b/test_crates/struct_now_doc_hidden/old/src/lib.rs @@ -7,3 +7,15 @@ pub mod MyPublicMod { } pub struct Example; + +mod MyNestedNonPublicMod { + pub mod PublicInnerStruct { + pub struct MyStruct; + } +} + +pub mod MyNestedPublicMod { + pub mod PublicInnerStruct { + pub struct MyStruct; + } +} diff --git a/test_outputs/struct_now_doc_hidden.output.ron b/test_outputs/struct_now_doc_hidden.output.ron index e438c972..b2384393 100644 --- a/test_outputs/struct_now_doc_hidden.output.ron +++ b/test_outputs/struct_now_doc_hidden.output.ron @@ -10,12 +10,23 @@ "span_filename": String("src/lib.rs"), "struct_name": String("MyStruct"), }, + { + "path": List([ + String("struct_now_doc_hidden"), + String("MyNestedPublicMod"), + String("PublicInnerStruct"), + String("MyStruct"), + ]), + "span_begin_line": Uint64(31), + "span_filename": String("src/lib.rs"), + "struct_name": String("MyStruct"), + }, { "path": List([ String("struct_now_doc_hidden"), String("Example"), ]), - "span_begin_line": Uint64(17), + "span_begin_line": Uint64(36), "span_filename": String("src/lib.rs"), "struct_name": String("Example"), }, From 21f829d5bffaac2f4e4c298898e3b7d0e6a0cd2d Mon Sep 17 00:00:00 2001 From: U9G Date: Mon, 27 Nov 2023 23:51:51 -0500 Subject: [PATCH 10/15] add mispelled doc hidden and hidden field to tests --- test_crates/struct_now_doc_hidden/new/src/lib.rs | 11 +++++++++++ test_crates/struct_now_doc_hidden/old/src/lib.rs | 6 ++++++ test_outputs/struct_now_doc_hidden.output.ron | 2 +- 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/test_crates/struct_now_doc_hidden/new/src/lib.rs b/test_crates/struct_now_doc_hidden/new/src/lib.rs index 60e973d9..7623fa15 100644 --- a/test_crates/struct_now_doc_hidden/new/src/lib.rs +++ b/test_crates/struct_now_doc_hidden/new/src/lib.rs @@ -32,5 +32,16 @@ pub mod MyNestedPublicMod { } } +#[doc(hide)] +pub struct MispelledDocHidden; + #[doc(hidden)] pub struct Example; + +pub struct PublicStructHiddenField { + // shouldn't flag `struct_now_doc_hidden` rule + // as this is a field that's hidden, + // not the entire struct + #[doc(hidden)] + pub my_field: i8, +} diff --git a/test_crates/struct_now_doc_hidden/old/src/lib.rs b/test_crates/struct_now_doc_hidden/old/src/lib.rs index 268efb1c..c93c032d 100644 --- a/test_crates/struct_now_doc_hidden/old/src/lib.rs +++ b/test_crates/struct_now_doc_hidden/old/src/lib.rs @@ -6,8 +6,14 @@ pub mod MyPublicMod { pub struct MyStruct; } +pub struct MispelledDocHidden; + pub struct Example; +pub struct PublicStructHiddenField { + pub my_field: i8, +} + mod MyNestedNonPublicMod { pub mod PublicInnerStruct { pub struct MyStruct; diff --git a/test_outputs/struct_now_doc_hidden.output.ron b/test_outputs/struct_now_doc_hidden.output.ron index b2384393..484717a9 100644 --- a/test_outputs/struct_now_doc_hidden.output.ron +++ b/test_outputs/struct_now_doc_hidden.output.ron @@ -26,7 +26,7 @@ String("struct_now_doc_hidden"), String("Example"), ]), - "span_begin_line": Uint64(36), + "span_begin_line": Uint64(39), "span_filename": String("src/lib.rs"), "struct_name": String("Example"), }, From bc0de143ca476c591793c157c50d9f06578849a7 Mon Sep 17 00:00:00 2001 From: U9G Date: Mon, 27 Nov 2023 23:55:09 -0500 Subject: [PATCH 11/15] add better explanation comment --- test_crates/struct_now_doc_hidden/new/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test_crates/struct_now_doc_hidden/new/src/lib.rs b/test_crates/struct_now_doc_hidden/new/src/lib.rs index 7623fa15..3f023cd5 100644 --- a/test_crates/struct_now_doc_hidden/new/src/lib.rs +++ b/test_crates/struct_now_doc_hidden/new/src/lib.rs @@ -32,7 +32,7 @@ pub mod MyNestedPublicMod { } } -#[doc(hide)] +#[doc(hide)] // shouldn't flag, it should be #[doc(hidden)] not #[doc(hide)] pub struct MispelledDocHidden; #[doc(hidden)] From f605781406723269edb3826f58a6833c04e6305d Mon Sep 17 00:00:00 2001 From: U9G Date: Tue, 28 Nov 2023 00:08:18 -0500 Subject: [PATCH 12/15] add test for adding doc hidden to a now-private struct --- test_crates/struct_now_doc_hidden/new/src/lib.rs | 3 +++ test_crates/struct_now_doc_hidden/old/src/lib.rs | 2 ++ test_outputs/struct_missing.output.ron | 13 +++++++++++++ 3 files changed, 18 insertions(+) diff --git a/test_crates/struct_now_doc_hidden/new/src/lib.rs b/test_crates/struct_now_doc_hidden/new/src/lib.rs index 3f023cd5..069ae391 100644 --- a/test_crates/struct_now_doc_hidden/new/src/lib.rs +++ b/test_crates/struct_now_doc_hidden/new/src/lib.rs @@ -45,3 +45,6 @@ pub struct PublicStructHiddenField { #[doc(hidden)] pub my_field: i8, } + +#[doc(hidden)] +struct PublicStructThatGoesPrivate; diff --git a/test_crates/struct_now_doc_hidden/old/src/lib.rs b/test_crates/struct_now_doc_hidden/old/src/lib.rs index c93c032d..f39a217f 100644 --- a/test_crates/struct_now_doc_hidden/old/src/lib.rs +++ b/test_crates/struct_now_doc_hidden/old/src/lib.rs @@ -25,3 +25,5 @@ pub mod MyNestedPublicMod { pub struct MyStruct; } } + +pub struct PublicStructThatGoesPrivate; diff --git a/test_outputs/struct_missing.output.ron b/test_outputs/struct_missing.output.ron index 2641ab26..87652937 100644 --- a/test_outputs/struct_missing.output.ron +++ b/test_outputs/struct_missing.output.ron @@ -84,6 +84,19 @@ "visibility_limit": String("public"), }, ], + "./test_crates/struct_now_doc_hidden/": [ + { + "name": String("PublicStructThatGoesPrivate"), + "path": List([ + String("struct_now_doc_hidden"), + String("PublicStructThatGoesPrivate"), + ]), + "span_begin_line": Uint64(29), + "span_filename": String("src/lib.rs"), + "struct_type": String("unit"), + "visibility_limit": String("public"), + }, + ], "./test_crates/struct_pub_field_missing/": [ { "name": String("StructRemoved"), From ed0424e4fd6d305c384640d6aa7da700d6996411 Mon Sep 17 00:00:00 2001 From: U9G Date: Tue, 28 Nov 2023 00:13:40 -0500 Subject: [PATCH 13/15] add comment to test --- test_crates/struct_now_doc_hidden/new/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test_crates/struct_now_doc_hidden/new/src/lib.rs b/test_crates/struct_now_doc_hidden/new/src/lib.rs index 069ae391..3128e9a5 100644 --- a/test_crates/struct_now_doc_hidden/new/src/lib.rs +++ b/test_crates/struct_now_doc_hidden/new/src/lib.rs @@ -35,7 +35,7 @@ pub mod MyNestedPublicMod { #[doc(hide)] // shouldn't flag, it should be #[doc(hidden)] not #[doc(hide)] pub struct MispelledDocHidden; -#[doc(hidden)] +#[doc(hidden)] // should flag, this is the simplest case of adding #[doc(hidden)] to a pub struct. pub struct Example; pub struct PublicStructHiddenField { From a333baef1a7f0bcb64133bcb54f7a3190e206d80 Mon Sep 17 00:00:00 2001 From: U9G Date: Tue, 28 Nov 2023 13:23:41 -0500 Subject: [PATCH 14/15] add test for possible doc hidden mistake --- test_crates/struct_now_doc_hidden/new/src/lib.rs | 4 ++++ test_crates/struct_now_doc_hidden/old/src/lib.rs | 2 ++ 2 files changed, 6 insertions(+) diff --git a/test_crates/struct_now_doc_hidden/new/src/lib.rs b/test_crates/struct_now_doc_hidden/new/src/lib.rs index 3128e9a5..2d7a3f13 100644 --- a/test_crates/struct_now_doc_hidden/new/src/lib.rs +++ b/test_crates/struct_now_doc_hidden/new/src/lib.rs @@ -48,3 +48,7 @@ pub struct PublicStructHiddenField { #[doc(hidden)] struct PublicStructThatGoesPrivate; + +#[doc = "hidden"] // this is just documented with the string "hidden", + // it's not actually #[doc(hidden)] +pub struct PublicStructDocumentedWithStringHidden; diff --git a/test_crates/struct_now_doc_hidden/old/src/lib.rs b/test_crates/struct_now_doc_hidden/old/src/lib.rs index f39a217f..f25c087e 100644 --- a/test_crates/struct_now_doc_hidden/old/src/lib.rs +++ b/test_crates/struct_now_doc_hidden/old/src/lib.rs @@ -27,3 +27,5 @@ pub mod MyNestedPublicMod { } pub struct PublicStructThatGoesPrivate; + +pub struct PublicStructDocumentedWithStringHidden; From 22798c079d35125499ab7b8fd7836a0654019b36 Mon Sep 17 00:00:00 2001 From: U9G Date: Tue, 28 Nov 2023 13:31:40 -0500 Subject: [PATCH 15/15] replace invalid test with valid test of alias of hidden --- test_crates/struct_now_doc_hidden/new/src/lib.rs | 7 ++++--- test_crates/struct_now_doc_hidden/old/src/lib.rs | 2 +- test_outputs/struct_now_doc_hidden.output.ron | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/test_crates/struct_now_doc_hidden/new/src/lib.rs b/test_crates/struct_now_doc_hidden/new/src/lib.rs index 2d7a3f13..7f349be7 100644 --- a/test_crates/struct_now_doc_hidden/new/src/lib.rs +++ b/test_crates/struct_now_doc_hidden/new/src/lib.rs @@ -32,8 +32,9 @@ pub mod MyNestedPublicMod { } } -#[doc(hide)] // shouldn't flag, it should be #[doc(hidden)] not #[doc(hide)] -pub struct MispelledDocHidden; +#[doc(alias = "hidden")] // shouldn't flag, this is just aliased as hidden, + // but it should be #[doc(hidden)] +pub struct AliasedAsDocHidden; #[doc(hidden)] // should flag, this is the simplest case of adding #[doc(hidden)] to a pub struct. pub struct Example; @@ -49,6 +50,6 @@ pub struct PublicStructHiddenField { #[doc(hidden)] struct PublicStructThatGoesPrivate; -#[doc = "hidden"] // this is just documented with the string "hidden", +#[doc = "hidden"] // shouldn't flag, this is just documented with the string "hidden", // it's not actually #[doc(hidden)] pub struct PublicStructDocumentedWithStringHidden; diff --git a/test_crates/struct_now_doc_hidden/old/src/lib.rs b/test_crates/struct_now_doc_hidden/old/src/lib.rs index f25c087e..a2b7f884 100644 --- a/test_crates/struct_now_doc_hidden/old/src/lib.rs +++ b/test_crates/struct_now_doc_hidden/old/src/lib.rs @@ -6,7 +6,7 @@ pub mod MyPublicMod { pub struct MyStruct; } -pub struct MispelledDocHidden; +pub struct AliasedAsDocHidden; pub struct Example; diff --git a/test_outputs/struct_now_doc_hidden.output.ron b/test_outputs/struct_now_doc_hidden.output.ron index 484717a9..f1ba11a6 100644 --- a/test_outputs/struct_now_doc_hidden.output.ron +++ b/test_outputs/struct_now_doc_hidden.output.ron @@ -26,7 +26,7 @@ String("struct_now_doc_hidden"), String("Example"), ]), - "span_begin_line": Uint64(39), + "span_begin_line": Uint64(40), "span_filename": String("src/lib.rs"), "struct_name": String("Example"), },