|
| 1 | +use rustc_errors::{DiagnosticArgValue, IntoDiagnosticArg}; |
| 2 | +use rustc_macros::Diagnostic; |
| 3 | +use rustc_middle::ty::Ty; |
| 4 | +use rustc_span::{Span, Symbol}; |
| 5 | +use std::borrow::Cow; |
| 6 | + |
| 7 | +struct ExitCode(Option<i32>); |
| 8 | + |
| 9 | +impl IntoDiagnosticArg for ExitCode { |
| 10 | + fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> { |
| 11 | + let ExitCode(exit_code) = self; |
| 12 | + match exit_code { |
| 13 | + Some(t) => t.into_diagnostic_arg(), |
| 14 | + None => DiagnosticArgValue::Str(Cow::Borrowed("<signal>")), |
| 15 | + } |
| 16 | + } |
| 17 | +} |
| 18 | + |
| 19 | +#[derive(Diagnostic)] |
| 20 | +#[diag(codegen_gcc::ranlib_failure)] |
| 21 | +pub(crate) struct RanlibFailure { |
| 22 | + exit_code: ExitCode, |
| 23 | +} |
| 24 | + |
| 25 | +impl RanlibFailure { |
| 26 | + pub fn new(exit_code: Option<i32>) -> Self { |
| 27 | + RanlibFailure { exit_code: ExitCode(exit_code) } |
| 28 | + } |
| 29 | +} |
| 30 | + |
| 31 | +#[derive(Diagnostic)] |
| 32 | +#[diag(codegen_gcc::invalid_monomorphization_basic_integer, code = "E0511")] |
| 33 | +pub(crate) struct InvalidMonomorphizationBasicInteger<'a> { |
| 34 | + #[primary_span] |
| 35 | + pub span: Span, |
| 36 | + pub name: Symbol, |
| 37 | + pub ty: Ty<'a>, |
| 38 | +} |
| 39 | + |
| 40 | +#[derive(Diagnostic)] |
| 41 | +#[diag(codegen_gcc::invalid_monomorphization_invalid_float_vector, code = "E0511")] |
| 42 | +pub(crate) struct InvalidMonomorphizationInvalidFloatVector<'a> { |
| 43 | + #[primary_span] |
| 44 | + pub span: Span, |
| 45 | + pub name: Symbol, |
| 46 | + pub elem_ty: &'a str, |
| 47 | + pub vec_ty: Ty<'a>, |
| 48 | +} |
| 49 | + |
| 50 | +#[derive(Diagnostic)] |
| 51 | +#[diag(codegen_gcc::invalid_monomorphization_not_float, code = "E0511")] |
| 52 | +pub(crate) struct InvalidMonomorphizationNotFloat<'a> { |
| 53 | + #[primary_span] |
| 54 | + pub span: Span, |
| 55 | + pub name: Symbol, |
| 56 | + pub ty: Ty<'a>, |
| 57 | +} |
| 58 | + |
| 59 | +#[derive(Diagnostic)] |
| 60 | +#[diag(codegen_gcc::invalid_monomorphization_unrecognized, code = "E0511")] |
| 61 | +pub(crate) struct InvalidMonomorphizationUnrecognized { |
| 62 | + #[primary_span] |
| 63 | + pub span: Span, |
| 64 | + pub name: Symbol, |
| 65 | +} |
| 66 | + |
| 67 | +#[derive(Diagnostic)] |
| 68 | +#[diag(codegen_gcc::invalid_monomorphization_expected_signed_unsigned, code = "E0511")] |
| 69 | +pub(crate) struct InvalidMonomorphizationExpectedSignedUnsigned<'a> { |
| 70 | + #[primary_span] |
| 71 | + pub span: Span, |
| 72 | + pub name: Symbol, |
| 73 | + pub elem_ty: Ty<'a>, |
| 74 | + pub vec_ty: Ty<'a>, |
| 75 | +} |
| 76 | + |
| 77 | +#[derive(Diagnostic)] |
| 78 | +#[diag(codegen_gcc::invalid_monomorphization_unsupported_element, code = "E0511")] |
| 79 | +pub(crate) struct InvalidMonomorphizationUnsupportedElement<'a> { |
| 80 | + #[primary_span] |
| 81 | + pub span: Span, |
| 82 | + pub name: Symbol, |
| 83 | + pub in_ty: Ty<'a>, |
| 84 | + pub elem_ty: Ty<'a>, |
| 85 | + pub ret_ty: Ty<'a>, |
| 86 | +} |
| 87 | + |
| 88 | +#[derive(Diagnostic)] |
| 89 | +#[diag(codegen_gcc::invalid_monomorphization_invalid_bitmask, code = "E0511")] |
| 90 | +pub(crate) struct InvalidMonomorphizationInvalidBitmask<'a> { |
| 91 | + #[primary_span] |
| 92 | + pub span: Span, |
| 93 | + pub name: Symbol, |
| 94 | + pub ty: Ty<'a>, |
| 95 | + pub expected_int_bits: u64, |
| 96 | + pub expected_bytes: u64, |
| 97 | +} |
| 98 | + |
| 99 | +#[derive(Diagnostic)] |
| 100 | +#[diag(codegen_gcc::invalid_monomorphization_simd_shuffle, code = "E0511")] |
| 101 | +pub(crate) struct InvalidMonomorphizationSimdShuffle<'a> { |
| 102 | + #[primary_span] |
| 103 | + pub span: Span, |
| 104 | + pub name: Symbol, |
| 105 | + pub ty: Ty<'a>, |
| 106 | +} |
| 107 | + |
| 108 | +#[derive(Diagnostic)] |
| 109 | +#[diag(codegen_gcc::invalid_monomorphization_expected_simd, code = "E0511")] |
| 110 | +pub(crate) struct InvalidMonomorphizationExpectedSimd<'a> { |
| 111 | + #[primary_span] |
| 112 | + pub span: Span, |
| 113 | + pub name: Symbol, |
| 114 | + pub position: &'a str, |
| 115 | + pub found_ty: Ty<'a>, |
| 116 | +} |
| 117 | + |
| 118 | +#[derive(Diagnostic)] |
| 119 | +#[diag(codegen_gcc::invalid_monomorphization_mask_type, code = "E0511")] |
| 120 | +pub(crate) struct InvalidMonomorphizationMaskType<'a> { |
| 121 | + #[primary_span] |
| 122 | + pub span: Span, |
| 123 | + pub name: Symbol, |
| 124 | + pub ty: Ty<'a>, |
| 125 | +} |
| 126 | + |
| 127 | +#[derive(Diagnostic)] |
| 128 | +#[diag(codegen_gcc::invalid_monomorphization_return_length, code = "E0511")] |
| 129 | +pub(crate) struct InvalidMonomorphizationReturnLength<'a> { |
| 130 | + #[primary_span] |
| 131 | + pub span: Span, |
| 132 | + pub name: Symbol, |
| 133 | + pub in_len: u64, |
| 134 | + pub ret_ty: Ty<'a>, |
| 135 | + pub out_len: u64, |
| 136 | +} |
| 137 | + |
| 138 | +#[derive(Diagnostic)] |
| 139 | +#[diag(codegen_gcc::invalid_monomorphization_return_length_input_type, code = "E0511")] |
| 140 | +pub(crate) struct InvalidMonomorphizationReturnLengthInputType<'a> { |
| 141 | + #[primary_span] |
| 142 | + pub span: Span, |
| 143 | + pub name: Symbol, |
| 144 | + pub in_len: u64, |
| 145 | + pub in_ty: Ty<'a>, |
| 146 | + pub ret_ty: Ty<'a>, |
| 147 | + pub out_len: u64, |
| 148 | +} |
| 149 | + |
| 150 | +#[derive(Diagnostic)] |
| 151 | +#[diag(codegen_gcc::invalid_monomorphization_return_element, code = "E0511")] |
| 152 | +pub(crate) struct InvalidMonomorphizationReturnElement<'a> { |
| 153 | + #[primary_span] |
| 154 | + pub span: Span, |
| 155 | + pub name: Symbol, |
| 156 | + pub in_elem: Ty<'a>, |
| 157 | + pub in_ty: Ty<'a>, |
| 158 | + pub ret_ty: Ty<'a>, |
| 159 | + pub out_ty: Ty<'a>, |
| 160 | +} |
| 161 | + |
| 162 | +#[derive(Diagnostic)] |
| 163 | +#[diag(codegen_gcc::invalid_monomorphization_return_type, code = "E0511")] |
| 164 | +pub(crate) struct InvalidMonomorphizationReturnType<'a> { |
| 165 | + #[primary_span] |
| 166 | + pub span: Span, |
| 167 | + pub name: Symbol, |
| 168 | + pub in_elem: Ty<'a>, |
| 169 | + pub in_ty: Ty<'a>, |
| 170 | + pub ret_ty: Ty<'a>, |
| 171 | +} |
| 172 | + |
| 173 | +#[derive(Diagnostic)] |
| 174 | +#[diag(codegen_gcc::invalid_monomorphization_inserted_type, code = "E0511")] |
| 175 | +pub(crate) struct InvalidMonomorphizationInsertedType<'a> { |
| 176 | + #[primary_span] |
| 177 | + pub span: Span, |
| 178 | + pub name: Symbol, |
| 179 | + pub in_elem: Ty<'a>, |
| 180 | + pub in_ty: Ty<'a>, |
| 181 | + pub out_ty: Ty<'a>, |
| 182 | +} |
| 183 | + |
| 184 | +#[derive(Diagnostic)] |
| 185 | +#[diag(codegen_gcc::invalid_monomorphization_return_integer_type, code = "E0511")] |
| 186 | +pub(crate) struct InvalidMonomorphizationReturnIntegerType<'a> { |
| 187 | + #[primary_span] |
| 188 | + pub span: Span, |
| 189 | + pub name: Symbol, |
| 190 | + pub ret_ty: Ty<'a>, |
| 191 | + pub out_ty: Ty<'a>, |
| 192 | +} |
| 193 | + |
| 194 | +#[derive(Diagnostic)] |
| 195 | +#[diag(codegen_gcc::invalid_monomorphization_mismatched_lengths, code = "E0511")] |
| 196 | +pub(crate) struct InvalidMonomorphizationMismatchedLengths { |
| 197 | + #[primary_span] |
| 198 | + pub span: Span, |
| 199 | + pub name: Symbol, |
| 200 | + pub m_len: u64, |
| 201 | + pub v_len: u64, |
| 202 | +} |
| 203 | + |
| 204 | +#[derive(Diagnostic)] |
| 205 | +#[diag(codegen_gcc::invalid_monomorphization_unsupported_cast, code = "E0511")] |
| 206 | +pub(crate) struct InvalidMonomorphizationUnsupportedCast<'a> { |
| 207 | + #[primary_span] |
| 208 | + pub span: Span, |
| 209 | + pub name: Symbol, |
| 210 | + pub in_ty: Ty<'a>, |
| 211 | + pub in_elem: Ty<'a>, |
| 212 | + pub ret_ty: Ty<'a>, |
| 213 | + pub out_elem: Ty<'a>, |
| 214 | +} |
| 215 | + |
| 216 | +#[derive(Diagnostic)] |
| 217 | +#[diag(codegen_gcc::invalid_monomorphization_unsupported_operation, code = "E0511")] |
| 218 | +pub(crate) struct InvalidMonomorphizationUnsupportedOperation<'a> { |
| 219 | + #[primary_span] |
| 220 | + pub span: Span, |
| 221 | + pub name: Symbol, |
| 222 | + pub in_ty: Ty<'a>, |
| 223 | + pub in_elem: Ty<'a>, |
| 224 | +} |
| 225 | + |
| 226 | +#[derive(Diagnostic)] |
| 227 | +#[diag(codegen_gcc::linkage_const_or_mut_type)] |
| 228 | +pub(crate) struct LinkageConstOrMutType { |
| 229 | + #[primary_span] |
| 230 | + pub span: Span |
| 231 | +} |
| 232 | + |
| 233 | +#[derive(Diagnostic)] |
| 234 | +#[diag(codegen_gcc::lto_not_supported)] |
| 235 | +pub(crate) struct LTONotSupported; |
| 236 | + |
| 237 | +#[derive(Diagnostic)] |
| 238 | +#[diag(codegen_gcc::unwinding_inline_asm)] |
| 239 | +pub(crate) struct UnwindingInlineAsm { |
| 240 | + #[primary_span] |
| 241 | + pub span: Span |
| 242 | +} |
0 commit comments