Skip to content

Commit f475098

Browse files
committed
Auto merge of #113877 - JhonnyBillM:reuse-codegen-ssa-monomorphization-errors-in-gcc, r=davidtwco
Reuse `codegen_ssa` monomorphization errors in `codegen_gcc` Removes monomorphization errors duplication by reusing the ones defined in `codegen_ssa`. Also updates `expected_simd` errors usage in `codegen_gcc` by assuming we want to treat those parameters as translatable. See 7a888fb
2 parents ced592a + 7a888fb commit f475098

File tree

4 files changed

+58
-322
lines changed

4 files changed

+58
-322
lines changed

compiler/rustc_codegen_gcc/messages.ftl

-57
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,6 @@
11
codegen_gcc_invalid_minimum_alignment =
22
invalid minimum global alignment: {$err}
33
4-
codegen_gcc_invalid_monomorphization_basic_integer =
5-
invalid monomorphization of `{$name}` intrinsic: expected basic integer type, found `{$ty}`
6-
7-
codegen_gcc_invalid_monomorphization_expected_signed_unsigned =
8-
invalid monomorphization of `{$name}` intrinsic: expected element type `{$elem_ty}` of vector type `{$vec_ty}` to be a signed or unsigned integer type
9-
10-
codegen_gcc_invalid_monomorphization_expected_simd =
11-
invalid monomorphization of `{$name}` intrinsic: expected SIMD {$expected_ty} type, found non-SIMD `{$found_ty}`
12-
13-
codegen_gcc_invalid_monomorphization_inserted_type =
14-
invalid monomorphization of `{$name}` intrinsic: expected inserted type `{$in_elem}` (element of input `{$in_ty}`), found `{$out_ty}`
15-
16-
codegen_gcc_invalid_monomorphization_invalid_bitmask =
17-
invalid monomorphization of `{$name}` intrinsic: invalid bitmask `{$ty}`, expected `u{$expected_int_bits}` or `[u8; {$expected_bytes}]`
18-
19-
codegen_gcc_invalid_monomorphization_invalid_float_vector =
20-
invalid monomorphization of `{$name}` intrinsic: unsupported element type `{$elem_ty}` of floating-point vector `{$vec_ty}`
21-
22-
codegen_gcc_invalid_monomorphization_mask_type =
23-
invalid monomorphization of `{$name}` intrinsic: mask element type is `{$ty}`, expected `i_`
24-
25-
codegen_gcc_invalid_monomorphization_mismatched_lengths =
26-
invalid monomorphization of `{$name}` intrinsic: mismatched lengths: mask length `{$m_len}` != other vector length `{$v_len}`
27-
28-
codegen_gcc_invalid_monomorphization_not_float =
29-
invalid monomorphization of `{$name}` intrinsic: `{$ty}` is not a floating-point type
30-
31-
codegen_gcc_invalid_monomorphization_return_element =
32-
invalid monomorphization of `{$name}` intrinsic: expected return element type `{$in_elem}` (element of input `{$in_ty}`), found `{$ret_ty}` with element type `{$out_ty}`
33-
34-
codegen_gcc_invalid_monomorphization_return_integer_type =
35-
invalid monomorphization of `{$name}` intrinsic: expected return type with integer elements, found `{$ret_ty}` with non-integer `{$out_ty}`
36-
37-
codegen_gcc_invalid_monomorphization_return_length =
38-
invalid monomorphization of `{$name}` intrinsic: expected return type of length {$in_len}, found `{$ret_ty}` with length {$out_len}
39-
40-
codegen_gcc_invalid_monomorphization_return_length_input_type =
41-
invalid monomorphization of `{$name}` intrinsic: expected return type with length {$in_len} (same as input type `{$in_ty}`), found `{$ret_ty}` with length {$out_len}
42-
43-
codegen_gcc_invalid_monomorphization_return_type =
44-
invalid monomorphization of `{$name}` intrinsic: expected return type `{$in_elem}` (element of input `{$in_ty}`), found `{$ret_ty}`
45-
46-
codegen_gcc_invalid_monomorphization_simd_shuffle =
47-
invalid monomorphization of `{$name}` intrinsic: simd_shuffle index must be an array of `u32`, got `{$ty}`
48-
49-
codegen_gcc_invalid_monomorphization_unrecognized =
50-
invalid monomorphization of `{$name}` intrinsic: unrecognized intrinsic `{$name}`
51-
52-
codegen_gcc_invalid_monomorphization_unsupported_cast =
53-
invalid monomorphization of `{$name}` intrinsic: unsupported cast from `{$in_ty}` with element `{$in_elem}` to `{$ret_ty}` with element `{$out_elem}`
54-
55-
codegen_gcc_invalid_monomorphization_unsupported_element =
56-
invalid monomorphization of `{$name}` intrinsic: unsupported {$name} from `{$in_ty}` with element `{$elem_ty}` to `{$ret_ty}`
57-
58-
codegen_gcc_invalid_monomorphization_unsupported_operation =
59-
invalid monomorphization of `{$name}` intrinsic: unsupported operation on `{$in_ty}` with element `{$in_elem}`
60-
614
codegen_gcc_lto_not_supported =
625
LTO is not supported. You may get a linker error.
636

