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

Formatting @generated from stdin results in empty output #5172

Closed
bjorn3 opened this issue Jan 14, 2022 · 5 comments
Closed

Formatting @generated from stdin results in empty output #5172

bjorn3 opened this issue Jan 14, 2022 · 5 comments

Comments

@bjorn3
Copy link
Member

bjorn3 commented Jan 14, 2022

This causes rust-analyzer to discard the entire file if you try to format it. See rust-lang/rust-analyzer#11285.

$ echo "//@notgenerated\nfn   foo() {}" | rustfmt
//@notgenerated
fn foo() {}
$ echo "//@generated\nfn   foo() {}" | rustfmt
$ rustfmt -V
rustfmt 1.4.38-stable (02072b4 2022-01-11)
@calebcartwright
Copy link
Member

This causes rust-analyzer to discard the entire file

Just to clarify, are you seeing this strictly with stdin or both stdin and files? I can reproduce the former, but not the latter

@Ten0
Copy link

Ten0 commented Jan 14, 2022

Strictly with stdin. IIUC the files he refers to are files manipulated by rust-analyzer.

@bjorn3
Copy link
Member Author

bjorn3 commented Jan 14, 2022

Indeed. Rust-analyzer writes the file to rustfmt's stdin as most of the time the changes made by the user haven't been saved yet.

@calebcartwright
Copy link
Member

Thanks for clarifying. Will get the resolution for this pulled in after work today, and it'll get pulled into a 1.58.1 patch release that fortunately was already being considered/planned

bors added a commit to rust-lang-ci/rust that referenced this issue Jan 15, 2022
…es, r=Mark-Simulacrum

resolve rustfmt issue with generated files

Discussed in https://rust-lang.zulipchat.com/#narrow/stream/241545-t-release/topic/1.2E58.20patch.20release

refs rust-lang/rustfmt#5080 (comment) and rust-lang/rustfmt#5172

updating in-tree vs. subtree sync to make backporting easier, would like to nominate backporting to both beta/1.59 as well as the 1.58.1 patch release
@calebcartwright
Copy link
Member

Going to close as there's nothing left to do now but wait for the releases to go out, thanks again for the reports!

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