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 inconsistency with file-lines option #3442

Closed
jsgf opened this issue Mar 12, 2019 · 1 comment · Fixed by #3459
Closed

Comment inconsistency with file-lines option #3442

jsgf opened this issue Mar 12, 2019 · 1 comment · Fixed by #3459
Labels
bug Panic, non-idempotency, invalid code, etc. only-with-option requires a non-default option value to reproduce

Comments

@jsgf
Copy link

jsgf commented Mar 12, 2019

Given this source:

extern crate ascii;
#[allow(unused_imports)] // workaround for macro_use
#[macro_use]
extern crate lazy_static;

If you format the whole file, then it works fine. However if you use --file-lines on a range that just covers lines 1 and 2, it drops the space before the comment:

$ rustfmt --unstable-features --emit-stdout -q --file-lines '[{"file": "t.rs", "range" : [2,2]}]' t.rs
extern crate ascii;
#[allow(unused_imports)]// workaround for macro_use
#[macro_use]
extern crate lazy_static;

Extending the range to the next line works correctly:

$ rustfmt --unstable-features --emit-stdout -q --file-lines '[{"file": "t.rs", "range" : [2,3]}]' t.rs
extern crate ascii;
#[allow(unused_imports)] // workaround for macro_use
#[macro_use]
extern crate lazy_static;

This is rustfmt 1.0.3-nightly (d6829d6 2019-02-14)

@scampi scampi added bug Panic, non-idempotency, invalid code, etc. only-with-option requires a non-default option value to reproduce labels Mar 12, 2019
@scampi
Copy link
Contributor

scampi commented Mar 18, 2019

I am having a look at this

scampi added a commit to scampi/rustfmt that referenced this issue Mar 19, 2019
- a leading/trailing newline character in missed spans was throwing off the
  start/end of ranges used to compare against file_lines
- fix handling of file_lines when closing a block

Close rust-lang#3442
topecongiro pushed a commit to topecongiro/rustfmt that referenced this issue Apr 14, 2019
- a leading/trailing newline character in missed spans was throwing off the
  start/end of ranges used to compare against file_lines
- fix handling of file_lines when closing a block

Close rust-lang#3442
hhvm-bot pushed a commit to facebook/hhvm that referenced this issue Apr 30, 2019
Summary: The [style guide](https://github.com/rust-dev-tools/fmt-rfcs/blob/master/guide/guide.md), other [people at FB](https://fb.workplace.com/groups/762853277096623/2450252935023307/?comment_tracking=%7B%22tn%22%3A%22R%22%7D), and [rustfmt](rust-lang/rustfmt#3442) all prefer `//`.

Reviewed By: losvald

Differential Revision: D15110139

fbshipit-source-id: 92386216c199d7f88499404ce985c5c84c71da05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Panic, non-idempotency, invalid code, etc. only-with-option requires a non-default option value to reproduce
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants