Merge pull request #1904 from spinda/assoc-types-bounds-fix

Fix wrapping of bounds in associated types
This commit is contained in:
Seiichi Uchida 2017-08-20 23:37:15 +09:00 committed by GitHub
commit 4fcbf7f489
3 changed files with 15 additions and 1 deletions

View file

@ -1551,7 +1551,8 @@ pub fn rewrite_associated_type(
let prefix = format!("type {}", ident);
let type_bounds_str = if let Some(ty_param_bounds) = ty_param_bounds_opt {
let shape = Shape::indented(indent, context.config);
// 2 = ": ".len()
let shape = try_opt!(Shape::indented(indent, context.config).offset_left(prefix.len() + 2));
let bounds: &[_] = ty_param_bounds;
let bound_str = try_opt!(
bounds

View file

@ -0,0 +1,6 @@
// rustfmt-max_width: 100
// Test proper wrapping of long associated type bounds
pub trait HttpService {
type WsService: 'static + Service<Request = WsCommand, Response = WsResponse, Error = ServerError>;
}

View file

@ -0,0 +1,7 @@
// rustfmt-max_width: 100
// Test proper wrapping of long associated type bounds
pub trait HttpService {
type WsService: 'static
+ Service<Request = WsCommand, Response = WsResponse, Error = ServerError>;
}