Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sym operands can not refer to generic parameters in recent nighty #96330

Closed
yvt opened this issue Apr 23, 2022 · 3 comments
Closed

sym operands can not refer to generic parameters in recent nighty #96330

yvt opened this issue Apr 23, 2022 · 3 comments
Labels
A-inline-assembly Area: Inline assembly (`asm!(…)`) C-bug Category: This is a bug. requires-nightly This issue requires a nightly compiler in some way.

Comments

@yvt
Copy link
Contributor

yvt commented Apr 23, 2022

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::<()>();
}

(Playground)

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
@yvt yvt added the C-bug Category: This is a bug. label Apr 23, 2022
@deltragon
Copy link
Contributor

Did this work before #94468?

@yvt
Copy link
Contributor Author

yvt commented Apr 23, 2022

I think so - this stopped working in nightly-2022-04-17, where #94468 was merged.

@oli-obk oli-obk added the requires-nightly This issue requires a nightly compiler in some way. label Apr 23, 2022
@nagisa nagisa added the A-inline-assembly Area: Inline assembly (`asm!(…)`) label Apr 23, 2022
@yvt
Copy link
Contributor Author

yvt commented May 20, 2022

Fixed by #96800

@yvt yvt closed this as completed May 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-inline-assembly Area: Inline assembly (`asm!(…)`) C-bug Category: This is a bug. requires-nightly This issue requires a nightly compiler in some way.
Projects
None yet
Development

No branches or pull requests

4 participants