Merge pull request #2396 from topecongiro/issue-2389
Put attributes and enum variants on different lines
This commit is contained in:
commit
4633786848
@ -134,6 +134,11 @@ fn comment_style(orig: &str, normalize_comments: bool) -> CommentStyle {
|
||||
}
|
||||
}
|
||||
|
||||
/// Combine `prev_str` and `next_str` into a single `String`. `span` may contain
|
||||
/// comments between two strings. If there are such comments, then that will be
|
||||
/// recovered. If `allow_extend` is true and there is no comment between the two
|
||||
/// strings, then they will be put on a single line as long as doing so does not
|
||||
/// exceed max width.
|
||||
pub fn combine_strs_with_missing_comments(
|
||||
context: &RewriteContext,
|
||||
prev_str: &str,
|
||||
|
11
src/items.rs
11
src/items.rs
@ -504,7 +504,7 @@ fn format_variant_list(
|
||||
items = itemize_list_with(0);
|
||||
}
|
||||
|
||||
let shape = self.shape().sub_width(2).unwrap();
|
||||
let shape = self.shape().sub_width(2)?;
|
||||
let fmt = ListFormatting {
|
||||
tactic: DefinitiveListTactic::Vertical,
|
||||
separator: ",",
|
||||
@ -558,14 +558,7 @@ fn format_variant(&self, field: &ast::Variant, one_line_width: usize) -> Option<
|
||||
}
|
||||
};
|
||||
|
||||
combine_strs_with_missing_comments(
|
||||
&context,
|
||||
&attrs_str,
|
||||
&variant_body,
|
||||
span,
|
||||
shape,
|
||||
is_attributes_extendable(&attrs_str),
|
||||
)
|
||||
combine_strs_with_missing_comments(&context, &attrs_str, &variant_body, span, shape, false)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -180,3 +180,15 @@ enum WidthOf101 {
|
||||
Xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx(::std::io::Error),
|
||||
Xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx(::std::io::Error),
|
||||
}
|
||||
|
||||
// #2389
|
||||
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),
|
||||
// (from, to)
|
||||
#[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>),
|
||||
}
|
||||
|
@ -24,7 +24,8 @@ enum EmtpyWithComment {
|
||||
// C-style enum
|
||||
enum Bar {
|
||||
A = 1,
|
||||
#[someAttr(test)] B = 2, // comment
|
||||
#[someAttr(test)]
|
||||
B = 2, // comment
|
||||
C,
|
||||
}
|
||||
|
||||
@ -225,7 +226,8 @@ enum AnError {
|
||||
|
||||
// #2193
|
||||
enum WidthOf101 {
|
||||
#[fail(display = ".....................................................")] Io(::std::io::Error),
|
||||
#[fail(display = ".....................................................")]
|
||||
Io(::std::io::Error),
|
||||
#[fail(display = ".....................................................")]
|
||||
Ioo(::std::io::Error),
|
||||
Xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx(::std::io::Error),
|
||||
@ -233,3 +235,21 @@ enum WidthOf101 {
|
||||
::std::io::Error,
|
||||
),
|
||||
}
|
||||
|
||||
// #2389
|
||||
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),
|
||||
// (from, to)
|
||||
#[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>),
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user