diff --git a/src/types.rs b/src/types.rs index 6e1fc8fc387..d96429c362a 100644 --- a/src/types.rs +++ b/src/types.rs @@ -931,7 +931,7 @@ fn join_bounds_inner( _ => false, }; - let shape = if i > 0 && need_indent && force_newline { + let shape = if need_indent && force_newline { shape .block_indent(context.config.tab_spaces()) .with_max_width(context.config) @@ -962,22 +962,21 @@ fn join_bounds_inner( joiner }; - let (trailing_str, extendable) = if i == 0 { + let (extendable, trailing_str) = if i == 0 { let bound_str = item.rewrite(context, shape)?; - let bound_str_clone = bound_str.clone(); - (bound_str, is_bound_extendable(&bound_str_clone, item)) + (is_bound_extendable(&bound_str, item), bound_str) } else { let bound_str = &item.rewrite(context, shape)?; match leading_span { Some(ls) if has_leading_comment => ( + is_bound_extendable(bound_str, item), combine_strs_with_missing_comments( context, joiner, bound_str, ls, shape, true, )?, - is_bound_extendable(bound_str, item), ), _ => ( - String::from(joiner) + bound_str, is_bound_extendable(bound_str, item), + String::from(joiner) + bound_str, ), } }; diff --git a/tests/source/issue_4636.rs b/tests/source/issue_4636.rs new file mode 100644 index 00000000000..ea7079f6c73 --- /dev/null +++ b/tests/source/issue_4636.rs @@ -0,0 +1,13 @@ +pub trait PrettyPrinter<'tcx>: + Printer< + 'tcx, + Error = fmt::Error, + Path = Self, + Region = Self, + Type = Self, + DynExistential = Self, + Const = Self, + > + fmt::Write + { + // + } \ No newline at end of file diff --git a/tests/target/issue_4636.rs b/tests/target/issue_4636.rs new file mode 100644 index 00000000000..a6465e29a02 --- /dev/null +++ b/tests/target/issue_4636.rs @@ -0,0 +1,13 @@ +pub trait PrettyPrinter<'tcx>: + Printer< + 'tcx, + Error = fmt::Error, + Path = Self, + Region = Self, + Type = Self, + DynExistential = Self, + Const = Self, + > + fmt::Write +{ + // +}