Fix excessive indentation in trait where clause when using Rfc style

This commit is contained in:
topecongiro 2017-06-13 10:18:55 +09:00
parent 5531a93b57
commit f084a8af96
4 changed files with 29 additions and 3 deletions

View file

@ -2306,7 +2306,7 @@ fn rewrite_where_clause_rfc_style(context: &RewriteContext,
terminator,
|pred| span_for_where_pred(pred).lo,
|pred| span_for_where_pred(pred).hi,
|pred| pred.rewrite(context, clause_shape),
|pred| pred.rewrite(context, shape),
span_start,
span_end);
let comma_tactic = if suppress_comma {

View file

@ -24,7 +24,7 @@ use lists::{itemize_list, format_fn_args};
use rewrite::{Rewrite, RewriteContext};
use utils::{extra_offset, format_mutability, colon_spaces, wrap_str, mk_sp, last_line_width};
use expr::{rewrite_unary_prefix, rewrite_pair, rewrite_tuple_type};
use config::TypeDensity;
use config::{Style, TypeDensity};
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub enum PathContext {
@ -383,7 +383,10 @@ impl Rewrite for ast::WherePredicate {
}
} else {
let used_width = type_str.len() + colon.len();
let ty_shape = try_opt!(shape.block_left(used_width));
let ty_shape = match context.config.where_style() {
Style::Legacy => try_opt!(shape.block_left(used_width)),
Style::Rfc => shape.block_indent(context.config.tab_spaces()),
};
let bounds: Vec<_> =
try_opt!(bounds
.iter()

View file

@ -42,3 +42,9 @@ struct Exactly100CharsToSemicolon<A, B, C, D, E>
struct AlwaysOnNextLine<LongLongTypename, LongTypename, A, B, C, D, E, F> where A: LongTrait {
x: i32
}
pub trait SomeTrait<T>
where
T: Something + Sync + Send + Display + Debug + Copy + Hash + Debug + Display + Write + Read + FromStr
{
}

View file

@ -96,3 +96,20 @@ where
{
x: i32,
}
pub trait SomeTrait<T>
where
T: Something
+ Sync
+ Send
+ Display
+ Debug
+ Copy
+ Hash
+ Debug
+ Display
+ Write
+ Read
+ FromStr
{
}