Remove E0019, use E0015 for inline assembly in a const

This commit is contained in:
Dylan MacKenzie 2020-09-30 09:58:01 -07:00
parent 0c26144b1a
commit 1301f43119
5 changed files with 6 additions and 44 deletions

View file

@ -18,7 +18,6 @@ E0010: include_str!("./error_codes/E0010.md"),
E0013: include_str!("./error_codes/E0013.md"),
E0014: include_str!("./error_codes/E0014.md"),
E0015: include_str!("./error_codes/E0015.md"),
E0019: include_str!("./error_codes/E0019.md"),
E0023: include_str!("./error_codes/E0023.md"),
E0025: include_str!("./error_codes/E0025.md"),
E0026: include_str!("./error_codes/E0026.md"),
@ -461,6 +460,7 @@ E0774: include_str!("./error_codes/E0774.md"),
;
// E0006, // merged with E0005
// E0008, // cannot bind by-move into a pattern guard
// E0019, merged into E0015
// E0035, merged into E0087/E0089
// E0036, merged into E0087/E0089
// E0068,

View file

@ -1,38 +0,0 @@
A function call isn't allowed in the const's initialization expression
because the expression's value must be known at compile-time.
Erroneous code example:
```compile_fail,E0019
#![feature(asm)]
fn main() {
static STATIC11: i32 = {
let x: i32;
unsafe { asm!("mov rax, 2", out("rax") x) }; // error!
x
};
}
```
Remember: you can't use a function call inside a const's initialization
expression! However, you can totally use it anywhere else:
```
enum Test {
V1
}
impl Test {
fn func(&self) -> i32 {
12
}
}
fn main() {
const FOO: Test = Test::V1;
FOO.func(); // here is good
let x = FOO.func(); // or even here!
}
```

View file

@ -193,8 +193,8 @@ impl NonConstOp for InlineAsm {
struct_span_err!(
ccx.tcx.sess,
span,
E0019,
"{} contains unimplemented expression type",
E0015,
"inline assembly is not allowed in {}s",
ccx.const_kind()
)
}

View file

@ -1,6 +1,6 @@
#![feature(llvm_asm)]
const _: () = unsafe { llvm_asm!("nop") };
//~^ ERROR contains unimplemented expression type
//~^ ERROR inline assembly
fn main() {}

View file

@ -1,4 +1,4 @@
error[E0019]: constant contains unimplemented expression type
error[E0015]: inline assembly is not allowed in constants
--> $DIR/inline_asm.rs:3:24
|
LL | const _: () = unsafe { llvm_asm!("nop") };
@ -8,4 +8,4 @@ LL | const _: () = unsafe { llvm_asm!("nop") };
error: aborting due to previous error
For more information about this error, try `rustc --explain E0019`.
For more information about this error, try `rustc --explain E0015`.