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

cargo fmt broken within proptest macro? #370

Closed
vlovich opened this issue Sep 9, 2023 · 5 comments
Closed

cargo fmt broken within proptest macro? #370

vlovich opened this issue Sep 9, 2023 · 5 comments

Comments

@vlovich
Copy link

vlovich commented Sep 9, 2023

Hi,

I noticed a strange issue where nothing within proptest! {} is formatted by cargo fmt.

#[cfg(test)]
mod property_tests {
    use proptest::proptest;

    proptest! {
         #[test]
         fn test_it(s: u8) {
             eprintln!("Example that never gets formatted even though its very very very long and {} {} {} {} {}", "this", "should", "be", "split", "up");
         }
    }
}
@vlovich vlovich changed the title cargo fmt and vscode debugging broken within proptest macro? cargo fmt broken within proptest macro? Sep 9, 2023
@vlovich
Copy link
Author

vlovich commented Sep 9, 2023

Oh maybe this is implicit by way of rust-lang/rustfmt#8? Not sure if that's about formatting the macro code or the call site.

@rex-remind101
Copy link
Collaborator

Thanks for raising this, this does appear to be an issue with rustfmt which we unfortunately do not have control over.

@tzemanovic
Copy link
Contributor

#316 will help with that

@matthew-russo
Copy link
Member

As mentioned, this is the expected rustfmt behavior with declarative macros and not specific to proptest. I'm going to close this as there is no action for us to take

@cgbur
Copy link

cgbur commented Jan 11, 2024

For the time being you could consider copying your proptest block into a new Rust file and formatting with https://github.com/andrewbaxter/genemichaels which handles macros. Granted it took 9 months to support stable let-else formatting, so macro formatting is probably still a few years out.

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

5 participants