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

Comment affects whether return expr fmts to return expr; #6150

Open
workingjubilee opened this issue Apr 19, 2024 · 2 comments
Open

Comment affects whether return expr fmts to return expr; #6150

workingjubilee opened this issue Apr 19, 2024 · 2 comments

Comments

@workingjubilee
Copy link

adding a comment here caused an unrelated diff in a semicolon formatting:

                     ArgValue::Lit(other) => {
+                        // FIXME: add a ui test for this
                         return Err(syn::Error::new(
                             other.span(),
                             "expected boolean, path, or string literal",
-                        ))
+                        ));
                     }

at least it doesn't depend much on the exact position of the comment, just whether it sees one?

             e => {
                 return Err(syn::Error::new(
+                    // FIXME: add a UI test for this
                     input.span(),
                     format!("Invalid option `{e}` inside `{ident} {input}`"),
-                ))
+                ));
            }

This sort of thing should not matter.

@ytmimi
Copy link
Contributor

ytmimi commented Apr 19, 2024

@workingjubilee If you could take this diff and create a snippet that someone can direclty run rustfmt on to reproduce the issue that would be very helpful. Also, what version of rustfmt are you using, and are you using any configurations?

@calebcartwright
Copy link
Member

https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=1b08120b0a4c44013840a6cbd24e9fa2

fn main() {
match x {
                         ArgValue::Lit(other) => {
                        // FIXME: add a ui test for this
                         return Err(syn::Error::new(
                             other.span(),
                             "expected boolean, path, or string literal",
                        ))
                     }
                     }
}

the presence/absence of the comma in the initial input influences the output. I believe there's something intentional here but I don't recall the specifics

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

3 participants