]> git.lizzy.rs Git - rust.git/blob - compiler/rustc_session/src/errors.rs
Auto merge of #101703 - nicholasbishop:bishop-add-uefi-ci-2, r=jyn514
[rust.git] / compiler / rustc_session / src / errors.rs
1 use std::num::NonZeroU32;
2
3 use crate::cgu_reuse_tracker::CguReuse;
4 use rustc_errors::MultiSpan;
5 use rustc_macros::Diagnostic;
6 use rustc_span::{Span, Symbol};
7 use rustc_target::spec::{SplitDebuginfo, StackProtector, TargetTriple};
8
9 #[derive(Diagnostic)]
10 #[diag(session_incorrect_cgu_reuse_type)]
11 pub struct IncorrectCguReuseType<'a> {
12     #[primary_span]
13     pub span: Span,
14     pub cgu_user_name: &'a str,
15     pub actual_reuse: CguReuse,
16     pub expected_reuse: CguReuse,
17     pub at_least: u8,
18 }
19
20 #[derive(Diagnostic)]
21 #[diag(session_cgu_not_recorded)]
22 pub struct CguNotRecorded<'a> {
23     pub cgu_user_name: &'a str,
24     pub cgu_name: &'a str,
25 }
26
27 #[derive(Diagnostic)]
28 #[diag(session_feature_gate_error, code = "E0658")]
29 pub struct FeatureGateError<'a> {
30     #[primary_span]
31     pub span: MultiSpan,
32     pub explain: &'a str,
33 }
34
35 #[derive(Subdiagnostic)]
36 #[note(session_feature_diagnostic_for_issue)]
37 pub struct FeatureDiagnosticForIssue {
38     pub n: NonZeroU32,
39 }
40
41 #[derive(Subdiagnostic)]
42 #[help(session_feature_diagnostic_help)]
43 pub struct FeatureDiagnosticHelp {
44     pub feature: Symbol,
45 }
46
47 #[derive(Diagnostic)]
48 #[diag(session_not_circumvent_feature)]
49 pub struct NotCircumventFeature;
50
51 #[derive(Diagnostic)]
52 #[diag(session_linker_plugin_lto_windows_not_supported)]
53 pub struct LinkerPluginToWindowsNotSupported;
54
55 #[derive(Diagnostic)]
56 #[diag(session_profile_use_file_does_not_exist)]
57 pub struct ProfileUseFileDoesNotExist<'a> {
58     pub path: &'a std::path::Path,
59 }
60
61 #[derive(Diagnostic)]
62 #[diag(session_profile_sample_use_file_does_not_exist)]
63 pub struct ProfileSampleUseFileDoesNotExist<'a> {
64     pub path: &'a std::path::Path,
65 }
66
67 #[derive(Diagnostic)]
68 #[diag(session_target_requires_unwind_tables)]
69 pub struct TargetRequiresUnwindTables;
70
71 #[derive(Diagnostic)]
72 #[diag(session_sanitizer_not_supported)]
73 pub struct SanitizerNotSupported {
74     pub us: String,
75 }
76
77 #[derive(Diagnostic)]
78 #[diag(session_sanitizers_not_supported)]
79 pub struct SanitizersNotSupported {
80     pub us: String,
81 }
82
83 #[derive(Diagnostic)]
84 #[diag(session_cannot_mix_and_match_sanitizers)]
85 pub struct CannotMixAndMatchSanitizers {
86     pub first: String,
87     pub second: String,
88 }
89
90 #[derive(Diagnostic)]
91 #[diag(session_cannot_enable_crt_static_linux)]
92 pub struct CannotEnableCrtStaticLinux;
93
94 #[derive(Diagnostic)]
95 #[diag(session_sanitizer_cfi_enabled)]
96 pub struct SanitizerCfiEnabled;
97
98 #[derive(Diagnostic)]
99 #[diag(session_unstable_virtual_function_elimination)]
100 pub struct UnstableVirtualFunctionElimination;
101
102 #[derive(Diagnostic)]
103 #[diag(session_unsupported_dwarf_version)]
104 pub struct UnsupportedDwarfVersion {
105     pub dwarf_version: u32,
106 }
107
108 #[derive(Diagnostic)]
109 #[diag(session_target_stack_protector_not_supported)]
110 pub struct StackProtectorNotSupportedForTarget<'a> {
111     pub stack_protector: StackProtector,
112     pub target_triple: &'a TargetTriple,
113 }
114
115 #[derive(Diagnostic)]
116 #[diag(session_split_debuginfo_unstable_platform)]
117 pub struct SplitDebugInfoUnstablePlatform {
118     pub debuginfo: SplitDebuginfo,
119 }
120
121 #[derive(Diagnostic)]
122 #[diag(session_file_is_not_writeable)]
123 pub struct FileIsNotWriteable<'a> {
124     pub file: &'a std::path::Path,
125 }
126
127 #[derive(Diagnostic)]
128 #[diag(session_crate_name_does_not_match)]
129 pub struct CrateNameDoesNotMatch<'a> {
130     #[primary_span]
131     pub span: Span,
132     pub s: &'a str,
133     pub name: Symbol,
134 }
135
136 #[derive(Diagnostic)]
137 #[diag(session_crate_name_invalid)]
138 pub struct CrateNameInvalid<'a> {
139     pub s: &'a str,
140 }
141
142 #[derive(Diagnostic)]
143 #[diag(session_crate_name_empty)]
144 pub struct CrateNameEmpty {
145     #[primary_span]
146     pub span: Option<Span>,
147 }
148
149 #[derive(Diagnostic)]
150 #[diag(session_invalid_character_in_create_name)]
151 pub struct InvalidCharacterInCrateName<'a> {
152     #[primary_span]
153     pub span: Option<Span>,
154     pub character: char,
155     pub crate_name: &'a str,
156 }
157
158 #[derive(Subdiagnostic)]
159 #[multipart_suggestion(session_expr_parentheses_needed, applicability = "machine-applicable")]
160 pub struct ExprParenthesesNeeded {
161     #[suggestion_part(code = "(")]
162     pub left: Span,
163     #[suggestion_part(code = ")")]
164     pub right: Span,
165 }
166
167 impl ExprParenthesesNeeded {
168     pub fn surrounding(s: Span) -> Self {
169         ExprParenthesesNeeded { left: s.shrink_to_lo(), right: s.shrink_to_hi() }
170     }
171 }
172
173 #[derive(Diagnostic)]
174 #[diag(session_skipping_const_checks)]
175 pub struct SkippingConstChecks {
176     #[subdiagnostic(eager)]
177     pub unleashed_features: Vec<UnleashedFeatureHelp>,
178 }
179
180 #[derive(Subdiagnostic)]
181 pub enum UnleashedFeatureHelp {
182     #[help(session_unleashed_feature_help_named)]
183     Named {
184         #[primary_span]
185         span: Span,
186         gate: Symbol,
187     },
188     #[help(session_unleashed_feature_help_unnamed)]
189     Unnamed {
190         #[primary_span]
191         span: Span,
192     },
193 }