Closed
Description
I tried this code:
#![feature(asm_sym)]
#![feature(generic_const_exprs)]
trait Call {
extern "C" fn call();
}
impl Call for () {
extern "C" fn call() {}
}
fn call_in_asm<T: Call>() {
unsafe {
core::arch::asm!("call {}", sym T::call, clobber_abi("C"));
}
}
fn main() {
call_in_asm::<()>();
}
I expected to see this happen: Successful compilation or compilation failure with an adequate error message
Instead, this happened: Compilation error, sym
operand marked with error: unconstrained generic constant
error: unconstrained generic constant
--> src/main.rs:16:37
|
16 | core::arch::asm!("call {}", sym T::call, clobber_abi("C"));
| ^^^^^^^^^^^
|
= help: try adding a `where` bound using this expression: `where [(); sym T::call]:`
Meta
rustc --version --verbose
:
rustc 1.62.0-nightly (de1bc0008 2022-04-21)
binary: rustc
commit-hash: de1bc0008be096cf7ed67b93402250d3b3e480d0
commit-date: 2022-04-21
host: aarch64-apple-darwin
release: 1.62.0-nightly
LLVM version: 14.0.1