|
1 | 1 | use std::num::NonZeroU32;
|
2 | 2 |
|
3 |
| -use crate as rustc_session; |
4 | 3 | use crate::cgu_reuse_tracker::CguReuse;
|
5 |
| -use rustc_errors::MultiSpan; |
| 4 | +use crate::{self as rustc_session, SessionDiagnostic}; |
| 5 | +use rustc_errors::{fluent, DiagnosticBuilder, Handler, MultiSpan}; |
6 | 6 | use rustc_macros::SessionDiagnostic;
|
7 | 7 | use rustc_span::{Span, Symbol};
|
| 8 | +use rustc_target::abi::TargetDataLayoutErrors; |
| 9 | +use rustc_target::spec::{SplitDebuginfo, StackProtector, TargetTriple}; |
8 | 10 |
|
9 | 11 | #[derive(SessionDiagnostic)]
|
10 | 12 | #[diag(session::incorrect_cgu_reuse_type)]
|
@@ -43,3 +45,128 @@ pub struct FeatureDiagnosticForIssue {
|
43 | 45 | pub struct FeatureDiagnosticHelp {
|
44 | 46 | pub feature: Symbol,
|
45 | 47 | }
|
| 48 | + |
| 49 | +impl SessionDiagnostic<'_, !> for TargetDataLayoutErrors<'_> { |
| 50 | + fn into_diagnostic(self, sess: &Handler) -> DiagnosticBuilder<'_, !> { |
| 51 | + let mut diag; |
| 52 | + match self { |
| 53 | + TargetDataLayoutErrors::InvalidAddressSpace { addr_space, err, cause } => { |
| 54 | + diag = sess.struct_fatal(fluent::session::target_invalid_address_space); |
| 55 | + diag.set_arg("addr_space", addr_space); |
| 56 | + diag.set_arg("cause", cause); |
| 57 | + diag.set_arg("err", err); |
| 58 | + diag |
| 59 | + } |
| 60 | + TargetDataLayoutErrors::InvalidBits { kind, bit, cause, err } => { |
| 61 | + diag = sess.struct_fatal(fluent::session::target_invalid_bits); |
| 62 | + diag.set_arg("kind", kind); |
| 63 | + diag.set_arg("bit", bit); |
| 64 | + diag.set_arg("cause", cause); |
| 65 | + diag.set_arg("err", err); |
| 66 | + diag |
| 67 | + } |
| 68 | + TargetDataLayoutErrors::MissingAlignment { cause } => { |
| 69 | + diag = sess.struct_fatal(fluent::session::target_missing_alignment); |
| 70 | + diag.set_arg("cause", cause); |
| 71 | + diag |
| 72 | + } |
| 73 | + TargetDataLayoutErrors::InvalidAlignment { cause, err } => { |
| 74 | + diag = sess.struct_fatal(fluent::session::target_invalid_alignment); |
| 75 | + diag.set_arg("cause", cause); |
| 76 | + diag.set_arg("err", err); |
| 77 | + diag |
| 78 | + } |
| 79 | + TargetDataLayoutErrors::InconsistentTargetArchitecture { dl, target } => { |
| 80 | + diag = sess.struct_fatal(fluent::session::target_inconsistent_architecture); |
| 81 | + diag.set_arg("dl", dl); |
| 82 | + diag.set_arg("target", target); |
| 83 | + diag |
| 84 | + } |
| 85 | + TargetDataLayoutErrors::InconsistentTargetPointerWidth { pointer_size, target } => { |
| 86 | + diag = sess.struct_fatal(fluent::session::target_inconsistent_pointer_width); |
| 87 | + diag.set_arg("pointer_size", pointer_size); |
| 88 | + diag.set_arg("target", target); |
| 89 | + diag |
| 90 | + } |
| 91 | + TargetDataLayoutErrors::InvalidBitsSize { err } => { |
| 92 | + diag = sess.struct_fatal(fluent::session::target_invalid_bits_size); |
| 93 | + diag.set_arg("err", err); |
| 94 | + diag |
| 95 | + } |
| 96 | + } |
| 97 | + } |
| 98 | +} |
| 99 | + |
| 100 | +#[derive(SessionDiagnostic)] |
| 101 | +#[diag(session::not_circumvent_feature)] |
| 102 | +pub struct NotCircumventFeature; |
| 103 | + |
| 104 | +#[derive(SessionDiagnostic)] |
| 105 | +#[diag(session::linker_plugin_lto_windows_not_supported)] |
| 106 | +pub struct LinkerPluginToWindowsNotSupported; |
| 107 | + |
| 108 | +#[derive(SessionDiagnostic)] |
| 109 | +#[diag(session::profile_use_file_does_not_exist)] |
| 110 | +pub struct ProfileUseFileDoesNotExist<'a> { |
| 111 | + pub path: &'a std::path::Path, |
| 112 | +} |
| 113 | + |
| 114 | +#[derive(SessionDiagnostic)] |
| 115 | +#[diag(session::profile_sample_use_file_does_not_exist)] |
| 116 | +pub struct ProfileSampleUseFileDoesNotExist<'a> { |
| 117 | + pub path: &'a std::path::Path, |
| 118 | +} |
| 119 | + |
| 120 | +#[derive(SessionDiagnostic)] |
| 121 | +#[diag(session::target_requires_unwind_tables)] |
| 122 | +pub struct TargetRequiresUnwindTables; |
| 123 | + |
| 124 | +#[derive(SessionDiagnostic)] |
| 125 | +#[diag(session::sanitizer_not_supported)] |
| 126 | +pub struct SanitizerNotSupported { |
| 127 | + pub us: String, |
| 128 | +} |
| 129 | + |
| 130 | +#[derive(SessionDiagnostic)] |
| 131 | +#[diag(session::sanitizers_not_supported)] |
| 132 | +pub struct SanitizersNotSupported { |
| 133 | + pub us: String, |
| 134 | +} |
| 135 | + |
| 136 | +#[derive(SessionDiagnostic)] |
| 137 | +#[diag(session::cannot_mix_and_match_sanitizers)] |
| 138 | +pub struct CannotMixAndMatchSanitizers { |
| 139 | + pub first: String, |
| 140 | + pub second: String, |
| 141 | +} |
| 142 | + |
| 143 | +#[derive(SessionDiagnostic)] |
| 144 | +#[diag(session::cannot_enable_crt_static_linux)] |
| 145 | +pub struct CannotEnableCrtStaticLinux; |
| 146 | + |
| 147 | +#[derive(SessionDiagnostic)] |
| 148 | +#[diag(session::sanitizer_cfi_enabled)] |
| 149 | +pub struct SanitizerCfiEnabled; |
| 150 | + |
| 151 | +#[derive(SessionDiagnostic)] |
| 152 | +#[diag(session::unstable_virtual_function_elimination)] |
| 153 | +pub struct UnstableVirtualFunctionElimination; |
| 154 | + |
| 155 | +#[derive(SessionDiagnostic)] |
| 156 | +#[diag(session::unsupported_dwarf_version)] |
| 157 | +pub struct UnsupportedDwarfVersion { |
| 158 | + pub dwarf_version: u32, |
| 159 | +} |
| 160 | + |
| 161 | +#[derive(SessionDiagnostic)] |
| 162 | +#[diag(session::target_stack_protector_not_supported)] |
| 163 | +pub struct StackProtectorNotSupportedForTarget<'a> { |
| 164 | + pub stack_protector: StackProtector, |
| 165 | + pub target_triple: &'a TargetTriple, |
| 166 | +} |
| 167 | + |
| 168 | +#[derive(SessionDiagnostic)] |
| 169 | +#[diag(session::split_debuginfo_unstable_platform)] |
| 170 | +pub struct SplitDebugInfoUnstablePlatform { |
| 171 | + pub debuginfo: SplitDebuginfo, |
| 172 | +} |
0 commit comments