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

Prepend super:: to function call? #173

Open
jhpratt opened this issue Dec 22, 2022 · 2 comments · May be fixed by #213
Open

Prepend super:: to function call? #173

jhpratt opened this issue Dec 22, 2022 · 2 comments · May be fixed by #213

Comments

@jhpratt
Copy link

jhpratt commented Dec 22, 2022

When seeing if I could make reasonable use of rstest for time, I quickly ran into an issue. If a case parameter is the same as the function name, compilation will fail. For example,

#[rstest]
#[case(Sunday, Monday)]
fn next(#[case] day: Weekday, #[case] next: Weekday) {
    assert_eq!(day.next(), next);
}

This fails because next is both a case parameter and the function name, and it is ambiguous in the expansion:

#[cfg(test)]
fn next(day: Weekday, next: Weekday) {
    assert_eq!(day.next(), next);
}
#[cfg(test)]
mod next {
    use super::*;
    #[test]
    fn case_1() {
        let day = Sunday;
        let next = Monday;
        next(day, next)
    }
}

However, if next(day, next) is instead super::next(day, next), compilation would succeed. Given that the module is generated by rstest, we know that this path is always correct. Would it be possible to add this prefix to support the edge case?

Thanks for maintaining this crate!

@la10736
Copy link
Owner

la10736 commented Dec 22, 2022

Yeah!!! Good point! I never thought about it. I'll fix it as soon as possible but I'm quite slow at the moment ... I've no too much time to spend on rstest in this period 😢
If you can submit a PR I'll really appreciate it 😄

@jhpratt
Copy link
Author

jhpratt commented Dec 22, 2022

I'm the same way, really. Lots going on! No rush on my end, naturally.

@jhpratt jhpratt linked a pull request Sep 18, 2023 that will close this issue
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

Successfully merging a pull request may close this issue.

2 participants