summaryrefslogtreecommitdiffstats
path: root/src/tools/rustfmt/tests/target/configs/indent_style
diff options
context:
space:
mode:
Diffstat (limited to 'src/tools/rustfmt/tests/target/configs/indent_style')
-rw-r--r--src/tools/rustfmt/tests/target/configs/indent_style/block_args.rs47
-rw-r--r--src/tools/rustfmt/tests/target/configs/indent_style/block_array.rs14
-rw-r--r--src/tools/rustfmt/tests/target/configs/indent_style/block_call.rs151
-rw-r--r--src/tools/rustfmt/tests/target/configs/indent_style/block_chain.rs12
-rw-r--r--src/tools/rustfmt/tests/target/configs/indent_style/block_generic.rs22
-rw-r--r--src/tools/rustfmt/tests/target/configs/indent_style/block_struct_lit.rs9
-rw-r--r--src/tools/rustfmt/tests/target/configs/indent_style/block_tab_spaces_call.rs14
-rw-r--r--src/tools/rustfmt/tests/target/configs/indent_style/block_trailing_comma_call/one.rs12
-rw-r--r--src/tools/rustfmt/tests/target/configs/indent_style/block_trailing_comma_call/two.rs14
-rw-r--r--src/tools/rustfmt/tests/target/configs/indent_style/block_where_pred.rs12
-rw-r--r--src/tools/rustfmt/tests/target/configs/indent_style/default.rs11
-rw-r--r--src/tools/rustfmt/tests/target/configs/indent_style/rfc_control.rs39
-rw-r--r--src/tools/rustfmt/tests/target/configs/indent_style/rfc_where.rs12
-rw-r--r--src/tools/rustfmt/tests/target/configs/indent_style/visual_args.rs40
-rw-r--r--src/tools/rustfmt/tests/target/configs/indent_style/visual_array.rs12
-rw-r--r--src/tools/rustfmt/tests/target/configs/indent_style/visual_call.rs13
-rw-r--r--src/tools/rustfmt/tests/target/configs/indent_style/visual_chain.rs11
-rw-r--r--src/tools/rustfmt/tests/target/configs/indent_style/visual_generics.rs20
-rw-r--r--src/tools/rustfmt/tests/target/configs/indent_style/visual_struct_lit.rs7
-rw-r--r--src/tools/rustfmt/tests/target/configs/indent_style/visual_trailing_comma.rs7
-rw-r--r--src/tools/rustfmt/tests/target/configs/indent_style/visual_where_pred.rs11
21 files changed, 490 insertions, 0 deletions
diff --git a/src/tools/rustfmt/tests/target/configs/indent_style/block_args.rs b/src/tools/rustfmt/tests/target/configs/indent_style/block_args.rs
new file mode 100644
index 000000000..80f4e1333
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/indent_style/block_args.rs
@@ -0,0 +1,47 @@
+// rustfmt-indent_style: Block
+// Function arguments layout
+
+fn lorem() {}
+
+fn lorem(ipsum: usize) {}
+
+fn lorem(
+ ipsum: usize,
+ dolor: usize,
+ sit: usize,
+ amet: usize,
+ consectetur: usize,
+ adipiscing: usize,
+ elit: usize,
+) {
+ // body
+}
+
+// #1441
+extern "system" {
+ pub fn GetConsoleHistoryInfo(
+ console_history_info: *mut ConsoleHistoryInfo,
+ ) -> Boooooooooooooool;
+}
+
+// rustfmt should not add trailing comma for variadic function. See #1623.
+extern "C" {
+ pub fn variadic_fn(
+ first_parameter: FirstParameterType,
+ second_parameter: SecondParameterType,
+ ...
+ );
+}
+
+// #1652
+fn deconstruct(
+ foo: Bar,
+) -> (
+ SocketAddr,
+ Header,
+ Method,
+ RequestUri,
+ HttpVersion,
+ AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA,
+) {
+}
diff --git a/src/tools/rustfmt/tests/target/configs/indent_style/block_array.rs b/src/tools/rustfmt/tests/target/configs/indent_style/block_array.rs
new file mode 100644
index 000000000..5d458248c
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/indent_style/block_array.rs
@@ -0,0 +1,14 @@
+// rustfmt-indent_style: Block
+// Array layout
+
+fn main() {
+ let lorem = vec![
+ "ipsum",
+ "dolor",
+ "sit",
+ "amet",
+ "consectetur",
+ "adipiscing",
+ "elit",
+ ];
+}
diff --git a/src/tools/rustfmt/tests/target/configs/indent_style/block_call.rs b/src/tools/rustfmt/tests/target/configs/indent_style/block_call.rs
new file mode 100644
index 000000000..19c44dc01
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/indent_style/block_call.rs
@@ -0,0 +1,151 @@
+// rustfmt-indent_style: Block
+// Function call style
+
+fn main() {
+ lorem(
+ "lorem",
+ "ipsum",
+ "dolor",
+ "sit",
+ "amet",
+ "consectetur",
+ "adipiscing",
+ "elit",
+ );
+ // #1501
+ let hyper = Arc::new(Client::with_connector(
+ HttpsConnector::new(TlsClient::new()),
+ ));
+
+ // chain
+ let x = yooooooooooooo
+ .fooooooooooooooo
+ .baaaaaaaaaaaaar(hello, world);
+
+ // #1380
+ {
+ {
+ let creds = self
+ .client
+ .client_credentials(&self.config.auth.oauth2.id, &self.config.auth.oauth2.secret)?;
+ }
+ }
+
+ // nesting macro and function call
+ try!(foo(
+ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx,
+ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+ ));
+ try!(foo(try!(
+ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx,
+ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+ )));
+}
+
+// #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(),
+ ))
+ }
+ }
+}
+
+fn issue1420() {
+ given(
+ r#"
+ # Getting started
+ ...
+ "#,
+ )
+ .running(waltz)
+}
+
+// #1563
+fn query(conn: &Connection) -> Result<()> {
+ conn.query_row(
+ r#"
+ SELECT title, date
+ FROM posts,
+ WHERE DATE(date) = $1
+ "#,
+ &[],
+ |row| Post {
+ title: row.get(0),
+ date: row.get(1),
+ },
+ )?;
+
+ 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
+ }
+ });
+ }
+}
+
+fn issue1581() {
+ bootstrap.checks.register("PERSISTED_LOCATIONS", move || {
+ if locations2.0.inner_mut.lock().poisoned {
+ Check::new(
+ State::Error,
+ "Persisted location storage is poisoned due to a write failure",
+ )
+ } else {
+ Check::new(State::Healthy, "Persisted location storage is healthy")
+ }
+ });
+}
+
+fn issue1651() {
+ {
+ let type_list: Vec<_> =
+ try_opt!(types.iter().map(|ty| ty.rewrite(context, shape)).collect());
+ }
+}
diff --git a/src/tools/rustfmt/tests/target/configs/indent_style/block_chain.rs b/src/tools/rustfmt/tests/target/configs/indent_style/block_chain.rs
new file mode 100644
index 000000000..23340a4ab
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/indent_style/block_chain.rs
@@ -0,0 +1,12 @@
+// rustfmt-indent_style: Block
+// Chain indent
+
+fn main() {
+ let lorem = ipsum
+ .dolor()
+ .sit()
+ .amet()
+ .consectetur()
+ .adipiscing()
+ .elite();
+}
diff --git a/src/tools/rustfmt/tests/target/configs/indent_style/block_generic.rs b/src/tools/rustfmt/tests/target/configs/indent_style/block_generic.rs
new file mode 100644
index 000000000..c4fcaaf65
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/indent_style/block_generic.rs
@@ -0,0 +1,22 @@
+// rustfmt-indent_style: Block
+// Generics indent
+
+fn lorem<
+ Ipsum: Eq = usize,
+ Dolor: Eq = usize,
+ Sit: Eq = usize,
+ Amet: Eq = usize,
+ Adipiscing: Eq = usize,
+ Consectetur: Eq = usize,
+ Elit: Eq = usize,
+>(
+ ipsum: Ipsum,
+ dolor: Dolor,
+ sit: Sit,
+ amet: Amet,
+ adipiscing: Adipiscing,
+ consectetur: Consectetur,
+ elit: Elit,
+) -> T {
+ // body
+}
diff --git a/src/tools/rustfmt/tests/target/configs/indent_style/block_struct_lit.rs b/src/tools/rustfmt/tests/target/configs/indent_style/block_struct_lit.rs
new file mode 100644
index 000000000..656b56226
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/indent_style/block_struct_lit.rs
@@ -0,0 +1,9 @@
+// rustfmt-indent_style: Block
+// Struct literal-style
+
+fn main() {
+ let lorem = Lorem {
+ ipsum: dolor,
+ sit: amet,
+ };
+}
diff --git a/src/tools/rustfmt/tests/target/configs/indent_style/block_tab_spaces_call.rs b/src/tools/rustfmt/tests/target/configs/indent_style/block_tab_spaces_call.rs
new file mode 100644
index 000000000..5531e61dd
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/indent_style/block_tab_spaces_call.rs
@@ -0,0 +1,14 @@
+// rustfmt-indent_style: Block
+// rustfmt-max_width: 80
+// rustfmt-tab_spaces: 2
+
+// #1427
+fn main() {
+ exceptaions::config(move || {
+ (
+ NmiConfig {},
+ HardFaultConfig {},
+ SysTickConfig { gpio_sbsrr },
+ )
+ });
+}
diff --git a/src/tools/rustfmt/tests/target/configs/indent_style/block_trailing_comma_call/one.rs b/src/tools/rustfmt/tests/target/configs/indent_style/block_trailing_comma_call/one.rs
new file mode 100644
index 000000000..6b9489bef
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/indent_style/block_trailing_comma_call/one.rs
@@ -0,0 +1,12 @@
+// rustfmt-version: One
+// rustfmt-error_on_line_overflow: false
+// rustfmt-indent_style: Block
+
+// rustfmt should not add trailing comma when rewriting macro. See #1528.
+fn a() {
+ panic!("this is a long string that goes past the maximum line length causing rustfmt to insert a comma here:");
+ foo(
+ a,
+ oooptoptoptoptptooptoptoptoptptooptoptoptoptptoptoptoptoptpt(),
+ );
+}
diff --git a/src/tools/rustfmt/tests/target/configs/indent_style/block_trailing_comma_call/two.rs b/src/tools/rustfmt/tests/target/configs/indent_style/block_trailing_comma_call/two.rs
new file mode 100644
index 000000000..4f4292e5f
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/indent_style/block_trailing_comma_call/two.rs
@@ -0,0 +1,14 @@
+// rustfmt-version: Two
+// rustfmt-error_on_line_overflow: false
+// rustfmt-indent_style: Block
+
+// rustfmt should not add trailing comma when rewriting macro. See #1528.
+fn a() {
+ panic!(
+ "this is a long string that goes past the maximum line length causing rustfmt to insert a comma here:"
+ );
+ foo(
+ a,
+ oooptoptoptoptptooptoptoptoptptooptoptoptoptptoptoptoptoptpt(),
+ );
+}
diff --git a/src/tools/rustfmt/tests/target/configs/indent_style/block_where_pred.rs b/src/tools/rustfmt/tests/target/configs/indent_style/block_where_pred.rs
new file mode 100644
index 000000000..ad7e0b8f3
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/indent_style/block_where_pred.rs
@@ -0,0 +1,12 @@
+// rustfmt-indent_style: Block
+// Where predicate indent
+
+fn lorem<Ipsum, Dolor, Sit, Amet>() -> T
+where
+ Ipsum: Eq,
+ Dolor: Eq,
+ Sit: Eq,
+ Amet: Eq,
+{
+ // body
+}
diff --git a/src/tools/rustfmt/tests/target/configs/indent_style/default.rs b/src/tools/rustfmt/tests/target/configs/indent_style/default.rs
new file mode 100644
index 000000000..a8f0902b3
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/indent_style/default.rs
@@ -0,0 +1,11 @@
+// rustfmt-indent_style: Visual
+// Where style
+
+fn lorem<Ipsum, Dolor, Sit, Amet>() -> T
+ where Ipsum: Eq,
+ Dolor: Eq,
+ Sit: Eq,
+ Amet: Eq
+{
+ // body
+}
diff --git a/src/tools/rustfmt/tests/target/configs/indent_style/rfc_control.rs b/src/tools/rustfmt/tests/target/configs/indent_style/rfc_control.rs
new file mode 100644
index 000000000..6619d8b26
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/indent_style/rfc_control.rs
@@ -0,0 +1,39 @@
+// rustfmt-indent_style: Block
+
+// #1618
+fn main() {
+ loop {
+ if foo {
+ if ((right_paddle_speed < 0.) && (right_paddle.position().y - paddle_size.y / 2. > 5.))
+ || ((right_paddle_speed > 0.)
+ && (right_paddle.position().y + paddle_size.y / 2. < game_height as f32 - 5.))
+ {
+ foo
+ }
+ if ai_timer.elapsed_time().as_microseconds() > ai_time.as_microseconds() {
+ if ball.position().y + ball_radius > right_paddle.position().y + paddle_size.y / 2.
+ {
+ foo
+ }
+ }
+ }
+ }
+}
+
+fn issue1656() {
+ {
+ {
+ match rewrite {
+ Some(ref body_str)
+ if (!body_str.contains('\n') && body_str.len() <= arm_shape.width)
+ || !context.config.match_arm_blocks()
+ || (extend && first_line_width(body_str) <= arm_shape.width)
+ || is_block =>
+ {
+ return None;
+ }
+ _ => {}
+ }
+ }
+ }
+}
diff --git a/src/tools/rustfmt/tests/target/configs/indent_style/rfc_where.rs b/src/tools/rustfmt/tests/target/configs/indent_style/rfc_where.rs
new file mode 100644
index 000000000..a7b9a4f02
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/indent_style/rfc_where.rs
@@ -0,0 +1,12 @@
+// rustfmt-indent_style: Block
+// Where style
+
+fn lorem<Ipsum, Dolor, Sit, Amet>() -> T
+where
+ Ipsum: Eq,
+ Dolor: Eq,
+ Sit: Eq,
+ Amet: Eq,
+{
+ // body
+}
diff --git a/src/tools/rustfmt/tests/target/configs/indent_style/visual_args.rs b/src/tools/rustfmt/tests/target/configs/indent_style/visual_args.rs
new file mode 100644
index 000000000..04c2eaee3
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/indent_style/visual_args.rs
@@ -0,0 +1,40 @@
+// rustfmt-indent_style: Visual
+// Function arguments layout
+
+fn lorem() {}
+
+fn lorem(ipsum: usize) {}
+
+fn lorem(ipsum: usize,
+ dolor: usize,
+ sit: usize,
+ amet: usize,
+ consectetur: usize,
+ adipiscing: usize,
+ elit: usize) {
+ // body
+}
+
+// #1922
+extern "C" {
+ pub fn LAPACKE_csytrs_rook_work(matrix_layout: c_int,
+ uplo: c_char,
+ n: lapack_int,
+ nrhs: lapack_int,
+ a: *const lapack_complex_float,
+ lda: lapack_int,
+ ipiv: *const lapack_int,
+ b: *mut lapack_complex_float,
+ ldb: lapack_int)
+ -> lapack_int;
+
+ pub fn LAPACKE_csytrs_rook_work(matrix_layout: c_int,
+ uplo: c_char,
+ n: lapack_int,
+ nrhs: lapack_int,
+ lda: lapack_int,
+ ipiv: *const lapack_int,
+ b: *mut lapack_complex_float,
+ ldb: lapack_int)
+ -> lapack_int;
+}
diff --git a/src/tools/rustfmt/tests/target/configs/indent_style/visual_array.rs b/src/tools/rustfmt/tests/target/configs/indent_style/visual_array.rs
new file mode 100644
index 000000000..1da6ff237
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/indent_style/visual_array.rs
@@ -0,0 +1,12 @@
+// rustfmt-indent_style: Visual
+// Array layout
+
+fn main() {
+ let lorem = vec!["ipsum",
+ "dolor",
+ "sit",
+ "amet",
+ "consectetur",
+ "adipiscing",
+ "elit"];
+}
diff --git a/src/tools/rustfmt/tests/target/configs/indent_style/visual_call.rs b/src/tools/rustfmt/tests/target/configs/indent_style/visual_call.rs
new file mode 100644
index 000000000..5454c44ef
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/indent_style/visual_call.rs
@@ -0,0 +1,13 @@
+// rustfmt-indent_style: Visual
+// Function call style
+
+fn main() {
+ lorem("lorem",
+ "ipsum",
+ "dolor",
+ "sit",
+ "amet",
+ "consectetur",
+ "adipiscing",
+ "elit");
+}
diff --git a/src/tools/rustfmt/tests/target/configs/indent_style/visual_chain.rs b/src/tools/rustfmt/tests/target/configs/indent_style/visual_chain.rs
new file mode 100644
index 000000000..569f3d8b8
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/indent_style/visual_chain.rs
@@ -0,0 +1,11 @@
+// rustfmt-indent_style: Visual
+// Chain indent
+
+fn main() {
+ let lorem = ipsum.dolor()
+ .sit()
+ .amet()
+ .consectetur()
+ .adipiscing()
+ .elite();
+}
diff --git a/src/tools/rustfmt/tests/target/configs/indent_style/visual_generics.rs b/src/tools/rustfmt/tests/target/configs/indent_style/visual_generics.rs
new file mode 100644
index 000000000..491075a14
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/indent_style/visual_generics.rs
@@ -0,0 +1,20 @@
+// rustfmt-indent_style: Visual
+// Generics indent
+
+fn lorem<Ipsum: Eq = usize,
+ Dolor: Eq = usize,
+ Sit: Eq = usize,
+ Amet: Eq = usize,
+ Adipiscing: Eq = usize,
+ Consectetur: Eq = usize,
+ Elit: Eq = usize>(
+ ipsum: Ipsum,
+ dolor: Dolor,
+ sit: Sit,
+ amet: Amet,
+ adipiscing: Adipiscing,
+ consectetur: Consectetur,
+ elit: Elit)
+ -> T {
+ // body
+}
diff --git a/src/tools/rustfmt/tests/target/configs/indent_style/visual_struct_lit.rs b/src/tools/rustfmt/tests/target/configs/indent_style/visual_struct_lit.rs
new file mode 100644
index 000000000..ec49021d3
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/indent_style/visual_struct_lit.rs
@@ -0,0 +1,7 @@
+// rustfmt-indent_style: Visual
+// Struct literal-style
+
+fn main() {
+ let lorem = Lorem { ipsum: dolor,
+ sit: amet };
+}
diff --git a/src/tools/rustfmt/tests/target/configs/indent_style/visual_trailing_comma.rs b/src/tools/rustfmt/tests/target/configs/indent_style/visual_trailing_comma.rs
new file mode 100644
index 000000000..9738d397d
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/indent_style/visual_trailing_comma.rs
@@ -0,0 +1,7 @@
+// rustfmt-error_on_line_overflow: false
+// rustfmt-indent_style: Visual
+
+// rustfmt should not add trailing comma when rewriting macro. See #1528.
+fn a() {
+ panic!("this is a long string that goes past the maximum line length causing rustfmt to insert a comma here:");
+}
diff --git a/src/tools/rustfmt/tests/target/configs/indent_style/visual_where_pred.rs b/src/tools/rustfmt/tests/target/configs/indent_style/visual_where_pred.rs
new file mode 100644
index 000000000..45799dcd5
--- /dev/null
+++ b/src/tools/rustfmt/tests/target/configs/indent_style/visual_where_pred.rs
@@ -0,0 +1,11 @@
+// rustfmt-indent_style: Visual
+// Where predicate indent
+
+fn lorem<Ipsum, Dolor, Sit, Amet>() -> T
+ where Ipsum: Eq,
+ Dolor: Eq,
+ Sit: Eq,
+ Amet: Eq
+{
+ // body
+}