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

Run cargo fmt #2

Merged
merged 1 commit into from
Jan 9, 2024
Merged

Run cargo fmt #2

merged 1 commit into from
Jan 9, 2024

Conversation

mtreinish
Copy link
Member

@mtreinish mtreinish commented Jan 8, 2024

This commit runs cargo fmt on the repository to apply rustfmt formatting to the repository. As we're preparing to publish the repository for public consumption using consistent automatic formatting for the source code makes contribution easier (and avoid needless arguments on style conventions and preferences).

@jlapeyre
Copy link
Collaborator

jlapeyre commented Jan 9, 2024

There is an issue with rustfmt and inline comments: rust-lang/rustfmt#3255 . The problem is that something like this:

struct AStruct {
    x: u32, // represents x
    y: u3,
}

is sometimes changed to this

struct AStruct {
    x: u32,
    // represents x
    y: u3,
}

(EDIT: I think the above example does not actually trigger the bug. Maybe it needs fn blah() { \\ a function.)

EDIT: See #4 which corrects what I could find with a regex

The linked issue gives details of how it works and why people are frustrated by it. It is apparently accepted as a bug, but has not been fixed. Since we would like this parser to be compatible with more than the latest rust, we can't wait for the bug fix (which has not even landed, don't know if because it's hard or lack of resources)

I am pretty sure there are no instances in this repo where moving the comment to another line (not the line rustfmt chooses) prevents making the desired comment.

I have been in the process of moving the comments by hand, but it requires finding all of these instances. This is why I have used https://github.com/Qiskit/openqasm3_parser/blob/main/run_rustfmt.sh . An alternative would be let rustfmt do the incorrect thing and leave the comments in the wrong spot, so that future coders puzzle over what they mean, or maybe fix some of them. I think the latter is not a good option.

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 this pull request may close these issues.

2 participants