Skip to content

Commit 5139b14

Browse files
fix: version gate changes for multiline single generic bound
1 parent 6eeb4fd commit 5139b14

File tree

2 files changed

+20
-19
lines changed

2 files changed

+20
-19
lines changed

Diff for: src/types.rs

+12-11
Original file line numberDiff line numberDiff line change
@@ -1057,21 +1057,22 @@ fn join_bounds_inner(
10571057
},
10581058
)?;
10591059

1060-
// Whether retry the function with forced newline is needed:
1060+
// Whether to retry with a forced newline:
10611061
// Only if result is not already multiline and did not exceed line width,
10621062
// and either there is more than one item;
10631063
// or the single item is of type `Trait`,
10641064
// and any of the internal arrays contains more than one item;
1065-
let retry_with_force_newline =
1066-
if force_newline || (!result.0.contains('\n') && result.0.len() <= shape.width) {
1067-
false
1068-
} else {
1069-
if items.len() > 1 {
1070-
true
1071-
} else {
1072-
is_item_with_multi_items_array(&items[0])
1073-
}
1074-
};
1065+
let retry_with_force_newline = match context.config.version() {
1066+
Version::One => {
1067+
!force_newline
1068+
&& items.len() > 1
1069+
&& (result.0.contains('\n') || result.0.len() > shape.width)
1070+
}
1071+
Version::Two if force_newline => false,
1072+
Version::Two if (!result.0.contains('\n') && result.0.len() <= shape.width) => false,
1073+
Version::Two if items.len() > 1 => true,
1074+
Version::Two => is_item_with_multi_items_array(&items[0]),
1075+
};
10751076

10761077
if retry_with_force_newline {
10771078
join_bounds_inner(context, shape, items, need_indent, true)

Diff for: tests/target/issue-4689/one.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
// Based on the issue description
44
pub trait PrettyPrinter<'tcx>:
55
Printer<
6-
'tcx,
7-
Error = fmt::Error,
8-
Path = Self,
9-
Region = Self,
10-
Type = Self,
11-
DynExistential = Self,
12-
Const = Self,
13-
>
6+
'tcx,
7+
Error = fmt::Error,
8+
Path = Self,
9+
Region = Self,
10+
Type = Self,
11+
DynExistential = Self,
12+
Const = Self,
13+
>
1414
{
1515
//
1616
}

0 commit comments

Comments
 (0)