Skip to content

--check output is editor-unfriendly. #4092

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

Closed
eddyb opened this issue Mar 22, 2020 · 4 comments · Fixed by #4150
Closed

--check output is editor-unfriendly. #4092

eddyb opened this issue Mar 22, 2020 · 4 comments · Fixed by #4150
Labels
good first issue Issues up for grabs, also good candidates for new rustfmt contributors help wanted

Comments

@eddyb
Copy link
Member

eddyb commented Mar 22, 2020

While the ergonomic problem will likely go away whenever I get around to moving my setup to VSCode Remote, the current --check diff output is still pretty frustrating, and inconsistent with compiler output.

The head of each diff chunk looks like this: (base dir omitted for clarity)

Diff in .../src/librustc_infer/infer/error_reporting/need_type_info.rs at line 48:

I suspect the at line 48: formatting is trying to be user-friendly or something, but if it was like this, it would be accessible without having to go to the line manually:

Diff at .../src/librustc_infer/infer/error_reporting/need_type_info.rs:48:

For me it's Ctrl+click that I use, but I recall seeing an issue about some other editor (emacs perhaps?), where a more specific format might be needed, I just can't find that issue now.

@calebcartwright
Copy link
Member

When you say editor-unfriendly, what's the context? Editor/IDE plugins that facilitate running rustfmt (on-demand, format-on-save) or something else?

Would the json rustfmt output be helpful at all?

@eddyb
Copy link
Member Author

eddyb commented Mar 23, 2020

I mean editors/IDE natively handling the text output, where file:line:col is sort of the "standard".

In my case, rustfmt is ran by x.py aka bootstrap/"rustbuild" in the rust-lang/rust repo, and the output is just in a terminal window, but like I was saying earlier, if it were adhering to file:line, Ctrl+click would "just" work to let me jump to that file and line.
Curretly, I have to Ctrl+click to open the file and Ctrl+G to the line manually.

Would the json rustfmt output be helpful at all?

No, since something would have to process it. At that point I should bite the bullet and switch to VSCode Remote to the server, where I could just run RLS, have format on save, etc.


What I'm hoping for is a tiny tweak to the --check diff output, to be clear.

@calebcartwright
Copy link
Member

if it were adhering to file:line, Ctrl+click would "just" work to let me jump to that file and line.

👍 makes sense, thank you. I'd never noticed that type of navigation in editors before

What I'm hoping for is a tiny tweak to the --check diff output, to be clear.

Seems reasonable to me. It's indeed a really easy change if anyone is interested in making the update, otherwise I can probably get around to it eventually

print_diff(
mismatch,
|line_num| format!("Diff in {} at line {}:", filename, line_num),
&self.config,
);

@eddyb
Copy link
Member Author

eddyb commented Mar 23, 2020

FWIW, I found a way to run rustfmt on save without RLS, so just in case it helps anyone:
https://marketplace.visualstudio.com/items?itemName=pucelle.run-on-save + this config:

    "runOnSave.commands": [
        {
            "match": "\\.rs$",
            "command": "rustfmt --edition=2018 ${file}",
            "runIn": "backend",
        }
    ],

EDIT: added --edition=2018 so that it doesn't break on some rust-lang/rust files.

@calebcartwright calebcartwright added good first issue Issues up for grabs, also good candidates for new rustfmt contributors help wanted labels Apr 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Issues up for grabs, also good candidates for new rustfmt contributors help wanted
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants