@@ -4,11 +4,17 @@ use rustc_macros::{Diagnostic, LintDiagnostic, Subdiagnostic};
44use rustc_span:: { Span , Symbol } ;
55
66#[ derive( Diagnostic ) ]
7- #[ diag( privacy_field_is_private, code = E0451 ) ]
7+ #[ diag( "{$len ->
8+ [1] field
9+ *[other] fields
10+ } {$field_names} of {$variant_descr} `{$def_path_str}` {$len ->
11+ [1] is
12+ *[other] are
13+ } private" , code = E0451 ) ]
814pub ( crate ) struct FieldIsPrivate {
915 #[ primary_span]
1016 pub span : MultiSpan ,
11- #[ label]
17+ #[ label( "in this type" ) ]
1218 pub struct_span : Option < Span > ,
1319 pub field_names : String ,
1420 pub variant_descr : & ' static str ,
@@ -20,71 +26,81 @@ pub(crate) struct FieldIsPrivate {
2026
2127#[ derive( Subdiagnostic ) ]
2228pub ( crate ) enum FieldIsPrivateLabel {
23- #[ label( privacy_field_is_private_is_update_syntax_label) ]
29+ #[ label(
30+ "{$rest_len ->
31+ [1] field
32+ *[other] fields
33+ } {$rest_field_names} {$rest_len ->
34+ [1] is
35+ *[other] are
36+ } private"
37+ ) ]
2438 IsUpdateSyntax {
2539 #[ primary_span]
2640 span : Span ,
2741 rest_field_names : String ,
2842 rest_len : usize ,
2943 } ,
30- #[ label( privacy_field_is_private_label ) ]
44+ #[ label( "private field" ) ]
3145 Other {
3246 #[ primary_span]
3347 span : Span ,
3448 } ,
3549}
3650
3751#[ derive( Diagnostic ) ]
38- #[ diag( privacy_item_is_private ) ]
52+ #[ diag( "{$kind} `{$descr}` is private" ) ]
3953pub ( crate ) struct ItemIsPrivate < ' a > {
4054 #[ primary_span]
41- #[ label]
55+ #[ label( "private {$kind}" ) ]
4256 pub span : Span ,
4357 pub kind : & ' a str ,
4458 pub descr : DiagArgFromDisplay < ' a > ,
4559}
4660
4761#[ derive( Diagnostic ) ]
48- #[ diag( privacy_unnamed_item_is_private ) ]
62+ #[ diag( "{$kind} is private" ) ]
4963pub ( crate ) struct UnnamedItemIsPrivate {
5064 #[ primary_span]
5165 pub span : Span ,
5266 pub kind : & ' static str ,
5367}
5468
5569#[ derive( Diagnostic ) ]
56- #[ diag( privacy_in_public_interface , code = E0446 ) ]
70+ #[ diag( "{$vis_descr} {$kind} `{$descr}` in public interface" , code = E0446 ) ]
5771pub ( crate ) struct InPublicInterface < ' a > {
5872 #[ primary_span]
59- #[ label]
73+ #[ label( "can't leak {$vis_descr} {$kind}" ) ]
6074 pub span : Span ,
6175 pub vis_descr : & ' static str ,
6276 pub kind : & ' a str ,
6377 pub descr : DiagArgFromDisplay < ' a > ,
64- #[ label( privacy_visibility_label ) ]
78+ #[ label( "`{$descr}` declared as {$vis_descr}" ) ]
6579 pub vis_span : Span ,
6680}
6781
6882#[ derive( Diagnostic ) ]
69- #[ diag( privacy_report_effective_visibility ) ]
83+ #[ diag( "{$descr}" ) ]
7084pub ( crate ) struct ReportEffectiveVisibility {
7185 #[ primary_span]
7286 pub span : Span ,
7387 pub descr : String ,
7488}
7589
7690#[ derive( LintDiagnostic ) ]
77- #[ diag( privacy_from_private_dep_in_public_interface ) ]
91+ #[ diag( "{$kind} `{$descr}` from private dependency '{$krate}' in public interface" ) ]
7892pub ( crate ) struct FromPrivateDependencyInPublicInterface < ' a > {
7993 pub kind : & ' a str ,
8094 pub descr : DiagArgFromDisplay < ' a > ,
8195 pub krate : Symbol ,
8296}
8397
8498#[ derive( LintDiagnostic ) ]
85- #[ diag( privacy_unnameable_types_lint ) ]
99+ #[ diag( "{$kind} `{$descr}` is reachable but cannot be named" ) ]
86100pub ( crate ) struct UnnameableTypesLint < ' a > {
87- #[ label]
101+ #[ label(
102+ "reachable at visibility `{$reachable_vis}`, but can only be named at visibility `{$reexported_vis}`"
103+ ) ]
88104 pub span : Span ,
89105 pub kind : & ' a str ,
90106 pub descr : DiagArgFromDisplay < ' a > ,
@@ -96,14 +112,14 @@ pub(crate) struct UnnameableTypesLint<'a> {
96112// They will replace private-in-public errors and compatibility lints in future.
97113// See https://rust-lang.github.io/rfcs/2145-type-privacy.html for more details.
98114#[ derive( LintDiagnostic ) ]
99- #[ diag( privacy_private_interface_or_bounds_lint ) ]
115+ #[ diag( "{$ty_kind} `{$ty_descr}` is more private than the item `{$item_descr}`" ) ]
100116pub ( crate ) struct PrivateInterfacesOrBoundsLint < ' a > {
101- #[ label( privacy_item_label ) ]
117+ #[ label( "{$item_kind} `{$item_descr}` is reachable at visibility `{$item_vis_descr}`" ) ]
102118 pub item_span : Span ,
103119 pub item_kind : & ' a str ,
104120 pub item_descr : DiagArgFromDisplay < ' a > ,
105121 pub item_vis_descr : & ' a str ,
106- #[ note( privacy_ty_note ) ]
122+ #[ note( "but {$ty_kind} `{$ty_descr}` is only usable at visibility `{$ty_vis_descr}`" ) ]
107123 pub ty_span : Span ,
108124 pub ty_kind : & ' a str ,
109125 pub ty_descr : DiagArgFromDisplay < ' a > ,
0 commit comments