Don't remove where clauses in type aliases

This commit is contained in:
Markus Westerlind 2015-12-02 19:39:45 +01:00
parent ae9ad7b288
commit a6b0d475f4
3 changed files with 32 additions and 0 deletions

View file

@ -774,6 +774,20 @@ pub fn rewrite_type_alias(context: &RewriteContext,
generics_span));
result.push_str(&generics_str);
let where_budget = try_opt!(context.config
.max_width
.checked_sub(last_line_width(&result)));
let where_clause_str = try_opt!(rewrite_where_clause(context,
&generics.where_clause,
context.config,
context.config.item_brace_style,
indent,
where_budget,
context.config.where_density,
"=",
Some(span.hi)));
result.push_str(&where_clause_str);
result.push_str(" = ");
let line_width = last_line_width(&result);

View file

@ -18,3 +18,10 @@ pub type CommentTest< /* Lifetime */ 'a
// Type
T
> = ();
pub type WithWhereClause<LONGPARAMETERNAME, T> where T: Clone, LONGPARAMETERNAME: Clone + Eq + OtherTrait = Option<T>;
pub type Exactly100CharstoEqualWhereTest<T, U, PARAMET> where T: Clone + Ord + Eq + SomeOtherTrait = Option<T>;
pub type Exactly101CharstoEqualWhereTest<T, U, PARAMETE> where T: Clone + Ord + Eq + SomeOtherTrait = Option<T>;

View file

@ -38,3 +38,14 @@ pub type GenericsFitButNotEqualTest<'a,
pub type CommentTest<// Lifetime
'a, // Type
T> = ();
pub type WithWhereClause<LONGPARAMETERNAME, T>
where T: Clone,
LONGPARAMETERNAME: Clone + Eq + OtherTrait = Option<T>;
pub type Exactly100CharstoEqualWhereTest<T, U, PARAMET> where T: Clone + Ord + Eq + SomeOtherTrait =
Option<T>;
pub type Exactly101CharstoEqualWhereTest<T, U, PARAMETE>
where T: Clone + Ord + Eq + SomeOtherTrait = Option<T>;