1 use std::num::NonZeroU32;
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};
10 #[diag(session::incorrect_cgu_reuse_type)]
11 pub struct IncorrectCguReuseType<'a> {
14 pub cgu_user_name: &'a str,
15 pub actual_reuse: CguReuse,
16 pub expected_reuse: CguReuse,
21 #[diag(session::cgu_not_recorded)]
22 pub struct CguNotRecorded<'a> {
23 pub cgu_user_name: &'a str,
24 pub cgu_name: &'a str,
28 #[diag(session::feature_gate_error, code = "E0658")]
29 pub struct FeatureGateError<'a> {
35 #[derive(Subdiagnostic)]
36 #[note(session::feature_diagnostic_for_issue)]
37 pub struct FeatureDiagnosticForIssue {
41 #[derive(Subdiagnostic)]
42 #[help(session::feature_diagnostic_help)]
43 pub struct FeatureDiagnosticHelp {
48 #[diag(session::not_circumvent_feature)]
49 pub struct NotCircumventFeature;
52 #[diag(session::linker_plugin_lto_windows_not_supported)]
53 pub struct LinkerPluginToWindowsNotSupported;
56 #[diag(session::profile_use_file_does_not_exist)]
57 pub struct ProfileUseFileDoesNotExist<'a> {
58 pub path: &'a std::path::Path,
62 #[diag(session::profile_sample_use_file_does_not_exist)]
63 pub struct ProfileSampleUseFileDoesNotExist<'a> {
64 pub path: &'a std::path::Path,
68 #[diag(session::target_requires_unwind_tables)]
69 pub struct TargetRequiresUnwindTables;
72 #[diag(session::sanitizer_not_supported)]
73 pub struct SanitizerNotSupported {
78 #[diag(session::sanitizers_not_supported)]
79 pub struct SanitizersNotSupported {
84 #[diag(session::cannot_mix_and_match_sanitizers)]
85 pub struct CannotMixAndMatchSanitizers {
91 #[diag(session::cannot_enable_crt_static_linux)]
92 pub struct CannotEnableCrtStaticLinux;
95 #[diag(session::sanitizer_cfi_enabled)]
96 pub struct SanitizerCfiEnabled;
99 #[diag(session::unstable_virtual_function_elimination)]
100 pub struct UnstableVirtualFunctionElimination;
102 #[derive(Diagnostic)]
103 #[diag(session::unsupported_dwarf_version)]
104 pub struct UnsupportedDwarfVersion {
105 pub dwarf_version: u32,
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,
115 #[derive(Diagnostic)]
116 #[diag(session::split_debuginfo_unstable_platform)]
117 pub struct SplitDebugInfoUnstablePlatform {
118 pub debuginfo: SplitDebuginfo,
121 #[derive(Diagnostic)]
122 #[diag(session::file_is_not_writeable)]
123 pub struct FileIsNotWriteable<'a> {
124 pub file: &'a std::path::Path,
127 #[derive(Diagnostic)]
128 #[diag(session::crate_name_does_not_match)]
129 pub struct CrateNameDoesNotMatch<'a> {
136 #[derive(Diagnostic)]
137 #[diag(session::crate_name_invalid)]
138 pub struct CrateNameInvalid<'a> {
142 #[derive(Diagnostic)]
143 #[diag(session::crate_name_empty)]
144 pub struct CrateNameEmpty {
146 pub span: Option<Span>,
149 #[derive(Diagnostic)]
150 #[diag(session::invalid_character_in_create_name)]
151 pub struct InvalidCharacterInCrateName<'a> {
153 pub span: Option<Span>,
155 pub crate_name: &'a str,
158 #[derive(Subdiagnostic)]
159 #[multipart_suggestion(session::expr_parentheses_needed, applicability = "machine-applicable")]
160 pub struct ExprParenthesesNeeded {
161 #[suggestion_part(code = "(")]
163 #[suggestion_part(code = ")")]
167 impl ExprParenthesesNeeded {
168 pub fn surrounding(s: Span) -> Self {
169 ExprParenthesesNeeded { left: s.shrink_to_lo(), right: s.shrink_to_hi() }
173 #[derive(Diagnostic)]
174 #[diag(session::skipping_const_checks)]
175 pub struct SkippingConstChecks {
176 #[subdiagnostic(eager)]
177 pub unleashed_features: Vec<UnleashedFeatureHelp>,
180 #[derive(Subdiagnostic)]
181 pub enum UnleashedFeatureHelp {
182 #[help(session::unleashed_feature_help_named)]
188 #[help(session::unleashed_feature_help_unnamed)]