]> git.lizzy.rs Git - rust.git/commitdiff
Update tests
authortopecongiro <seuchida@gmail.com>
Sun, 21 May 2017 10:56:37 +0000 (19:56 +0900)
committertopecongiro <seuchida@gmail.com>
Tue, 23 May 2017 03:51:13 +0000 (12:51 +0900)
src/expr.rs
tests/source/configs-fn_call_style-block.rs
tests/source/expr-block.rs
tests/target/closure-block-inside-macro.rs
tests/target/configs-fn_call_style-block.rs
tests/target/expr-block.rs

index f0db88ae56679a216018b2cb82bc1b9ae8ce6cc8..c1b130fd8f3d073726c609a297433b625f959ae9 100644 (file)
@@ -1348,7 +1348,7 @@ fn rewrite(&self, context: &RewriteContext, shape: Shape) -> Option<String> {
             ast::ExprKind::Closure(..) => (true, &**body),
             _ => (false, &**body),
         };
-        extend &= context.config.fn_call_style == IndentStyle::Block;
+        extend &= context.config.fn_call_style() == IndentStyle::Block;
 
         let comma = arm_comma(&context.config, body);
         let alt_block_sep = String::from("\n") +
@@ -1746,9 +1746,9 @@ fn rewrite_call_args(context: &RewriteContext,
     if overflow_last {
         let last_arg = args.last().unwrap();
         let arg_shape = match last_arg.node {
-            ast::ExprKind::Closure(..) if context.config.fn_call_style == IndentStyle::Block => {
+            ast::ExprKind::Closure(..) if context.config.fn_call_style() == IndentStyle::Block => {
                 let mut arg_shape = shape.block();
-                arg_shape.indent.block_indent -= context.config.tab_spaces;
+                arg_shape.indent.block_indent -= context.config.tab_spaces();
                 arg_shape
             }
             _ => shape.block(),
index 35030189b8bf359379b840b39261b95df899b5e1..6708966fa691ba1df0f17e13506bb71985392947 100644 (file)
@@ -45,3 +45,54 @@ fn query(conn: &Connection) -> Result<()> {
 
     Ok(())
 }
+
+// #1449
+fn future_rayon_wait_1_thread() {
+    // run with only 1 worker thread; this would deadlock if we couldn't make progress
+    let mut result = None;
+    ThreadPool::new(Configuration::new().num_threads(1))
+        .unwrap()
+        .install(
+            || {
+                scope(
+                    |s| {
+                        use std::sync::mpsc::channel;
+                        let (tx, rx) = channel();
+                        let a = s.spawn_future(lazy(move || Ok::<usize, ()>(rx.recv().unwrap())));
+                        //                          ^^^^ FIXME: why is this needed?
+                        let b = s.spawn_future(a.map(|v| v + 1));
+                        let c = s.spawn_future(b.map(|v| v + 1));
+                        s.spawn(move |_| tx.send(20).unwrap());
+                        result = Some(c.rayon_wait().unwrap());
+                    },
+                );
+            },
+        );
+    assert_eq!(result, Some(22));
+}
+
+// #1494
+impl Cursor {
+    fn foo() {
+        self.cur_type()
+            .num_template_args()
+            .or_else(|| {
+                let n: c_int = unsafe { clang_Cursor_getNumTemplateArguments(self.x) };
+
+                if n >= 0 {
+                    Some(n as u32)
+                } else {
+                    debug_assert_eq!(n, -1);
+                    None
+                }
+            })
+            .or_else(|| {
+                let canonical = self.canonical();
+                if canonical != *self {
+                    canonical.num_template_args()
+                } else {
+                    None
+                }
+            });
+    }
+}
index ad959f8ee0172561b3cf078fbddf6cccb5e6fbcf..bf5d23a7d9e78b069f8fa4bf4d0f39c60240dffb 100644 (file)
@@ -143,3 +143,88 @@ fn foo() {
          DefinitiveListTactic::Horizontal
     }
 }
+
+fn combine_block() {
+    foo(
+        Bar {
+            x: value,
+            y: value2,
+        },
+    );
+
+    let opt = Some(
+        Struct(
+            long_argument_one,
+            long_argument_two,
+            long_argggggggg,
+        ),
+    );
+
+    do_thing(
+        |param| {
+            action();
+            foo(param)
+        },
+    );
+
+    do_thing(
+        x,
+        |param| {
+            action();
+            foo(param)
+        },
+    );
+
+    Ok(
+        some_function(
+            lllllllllong_argument_one,
+            lllllllllong_argument_two,
+            lllllllllllllllllllllllllllllong_argument_three,
+        ),
+    );
+
+    foo(
+        thing,
+        bar(
+            param2,
+            pparam1param1param1param1param1param1param1param1param1param1aram1,
+            param3,
+        ),
+    );
+
+    foo.map_or(
+        || {
+            Ok(
+                SomeStruct {
+                    f1: 0,
+                    f2: 0,
+                    f3: 0,
+                },
+            )
+        },
+    );
+
+    match opt {
+        Some(x) => somefunc(anotherfunc(
+            long_argument_one,
+            long_argument_two,
+            long_argument_three,
+        )),
+        None => Ok(SomeStruct {
+            f1: long_argument_one,
+            f2: long_argument_two,
+            f3: long_argument_three,
+        }),
+    };
+
+    match x {
+        y => func(
+            xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx,
+        ),
+        _ => func(
+            x,
+            yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy,
+            zzz,
+        ),
+    }
+}
index b58527eb8fbbd5a19c1f626c2b154cc51b3cae2c..5d1e1de0f68981711bd849cc999b970fb57ec9d8 100644 (file)
@@ -1,15 +1,13 @@
 // rustfmt-fn_call_style: Block
 
 // #1547
-fuzz_target!(
-    |data: &[u8]| {
-        if let Some(first) = data.first() {
-            let index = *first as usize;
-            if index >= ENCODINGS.len() {
-                return;
-            }
-            let encoding = ENCODINGS[index];
-            dispatch_test(encoding, &data[1..]);
+fuzz_target!(|data: &[u8]| {
+    if let Some(first) = data.first() {
+        let index = *first as usize;
+        if index >= ENCODINGS.len() {
+            return;
         }
+        let encoding = ENCODINGS[index];
+        dispatch_test(encoding, &data[1..]);
     }
-);
+});
index d7f65635379e0aaaa950b530e9a6838dfb973193..ed3dd76c04dd8225b30bc4b6d0df7d42c30ddcd2 100644 (file)
@@ -13,18 +13,20 @@ fn main() {
         "elit",
     );
     // #1501
-    let hyper = Arc::new(
-        Client::with_connector(HttpsConnector::new(TlsClient::new())),
-    );
+    let hyper = Arc::new(Client::with_connector(HttpsConnector::new(
+        TlsClient::new(),
+    )));
 }
 
 // #1521
 impl Foo {
     fn map_pixel_to_coords(&self, point: &Vector2i, view: &View) -> Vector2f {
         unsafe {
-            Vector2f::from_raw(
-                ffi::sfRenderTexture_mapPixelToCoords(self.render_texture, point.raw(), view.raw()),
-            )
+            Vector2f::from_raw(ffi::sfRenderTexture_mapPixelToCoords(
+                self.render_texture,
+                point.raw(),
+                view.raw(),
+            ))
         }
     }
 }
@@ -58,3 +60,50 @@ fn query(conn: &Connection) -> Result<()> {
 
     Ok(())
 }
+
+// #1449
+fn future_rayon_wait_1_thread() {
+    // run with only 1 worker thread; this would deadlock if we couldn't make progress
+    let mut result = None;
+    ThreadPool::new(Configuration::new().num_threads(1))
+        .unwrap()
+        .install(|| {
+            scope(|s| {
+                use std::sync::mpsc::channel;
+                let (tx, rx) = channel();
+                let a = s.spawn_future(lazy(move || Ok::<usize, ()>(rx.recv().unwrap())));
+                //                          ^^^^ FIXME: why is this needed?
+                let b = s.spawn_future(a.map(|v| v + 1));
+                let c = s.spawn_future(b.map(|v| v + 1));
+                s.spawn(move |_| tx.send(20).unwrap());
+                result = Some(c.rayon_wait().unwrap());
+            });
+        });
+    assert_eq!(result, Some(22));
+}
+
+// #1494
+impl Cursor {
+    fn foo() {
+        self.cur_type()
+            .num_template_args()
+            .or_else(|| {
+                let n: c_int = unsafe { clang_Cursor_getNumTemplateArguments(self.x) };
+
+                if n >= 0 {
+                    Some(n as u32)
+                } else {
+                    debug_assert_eq!(n, -1);
+                    None
+                }
+            })
+            .or_else(|| {
+                let canonical = self.canonical();
+                if canonical != *self {
+                    canonical.num_template_args()
+                } else {
+                    None
+                }
+            });
+    }
+}
index b6f35f65aec82cfcb6d4f6d932f68f2a95a6f8f9..1f3082f306878942aec673cbf1dde159d0214d94 100644 (file)
@@ -213,3 +213,75 @@ fn foo() {
         DefinitiveListTactic::Horizontal
     }
 }
+
+fn combine_block() {
+    foo(Bar {
+        x: value,
+        y: value2,
+    });
+
+    let opt = Some(Struct(
+        long_argument_one,
+        long_argument_two,
+        long_argggggggg,
+    ));
+
+    do_thing(|param| {
+        action();
+        foo(param)
+    });
+
+    do_thing(x, |param| {
+        action();
+        foo(param)
+    });
+
+    Ok(some_function(
+        lllllllllong_argument_one,
+        lllllllllong_argument_two,
+        lllllllllllllllllllllllllllllong_argument_three,
+    ));
+
+    foo(
+        thing,
+        bar(
+            param2,
+            pparam1param1param1param1param1param1param1param1param1param1aram1,
+            param3,
+        ),
+    );
+
+    foo.map_or(|| {
+        Ok(SomeStruct {
+            f1: 0,
+            f2: 0,
+            f3: 0,
+        })
+    });
+
+    match opt {
+        Some(x) => somefunc(anotherfunc(
+            long_argument_one,
+            long_argument_two,
+            long_argument_three,
+        )),
+        None => Ok(SomeStruct {
+            f1: long_argument_one,
+            f2: long_argument_two,
+            f3: long_argument_three,
+        }),
+    };
+
+    match x {
+        y => func(
+            xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx,
+        ),
+        _ => {
+            func(
+                x,
+                yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy,
+                zzz,
+            )
+        }
+    }
+}