Skip to content

Same-line attributes on enum variants maybe sub-optimal #2389

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
nrc opened this issue Jan 23, 2018 · 1 comment
Closed

Same-line attributes on enum variants maybe sub-optimal #2389

nrc opened this issue Jan 23, 2018 · 1 comment

Comments

@nrc
Copy link
Member

nrc commented Jan 23, 2018

We recently changed the interaction of attributes and fields/variants - we put them on separate lines for struct fields and the same lines for enum variants. However, for complex enum variants this looks sub-optimal. I wonder if we should class enum variants with struct fields? Or more precisely any sub-item which has its own line should have an attribute on a different line, and any sub-item formatted on a line with other sub-items has same-line attributes.

E.g.,

pub enum QlError {
-    #[fail(display = "Parsing error: {}", 0)]
-    LexError(parser::lexer::LexError),
-    #[fail(display = "Parsing error: {:?}", 0)]
-    ParseError(parser::ParseError),
-    #[fail(display = "Validation error: {:?}", 0)]
-    ValidationError(Vec<validation::Error>),
-    #[fail(display = "Execution error: {}", 0)]
-    ExecutionError(String),
+    #[fail(display = "Parsing error: {}", 0)] LexError(parser::lexer::LexError),
+    #[fail(display = "Parsing error: {:?}", 0)] ParseError(parser::ParseError),
+    #[fail(display = "Validation error: {:?}", 0)] ValidationError(Vec<validation::Error>),
+    #[fail(display = "Execution error: {}", 0)] ExecutionError(String),
     // (from, to)
-    #[fail(display = "Translation error: from {} to {}", 0, 1)]
-    TranslationError(String, String),
+    #[fail(display = "Translation error: from {} to {}", 0, 1)] TranslationError(String, String),
     // (kind, input, expected)
     #[fail(display = "Could not find {}: Found: {}, expected: {:?}", 0, 1, 2)]
     ResolveError(&'static str, String, Option<String>),
 }
@RReverser
Copy link
Contributor

RReverser commented Jan 24, 2018

I just added same_line_attributes = false to my rustfmt.toml to workaround exactly this issue, but after yesterday update that config is gone and enum variants are reformatted back to long lines.

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

2 participants