compiler/rustc_codegen_gcc/src/errors.rs

+1-197
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use rustc_errors::{DiagnosticArgValue, IntoDiagnosticArg};
22
use rustc_macros::Diagnostic;
3-
use rustc_middle::ty::Ty;
4-
use rustc_span::{Span, Symbol};
3+
use rustc_span::Span;
54
use std::borrow::Cow;
65

76
struct ExitCode(Option<i32>);
@@ -16,201 +15,6 @@ impl IntoDiagnosticArg for ExitCode {
1615
}
1716
}
1817

19-
#[derive(Diagnostic)]
20-
#[diag(codegen_gcc_invalid_monomorphization_basic_integer, code = "E0511")]
21-
pub(crate) struct InvalidMonomorphizationBasicInteger<'a> {
22-
#[primary_span]
23-
pub span: Span,
24-
pub name: Symbol,
25-
pub ty: Ty<'a>,
26-
}
27-
28-
#[derive(Diagnostic)]
29-
#[diag(codegen_gcc_invalid_monomorphization_invalid_float_vector, code = "E0511")]
30-
pub(crate) struct InvalidMonomorphizationInvalidFloatVector<'a> {
31-
#[primary_span]
32-
pub span: Span,
33-
pub name: Symbol,
34-
pub elem_ty: &'a str,
35-
pub vec_ty: Ty<'a>,
36-
}
37-
38-
#[derive(Diagnostic)]
39-
#[diag(codegen_gcc_invalid_monomorphization_not_float, code = "E0511")]
40-
pub(crate) struct InvalidMonomorphizationNotFloat<'a> {
41-
#[primary_span]
42-
pub span: Span,
43-
pub name: Symbol,
44-
pub ty: Ty<'a>,
45-
}
46-
47-
#[derive(Diagnostic)]
48-
#[diag(codegen_gcc_invalid_monomorphization_unrecognized, code = "E0511")]
49-
pub(crate) struct InvalidMonomorphizationUnrecognized {
50-
#[primary_span]
51-
pub span: Span,
52-
pub name: Symbol,
53-
}
54-
55-
#[derive(Diagnostic)]
56-
#[diag(codegen_gcc_invalid_monomorphization_expected_signed_unsigned, code = "E0511")]
57-
pub(crate) struct InvalidMonomorphizationExpectedSignedUnsigned<'a> {
58-
#[primary_span]
59-
pub span: Span,
60-
pub name: Symbol,
61-
pub elem_ty: Ty<'a>,
62-
pub vec_ty: Ty<'a>,
63-
}
64-
65-
#[derive(Diagnostic)]
66-
#[diag(codegen_gcc_invalid_monomorphization_unsupported_element, code = "E0511")]
67-
pub(crate) struct InvalidMonomorphizationUnsupportedElement<'a> {
68-
#[primary_span]
69-
pub span: Span,
70-
pub name: Symbol,
71-
pub in_ty: Ty<'a>,
72-
pub elem_ty: Ty<'a>,
73-
pub ret_ty: Ty<'a>,
74-
}
75-
76-
#[derive(Diagnostic)]
77-
#[diag(codegen_gcc_invalid_monomorphization_invalid_bitmask, code = "E0511")]
78-
pub(crate) struct InvalidMonomorphizationInvalidBitmask<'a> {
79-
#[primary_span]
80-
pub span: Span,
81-
pub name: Symbol,
82-
pub ty: Ty<'a>,
83-
pub expected_int_bits: u64,
84-
pub expected_bytes: u64,
85-
}
86-
87-
#[derive(Diagnostic)]
88-
#[diag(codegen_gcc_invalid_monomorphization_simd_shuffle, code = "E0511")]
89-
pub(crate) struct InvalidMonomorphizationSimdShuffle<'a> {
90-
#[primary_span]
91-
pub span: Span,
92-
pub name: Symbol,
93-
pub ty: Ty<'a>,
94-
}
95-
96-
#[derive(Diagnostic)]
97-
#[diag(codegen_gcc_invalid_monomorphization_expected_simd, code = "E0511")]
98-
pub(crate) struct InvalidMonomorphizationExpectedSimd<'a> {
99-
#[primary_span]
100-
pub span: Span,
101-
pub name: Symbol,
102-
pub position: &'a str,
103-
pub found_ty: Ty<'a>,
104-
}
105-
106-
#[derive(Diagnostic)]
107-
#[diag(codegen_gcc_invalid_monomorphization_mask_type, code = "E0511")]
108-
pub(crate) struct InvalidMonomorphizationMaskType<'a> {
109-
#[primary_span]
110-
pub span: Span,
111-
pub name: Symbol,
112-
pub ty: Ty<'a>,
113-
}
114-
115-
#[derive(Diagnostic)]
116-
#[diag(codegen_gcc_invalid_monomorphization_return_length, code = "E0511")]
117-
pub(crate) struct InvalidMonomorphizationReturnLength<'a> {
118-
#[primary_span]
119-
pub span: Span,
120-
pub name: Symbol,
121-
pub in_len: u64,
122-
pub ret_ty: Ty<'a>,
123-
pub out_len: u64,
124-
}
125-
126-
#[derive(Diagnostic)]
127-
#[diag(codegen_gcc_invalid_monomorphization_return_length_input_type, code = "E0511")]
128-
pub(crate) struct InvalidMonomorphizationReturnLengthInputType<'a> {
129-
#[primary_span]
130-
pub span: Span,
131-
pub name: Symbol,
132-
pub in_len: u64,
133-
pub in_ty: Ty<'a>,
134-
pub ret_ty: Ty<'a>,
135-
pub out_len: u64,
136-
}
137-
138-
#[derive(Diagnostic)]
139-
#[diag(codegen_gcc_invalid_monomorphization_return_element, code = "E0511")]
140-
pub(crate) struct InvalidMonomorphizationReturnElement<'a> {
141-
#[primary_span]
142-
pub span: Span,
143-
pub name: Symbol,
144-
pub in_elem: Ty<'a>,
145-
pub in_ty: Ty<'a>,
146-
pub ret_ty: Ty<'a>,
147-
pub out_ty: Ty<'a>,
148-
}
149-
150-
#[derive(Diagnostic)]
151-
#[diag(codegen_gcc_invalid_monomorphization_return_type, code = "E0511")]
152-
pub(crate) struct InvalidMonomorphizationReturnType<'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-
}
160-
161-
#[derive(Diagnostic)]
162-
#[diag(codegen_gcc_invalid_monomorphization_inserted_type, code = "E0511")]
163-
pub(crate) struct InvalidMonomorphizationInsertedType<'a> {
164-
#[primary_span]
165-
pub span: Span,
166-
pub name: Symbol,
167-
pub in_elem: Ty<'a>,
168-
pub in_ty: Ty<'a>,
169-
pub out_ty: Ty<'a>,
170-
}
171-
172-
#[derive(Diagnostic)]
173-
#[diag(codegen_gcc_invalid_monomorphization_return_integer_type, code = "E0511")]
174-
pub(crate) struct InvalidMonomorphizationReturnIntegerType<'a> {
175-
#[primary_span]
176-
pub span: Span,
177-
pub name: Symbol,
178-
pub ret_ty: Ty<'a>,
179-
pub out_ty: Ty<'a>,
180-
}
181-
182-
#[derive(Diagnostic)]
183-
#[diag(codegen_gcc_invalid_monomorphization_mismatched_lengths, code = "E0511")]
184-
pub(crate) struct InvalidMonomorphizationMismatchedLengths {
185-
#[primary_span]
186-
pub span: Span,
187-
pub name: Symbol,
188-
pub m_len: u64,
189-
pub v_len: u64,
190-
}
191-
192-
#[derive(Diagnostic)]
193-
#[diag(codegen_gcc_invalid_monomorphization_unsupported_cast, code = "E0511")]
194-
pub(crate) struct InvalidMonomorphizationUnsupportedCast<'a> {
195-
#[primary_span]
196-
pub span: Span,
197-
pub name: Symbol,
198-
pub in_ty: Ty<'a>,
199-
pub in_elem: Ty<'a>,
200-
pub ret_ty: Ty<'a>,
201-
pub out_elem: Ty<'a>,
202-
}
203-
204-
#[derive(Diagnostic)]
205-
#[diag(codegen_gcc_invalid_monomorphization_unsupported_operation, code = "E0511")]
206-
pub(crate) struct InvalidMonomorphizationUnsupportedOperation<'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-
}
213-
21418
#[derive(Diagnostic)]
21519
#[diag(codegen_gcc_lto_not_supported)]
21620
pub(crate) struct LTONotSupported;

