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

Typechecking of asm! failed in let _ #3061

Closed
badumbatish opened this issue Jun 23, 2024 · 2 comments · Fixed by #3060
Closed

Typechecking of asm! failed in let _ #3061

badumbatish opened this issue Jun 23, 2024 · 2 comments · Fixed by #3060

Comments

@badumbatish
Copy link
Contributor

badumbatish commented Jun 23, 2024

I tried this code:

#![feature(rustc_attrs)]

#[rustc_builtin_macro]
macro_rules! asm {
    () => {}
}

fn main() {
    unsafe {
        let _ = asm!("nop");
    }
}

I expected to see this happen: Nothing should error out, as expected from rustc

Instead, this happened: gccrs errors out with

/home/workspace/gccrs/gcc/testsuite/rust/compile/inline_asm_compile_nop.rs:10:9: fatal error: failed to lookup variable declaration type
   10 |         let _ = asm!("nop");
      |         ^~~
compilation terminated.

From Arthur Cohen

the error that gccrs is spitting out, but not rustc, is due to typechecking. we haven't yet done any typechecking for HIR::InlineAsm nodes, so when the typechecker tries to check everything is okay for an HIR::LetStmt, it fails to lookup the type of the let's expression

Meta

  • What version of Rust GCC were you using, git sha if possible. 7fa14d4f64a1339fcecf9c73c8831c6db434a741
@badumbatish
Copy link
Contributor Author

badumbatish commented Jun 24, 2024

the asm! returns () on default, and ! when the option(no_return) is added (from bjorn3)

@CohenArthur CohenArthur added this to the [GSoC] Inline assembly milestone Jun 24, 2024
@badumbatish
Copy link
Contributor Author

closable by #3060

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants