Skip to content

Commit 712ef4e

Browse files
aryan-debugnyurik
authored andcommitted
Added suggestion instead of help
1 parent b2829e5 commit 712ef4e

File tree

7 files changed

+63
-18
lines changed

7 files changed

+63
-18
lines changed

compiler/rustc_privacy/messages.ftl

+1-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ privacy_from_private_dep_in_public_interface =
88
privacy_in_public_interface = {$vis_descr} {$kind} `{$descr}` in public interface
99
.label = can't leak {$vis_descr} {$kind}
1010
.visibility_label = `{$descr}` declared as {$vis_descr}
11-
.help = - Either remove the `pub` from the function
12-
- Or add `pub` to `{$descr}`
11+
.suggestion = consider adding `pub` in front of it
1312
1413
privacy_item_is_private = {$kind} `{$descr}` is private
1514
.label = private {$kind}

compiler/rustc_privacy/src/errors.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ pub struct UnnamedItemIsPrivate {
4848
}
4949

5050
#[derive(Diagnostic)]
51-
#[help]
5251
#[diag(privacy_in_public_interface, code = "E0446")]
5352
pub struct InPublicInterface<'a> {
5453
#[primary_span]
@@ -59,6 +58,8 @@ pub struct InPublicInterface<'a> {
5958
pub descr: DiagnosticArgFromDisplay<'a>,
6059
#[label(privacy_visibility_label)]
6160
pub vis_span: Span,
61+
#[suggestion(code="", applicability = "maybe-incorrect")]
62+
pub suggestion: Span,
6263
}
6364

6465
#[derive(Diagnostic)]

tests/ui/const-generics/generic_const_exprs/eval-privacy.stderr