compiler/rustc_codegen_gcc/src/intrinsic/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ use rustc_codegen_ssa::mir::place::PlaceRef;
1313
use rustc_codegen_ssa::traits::{ArgAbiMethods, BaseTypeMethods, BuilderMethods, ConstMethods, IntrinsicCallMethods};
1414
#[cfg(feature="master")]
1515
use rustc_codegen_ssa::traits::{DerivedTypeMethods, MiscMethods};
16+
use rustc_codegen_ssa::errors::InvalidMonomorphization;
1617
use rustc_middle::bug;
1718
use rustc_middle::ty::{self, Instance, Ty};
1819
use rustc_middle::ty::layout::LayoutOf;
@@ -31,7 +32,6 @@ use crate::abi::FnAbiGccExt;
3132
use crate::builder::Builder;
3233
use crate::common::{SignType, TypeReflection};
3334
use crate::context::CodegenCx;
34-
use crate::errors::InvalidMonomorphizationBasicInteger;
3535
use crate::type_of::LayoutGccExt;
3636
use crate::intrinsic::simd::generic_simd_intrinsic;
3737

@@ -256,7 +256,7 @@ impl<'a, 'gcc, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'a, 'gcc, 'tcx> {
256256
_ => bug!(),
257257
},
258258
None => {
259-
tcx.sess.emit_err(InvalidMonomorphizationBasicInteger { span, name, ty });
259+
tcx.sess.emit_err(InvalidMonomorphization::BasicIntegerType { span, name, ty });
260260
return;
261261
}
262262
}

0 commit comments

Comments
 (0)