]> git.lizzy.rs Git - rust.git/blob - compiler/rustc_privacy/src/errors.rs
Rollup merge of #98646 - notriddle:notriddle/main.js, r=GuillaumeGomez
[rust.git] / compiler / rustc_privacy / src / errors.rs
1 use rustc_macros::{SessionDiagnostic, SessionSubdiagnostic};
2 use rustc_span::{Span, Symbol};
3
4 #[derive(SessionDiagnostic)]
5 #[error(privacy::field_is_private, code = "E0451")]
6 pub struct FieldIsPrivate {
7     #[primary_span]
8     pub span: Span,
9     pub field_name: Symbol,
10     pub variant_descr: &'static str,
11     pub def_path_str: String,
12     #[subdiagnostic]
13     pub label: FieldIsPrivateLabel,
14 }
15
16 #[derive(SessionSubdiagnostic)]
17 pub enum FieldIsPrivateLabel {
18     #[label(privacy::field_is_private_is_update_syntax_label)]
19     IsUpdateSyntax {
20         #[primary_span]
21         span: Span,
22         field_name: Symbol,
23     },
24     #[label(privacy::field_is_private_label)]
25     Other {
26         #[primary_span]
27         span: Span,
28     },
29 }
30
31 #[derive(SessionDiagnostic)]
32 #[error(privacy::item_is_private)]
33 pub struct ItemIsPrivate<'a> {
34     #[primary_span]
35     #[label]
36     pub span: Span,
37     pub kind: &'a str,
38     pub descr: String,
39 }
40
41 #[derive(SessionDiagnostic)]
42 #[error(privacy::unnamed_item_is_private)]
43 pub struct UnnamedItemIsPrivate {
44     #[primary_span]
45     pub span: Span,
46     pub kind: &'static str,
47 }
48
49 // Duplicate of `InPublicInterface` but with a different error code, shares the same slug.
50 #[derive(SessionDiagnostic)]
51 #[error(privacy::in_public_interface, code = "E0445")]
52 pub struct InPublicInterfaceTraits<'a> {
53     #[primary_span]
54     #[label]
55     pub span: Span,
56     pub vis_descr: &'static str,
57     pub kind: &'a str,
58     pub descr: String,
59     #[label(privacy::visibility_label)]
60     pub vis_span: Span,
61 }
62
63 // Duplicate of `InPublicInterfaceTraits` but with a different error code, shares the same slug.
64 #[derive(SessionDiagnostic)]
65 #[error(privacy::in_public_interface, code = "E0446")]
66 pub struct InPublicInterface<'a> {
67     #[primary_span]
68     #[label]
69     pub span: Span,
70     pub vis_descr: &'static str,
71     pub kind: &'a str,
72     pub descr: String,
73     #[label(privacy::visibility_label)]
74     pub vis_span: Span,
75 }