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

arbitrary expressions in key-value attributes are unstable #117

Closed
aliemjay opened this issue Apr 24, 2021 · 1 comment
Closed

arbitrary expressions in key-value attributes are unstable #117

aliemjay opened this issue Apr 24, 2021 · 1 comment

Comments

@aliemjay
Copy link

aliemjay commented Apr 24, 2021

The key-value attributes, which are used by the new syntax (#99), accept only literals on stable compiler. Trying to use any other expression yields the following error message:

error[E0658]: arbitrary expressions in key-value attributes are unstable
note: see issue #78835 rust-lang/rust#78835 for more information

This makes it impossible to set trivial defaults such as None or &[].

Here is the test code:

// rustc 1.51
// rstest 0.7.0
use rstest::{fixture, rstest};

// Old syntax is OK
#[fixture(val=1+1)]
fn echo(val: i32) -> i32 {
    val
}

// New syntax fails
#[fixture]
fn echo2(#[default=1+1] val: i32) -> i32 {
    val
}
@la10736
Copy link
Owner

la10736 commented Apr 24, 2021

Ok, I missed it. I'll switch to #[deafult( 1 + 1 )] syntax till the syntax become stable.

la10736 added a commit that referenced this issue Apr 25, 2021
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