]> git.lizzy.rs Git - rust.git/commitdiff
fix internal error for long closure types (#3653)
authorrChaser53 <tayoshizawa29@gmail.com>
Tue, 25 Jun 2019 14:14:19 +0000 (23:14 +0900)
committerSeiichi Uchida <seuchida@gmail.com>
Tue, 25 Jun 2019 14:14:19 +0000 (23:14 +0900)
src/types.rs
tests/source/issue-3651.rs [new file with mode: 0644]
tests/target/issue-3651.rs [new file with mode: 0644]

index c15a580f1a87fe291891440a5d1c543d1d9dafcf..95f8014f38afb211200673025a049f396d5d6190 100644 (file)
@@ -328,8 +328,9 @@ fn format_function_type<'a, I>(
         Shape::legacy(budget, offset)
     };
 
+    let is_inputs_empty = inputs.len() == 0;
     let list_lo = context.snippet_provider.span_after(span, "(");
-    let (list_str, tactic) = if inputs.len() == 0 {
+    let (list_str, tactic) = if is_inputs_empty {
         let tactic = get_tactics(&[], &output, shape);
         let list_hi = context.snippet_provider.span_before(span, ")");
         let comment = context
@@ -377,7 +378,10 @@ fn format_function_type<'a, I>(
         (write_list(&item_vec, &fmt)?, tactic)
     };
 
-    let args = if tactic == DefinitiveListTactic::Horizontal || !context.use_block_indent() {
+    let args = if tactic == DefinitiveListTactic::Horizontal
+        || !context.use_block_indent()
+        || is_inputs_empty
+    {
         format!("({})", list_str)
     } else {
         format!(
diff --git a/tests/source/issue-3651.rs b/tests/source/issue-3651.rs
new file mode 100644 (file)
index 0000000..c153e99
--- /dev/null
@@ -0,0 +1,4 @@
+fn f() -> Box<
+    dyn FnMut() -> Thing< WithType = LongItemName, Error = LONGLONGLONGLONGLONGONGEvenLongerErrorNameLongerLonger>,
+>{
+}
\ No newline at end of file
diff --git a/tests/target/issue-3651.rs b/tests/target/issue-3651.rs
new file mode 100644 (file)
index 0000000..4a95a17
--- /dev/null
@@ -0,0 +1,7 @@
+fn f() -> Box<
+    dyn FnMut() -> Thing<
+        WithType = LongItemName,
+        Error = LONGLONGLONGLONGLONGONGEvenLongerErrorNameLongerLonger,
+    >,
+> {
+}