diff --git a/out.txt b/out.txt new file mode 100644 index 000000000..a3d3f0c7e --- /dev/null +++ b/out.txt @@ -0,0 +1,11 @@ + Documenting function_changed_abi v0.1.0 (/Users/jasonlernerman/code/cargo-semver-checks/test_crates/function_changed_abi/new) + Finished dev [unoptimized + debuginfo] target(s) in 0.13s + Documenting function_changed_abi v0.1.0 (/Users/jasonlernerman/code/cargo-semver-checks/test_crates/function_changed_abi/old) + Finished dev [unoptimized ~/code/cargo-semver-checks +Gener Documenting features_no_default v0.1.0 (/Users/jasonlernerman/code/cargo-semver-checks/test_crates/features_no_default/ne~/code/cargo-semver-checks +Generating: /features_no_default/old +~ Documenting features_no_default v0.1.0 (/Users/jasonlernerman/code/cargo-semver-checks/t~/code/cargo-semver-checks +Generating: /struct_now_doc_hidden/new +~/code/cargo-semver-checks/test_ Documenting template v0.1.0 (/Users/jasonlernerman/code/cargo-semver-checks/test_crates/struct_now_doc_hidden/new) + Finished dev [unoptimized + debuginfo] target(s) in 0.13s +mv: rename /tmp/test_crates/doc//struct_now_doc_hidden.json to /Users/jasonlernerman/code/cargo-semver-checks/localdata/test_data//struct_now_doc_hidden/new/rustdoc.json: No such file or directory diff --git a/src/lints/struct_now_doc_hidden.ron b/src/lints/struct_now_doc_hidden.ron new file mode 100644 index 000000000..bd64f091d --- /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 2a45dd0e5..c35e8ed08 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 000000000..9e827d01b --- /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 000000000..a66ae2b58 --- /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 000000000..9e827d01b --- /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 000000000..6b9445064 --- /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 000000000..1f2676835 --- /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