diff --git a/compiler/rustc_error_codes/src/error_codes.rs b/compiler/rustc_error_codes/src/error_codes.rs index a202736ea6c..6af265d5069 100644 --- a/compiler/rustc_error_codes/src/error_codes.rs +++ b/compiler/rustc_error_codes/src/error_codes.rs @@ -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, diff --git a/compiler/rustc_error_codes/src/error_codes/E0019.md b/compiler/rustc_error_codes/src/error_codes/E0019.md deleted file mode 100644 index ef43a57a981..00000000000 --- a/compiler/rustc_error_codes/src/error_codes/E0019.md +++ /dev/null @@ -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! -} -``` diff --git a/compiler/rustc_mir/src/transform/check_consts/ops.rs b/compiler/rustc_mir/src/transform/check_consts/ops.rs index 6c34e0681c4..25ed7859d21 100644 --- a/compiler/rustc_mir/src/transform/check_consts/ops.rs +++ b/compiler/rustc_mir/src/transform/check_consts/ops.rs @@ -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() ) } diff --git a/src/test/ui/consts/inline_asm.rs b/src/test/ui/consts/inline_asm.rs index c2ab97e54f0..b8b755018e6 100644 --- a/src/test/ui/consts/inline_asm.rs +++ b/src/test/ui/consts/inline_asm.rs @@ -1,6 +1,6 @@ #![feature(llvm_asm)] const _: () = unsafe { llvm_asm!("nop") }; -//~^ ERROR contains unimplemented expression type +//~^ ERROR inline assembly fn main() {} diff --git a/src/test/ui/consts/inline_asm.stderr b/src/test/ui/consts/inline_asm.stderr index 0a064c81366..6fb6b69d220 100644 --- a/src/test/ui/consts/inline_asm.stderr +++ b/src/test/ui/consts/inline_asm.stderr @@ -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`.