]> git.lizzy.rs Git - rust.git/blob - src/librustc_codegen_ssa/error_codes.rs
Rollup merge of #66263 - guanqun:make-error-explicit, r=alexcrichton
[rust.git] / src / librustc_codegen_ssa / error_codes.rs
1 syntax::register_diagnostics! {
2
3 E0511: r##"
4 Invalid monomorphization of an intrinsic function was used. Erroneous code
5 example:
6
7 ```ignore (error-emitted-at-codegen-which-cannot-be-handled-by-compile_fail)
8 #![feature(platform_intrinsics)]
9
10 extern "platform-intrinsic" {
11     fn simd_add<T>(a: T, b: T) -> T;
12 }
13
14 fn main() {
15     unsafe { simd_add(0, 1); }
16     // error: invalid monomorphization of `simd_add` intrinsic
17 }
18 ```
19
20 The generic type has to be a SIMD type. Example:
21
22 ```
23 #![feature(repr_simd)]
24 #![feature(platform_intrinsics)]
25
26 #[repr(simd)]
27 #[derive(Copy, Clone)]
28 struct i32x2(i32, i32);
29
30 extern "platform-intrinsic" {
31     fn simd_add<T>(a: T, b: T) -> T;
32 }
33
34 unsafe { simd_add(i32x2(0, 0), i32x2(1, 2)); } // ok!
35 ```
36 "##,
37
38 E0668: r##"
39 Malformed inline assembly rejected by LLVM.
40
41 LLVM checks the validity of the constraints and the assembly string passed to
42 it. This error implies that LLVM seems something wrong with the inline
43 assembly call.
44
45 In particular, it can happen if you forgot the closing bracket of a register
46 constraint (see issue #51430):
47 ```ignore (error-emitted-at-codegen-which-cannot-be-handled-by-compile_fail)
48 #![feature(asm)]
49
50 fn main() {
51     let rax: u64;
52     unsafe {
53         asm!("" :"={rax"(rax));
54         println!("Accumulator is: {}", rax);
55     }
56 }
57 ```
58 "##,
59
60 E0669: r##"
61 Cannot convert inline assembly operand to a single LLVM value.
62
63 This error usually happens when trying to pass in a value to an input inline
64 assembly operand that is actually a pair of values. In particular, this can
65 happen when trying to pass in a slice, for instance a `&str`. In Rust, these
66 values are represented internally as a pair of values, the pointer and its
67 length. When passed as an input operand, this pair of values can not be
68 coerced into a register and thus we must fail with an error.
69 "##,
70
71 }