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

rustfmt deletes vertical bar for match branches! #2462

Closed
rusterize opened this issue Feb 17, 2018 · 7 comments
Closed

rustfmt deletes vertical bar for match branches! #2462

rusterize opened this issue Feb 17, 2018 · 7 comments

Comments

@rusterize
Copy link

The vertical bar for match brances was just stabilized, but rustfmt deletes them.

Thanks for the great work.

@topecongiro
Copy link
Contributor

The stabilization PR removed beginning_vert field from ast::Arm. We need to bring it back to support it in rustfmt.

@topecongiro
Copy link
Contributor

Note that rustfmt will not remove the vertical bar at the beginning of march arms, but it will not format the entire arm with the beginning vertical bar.

@rusterize Would you tell us which version of rustfmt you are using please? I think you might be using older version of rustfmt.

@rusterize
Copy link
Author

$ rustfmt --version
0.3.8-nightly (346238f 2018-02-04)

@topecongiro
Copy link
Contributor

@rusterize Thanks! You are using the latest rustfmt, so I assume that the removal of the vertical bar happens in non-simple cases.

Could you please share your code that caused the removal of the vertical bar?

@rusterize
Copy link
Author

Before rustfmt:

        match anchor {
            | &Some(ref row_index) => Ok(row_nodes_borrow
                .get(row_index)
                .ok_or(RowIndexNotFound(format!("{}", row_index)))?),

            | &None => Ok(&self.root_node_iter),
        }

after rustfmt:

        match anchor {
            &Some(ref row_index) => Ok(row_nodes_borrow
                .get(row_index)
                .ok_or(RowIndexNotFound(format!("{}", row_index)))?),
            |
            &None => Ok(&self.root_node_iter),
        }

@topecongiro
Copy link
Contributor

@rusterize Thank you for sharing the code! I could confirm the issue. And it should be fixed with #2464.

@nrc nrc closed this as completed in #2464 Feb 18, 2018
@nrc
Copy link
Member

nrc commented Feb 18, 2018

I'm not 100% sure what Rustfmt should be doing here, see rust-lang/style-team#119, however, it is clear the current behaviour is bad so I've merged the fixing PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants