Skip to content

Commit f559342

Browse files
Added public API sealed in trait_newly_sealed (#1160)
Resolves #1115 --------- Co-authored-by: Predrag Gruevski <2348618+obi1kenobi@users.noreply.github.com>
1 parent 203bef6 commit f559342

File tree

4 files changed

+77
-2
lines changed

4 files changed

+77
-2
lines changed

src/lints/trait_newly_sealed.ron

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ SemverQuery(
1212
item {
1313
... on Trait {
1414
visibility_limit @filter(op: "=", value: ["$public"]) @output
15-
unconditionally_sealed @filter(op: "!=", value: ["$true"])
15+
public_api_sealed @filter(op: "!=", value: ["$true"])
1616
1717
importable_path {
1818
path @output @tag
@@ -25,7 +25,7 @@ SemverQuery(
2525
item {
2626
... on Trait {
2727
visibility_limit @filter(op: "=", value: ["$public"])
28-
unconditionally_sealed @filter(op: "=", value: ["$true"])
28+
public_api_sealed @filter(op: "=", value: ["$true"])
2929
name @output
3030
3131
importable_path {

test_crates/trait_newly_sealed/new/src/lib.rs

+8
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,11 @@ pub trait TraitBecomesPublicAndSealed: private::Sealed {}
2222
// and should be the only violation that's reported:
2323
// Thus being newly sealed is not the main problem
2424
trait TraitBecomesPrivateAndSealed: private::Sealed {}
25+
26+
// This trait was public API sealed to begin with.
27+
// Here it becomes unconditionally sealed, which we shouldn't flag.
28+
// The only breakage is among uses that went beyond the public API.
29+
pub trait PublicAPISealed: private::Sealed {
30+
#[doc(hidden)]
31+
type Hidden;
32+
}

test_crates/trait_newly_sealed/old/src/lib.rs

+8
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,11 @@ trait TraitBecomesPublicAndSealed {}
1616
// and should be the only violation that's reported:
1717
// Thus being newly sealed is not the main problem
1818
pub trait TraitBecomesPrivateAndSealed {}
19+
20+
// This trait is public API sealed.
21+
// In the new code, it becomes unconditionally sealed, which we shouldn't flag.
22+
// The only breakage is among uses that went beyond the public API.
23+
pub trait PublicAPISealed {
24+
#[doc(hidden)]
25+
type Hidden;
26+
}

test_outputs/query_execution/trait_newly_sealed.snap

+59
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,17 @@ expression: "&query_execution_results"
1515
"span_filename": String("src/lib.rs"),
1616
"visibility_limit": String("public"),
1717
},
18+
{
19+
"name": String("WillGainADocHiddenConst"),
20+
"path": List([
21+
String("trait_associated_const_added"),
22+
String("WillGainADocHiddenConst"),
23+
]),
24+
"span_begin_line": Uint64(46),
25+
"span_end_line": Uint64(51),
26+
"span_filename": String("src/lib.rs"),
27+
"visibility_limit": String("public"),
28+
},
1829
],
1930
"./test_crates/trait_associated_type_added/": [
2031
{
@@ -28,6 +39,17 @@ expression: "&query_execution_results"
2839
"span_filename": String("src/lib.rs"),
2940
"visibility_limit": String("public"),
3041
},
42+
{
43+
"name": String("WillGainADocHiddenType"),
44+
"path": List([
45+
String("trait_associated_type_added"),
46+
String("WillGainADocHiddenType"),
47+
]),
48+
"span_begin_line": Uint64(51),
49+
"span_end_line": Uint64(56),
50+
"span_filename": String("src/lib.rs"),
51+
"visibility_limit": String("public"),
52+
},
3153
],
3254
"./test_crates/trait_method_added/": [
3355
{
@@ -41,6 +63,17 @@ expression: "&query_execution_results"
4163
"span_filename": String("src/lib.rs"),
4264
"visibility_limit": String("public"),
4365
},
66+
{
67+
"name": String("WIllGainDocHiddenMethodWithoutDefault"),
68+
"path": List([
69+
String("trait_method_added"),
70+
String("WIllGainDocHiddenMethodWithoutDefault"),
71+
]),
72+
"span_begin_line": Uint64(24),
73+
"span_end_line": Uint64(27),
74+
"span_filename": String("src/lib.rs"),
75+
"visibility_limit": String("public"),
76+
},
4477
],
4578
"./test_crates/trait_method_default_impl_removed/": [
4679
{
@@ -66,6 +99,19 @@ expression: "&query_execution_results"
6699
"visibility_limit": String("public"),
67100
},
68101
],
102+
"./test_crates/trait_method_now_doc_hidden/": [
103+
{
104+
"name": String("PublicTrait"),
105+
"path": List([
106+
String("trait_method_now_doc_hidden"),
107+
String("PublicTrait"),
108+
]),
109+
"span_begin_line": Uint64(12),
110+
"span_end_line": Uint64(17),
111+
"span_filename": String("src/lib.rs"),
112+
"visibility_limit": String("public"),
113+
},
114+
],
69115
"./test_crates/trait_newly_sealed/": [
70116
{
71117
"name": String("TraitBecomesSealed"),
@@ -90,4 +136,17 @@ expression: "&query_execution_results"
90136
"visibility_limit": String("public"),
91137
},
92138
],
139+
"./test_crates/trait_now_doc_hidden/": [
140+
{
141+
"name": String("PublicTraitHiddenVariant"),
142+
"path": List([
143+
String("trait_now_doc_hidden"),
144+
String("PublicTraitHiddenVariant"),
145+
]),
146+
"span_begin_line": Uint64(49),
147+
"span_end_line": Uint64(55),
148+
"span_filename": String("src/lib.rs"),
149+
"visibility_limit": String("public"),
150+
},
151+
],
93152
}

0 commit comments

Comments
 (0)