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

Compile error: cannot transmute between types of different sizes, or dependently-sized types [E0512] #5189

Open
vvzen opened this issue Mar 9, 2024 · 2 comments
Labels
C-bug Something isn't working

Comments

@vvzen
Copy link

vvzen commented Mar 9, 2024

Summary

Hi all!
And thank you for the super interesting project.
I'm not sure if this is a bug or not - technically it's just a compile issue.

I wanted to try the embedded example (https://github.com/RustPython/RustPython/blob/main/examples/hello_embed.rs) :

use rustpython_vm as vm;

fn main() -> vm::PyResult<()> {
    vm::Interpreter::without_stdlib(Default::default()).enter(|vm| {
        let scope = vm.new_scope_with_builtins();
        let source = r#"print("Hello World!")"#;
        let code_obj = vm
            .compile(source, vm::compiler::Mode::Exec, "<embedded>".to_owned())
            .map_err(|err| vm.new_syntax_error(&err, Some(source)))?;

        vm.run_code_obj(code_obj, scope)?;

        Ok(())
    })
}

But when I try a cargo run --release with the code above, I get an assertion error:

   Compiling rustpython-compiler-core v0.3.0
error[E0512]: cannot transmute between types of different sizes, or dependently-sized types
  --> ~/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rustpython-ast-0.3.0/src/impls.rs:60:1
   |
60 | static_assertions::assert_eq_size!(crate::Stmt, [u8; 160]);
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: source type: `generic::Stmt` (1216 bits)
   = note: target type: `[u8; 160]` (1280 bits)
   = note: this error originates in the macro `static_assertions::assert_eq_size` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0512]: cannot transmute between types of different sizes, or dependently-sized types
  --> ~/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rustpython-ast-0.3.0/src/impls.rs:62:1
   |
62 | static_assertions::assert_eq_size!(crate::Pattern, [u8; 96]);
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: source type: `generic::Pattern` (704 bits)
   = note: target type: `[u8; 96]` (768 bits)
   = note: this error originates in the macro `static_assertions::assert_eq_size` (in Nightly builds, run with -Z macro-backtrace for more info)

   Compiling rustpython-derive-impl v0.3.0
For more information about this error, try `rustc --explain E0512`.
error: could not compile `rustpython-ast` (lib) due to 2 previous errors
warning: build failed, waiting for other jobs to finish...
~/dev/creative/nannou-sketches/rustpython-101 13:51:08 

I'm on:

$ rustc --version
rustc 1.76.0 (07dca489a 2024-02-04)

# Arch linux
$ uname -r
6.7.2-arch1-2

And this is my Cargo.toml:

[package]
name = "rustpython-101"
version = "0.1.0"
edition = "2021"

[dependencies]
rustpython-vm = "0.3.0"

Expected

The hello_embed.rs code run without errors.

Actual

The hello_embed.rs example code doesn't compile.

Thanks!

@vvzen vvzen added the C-bug Something isn't working label Mar 9, 2024
@sum-catnip
Copy link

its coming from the parser repo: RustPython/Parser#114.
looks like its been fixed on the main branch but not released yet.

@fgadaleta
Copy link

fgadaleta commented Mar 20, 2024

when will parser be released?
same problem here on Rust 1.79 nightly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants