diff --git a/src/lints/trait_newly_sealed.ron b/src/lints/trait_newly_sealed.ron index 327dbe9b..a3452a14 100644 --- a/src/lints/trait_newly_sealed.ron +++ b/src/lints/trait_newly_sealed.ron @@ -12,7 +12,7 @@ SemverQuery( item { ... on Trait { visibility_limit @filter(op: "=", value: ["$public"]) @output - unconditionally_sealed @filter(op: "!=", value: ["$true"]) + public_api_sealed @filter(op: "!=", value: ["$true"]) importable_path { path @output @tag @@ -25,7 +25,7 @@ SemverQuery( item { ... on Trait { visibility_limit @filter(op: "=", value: ["$public"]) - unconditionally_sealed @filter(op: "=", value: ["$true"]) + public_api_sealed @filter(op: "=", value: ["$true"]) name @output importable_path { diff --git a/test_crates/trait_newly_sealed/new/src/lib.rs b/test_crates/trait_newly_sealed/new/src/lib.rs index 852d7039..caefd63b 100644 --- a/test_crates/trait_newly_sealed/new/src/lib.rs +++ b/test_crates/trait_newly_sealed/new/src/lib.rs @@ -22,3 +22,11 @@ pub trait TraitBecomesPublicAndSealed: private::Sealed {} // and should be the only violation that's reported: // Thus being newly sealed is not the main problem trait TraitBecomesPrivateAndSealed: private::Sealed {} + +// This trait was public API sealed to begin with. +// Here it becomes unconditionally sealed, which we shouldn't flag. +// The only breakage is among uses that went beyond the public API. +pub trait PublicAPISealed: private::Sealed { + #[doc(hidden)] + type Hidden; +} diff --git a/test_crates/trait_newly_sealed/old/src/lib.rs b/test_crates/trait_newly_sealed/old/src/lib.rs index 4c574b15..f4033b16 100644 --- a/test_crates/trait_newly_sealed/old/src/lib.rs +++ b/test_crates/trait_newly_sealed/old/src/lib.rs @@ -16,3 +16,11 @@ trait TraitBecomesPublicAndSealed {} // and should be the only violation that's reported: // Thus being newly sealed is not the main problem pub trait TraitBecomesPrivateAndSealed {} + +// This trait is public API sealed. +// In the new code, it becomes unconditionally sealed, which we shouldn't flag. +// The only breakage is among uses that went beyond the public API. +pub trait PublicAPISealed { + #[doc(hidden)] + type Hidden; +} diff --git a/test_outputs/query_execution/trait_newly_sealed.snap b/test_outputs/query_execution/trait_newly_sealed.snap index c6d757ac..b1ecf9eb 100644 --- a/test_outputs/query_execution/trait_newly_sealed.snap +++ b/test_outputs/query_execution/trait_newly_sealed.snap @@ -15,6 +15,17 @@ expression: "&query_execution_results" "span_filename": String("src/lib.rs"), "visibility_limit": String("public"), }, + { + "name": String("WillGainADocHiddenConst"), + "path": List([ + String("trait_associated_const_added"), + String("WillGainADocHiddenConst"), + ]), + "span_begin_line": Uint64(46), + "span_end_line": Uint64(51), + "span_filename": String("src/lib.rs"), + "visibility_limit": String("public"), + }, ], "./test_crates/trait_associated_type_added/": [ { @@ -28,6 +39,17 @@ expression: "&query_execution_results" "span_filename": String("src/lib.rs"), "visibility_limit": String("public"), }, + { + "name": String("WillGainADocHiddenType"), + "path": List([ + String("trait_associated_type_added"), + String("WillGainADocHiddenType"), + ]), + "span_begin_line": Uint64(51), + "span_end_line": Uint64(56), + "span_filename": String("src/lib.rs"), + "visibility_limit": String("public"), + }, ], "./test_crates/trait_method_added/": [ { @@ -41,6 +63,17 @@ expression: "&query_execution_results" "span_filename": String("src/lib.rs"), "visibility_limit": String("public"), }, + { + "name": String("WIllGainDocHiddenMethodWithoutDefault"), + "path": List([ + String("trait_method_added"), + String("WIllGainDocHiddenMethodWithoutDefault"), + ]), + "span_begin_line": Uint64(24), + "span_end_line": Uint64(27), + "span_filename": String("src/lib.rs"), + "visibility_limit": String("public"), + }, ], "./test_crates/trait_method_default_impl_removed/": [ { @@ -66,6 +99,19 @@ expression: "&query_execution_results" "visibility_limit": String("public"), }, ], + "./test_crates/trait_method_now_doc_hidden/": [ + { + "name": String("PublicTrait"), + "path": List([ + String("trait_method_now_doc_hidden"), + String("PublicTrait"), + ]), + "span_begin_line": Uint64(12), + "span_end_line": Uint64(17), + "span_filename": String("src/lib.rs"), + "visibility_limit": String("public"), + }, + ], "./test_crates/trait_newly_sealed/": [ { "name": String("TraitBecomesSealed"), @@ -90,4 +136,17 @@ expression: "&query_execution_results" "visibility_limit": String("public"), }, ], + "./test_crates/trait_now_doc_hidden/": [ + { + "name": String("PublicTraitHiddenVariant"), + "path": List([ + String("trait_now_doc_hidden"), + String("PublicTraitHiddenVariant"), + ]), + "span_begin_line": Uint64(49), + "span_end_line": Uint64(55), + "span_filename": String("src/lib.rs"), + "visibility_limit": String("public"), + }, + ], }