]> git.lizzy.rs Git - rust.git/commitdiff
Add a test
authortopecongiro <seuchida@gmail.com>
Fri, 27 Oct 2017 06:39:15 +0000 (15:39 +0900)
committertopecongiro <seuchida@gmail.com>
Fri, 27 Oct 2017 06:39:15 +0000 (15:39 +0900)
rustfmt fails to format a function call when it has a single closure argument
and that closure has a block body which contains comments at the beginnig of
the block, and the block only contains a single expression as its statement.
Phew!

tests/source/closure.rs
tests/target/closure.rs

index 39059f40807fd80d4847a5b34b45830c6f2a5188..5bf177838420bb76f733584b9e56e45649ebcd7f 100644 (file)
@@ -41,7 +41,16 @@ fn main() {
     let closure_with_return_type = |aaaaaaaaaaaaaaaaaaaaaaarg1, aaaaaaaaaaaaaaaaaaaaaaarg2| -> Strong { "sup".to_owned() };
 
     |arg1, arg2, _, _, arg3, arg4| { let temp = arg4 + arg3;
-                                     arg2 * arg1 - temp }
+                                     arg2 * arg1 - temp };
+
+    let block_body_with_comment = args.iter()
+        .map(|a| {
+            // Emitting only dep-info is possible only for final crate type, as
+            // as others may emit required metadata for dependent crate types
+            if a.starts_with("--emit") && is_final_crate_type && !self.workspace_mode {
+                "--emit=dep-info"
+            } else { a }
+        });
 }
 
 fn issue311() {
index 9d59bfb64cbdb63281cc34628d893fca08153959..2005d85bf175fc26f088ba64f7fc64d57045e1de 100644 (file)
@@ -60,7 +60,17 @@ fn main() {
     |arg1, arg2, _, _, arg3, arg4| {
         let temp = arg4 + arg3;
         arg2 * arg1 - temp
-    }
+    };
+
+    let block_body_with_comment = args.iter().map(|a| {
+        // Emitting only dep-info is possible only for final crate type, as
+        // as others may emit required metadata for dependent crate types
+        if a.starts_with("--emit") && is_final_crate_type && !self.workspace_mode {
+            "--emit=dep-info"
+        } else {
+            a
+        }
+    });
 }
 
 fn issue311() {