EmbarkStudios/rust-gpu

asm reference to non-existent value causes ICE

Opened this issue · 1 comments

If you pass a reference to malformed instruction, it will cause the compiler to panic, when it should fail just fail to compile.

Rust

#[spirv(fragment)]
pub fn foo() {
    asm! {
        "%u32 = OpTypeInte 32 0",
        "%zero = OpConstant %u32 0",
}

Error

error: unknown spirv instruction OpTypeInte
  --> /Users/erin.power/src/rust-gpu2/crates/spirv-std/src/arch/barrier.rs:5:5
   |
5  | /     asm! {
6  | |         "%u32 = OpTypeInte 32 0",
7  | |         "%execution = OpConstant %u32 {execution}",
8  | |         // "%memory = OpConstant %u32 {memory}",
...  |
13 | |         // semantics = const SEMANTICS as u8,
14 | |     }
   | |_____^

thread 'rustc' panicked at 'Tried to lookup value that wasn't a type, or has no definition', crates/rustc_codegen_spirv/src/spirv_type.rs:674:14
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

error: internal compiler error: unexpected panic

This issue is now being tracked at: Rust-GPU/rust-gpu#132