+4-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ LL | type AssocTy = Const<{ my_const_fn(U) }>;
55
| ^^^^^^^^^^^^ can't leak private type
66
...
77
LL | const fn my_const_fn(val: u8) -> u8 {
8-
| ----------------------------------- `fn(u8) -> u8 {my_const_fn}` declared as private
8+
| -----------------------------------
9+
| |
10+
| `fn(u8) -> u8 {my_const_fn}` declared as private
11+
| help: consider adding `pub` in front of it
912

1013
error: aborting due to 1 previous error
1114

tests/ui/privacy/issue-30079.stderr

+8-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@ error[E0446]: private type `m2::Priv` in public interface
1515
--> $DIR/issue-30079.rs:17:9
1616
|
1717
LL | struct Priv;
18-
| ----------- `m2::Priv` declared as private
18+
| -----------
19+
| |
20+
| `m2::Priv` declared as private
21+
| help: consider adding `pub` in front of it
1922
LL | impl ::std::ops::Deref for ::SemiPriv {
2023
LL | type Target = Priv;
2124
| ^^^^^^^^^^^ can't leak private type
@@ -24,7 +27,10 @@ error[E0446]: private type `m3::Priv` in public interface
2427
--> $DIR/issue-30079.rs:34:9
2528
|
2629
LL | struct Priv;
27-
| ----------- `m3::Priv` declared as private
30+
| -----------
31+
| |
32+
| `m3::Priv` declared as private
33+
| help: consider adding `pub` in front of it
2834
LL | impl ::SemiPrivTrait for () {
2935
LL | type Assoc = Priv;
3036
| ^^^^^^^^^^ can't leak private type

tests/ui/privacy/private-in-public-assoc-ty.stderr

+12-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@ error[E0446]: private type `Priv` in public interface
22
--> $DIR/private-in-public-assoc-ty.rs:17:9
33
|
44
LL | struct Priv;
5-
| ----------- `Priv` declared as private
5+
| -----------
6+
| |
7+
| `Priv` declared as private
8+
| help: consider adding `pub` in front of it
69
...
710
LL | type A = Priv;
811
| ^^^^^^ can't leak private type
@@ -48,7 +51,10 @@ error[E0446]: private type `Priv` in public interface
4851
--> $DIR/private-in-public-assoc-ty.rs:31:9
4952
|
5053
LL | struct Priv;
51-
| ----------- `Priv` declared as private
54+
| -----------
55+
| |
56+
| `Priv` declared as private
57+
| help: consider adding `pub` in front of it
5258
...
5359
LL | type Alias4 = Priv;
5460
| ^^^^^^^^^^^ can't leak private type
@@ -57,7 +63,10 @@ error[E0446]: private type `Priv` in public interface
5763
--> $DIR/private-in-public-assoc-ty.rs:38:9
5864
|
5965
LL | struct Priv;
60-
| ----------- `Priv` declared as private
66+
| -----------
67+
| |
68+
| `Priv` declared as private
69+
| help: consider adding `pub` in front of it
6170
...
6271
LL | type Alias1 = Priv;
6372
| ^^^^^^^^^^^ can't leak private type

tests/ui/privacy/private-in-public-warn.stderr

+28-7
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,10 @@ error[E0446]: private type `types::Priv` in public interface
5555
--> $DIR/private-in-public-warn.rs:22:9
5656
|
5757
LL | struct Priv;
58-
| ----------- `types::Priv` declared as private
58+
| -----------
59+
| |
60+
| `types::Priv` declared as private
61+
| help: consider adding `pub` in front of it
5962
...
6063
LL | type Alias = Priv;
6164
| ^^^^^^^^^^ can't leak private type
@@ -124,7 +127,10 @@ error[E0446]: private type `types::Priv` in public interface
124127
--> $DIR/private-in-public-warn.rs:32:9
125128
|
126129
LL | struct Priv;
127-
| ----------- `types::Priv` declared as private
130+
| -----------
131+
| |
132+
| `types::Priv` declared as private
133+
| help: consider adding `pub` in front of it
128134
...
129135
LL | type Alias = Priv;
130136
| ^^^^^^^^^^ can't leak private type
@@ -306,7 +312,10 @@ error[E0446]: private type `impls::Priv` in public interface
306312
--> $DIR/private-in-public-warn.rs:109:9
307313
|
308314
LL | struct Priv;
309-
| ----------- `impls::Priv` declared as private
315+
| -----------
316+
| |
317+
| `impls::Priv` declared as private
318+
| help: consider adding `pub` in front of it
310319
...
311320
LL | type Alias = Priv;
312321
| ^^^^^^^^^^ can't leak private type
@@ -327,7 +336,10 @@ error[E0446]: private type `aliases_pub::Priv` in public interface
327336
--> $DIR/private-in-public-warn.rs:183:9
328337
|
329338
LL | struct Priv;
330-
| ----------- `aliases_pub::Priv` declared as private
339+
| -----------
340+
| |
341+
| `aliases_pub::Priv` declared as private
342+
| help: consider adding `pub` in front of it
331343
...
332344
LL | type Check = Priv;
333345
| ^^^^^^^^^^ can't leak private type
@@ -336,7 +348,10 @@ error[E0446]: private type `aliases_pub::Priv` in public interface
336348
--> $DIR/private-in-public-warn.rs:186:9
337349
|
338350
LL | struct Priv;
339-
| ----------- `aliases_pub::Priv` declared as private
351+
| -----------
352+
| |
353+
| `aliases_pub::Priv` declared as private
354+
| help: consider adding `pub` in front of it
340355
...
341356
LL | type Check = Priv;
342357
| ^^^^^^^^^^ can't leak private type
@@ -345,7 +360,10 @@ error[E0446]: private type `aliases_pub::Priv` in public interface
345360
--> $DIR/private-in-public-warn.rs:189:9
346361
|
347362
LL | struct Priv;
348-
| ----------- `aliases_pub::Priv` declared as private
363+
| -----------
364+
| |
365+
| `aliases_pub::Priv` declared as private
366+
| help: consider adding `pub` in front of it
349367
...
350368
LL | type Check = Priv;
351369
| ^^^^^^^^^^ can't leak private type
@@ -354,7 +372,10 @@ error[E0446]: private type `aliases_pub::Priv` in public interface
354372
--> $DIR/private-in-public-warn.rs:192:9
355373
|
356374
LL | struct Priv;
357-
| ----------- `aliases_pub::Priv` declared as private
375+
| -----------
376+
| |
377+
| `aliases_pub::Priv` declared as private
378+
| help: consider adding `pub` in front of it
358379
...
359380
LL | type Check = Priv;
360381
| ^^^^^^^^^^ can't leak private type

tests/ui/privacy/private-inferred-type.stderr

+8-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@ error[E0446]: private type `Priv` in public interface
22
--> $DIR/private-inferred-type.rs:61:36
33
|
44
LL | struct Priv;
5-
| ----------- `Priv` declared as private
5+
| -----------
6+
| |
7+
| `Priv` declared as private
8+
| help: consider adding `pub` in front of it
69
...
710
LL | impl TraitWithAssocTy for u8 { type AssocTy = Priv; }
811
| ^^^^^^^^^^^^ can't leak private type
@@ -11,7 +14,10 @@ error[E0446]: private type `S2` in public interface
1114
--> $DIR/private-inferred-type.rs:83:9
1215
|
1316
LL | struct S2;
14-
| --------- `S2` declared as private
17+
| ---------
18+
| |
19+
| `S2` declared as private
20+
| help: consider adding `pub` in front of it
1521
...
1622
LL | type Target = S2Alias;
1723
| ^^^^^^^^^^^ can't leak private type

0 commit comments

Comments
 (0)