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

Multiversion has unexpected token using inline const expression with missing semi-colon #45

Open
sammysheep opened this issue Sep 23, 2024 · 1 comment

Comments

@sammysheep
Copy link

With the inline const expression feature introduced in 1.79, I noticed that omitting a semi-colon after the const {} block interacts poorly with multiversion v0.7.4. On nightly, Rust will happily compile the version without the semi-colon--albeit this could be considered badly written Rust--so it caught me off guard when my const { assert!() } + mulltiversion made the function vanish.

Minimal error

use multiversion::multiversion;

// Unexpected token
#[multiversion(targets = "simd")]
pub fn x() -> u32 {
    const {
        2;
    }
    0
}

// Cannot find function `x` in this scope
pub fn y() -> u32 {
    x() + 1
}

// Compiles
pub fn x_again() -> u32 {
    const {
        2;
    }
    0
}

// Compiles
#[multiversion(targets = "simd")]
pub fn x_one_more_time() -> u32 {
    const {
        2;
    };
    0
}

// Compiles
#[multiversion(targets = "simd")]
pub fn abc() -> u32 {
    0
}

// Compiles
pub fn def() -> u32 {
    abc() + 1
}

Systems tested

  • rustc 1.83.0-nightly (6c6d21008 2024-09-22), M2 Ultra
  • rustc 1.83.0-nightly (28e8f01c2 2024-09-17), Intel Xeon
@calebzulawski
Copy link
Owner

It appears that this is fixed after upgrading to syn 2

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

No branches or pull requests

2 participants