Open
Description
Function declarations that had their parameters "multi-lined" were forcing the brace after the where
clause to the next line like so:
fn fn_with_everything_long_and_body<T, U, 'a>(
aaaa: f64,
bbbb: f64,
cccc: f64,
dddd: f64,
eeee: f64,
ffff: f64, // Note: multiple arguments here
) -> Result<
HashMap<String, Vec<(SomeLongTypeName, AnotherLongTypeName, YetAnotherType)>>,
Box<dyn Error + Send + Sync + 'static>,
>
where
T: Debug + Display + Clone + Send + Sync + 'static,
U: Iterator<Item = &'a T> + ExactSizeIterator,
{ // <- brace here, incorrect ?
}
Whereas for an equivalent function that had no multi-lined arguments the brace would be on the same line as the last where
predicate:
fn fn_with_long_return_and_where_and_body<T, U, 'a>(
a: f64, // Note: single argument here
) -> Result<
HashMap<String, Vec<(SomeLongTypeName, AnotherLongTypeName, YetAnotherType)>>,
Box<dyn Error + Send + Sync + 'static>,
>
where
T: Debug + Display + Clone + Send + Sync + 'static,
U: Iterator<Item = &'a T> + ExactSizeIterator, { // <- brace here, correct by PreferSameLine
}
I've tracked it down to these lines of code:
Lines 2750 to 2751 in 0332da0
With PreferSameLine, should the opening brace always be on the same line as the last where
predicate? If so, then a condition can be added to not force the brace to a new line if brace_style is PreferSameLine:
- force_new_line_for_brace |=
- is_params_multi_lined && context.config.where_single_line() && !where_clause_str.is_empty();
+ force_new_line_for_brace |= is_params_multi_lined
+ && context.config.where_single_line()
+ && !where_clause_str.is_empty()
+ && context.config.brace_style() != BraceStyle::PreferSameLine;
Metadata
Metadata
Assignees
Labels
No labels