Skip to content

Commit 9986b9d

Browse files
rchaser53topecongiro
authored andcommitted
fix internal error for long closure types (rust-lang#3653)
1 parent 5616533 commit 9986b9d

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

src/types.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -328,8 +328,9 @@ where
328328
Shape::legacy(budget, offset)
329329
};
330330

331+
let is_inputs_empty = inputs.len() == 0;
331332
let list_lo = context.snippet_provider.span_after(span, "(");
332-
let (list_str, tactic) = if inputs.len() == 0 {
333+
let (list_str, tactic) = if is_inputs_empty {
333334
let tactic = get_tactics(&[], &output, shape);
334335
let list_hi = context.snippet_provider.span_before(span, ")");
335336
let comment = context
@@ -377,7 +378,10 @@ where
377378
(write_list(&item_vec, &fmt)?, tactic)
378379
};
379380

380-
let args = if tactic == DefinitiveListTactic::Horizontal || !context.use_block_indent() {
381+
let args = if tactic == DefinitiveListTactic::Horizontal
382+
|| !context.use_block_indent()
383+
|| is_inputs_empty
384+
{
381385
format!("({})", list_str)
382386
} else {
383387
format!(

tests/source/issue-3651.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
fn f() -> Box<
2+
dyn FnMut() -> Thing< WithType = LongItemName, Error = LONGLONGLONGLONGLONGONGEvenLongerErrorNameLongerLonger>,
3+
>{
4+
}

tests/target/issue-3651.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
fn f() -> Box<
2+
dyn FnMut() -> Thing<
3+
WithType = LongItemName,
4+
Error = LONGLONGLONGLONGLONGONGEvenLongerErrorNameLongerLonger,
5+
>,
6+
> {
7+
}

0 commit comments

Comments
 (0)