5
jestdotty
100d

rust, where pressing autoformat won't format your code but will format your comments which are just there because you're trying to keep track of the data you're going to parse and now that shit is off the page motherfucker can you not

Comments
  • 2
    Since it is not me this is kinda funny. Sorry..
  • 1
    you have a syntax error or a macro which makes it impossible to assert that formatting is isomorphic
  • 1
    I agree though that the comment formatting rules are weird and almost never intuitive. My suspicion is that it's because comments aren't really recognized as an AST node but rather as attachments to other AST nodes and they are often associated with a different node from the one you expected
  • 0
    @jestdotty That's strange. all syntactically correct code outside macro calls, including the enclosing call tokens themselves and optionally even template macro definitions but not the tokens inside the macro call, should be formatted by rustfmt. The only other things I can think of are either

    - you haven't saved all your files so rustfmt sees a different project from the language server
    - the code isn't referenced into the workspace
    - you're running rustfmt inside a different project. In workspaces, most cargo commands implicitly target the project and not the workspace if they're run inside a project folder.
  • 1
    @jestdotty that is really strange. Another thought, I think in VSCode the format command is actually issued by the rust-analyzer extension, and I ran into several bugs in rust-analyzer and the extension in the past. Either way, you can probably look at the final command being issued in the extension's output and try to run it and variations by hand to determine where the issue lies. Although as I said, RA is pretty buggy so if that's your problem I don't expect it to be fixed.
Add Comment