From a89222a0cbcd6beb49b69c9bb5915edbda7a0eb0 Mon Sep 17 00:00:00 2001 From: Caleb Cartwright Date: Tue, 12 Jan 2021 17:40:53 -0600 Subject: [PATCH 1/2] refactor: remove unneeded clone --- src/types.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/types.rs b/src/types.rs index 6e1fc8fc387..f43ade298f7 100644 --- a/src/types.rs +++ b/src/types.rs @@ -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, ), } }; From 1844a98580eca0f7caa4365a47f8fb1218349c4a Mon Sep 17 00:00:00 2001 From: Caleb Cartwright Date: Tue, 12 Jan 2021 17:39:03 -0600 Subject: [PATCH 2/2] fix: indentation issue on generic bounds --- src/types.rs | 2 +- tests/source/issue_4636.rs | 13 +++++++++++++ tests/target/issue_4636.rs | 13 +++++++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 tests/source/issue_4636.rs create mode 100644 tests/target/issue_4636.rs diff --git a/src/types.rs b/src/types.rs index f43ade298f7..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) 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 +{ + // +}