]> git.lizzy.rs Git - rust.git/blob - src/librustc_codegen_llvm/diagnostics.rs
Auto merge of #54720 - davidtwco:issue-51191, r=nikomatsakis
[rust.git] / src / librustc_codegen_llvm / diagnostics.rs
1 // Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 #![allow(non_snake_case)]
12
13 register_long_diagnostics! {
14
15 E0511: r##"
16 Invalid monomorphization of an intrinsic function was used. Erroneous code
17 example:
18
19 ```ignore (error-emitted-at-codegen-which-cannot-be-handled-by-compile_fail)
20 #![feature(platform_intrinsics)]
21
22 extern "platform-intrinsic" {
23     fn simd_add<T>(a: T, b: T) -> T;
24 }
25
26 fn main() {
27     unsafe { simd_add(0, 1); }
28     // error: invalid monomorphization of `simd_add` intrinsic
29 }
30 ```
31
32 The generic type has to be a SIMD type. Example:
33
34 ```
35 #![feature(repr_simd)]
36 #![feature(platform_intrinsics)]
37
38 #[repr(simd)]
39 #[derive(Copy, Clone)]
40 struct i32x2(i32, i32);
41
42 extern "platform-intrinsic" {
43     fn simd_add<T>(a: T, b: T) -> T;
44 }
45
46 unsafe { simd_add(i32x2(0, 0), i32x2(1, 2)); } // ok!
47 ```
48 "##,
49
50 E0668: r##"
51 Malformed inline assembly rejected by LLVM.
52
53 LLVM checks the validity of the constraints and the assembly string passed to
54 it. This error implies that LLVM seems something wrong with the inline
55 assembly call.
56
57 In particular, it can happen if you forgot the closing bracket of a register
58 constraint (see issue #51430):
59 ```ignore (error-emitted-at-codegen-which-cannot-be-handled-by-compile_fail)
60 #![feature(asm)]
61
62 fn main() {
63     let rax: u64;
64     unsafe {
65         asm!("" :"={rax"(rax));
66         println!("Accumulator is: {}", rax);
67     }
68 }
69 ```
70 "##,
71
72 }