This was done by running the following.
```sh
for f in `find . -name "configs-*.rs"`; do
topdir=`echo $f | cut -d/ -f2`;
configname=`echo $f | cut -d/ -f3 | cut -d- -f2`;
testname=`echo $f | cut -d/ -f3 | cut -d- -f3`;
mkdir -p $topdir/configs/$configname;
git mv $f $topdir/configs/$configname/$testname;
done
```
+++ /dev/null
-// rustfmt-indent_style: Block
-// Array layout
-
-fn main() {
- let lorem = vec!["ipsum","dolor","sit","amet","consectetur","adipiscing","elit"];
-}
+++ /dev/null
-// rustfmt-indent_style: Visual
-// Array layout
-
-fn main() {
- let lorem = vec!["ipsum","dolor","sit","amet","consectetur","adipiscing","elit"];
-}
+++ /dev/null
-// rustfmt-blank_lines_lower_bound: 1
-
-fn foo() {}
-fn bar() {}
-// comment
-fn foobar() {}
-
-fn foo1() {}
-fn bar1() {}
-
-// comment
-
-fn foobar1() {}
+++ /dev/null
-// rustfmt-indent_style: Block
-// Chain indent
-
-fn main() {
- let lorem = ipsum.dolor().sit().amet().consectetur().adipiscing().elite();
-}
+++ /dev/null
-// rustfmt-indent_style: Visual
-// Chain indent
-
-fn main() {
- let lorem = ipsum.dolor().sit().amet().consectetur().adipiscing().elite();
-}
+++ /dev/null
-// rustfmt-comment_width: 40
-// rustfmt-wrap_comments: true
-// Comment width
-
-fn main() {
- // Lorem ipsum dolor sit amet, consectetur adipiscing elit.
-}
+++ /dev/null
-// rustfmt-comment_width: 80
-// rustfmt-wrap_comments: true
-// Comment width
-
-fn main() {
- // Lorem ipsum dolor sit amet, consectetur adipiscing elit.
-}
+++ /dev/null
-// rustfmt-comment_width: 40
-// rustfmt-wrap_comments: false
-// Comment width
-
-fn main() {
- // Lorem ipsum dolor sit amet, consectetur adipiscing elit.
-}
+++ /dev/null
-// rustfmt-condense_wildcard_suffixes: false
-// Condense wildcard suffixes
-
-fn main() {
- let (lorem, ipsum, _, _) = (1, 2, 3, 4);
-}
+++ /dev/null
-// rustfmt-condense_wildcard_suffixes: true
-// Condense wildcard suffixes
-
-fn main() {
- let (lorem, ipsum, _, _) = (1, 2, 3, 4);
-}
+++ /dev/null
-// rustfmt-control_brace_style: AlwaysNextLine
-// Control brace style
-
-fn main() {
- if lorem { println!("ipsum!"); } else { println!("dolor!"); }
- match magi {
- Homura => "Akemi",
- Madoka => "Kaname",
- }
-}
+++ /dev/null
-// rustfmt-control_brace_style: AlwaysSameLine
-// Control brace style
-
-fn main() {
- if lorem { println!("ipsum!"); } else { println!("dolor!"); }
- match magi {
- Homura => "Akemi",
- Madoka => "Kaname",
- }
-}
+++ /dev/null
-// rustfmt-control_brace_style: ClosingNextLine
-// Control brace style
-
-fn main() {
- if lorem { println!("ipsum!"); } else { println!("dolor!"); }
- match magi {
- Homura => "Akemi",
- Madoka => "Kaname",
- }
-}
+++ /dev/null
-// rustfmt-disable_all_formatting: false
-// Disable all formatting
-
-fn main() {
- if lorem{println!("ipsum!");}else{println!("dolor!");}
-}
+++ /dev/null
-// rustfmt-disable_all_formatting: true
-// Disable all formatting
-
-fn main() {
- iflorem{println!("ipsum!");}else{println!("dolor!");}
-}
+++ /dev/null
-// rustfmt-empty_item_single_line: false
-// Empty impl on single line
-
-impl Lorem {
-
-}
-
-impl Ipsum {
-
-}
-
-fn lorem() {
-}
-
-fn lorem() {
-
-}
+++ /dev/null
-// rustfmt-empty_item_single_line: true
-// Empty impl on single line
-
-impl Lorem {
-
-}
-
-impl Ipsum {
-
-}
-
-fn lorem() {
-}
-
-fn lorem() {
-
-}
+++ /dev/null
-// rustfmt-error_on_line_overflow: false
-// Error on line overflow
-
-fn main() {
- let lorem_ipsum_dolor_sit_amet_consectetur_adipiscing_elit_lorem_ipsum_dolor_sit_amet_consectetur_adipiscing_elit;
-}
+++ /dev/null
-// rustfmt-fn_args_density: Compressed
-// Function arguments density
-
-trait Lorem {
- fn lorem(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet);
-
- fn lorem(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet) {
- // body
- }
-
- fn lorem(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet, consectetur: onsectetur, adipiscing: Adipiscing, elit: Elit);
-
- fn lorem(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet, consectetur: onsectetur, adipiscing: Adipiscing, elit: Elit) {
- // body
- }
-}
+++ /dev/null
-// rustfmt-fn_args_density: Tall
-// Function arguments density
-
-trait Lorem {
- fn lorem(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet);
-
- fn lorem(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet) {
- // body
- }
-
- fn lorem(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet, consectetur: onsectetur, adipiscing: Adipiscing, elit: Elit);
-
- fn lorem(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet, consectetur: onsectetur, adipiscing: Adipiscing, elit: Elit) {
- // body
- }
-}
+++ /dev/null
-// rustfmt-fn_args_density: Vertical
-// Function arguments density
-
-trait Lorem {
- fn lorem(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet);
-
- fn lorem(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet) {
- // body
- }
-
- fn lorem(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet, consectetur: onsectetur, adipiscing: Adipiscing, elit: Elit);
-
- fn lorem(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet, consectetur: onsectetur, adipiscing: Adipiscing, elit: Elit) {
- // body
- }
-}
+++ /dev/null
-// 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) {
-}
+++ /dev/null
-// 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;
-}
+++ /dev/null
-// rustfmt-brace_style: AlwaysNextLine
-// Function brace style
-
-fn lorem() {
- // body
-}
-
-fn lorem(ipsum: usize) {
- // body
-}
-
-fn lorem<T>(ipsum: T) where T: Add + Sub + Mul + Div {
- // body
-}
+++ /dev/null
-// rustfmt-brace_style: PreferSameLine
-// Function brace style
-
-fn lorem() {
- // body
-}
-
-fn lorem(ipsum: usize) {
- // body
-}
-
-fn lorem<T>(ipsum: T) where T: Add + Sub + Mul + Div {
- // body
-}
+++ /dev/null
-// rustfmt-brace_style: SameLineWhere
-// Function brace style
-
-fn lorem() {
- // body
-}
-
-fn lorem(ipsum: usize) {
- // body
-}
-
-fn lorem<T>(ipsum: T) where T: Add + Sub + Mul + Div {
- // body
-}
+++ /dev/null
-// 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());
- }
-}
+++ /dev/null
-// 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());
-}
+++ /dev/null
-// rustfmt-indent_style: Visual
-// Function call style
-
-fn main() {
- lorem("lorem", "ipsum", "dolor", "sit", "amet", "consectetur", "adipiscing", "elit");
-}
+++ /dev/null
-// 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:");
-}
+++ /dev/null
-// rustfmt-fn_single_line: false
-// Single-expression function on single line
-
-fn lorem() -> usize {
- 42
-}
-
-fn lorem() -> usize {
- let ipsum = 42;
- ipsum
-}
+++ /dev/null
-// rustfmt-fn_single_line: true
-// Single-expression function on single line
-
-fn lorem() -> usize {
- 42
-}
-
-fn lorem() -> usize {
- let ipsum = 42;
- ipsum
-}
+++ /dev/null
-// rustfmt-force_explicit_abi: false
-// Force explicit abi
-
-extern {
- pub static lorem: c_int;
-}
+++ /dev/null
-// rustfmt-force_explicit_abi: true
-// Force explicit abi
-
-extern {
- pub static lorem: c_int;
-}
+++ /dev/null
-// rustfmt-force_multiline_blocks: false
-// Option forces multiline match arm and closure bodies to be wrapped in a block
-
-fn main() {
- match lorem {
- Lorem::Ipsum => {
- if ipsum {
- println!("dolor");
- }
- }
- Lorem::Dolor => println!("amet"),
- }
-}
-
-fn main() {
- result.and_then(|maybe_value| {
- match maybe_value {
- None => Err("oops"),
- Some(value) => Ok(1),
- }
- });
-}
+++ /dev/null
-// rustfmt-force_multiline_blocks: true
-// Option forces multiline match arm and closure bodies to be wrapped in a block
-
-fn main() {
- match lorem {
- Lorem::Ipsum => if ipsum {
- println!("dolor");
- },
- Lorem::Dolor => println!("amet"),
- }
-}
-
-fn main() {
- result.and_then(|maybe_value| match maybe_value {
- None => Err("oops"),
- Some(value) => Ok(1),
- });
-}
+++ /dev/null
-// rustfmt-format_strings: false
-// rustfmt-max_width: 50
-// rustfmt-error_on_line_overflow: false
-// Force format strings
-
-fn main() {
- let lorem = "ipsum dolor sit amet consectetur adipiscing elit lorem ipsum dolor sit";
-}
+++ /dev/null
-// rustfmt-format_strings: true
-// rustfmt-max_width: 50
-// Force format strings
-
-fn main() {
- let lorem = "ipsum dolor sit amet consectetur adipiscing elit lorem ipsum dolor sit";
-}
+++ /dev/null
-// 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
-}
+++ /dev/null
-// 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
-}
+++ /dev/null
-// rustfmt-hard_tabs: false
-// Hard tabs
-
-fn lorem() -> usize {
-42 // spaces before 42
-}
+++ /dev/null
-// rustfmt-hard_tabs: true
-// Hard tabs
-
-fn lorem() -> usize {
-42 // spaces before 42
-}
+++ /dev/null
-// rustfmt-brace_style: AlwaysNextLine
-// Item brace style
-
-enum Foo {}
-
-struct Bar {}
-
-struct Lorem {
- ipsum: bool,
-}
-
-struct Dolor<T> where T: Eq {
- sit: T,
-}
-
-#[cfg(test)]
-mod tests {
- #[test]
- fn it_works() {}
-}
+++ /dev/null
-// rustfmt-brace_style: PreferSameLine
-// Item brace style
-
-struct Lorem {
- ipsum: bool,
-}
-
-struct Dolor<T> where T: Eq {
- sit: T,
-}
-
-#[cfg(test)]
-mod tests {
- #[test]
- fn it_works() {}
-}
+++ /dev/null
-// rustfmt-brace_style: SameLineWhere
-// Item brace style
-
-struct Lorem {
- ipsum: bool,
-}
-
-struct Dolor<T> where T: Eq {
- sit: T,
-}
-
-#[cfg(test)]
-mod tests {
- #[test]
- fn it_works() {}
-}
+++ /dev/null
-// rustfmt-match_arm_blocks: false
-// Wrap match-arms
-
-fn main() {
- match lorem {
- true => foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo(x),
- false => {
- println!("{}", sit)
- }
- }
-}
+++ /dev/null
-// rustfmt-match_arm_blocks: true
-// Wrap match-arms
-
-fn main() {
- match lorem {
- true => foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo(x),
- false => {
- println!("{}", sit)
- }
- }
-}
+++ /dev/null
-// rustfmt-match_block_trailing_comma: false
-// Match block trailing comma
-
-fn main() {
- match lorem {
- Lorem::Ipsum => {
- println!("ipsum");
- }
- Lorem::Dolor => println!("dolor"),
- }
-}
+++ /dev/null
-// rustfmt-match_block_trailing_comma: true
-// Match block trailing comma
-
-fn main() {
- match lorem {
- Lorem::Ipsum => {
- println!("ipsum");
- }
- Lorem::Dolor => println!("dolor"),
- }
-}
+++ /dev/null
-// rustfmt-merge_derives: true
-// Merge multiple derives to a single one.
-
-#[bar]
-#[derive(Eq, PartialEq)]
-#[foo]
-#[derive(Debug)]
-#[foobar]
-#[derive(Copy, Clone)]
-pub enum Foo {}
-
-#[derive(Eq, PartialEq)]
-#[derive(Debug)]
-#[foobar]
-#[derive(Copy, Clone)]
-pub enum Bar {}
-
-#[derive(Eq, PartialEq)]
-#[derive(Debug)]
-#[derive(Copy, Clone)]
-pub enum FooBar {}
-
-mod foo {
-#[bar]
-#[derive(Eq, PartialEq)]
-#[foo]
-#[derive(Debug)]
-#[foobar]
-#[derive(Copy, Clone)]
-pub enum Foo {}
-}
-
-mod bar {
-#[derive(Eq, PartialEq)]
-#[derive(Debug)]
-#[foobar]
-#[derive(Copy, Clone)]
-pub enum Bar {}
-}
-
-mod foobar {
-#[derive(Eq, PartialEq)]
-#[derive(Debug)]
-#[derive(Copy, Clone)]
-pub enum FooBar {}
-}
+++ /dev/null
-// rustfmt-normalize_comments: false
-// Normalize comments
-
-// Lorem ipsum:
-fn dolor() -> usize {}
-
-/* sit amet: */
-fn adipiscing() -> usize {}
-
-// #652
-////////////////////////////////////////////////////////////////////////////////
-// Basic slice extension methods
-////////////////////////////////////////////////////////////////////////////////
+++ /dev/null
-// rustfmt-normalize_comments: true
-// Normalize comments
-
-// Lorem ipsum:
-fn dolor() -> usize {}
-
-/* sit amet: */
-fn adipiscing() -> usize {}
-
-// #652
-////////////////////////////////////////////////////////////////////////////////
-// Basic slice extension methods
-////////////////////////////////////////////////////////////////////////////////
+++ /dev/null
-// rustfmt-reorder_imported_names: false
-// Reorder imported names
-
-use super::{lorem, ipsum, dolor, sit};
+++ /dev/null
-// rustfmt-reorder_imported_names: true
-// Reorder imported names
-
-use super::{lorem, ipsum, dolor, sit};
+++ /dev/null
-// rustfmt-reorder_imports: false
-// Reorder imports
-
-use lorem;
-use ipsum;
-use dolor;
-use sit;
+++ /dev/null
-// rustfmt-reorder_imports: true
-// Reorder imports
-
-use lorem;
-use ipsum;
-use dolor;
-use sit;
-
-fn foo() {
- use C;
- use B;
- use A;
-
- bar();
-
- use F;
- use E;
- use D;
-}
+++ /dev/null
-// rustfmt-reorder_imports: true
-// rustfmt-reorder_imports_in_group: false
-// Reorder imports in group
-
-/// This comment should stay with `use std::mem;`
-use std::mem;
-use std::io;
-
-use lorem;
-/// This comment should stay with `use ipsum;`
-use ipsum;
-use dolor;
-use sit;
+++ /dev/null
-// rustfmt-reorder_imports: true
-// rustfmt-reorder_imports_in_group: true
-// Reorder imports in group
-
-/// This comment should stay with `use std::mem;`
-use std::mem;
-use std::io;
-
-use lorem;
-/// This comment should stay with `use ipsum;`
-use ipsum;
-use dolor;
-use sit;
+++ /dev/null
-// rustfmt-same_line_attributes: false
-// Option to place attributes on the same line as fields and variants where possible
-
-enum Lorem {
- #[ serde(skip_serializing) ]
- Ipsum,
- #[ serde(skip_serializing) ]
- Dolor,
- #[ serde(skip_serializing) ]
- Amet,
-}
-
-struct Lorem {
- #[ serde(rename = "Ipsum") ]
- ipsum: usize,
- #[ serde(rename = "Dolor") ]
- dolor: usize,
- #[ serde(rename = "Amet") ]
- amet: usize,
-}
-
-// #1943
-pub struct Bzip2 {
- # [ serde (rename = "level") ]
- level: i32 ,
-}
+++ /dev/null
-// rustfmt-same_line_attributes: true
-// Option to place attributes on the same line as fields and variants where possible
-
-enum Lorem {
- #[ serde(skip_serializing) ]
- Ipsum,
- #[ serde(skip_serializing) ]
- Dolor,
- #[ serde(skip_serializing) ]
- Amet,
-}
-
-struct Lorem {
- #[ serde(rename = "Ipsum") ]
- ipsum: usize,
- #[ serde(rename = "Dolor") ]
- dolor: usize,
- #[ serde(rename = "Amet") ]
- amet: usize,
-}
+++ /dev/null
-// rustfmt-space_before_colon: true
-// Space before colon
-
-fn lorem<T : Eq>(t : T) {
- let ipsum: Dolor = sit;
-}
-
-const LOREM : Lorem = Lorem {
- ipsum : dolor,
- sit : amet,
-};
+++ /dev/null
-// rustfmt-spaces_around_ranges: false
-// Spaces around ranges
-
-fn main() {
- let lorem = 0..10;
-}
+++ /dev/null
-// rustfmt-spaces_around_ranges: true
-// Spaces around ranges
-
-fn main() {
- let lorem = 0..10;
-}
+++ /dev/null
-// rustfmt-spaces_within_parens_and_brackets: false
-// Spaces within parens and brackets
-
-fn lorem<T: Eq>(t: T) {
- let lorem = (ipsum, dolor);
- let lorem: [usize; 2] = [ipsum, dolor];
-}
+++ /dev/null
-// rustfmt-spaces_within_parens_and_brackets: true
-// Spaces within parens and brackets
-
-fn lorem<T: Eq>(t: T) {
- let lorem = (ipsum, dolor);
- let lorem: [usize; 2] = [ipsum, dolor];
-}
-
-enum E {
- A(u32),
- B(u32, u32),
- C(u32, u32, u32),
- D(),
-}
-
-struct TupleStruct0();
-struct TupleStruct1(u32);
-struct TupleStruct2(u32, u32);
-
-fn fooEmpty() {}
-
-fn foo(e: E, _: u32) -> (u32, u32) {
- // Tuples
- let t1 = ();
- let t2 = (1,);
- let t3 = (1, 2);
-
- let ts0 = TupleStruct0();
- let ts1 = TupleStruct1(1);
- let ts2 = TupleStruct2(1, 2);
-
- // Tuple pattern
- let (a,b,c) = (1,2,3);
-
- // Expressions
- let x = (1 + 2) * (3);
-
- // Function call
- fooEmpty();
- foo(1, 2);
-
- // Pattern matching
- match e {
- A(_) => (),
- B(_, _) => (),
- C(..) => (),
- D => (),
- }
-
- (1,2)
-}
-
-struct Foo<T> {
- i: T,
-}
-
-struct Bar<T, E> {
- i: T,
- e: E,
-}
-
-struct Foo<'a> {
- i: &'a str,
-}
-
-enum E<T> {
- T(T),
-}
-
-enum E<T, S> {
- T(T),
- S(S),
-}
-
-fn foo<T>(a: T) {
- foo::<u32>(10);
-}
-
-fn foo<T, E>(a: T, b: E) {
- foo::<u32, str>(10, "bar");
-}
-
-fn foo<T: Send, E: Send>(a: T, b: E) {
- foo::<u32, str>(10, "bar");
-
- let opt: Option<u32>;
- let res: Result<u32, String>;
-}
-
-fn foo<'a>(a: &'a str) {
- foo("foo");
-}
-
-fn foo<'a, 'b>(a: &'a str, b: &'b str) {
- foo("foo", "bar");
-}
-
-impl Foo {
- fn bar() {
- <Foo as Foo>::bar();
- }
-}
-
-trait MyTrait<A, D> {}
-impl<A: Send, D: Send> MyTrait<A, D> for Foo {}
-
-fn foo() where for<'a> u32: 'a {}
-
-fn main() {
- let arr: [i32; 5] = [1, 2, 3, 4, 5];
- let arr: [i32; 500] = [0; 500];
-
- let v = vec![1, 2, 3];
- assert_eq!(arr, [1, 2, 3]);
-
- let i = arr[0];
-
- let slice = &arr[1..2];
-
- let line100_________________________________________________________________________ = [1, 2];
- let line101__________________________________________________________________________ = [1, 2];
- let line102___________________________________________________________________________ = [1, 2];
- let line103____________________________________________________________________________ = [1, 2];
- let line104_____________________________________________________________________________ = [1, 2];
-
- let line100_____________________________________________________________________ = vec![1, 2];
- let line101______________________________________________________________________ = vec![1, 2];
- let line102_______________________________________________________________________ = vec![1, 2];
- let line103________________________________________________________________________ = vec![1, 2];
- let line104_________________________________________________________________________ = vec![1, 2];
-}
-
-fn f(slice: &[i32]) {}
+++ /dev/null
-// rustfmt-struct_field_align_threshold: 20
-// rustfmt-normalize_comments: true
-// rustfmt-wrap_comments: true
-// rustfmt-error_on_line_overflow: false
-
-struct Foo {
- x: u32,
- yy: u32, // comment
- zzz: u32,
-}
-
-pub struct Bar {
- x: u32,
- yy: u32,
- zzz: u32,
-
- xxxxxxx: u32,
-}
-
-fn main() {
- let foo = Foo {
- x: 0,
- yy: 1,
- zzz: 2,
- };
-
- let bar = Bar {
- x: 0,
- yy: 1,
- zzz: 2,
-
- xxxxxxx: 3,
- };
-}
-
- /// A Doc comment
-#[AnAttribute]
-pub struct Foo {
- #[rustfmt_skip]
- f : SomeType, // Comment beside a field
- f: SomeType, // Comment beside a field
- // Comment on a field
- #[AnAttribute]
- g: SomeOtherType,
- /// A doc comment on a field
- h: AThirdType,
- pub i: TypeForPublicField
-}
-
-// #1029
-pub struct Foo {
- #[doc(hidden)]
- // This will NOT get deleted!
- bar: String, // hi
-}
-
-// #1029
-struct X {
- // `x` is an important number.
- #[allow(unused)] // TODO: use
- x: u32,
-}
-
-// #410
-#[allow(missing_docs)]
-pub struct Writebatch<K: Key> {
- #[allow(dead_code)] //only used for holding the internal pointer
- writebatch: RawWritebatch,
- marker: PhantomData<K>,
-}
-
-struct Bar;
-
-struct NewType(Type, OtherType);
-
-struct
-NewInt <T: Copy>(pub i32, SomeType /* inline comment */, T /* sup */
-
-
- );
-
-struct Qux<'a,
- N: Clone + 'a,
- E: Clone + 'a,
- G: Labeller<'a, N, E> + GraphWalk<'a, N, E>,
- W: Write + Copy>
-(
- AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA, // Comment
- BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB,
- #[AnAttr]
- // Comment
- /// Testdoc
- G,
- pub W,
-);
-
-struct Tuple(/*Comment 1*/ AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA,
- /* Comment 2 */ BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB,);
-
-// With a where clause and generics.
-pub struct Foo<'a, Y: Baz>
- where X: Whatever
-{
- f: SomeType, // Comment beside a field
-}
-
-struct Baz {
-
- a: A, // Comment A
- b: B, // Comment B
- c: C, // Comment C
-
-}
-
-struct Baz {
- a: A, // Comment A
-
- b: B, // Comment B
-
-
-
-
- c: C, // Comment C
-}
-
-struct Baz {
-
- a: A,
-
- b: B,
- c: C,
-
-
-
-
- d: D
-
-}
-
-struct Baz
-{
- // Comment A
- a: A,
-
- // Comment B
-b: B,
- // Comment C
- c: C,}
-
-// Will this be a one-liner?
-struct Tuple(
- A, //Comment
- B
-);
-
-pub struct State<F: FnMut() -> time::Timespec> { now: F }
-
-pub struct State<F: FnMut() -> ()> { now: F }
-
-pub struct State<F: FnMut()> { now: F }
-
-struct Palette { /// A map of indices in the palette to a count of pixels in approximately that color
- foo: i32}
-
-// Splitting a single line comment into a block previously had a misalignment
-// when the field had attributes
-struct FieldsWithAttributes {
- // Pre Comment
- #[rustfmt_skip] pub host:String, // Post comment BBBBBBBBBBBBBB BBBBBBBBBBBBBBBB BBBBBBBBBBBBBBBB BBBBBBBBBBBBBBBBB BBBBBBBBBBB
- //Another pre comment
- #[attr1]
- #[attr2] pub id: usize // CCCCCCCCCCCCCCCCCCC CCCCCCCCCCCCCCCCCCC CCCCCCCCCCCCCCCC CCCCCCCCCCCCCCCCCC CCCCCCCCCCCCCC CCCCCCCCCCCC
-}
-
-struct Deep {
- deeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeep: node::Handle<IdRef<'id, Node<K, V>>,
- Type,
- NodeType>,
-}
-
-struct Foo<T>(T);
-struct Foo<T>(T) where T: Copy, T: Eq;
-struct Foo<T>(TTTTTTTTTTTTTTTTT, UUUUUUUUUUUUUUUUUUUUUUUU, TTTTTTTTTTTTTTTTTTT, UUUUUUUUUUUUUUUUUUU);
-struct Foo<T>(TTTTTTTTTTTTTTTTTT, UUUUUUUUUUUUUUUUUUUUUUUU, TTTTTTTTTTTTTTTTTTT) where T: PartialEq;
-struct Foo<T>(TTTTTTTTTTTTTTTTT, UUUUUUUUUUUUUUUUUUUUUUUU, TTTTTTTTTTTTTTTTTTTTT) where T: PartialEq;
-struct Foo<T>(TTTTTTTTTTTTTTTTT, UUUUUUUUUUUUUUUUUUUUUUUU, TTTTTTTTTTTTTTTTTTT, UUUUUUUUUUUUUUUUUUU) where T: PartialEq;
-struct Foo<T>(TTTTTTTTTTTTTTTTT, // Foo
- UUUUUUUUUUUUUUUUUUUUUUUU /* Bar */,
- // Baz
- TTTTTTTTTTTTTTTTTTT,
- // Qux (FIXME #572 - doc comment)
- UUUUUUUUUUUUUUUUUUU);
-
-mod m {
- struct X<T> where T: Sized {
- a: T,
- }
-}
-
-struct Foo<T>(TTTTTTTTTTTTTTTTTTT,
- /// Qux
- UUUUUUUUUUUUUUUUUUU);
-
-struct Issue677 {
- pub ptr: *const libc::c_void,
- pub trace: fn( obj:
- *const libc::c_void, tracer : *mut JSTracer ),
-}
-
-struct Foo {}
-struct Foo {
- }
-struct Foo {
- // comment
- }
-struct Foo {
- // trailing space ->
-
-
- }
-struct Foo { /* comment */ }
-struct Foo( /* comment */ );
-
-struct LongStruct {
- a: A,
- the_quick_brown_fox_jumps_over_the_lazy_dog:AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA,
-}
-
-struct Deep {
- deeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeep: node::Handle<IdRef<'id, Node<Key, Value>>,
- Type,
- NodeType>,
-}
-
-struct Foo<C=()>(String);
-
-// #1364
-fn foo() {
- convex_shape.set_point(0, &Vector2f { x: 400.0, y: 100.0 });
- convex_shape.set_point(1, &Vector2f { x: 500.0, y: 70.0 });
- convex_shape.set_point(2, &Vector2f { x: 450.0, y: 100.0 });
- convex_shape.set_point(3, &Vector2f { x: 580.0, y: 150.0 });
-}
-
-fn main() {
- let x = Bar;
-
- // Comment
- let y = Foo {a: x };
-
- Foo { a: foo() /* comment*/, /* comment*/ b: bar(), ..something };
-
- Fooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo { a: f(), b: b(), };
-
- Foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo { a: f(), b: b(), };
-
- Foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo {
- // Comment
- a: foo(), // Comment
- // Comment
- b: bar(), // Comment
- };
-
- Foo { a:Bar,
- b:f() };
-
- Quux { x: if cond { bar(); }, y: baz() };
-
- A {
- // Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec a diam lectus. Sed sit amet ipsum mauris. Maecenas congue ligula ac quam viverra nec consectetur ante hendrerit. Donec et mollis dolor.
- first: item(),
- // Praesent et diam eget libero egestas mattis sit amet vitae augue.
- // Nam tincidunt congue enim, ut porta lorem lacinia consectetur.
- second: Item
- };
-
- Some(Data::MethodCallData(MethodCallData {
- span: sub_span.unwrap(),
- scope: self.enclosing_scope(id),
- ref_id: def_id,
- decl_id: Some(decl_id),
- }));
-
- Diagram { /* o This graph demonstrates how
- * / \ significant whitespace is
- * o o preserved.
- * /|\ \
- * o o o o */
- graph: G, }
-}
-
-fn matcher() {
- TagTerminatedByteMatcher {
- matcher: ByteMatcher {
- pattern: b"<HTML",
- mask: b"\xFF\xDF\xDF\xDF\xDF\xFF",
- },
- };
-}
-
-fn issue177() {
- struct Foo<T> { memb: T }
- let foo = Foo::<i64> { memb: 10 };
-}
-
-fn issue201() {
- let s = S{a:0, .. b};
-}
-
-fn issue201_2() {
- let s = S{a: S2{ .. c}, .. b};
-}
-
-fn issue278() {
- let s = S {
- a: 0,
- //
- b: 0,
- };
- let s1 = S {
- a: 0,
- // foo
- //
- // bar
- b: 0,
- };
-}
-
-fn struct_exprs() {
- Foo
- { a : 1, b:f( 2)};
- Foo{a:1,b:f(2),..g(3)};
- LoooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooongStruct { ..base };
- IntrinsicISizesContribution { content_intrinsic_sizes: IntrinsicISizes { minimum_inline_size: 0, }, };
-}
-
-fn issue123() {
- Foo { a: b, c: d, e: f };
-
- Foo { a: bb, c: dd, e: ff };
-
- Foo { a: ddddddddddddddddddddd, b: cccccccccccccccccccccccccccccccccccccc };
-}
-
-fn issue491() {
- Foo {
- guard: None,
- arm: 0, // Comment
- };
-
- Foo {
- arm: 0, // Comment
- };
-
- Foo { a: aaaaaaaaaa, b: bbbbbbbb, c: cccccccccc, d: dddddddddd, /* a comment */
- e: eeeeeeeee };
-}
-
-fn issue698() {
- Record {
- ffffffffffffffffffffffffffields: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
- };
- Record {
- ffffffffffffffffffffffffffields: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
- }
-}
-
-fn issue835() {
- MyStruct {};
- MyStruct { /* a comment */ };
- MyStruct {
- // Another comment
- };
- MyStruct {}
-}
-
-fn field_init_shorthand() {
- MyStruct { x, y, z };
- MyStruct { x, y, z, .. base };
- Foo { aaaaaaaaaa, bbbbbbbb, cccccccccc, dddddddddd, /* a comment */
- eeeeeeeee };
- Record { ffffffffffffffffffffffffffieldsaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa };
-}
+++ /dev/null
-// rustfmt-indent_style: Block
-// Struct literal-style
-
-fn main() {
- let lorem = Lorem { ipsum: dolor, sit: amet };
-}
+++ /dev/null
-// rustfmt-indent_style: Visual
-// Struct literal-style
-
-fn main() {
- let lorem = Lorem { ipsum: dolor, sit: amet };
-}
+++ /dev/null
-// rustfmt-struct_lit_single_line: false
-// Struct literal multiline-style
-
-fn main() {
- let lorem = Lorem { ipsum: dolor, sit: amet };
-}
+++ /dev/null
-// rustfmt-tab_spaces: 2
-// rustfmt-max_width: 30
-// rustfmt-indent_style: Block
-// Tab spaces
-
-fn lorem() {
-let ipsum = dolor();
-let sit = vec![
-"amet", "consectetur", "adipiscing", "elit."
-];
-}
+++ /dev/null
-// rustfmt-tab_spaces: 4
-// rustfmt-max_width: 30
-// rustfmt-indent_style: Block
-// Tab spaces
-
-fn lorem() {
-let ipsum = dolor();
-let sit = vec![
-"amet", "consectetur", "adipiscing", "elit."
-];
-}
+++ /dev/null
-// rustfmt-trailing_comma: Always
-// Trailing comma
-
-fn main() {
- let Lorem { ipsum, dolor, sit, } = amet;
- let Lorem { ipsum, dolor, sit, amet, consectetur, adipiscing } = elit;
-}
+++ /dev/null
-// rustfmt-trailing_comma: Never
-// Trailing comma
-
-fn main() {
- let Lorem { ipsum, dolor, sit, } = amet;
- let Lorem { ipsum, dolor, sit, amet, consectetur, adipiscing } = elit;
-
- // #1544
- if let VrMsg::ClientReply {request_num: reply_req_num, value, ..} = msg {
- let _ = safe_assert_eq!(reply_req_num, request_num, op);
- return Ok((request_num, op, value));
- }
-
- // #1710
- pub struct FileInput {
- input: StringInput,
- file_name: OsString,
- }
- match len {
- Some(len) => Ok(new(self.input, self.pos + len)),
- None => Err(self),
- }
-}
+++ /dev/null
-// rustfmt-trailing_comma: Vertical
-// Trailing comma
-
-fn main() {
- let Lorem { ipsum, dolor, sit, } = amet;
- let Lorem { ipsum, dolor, sit, amet, consectetur, adipiscing } = elit;
-}
+++ /dev/null
-// rustfmt-type_punctuation_density: Compressed
-// Type punctuation density
-
-fn lorem<Ipsum:Dolor+Sit=Amet>() {
- // body
-}
+++ /dev/null
-// rustfmt-type_punctuation_density: Wide
-// Type punctuation density
-
-fn lorem<Ipsum:Dolor+Sit=Amet>() {
- // body
-}
+++ /dev/null
-// rustfmt-use_try_shorthand: false
-// Use try! shorthand
-
-fn main() {
- let lorem = try!(ipsum.map(|dolor| dolor.sit()));
-}
+++ /dev/null
-// rustfmt-use_try_shorthand: true
-// Use try! shorthand
-
-fn main() {
- let lorem = try!(ipsum.map(|dolor| dolor.sit()));
-}
+++ /dev/null
-// rustfmt-indent_style: Block
-// Where predicate indent
-
-fn lorem<Ipsum, Dolor, Sit, Amet>() -> T where Ipsum: Eq, Dolor: Eq, Sit: Eq, Amet: Eq {
- // body
-}
+++ /dev/null
-// rustfmt-indent_style: Visual
-// Where predicate indent
-
-fn lorem<Ipsum, Dolor, Sit, Amet>() -> T where Ipsum: Eq, Dolor: Eq, Sit: Eq, Amet: Eq {
- // body
-}
+++ /dev/null
-// rustfmt-where_single_line: true
-// Where style
-
-
-fn lorem_two_items<Ipsum, Dolor, Sit, Amet>() -> T where Ipsum: Eq, Lorem: Eq {
- // body
-}
-
-fn lorem_multi_line<Ipsum, Dolor, Sit, Amet>(
- a: Aaaaaaaaaaaaaaa,
- b: Bbbbbbbbbbbbbbbb,
- c: Ccccccccccccccccc,
- d: Ddddddddddddddddddddddddd,
- e: Eeeeeeeeeeeeeeeeeee,
-) -> T
-where
- Ipsum: Eq,
-{
- // body
-}
-
-fn lorem<Ipsum, Dolor, Sit, Amet>() -> T where Ipsum: Eq {
- // body
-}
+++ /dev/null
-// rustfmt-indent_style: Visual
-// Where style
-
-fn lorem<Ipsum, Dolor, Sit, Amet>() -> T where Ipsum: Eq, Dolor: Eq, Sit: Eq, Amet: Eq {
- // body
-}
+++ /dev/null
-// rustfmt-indent_style: Block
-// Where style
-
-fn lorem<Ipsum, Dolor, Sit, Amet>() -> T where Ipsum: Eq, Dolor: Eq, Sit: Eq, Amet: Eq {
- // body
-}
+++ /dev/null
-// rustfmt-wrap_comments: false
-// rustfmt-max_width: 50
-// rustfmt-error_on_line_overflow: false
-// Wrap comments
-
-fn main() {
- // Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
-}
+++ /dev/null
-// rustfmt-wrap_comments: true
-// rustfmt-max_width: 50
-// Wrap comments
-
-fn main() {
- // Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
-}
-
-fn code_block() {
- // ```rust
- // let x = 3;
- //
- // println!("x = {}", x);
- // ```
-}
--- /dev/null
+// rustfmt-indent_style: Block
+// Array layout
+
+fn main() {
+ let lorem = vec!["ipsum","dolor","sit","amet","consectetur","adipiscing","elit"];
+}
--- /dev/null
+// rustfmt-indent_style: Visual
+// Array layout
+
+fn main() {
+ let lorem = vec!["ipsum","dolor","sit","amet","consectetur","adipiscing","elit"];
+}
--- /dev/null
+// rustfmt-blank_lines_lower_bound: 1
+
+fn foo() {}
+fn bar() {}
+// comment
+fn foobar() {}
+
+fn foo1() {}
+fn bar1() {}
+
+// comment
+
+fn foobar1() {}
--- /dev/null
+// rustfmt-indent_style: Block
+// Chain indent
+
+fn main() {
+ let lorem = ipsum.dolor().sit().amet().consectetur().adipiscing().elite();
+}
--- /dev/null
+// rustfmt-indent_style: Visual
+// Chain indent
+
+fn main() {
+ let lorem = ipsum.dolor().sit().amet().consectetur().adipiscing().elite();
+}
--- /dev/null
+// rustfmt-comment_width: 40
+// rustfmt-wrap_comments: true
+// Comment width
+
+fn main() {
+ // Lorem ipsum dolor sit amet, consectetur adipiscing elit.
+}
--- /dev/null
+// rustfmt-comment_width: 80
+// rustfmt-wrap_comments: true
+// Comment width
+
+fn main() {
+ // Lorem ipsum dolor sit amet, consectetur adipiscing elit.
+}
--- /dev/null
+// rustfmt-comment_width: 40
+// rustfmt-wrap_comments: false
+// Comment width
+
+fn main() {
+ // Lorem ipsum dolor sit amet, consectetur adipiscing elit.
+}
--- /dev/null
+// rustfmt-condense_wildcard_suffixes: false
+// Condense wildcard suffixes
+
+fn main() {
+ let (lorem, ipsum, _, _) = (1, 2, 3, 4);
+}
--- /dev/null
+// rustfmt-condense_wildcard_suffixes: true
+// Condense wildcard suffixes
+
+fn main() {
+ let (lorem, ipsum, _, _) = (1, 2, 3, 4);
+}
--- /dev/null
+// rustfmt-control_brace_style: AlwaysNextLine
+// Control brace style
+
+fn main() {
+ if lorem { println!("ipsum!"); } else { println!("dolor!"); }
+ match magi {
+ Homura => "Akemi",
+ Madoka => "Kaname",
+ }
+}
--- /dev/null
+// rustfmt-control_brace_style: AlwaysSameLine
+// Control brace style
+
+fn main() {
+ if lorem { println!("ipsum!"); } else { println!("dolor!"); }
+ match magi {
+ Homura => "Akemi",
+ Madoka => "Kaname",
+ }
+}
--- /dev/null
+// rustfmt-control_brace_style: ClosingNextLine
+// Control brace style
+
+fn main() {
+ if lorem { println!("ipsum!"); } else { println!("dolor!"); }
+ match magi {
+ Homura => "Akemi",
+ Madoka => "Kaname",
+ }
+}
--- /dev/null
+// rustfmt-disable_all_formatting: false
+// Disable all formatting
+
+fn main() {
+ if lorem{println!("ipsum!");}else{println!("dolor!");}
+}
--- /dev/null
+// rustfmt-disable_all_formatting: true
+// Disable all formatting
+
+fn main() {
+ iflorem{println!("ipsum!");}else{println!("dolor!");}
+}
--- /dev/null
+// rustfmt-empty_item_single_line: false
+// Empty impl on single line
+
+impl Lorem {
+
+}
+
+impl Ipsum {
+
+}
+
+fn lorem() {
+}
+
+fn lorem() {
+
+}
--- /dev/null
+// rustfmt-empty_item_single_line: true
+// Empty impl on single line
+
+impl Lorem {
+
+}
+
+impl Ipsum {
+
+}
+
+fn lorem() {
+}
+
+fn lorem() {
+
+}
--- /dev/null
+// rustfmt-error_on_line_overflow: false
+// Error on line overflow
+
+fn main() {
+ let lorem_ipsum_dolor_sit_amet_consectetur_adipiscing_elit_lorem_ipsum_dolor_sit_amet_consectetur_adipiscing_elit;
+}
--- /dev/null
+// rustfmt-fn_args_density: Compressed
+// Function arguments density
+
+trait Lorem {
+ fn lorem(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet);
+
+ fn lorem(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet) {
+ // body
+ }
+
+ fn lorem(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet, consectetur: onsectetur, adipiscing: Adipiscing, elit: Elit);
+
+ fn lorem(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet, consectetur: onsectetur, adipiscing: Adipiscing, elit: Elit) {
+ // body
+ }
+}
--- /dev/null
+// rustfmt-fn_args_density: Tall
+// Function arguments density
+
+trait Lorem {
+ fn lorem(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet);
+
+ fn lorem(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet) {
+ // body
+ }
+
+ fn lorem(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet, consectetur: onsectetur, adipiscing: Adipiscing, elit: Elit);
+
+ fn lorem(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet, consectetur: onsectetur, adipiscing: Adipiscing, elit: Elit) {
+ // body
+ }
+}
--- /dev/null
+// rustfmt-fn_args_density: Vertical
+// Function arguments density
+
+trait Lorem {
+ fn lorem(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet);
+
+ fn lorem(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet) {
+ // body
+ }
+
+ fn lorem(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet, consectetur: onsectetur, adipiscing: Adipiscing, elit: Elit);
+
+ fn lorem(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet, consectetur: onsectetur, adipiscing: Adipiscing, elit: Elit) {
+ // body
+ }
+}
--- /dev/null
+// 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) {
+}
--- /dev/null
+// 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;
+}
--- /dev/null
+// rustfmt-brace_style: AlwaysNextLine
+// Function brace style
+
+fn lorem() {
+ // body
+}
+
+fn lorem(ipsum: usize) {
+ // body
+}
+
+fn lorem<T>(ipsum: T) where T: Add + Sub + Mul + Div {
+ // body
+}
--- /dev/null
+// rustfmt-brace_style: PreferSameLine
+// Function brace style
+
+fn lorem() {
+ // body
+}
+
+fn lorem(ipsum: usize) {
+ // body
+}
+
+fn lorem<T>(ipsum: T) where T: Add + Sub + Mul + Div {
+ // body
+}
--- /dev/null
+// rustfmt-brace_style: SameLineWhere
+// Function brace style
+
+fn lorem() {
+ // body
+}
+
+fn lorem(ipsum: usize) {
+ // body
+}
+
+fn lorem<T>(ipsum: T) where T: Add + Sub + Mul + Div {
+ // body
+}
--- /dev/null
+// 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());
+ }
+}
--- /dev/null
+// 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());
+}
--- /dev/null
+// rustfmt-indent_style: Visual
+// Function call style
+
+fn main() {
+ lorem("lorem", "ipsum", "dolor", "sit", "amet", "consectetur", "adipiscing", "elit");
+}
--- /dev/null
+// 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:");
+}
--- /dev/null
+// rustfmt-fn_single_line: false
+// Single-expression function on single line
+
+fn lorem() -> usize {
+ 42
+}
+
+fn lorem() -> usize {
+ let ipsum = 42;
+ ipsum
+}
--- /dev/null
+// rustfmt-fn_single_line: true
+// Single-expression function on single line
+
+fn lorem() -> usize {
+ 42
+}
+
+fn lorem() -> usize {
+ let ipsum = 42;
+ ipsum
+}
--- /dev/null
+// rustfmt-force_explicit_abi: false
+// Force explicit abi
+
+extern {
+ pub static lorem: c_int;
+}
--- /dev/null
+// rustfmt-force_explicit_abi: true
+// Force explicit abi
+
+extern {
+ pub static lorem: c_int;
+}
--- /dev/null
+// rustfmt-force_multiline_blocks: false
+// Option forces multiline match arm and closure bodies to be wrapped in a block
+
+fn main() {
+ match lorem {
+ Lorem::Ipsum => {
+ if ipsum {
+ println!("dolor");
+ }
+ }
+ Lorem::Dolor => println!("amet"),
+ }
+}
+
+fn main() {
+ result.and_then(|maybe_value| {
+ match maybe_value {
+ None => Err("oops"),
+ Some(value) => Ok(1),
+ }
+ });
+}
--- /dev/null
+// rustfmt-force_multiline_blocks: true
+// Option forces multiline match arm and closure bodies to be wrapped in a block
+
+fn main() {
+ match lorem {
+ Lorem::Ipsum => if ipsum {
+ println!("dolor");
+ },
+ Lorem::Dolor => println!("amet"),
+ }
+}
+
+fn main() {
+ result.and_then(|maybe_value| match maybe_value {
+ None => Err("oops"),
+ Some(value) => Ok(1),
+ });
+}
--- /dev/null
+// rustfmt-format_strings: false
+// rustfmt-max_width: 50
+// rustfmt-error_on_line_overflow: false
+// Force format strings
+
+fn main() {
+ let lorem = "ipsum dolor sit amet consectetur adipiscing elit lorem ipsum dolor sit";
+}
--- /dev/null
+// rustfmt-format_strings: true
+// rustfmt-max_width: 50
+// Force format strings
+
+fn main() {
+ let lorem = "ipsum dolor sit amet consectetur adipiscing elit lorem ipsum dolor sit";
+}
--- /dev/null
+// 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
+}
--- /dev/null
+// 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
+}
--- /dev/null
+// rustfmt-hard_tabs: false
+// Hard tabs
+
+fn lorem() -> usize {
+42 // spaces before 42
+}
--- /dev/null
+// rustfmt-hard_tabs: true
+// Hard tabs
+
+fn lorem() -> usize {
+42 // spaces before 42
+}
--- /dev/null
+// rustfmt-brace_style: AlwaysNextLine
+// Item brace style
+
+enum Foo {}
+
+struct Bar {}
+
+struct Lorem {
+ ipsum: bool,
+}
+
+struct Dolor<T> where T: Eq {
+ sit: T,
+}
+
+#[cfg(test)]
+mod tests {
+ #[test]
+ fn it_works() {}
+}
--- /dev/null
+// rustfmt-brace_style: PreferSameLine
+// Item brace style
+
+struct Lorem {
+ ipsum: bool,
+}
+
+struct Dolor<T> where T: Eq {
+ sit: T,
+}
+
+#[cfg(test)]
+mod tests {
+ #[test]
+ fn it_works() {}
+}
--- /dev/null
+// rustfmt-brace_style: SameLineWhere
+// Item brace style
+
+struct Lorem {
+ ipsum: bool,
+}
+
+struct Dolor<T> where T: Eq {
+ sit: T,
+}
+
+#[cfg(test)]
+mod tests {
+ #[test]
+ fn it_works() {}
+}
--- /dev/null
+// rustfmt-match_arm_blocks: false
+// Wrap match-arms
+
+fn main() {
+ match lorem {
+ true => foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo(x),
+ false => {
+ println!("{}", sit)
+ }
+ }
+}
--- /dev/null
+// rustfmt-match_arm_blocks: true
+// Wrap match-arms
+
+fn main() {
+ match lorem {
+ true => foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo(x),
+ false => {
+ println!("{}", sit)
+ }
+ }
+}
--- /dev/null
+// rustfmt-match_block_trailing_comma: false
+// Match block trailing comma
+
+fn main() {
+ match lorem {
+ Lorem::Ipsum => {
+ println!("ipsum");
+ }
+ Lorem::Dolor => println!("dolor"),
+ }
+}
--- /dev/null
+// rustfmt-match_block_trailing_comma: true
+// Match block trailing comma
+
+fn main() {
+ match lorem {
+ Lorem::Ipsum => {
+ println!("ipsum");
+ }
+ Lorem::Dolor => println!("dolor"),
+ }
+}
--- /dev/null
+// rustfmt-merge_derives: true
+// Merge multiple derives to a single one.
+
+#[bar]
+#[derive(Eq, PartialEq)]
+#[foo]
+#[derive(Debug)]
+#[foobar]
+#[derive(Copy, Clone)]
+pub enum Foo {}
+
+#[derive(Eq, PartialEq)]
+#[derive(Debug)]
+#[foobar]
+#[derive(Copy, Clone)]
+pub enum Bar {}
+
+#[derive(Eq, PartialEq)]
+#[derive(Debug)]
+#[derive(Copy, Clone)]
+pub enum FooBar {}
+
+mod foo {
+#[bar]
+#[derive(Eq, PartialEq)]
+#[foo]
+#[derive(Debug)]
+#[foobar]
+#[derive(Copy, Clone)]
+pub enum Foo {}
+}
+
+mod bar {
+#[derive(Eq, PartialEq)]
+#[derive(Debug)]
+#[foobar]
+#[derive(Copy, Clone)]
+pub enum Bar {}
+}
+
+mod foobar {
+#[derive(Eq, PartialEq)]
+#[derive(Debug)]
+#[derive(Copy, Clone)]
+pub enum FooBar {}
+}
--- /dev/null
+// rustfmt-normalize_comments: false
+// Normalize comments
+
+// Lorem ipsum:
+fn dolor() -> usize {}
+
+/* sit amet: */
+fn adipiscing() -> usize {}
+
+// #652
+////////////////////////////////////////////////////////////////////////////////
+// Basic slice extension methods
+////////////////////////////////////////////////////////////////////////////////
--- /dev/null
+// rustfmt-normalize_comments: true
+// Normalize comments
+
+// Lorem ipsum:
+fn dolor() -> usize {}
+
+/* sit amet: */
+fn adipiscing() -> usize {}
+
+// #652
+////////////////////////////////////////////////////////////////////////////////
+// Basic slice extension methods
+////////////////////////////////////////////////////////////////////////////////
--- /dev/null
+// rustfmt-reorder_imported_names: false
+// Reorder imported names
+
+use super::{lorem, ipsum, dolor, sit};
--- /dev/null
+// rustfmt-reorder_imported_names: true
+// Reorder imported names
+
+use super::{lorem, ipsum, dolor, sit};
--- /dev/null
+// rustfmt-reorder_imports: false
+// Reorder imports
+
+use lorem;
+use ipsum;
+use dolor;
+use sit;
--- /dev/null
+// rustfmt-reorder_imports: true
+// Reorder imports
+
+use lorem;
+use ipsum;
+use dolor;
+use sit;
+
+fn foo() {
+ use C;
+ use B;
+ use A;
+
+ bar();
+
+ use F;
+ use E;
+ use D;
+}
--- /dev/null
+// rustfmt-reorder_imports: true
+// rustfmt-reorder_imports_in_group: false
+// Reorder imports in group
+
+/// This comment should stay with `use std::mem;`
+use std::mem;
+use std::io;
+
+use lorem;
+/// This comment should stay with `use ipsum;`
+use ipsum;
+use dolor;
+use sit;
--- /dev/null
+// rustfmt-reorder_imports: true
+// rustfmt-reorder_imports_in_group: true
+// Reorder imports in group
+
+/// This comment should stay with `use std::mem;`
+use std::mem;
+use std::io;
+
+use lorem;
+/// This comment should stay with `use ipsum;`
+use ipsum;
+use dolor;
+use sit;
--- /dev/null
+// rustfmt-same_line_attributes: false
+// Option to place attributes on the same line as fields and variants where possible
+
+enum Lorem {
+ #[ serde(skip_serializing) ]
+ Ipsum,
+ #[ serde(skip_serializing) ]
+ Dolor,
+ #[ serde(skip_serializing) ]
+ Amet,
+}
+
+struct Lorem {
+ #[ serde(rename = "Ipsum") ]
+ ipsum: usize,
+ #[ serde(rename = "Dolor") ]
+ dolor: usize,
+ #[ serde(rename = "Amet") ]
+ amet: usize,
+}
+
+// #1943
+pub struct Bzip2 {
+ # [ serde (rename = "level") ]
+ level: i32 ,
+}
--- /dev/null
+// rustfmt-same_line_attributes: true
+// Option to place attributes on the same line as fields and variants where possible
+
+enum Lorem {
+ #[ serde(skip_serializing) ]
+ Ipsum,
+ #[ serde(skip_serializing) ]
+ Dolor,
+ #[ serde(skip_serializing) ]
+ Amet,
+}
+
+struct Lorem {
+ #[ serde(rename = "Ipsum") ]
+ ipsum: usize,
+ #[ serde(rename = "Dolor") ]
+ dolor: usize,
+ #[ serde(rename = "Amet") ]
+ amet: usize,
+}
--- /dev/null
+// rustfmt-space_before_colon: true
+// Space before colon
+
+fn lorem<T : Eq>(t : T) {
+ let ipsum: Dolor = sit;
+}
+
+const LOREM : Lorem = Lorem {
+ ipsum : dolor,
+ sit : amet,
+};
--- /dev/null
+// rustfmt-spaces_around_ranges: false
+// Spaces around ranges
+
+fn main() {
+ let lorem = 0..10;
+}
--- /dev/null
+// rustfmt-spaces_around_ranges: true
+// Spaces around ranges
+
+fn main() {
+ let lorem = 0..10;
+}
--- /dev/null
+// rustfmt-spaces_within_parens_and_brackets: false
+// Spaces within parens and brackets
+
+fn lorem<T: Eq>(t: T) {
+ let lorem = (ipsum, dolor);
+ let lorem: [usize; 2] = [ipsum, dolor];
+}
--- /dev/null
+// rustfmt-spaces_within_parens_and_brackets: true
+// Spaces within parens and brackets
+
+fn lorem<T: Eq>(t: T) {
+ let lorem = (ipsum, dolor);
+ let lorem: [usize; 2] = [ipsum, dolor];
+}
+
+enum E {
+ A(u32),
+ B(u32, u32),
+ C(u32, u32, u32),
+ D(),
+}
+
+struct TupleStruct0();
+struct TupleStruct1(u32);
+struct TupleStruct2(u32, u32);
+
+fn fooEmpty() {}
+
+fn foo(e: E, _: u32) -> (u32, u32) {
+ // Tuples
+ let t1 = ();
+ let t2 = (1,);
+ let t3 = (1, 2);
+
+ let ts0 = TupleStruct0();
+ let ts1 = TupleStruct1(1);
+ let ts2 = TupleStruct2(1, 2);
+
+ // Tuple pattern
+ let (a,b,c) = (1,2,3);
+
+ // Expressions
+ let x = (1 + 2) * (3);
+
+ // Function call
+ fooEmpty();
+ foo(1, 2);
+
+ // Pattern matching
+ match e {
+ A(_) => (),
+ B(_, _) => (),
+ C(..) => (),
+ D => (),
+ }
+
+ (1,2)
+}
+
+struct Foo<T> {
+ i: T,
+}
+
+struct Bar<T, E> {
+ i: T,
+ e: E,
+}
+
+struct Foo<'a> {
+ i: &'a str,
+}
+
+enum E<T> {
+ T(T),
+}
+
+enum E<T, S> {
+ T(T),
+ S(S),
+}
+
+fn foo<T>(a: T) {
+ foo::<u32>(10);
+}
+
+fn foo<T, E>(a: T, b: E) {
+ foo::<u32, str>(10, "bar");
+}
+
+fn foo<T: Send, E: Send>(a: T, b: E) {
+ foo::<u32, str>(10, "bar");
+
+ let opt: Option<u32>;
+ let res: Result<u32, String>;
+}
+
+fn foo<'a>(a: &'a str) {
+ foo("foo");
+}
+
+fn foo<'a, 'b>(a: &'a str, b: &'b str) {
+ foo("foo", "bar");
+}
+
+impl Foo {
+ fn bar() {
+ <Foo as Foo>::bar();
+ }
+}
+
+trait MyTrait<A, D> {}
+impl<A: Send, D: Send> MyTrait<A, D> for Foo {}
+
+fn foo() where for<'a> u32: 'a {}
+
+fn main() {
+ let arr: [i32; 5] = [1, 2, 3, 4, 5];
+ let arr: [i32; 500] = [0; 500];
+
+ let v = vec![1, 2, 3];
+ assert_eq!(arr, [1, 2, 3]);
+
+ let i = arr[0];
+
+ let slice = &arr[1..2];
+
+ let line100_________________________________________________________________________ = [1, 2];
+ let line101__________________________________________________________________________ = [1, 2];
+ let line102___________________________________________________________________________ = [1, 2];
+ let line103____________________________________________________________________________ = [1, 2];
+ let line104_____________________________________________________________________________ = [1, 2];
+
+ let line100_____________________________________________________________________ = vec![1, 2];
+ let line101______________________________________________________________________ = vec![1, 2];
+ let line102_______________________________________________________________________ = vec![1, 2];
+ let line103________________________________________________________________________ = vec![1, 2];
+ let line104_________________________________________________________________________ = vec![1, 2];
+}
+
+fn f(slice: &[i32]) {}
--- /dev/null
+// rustfmt-struct_field_align_threshold: 20
+// rustfmt-normalize_comments: true
+// rustfmt-wrap_comments: true
+// rustfmt-error_on_line_overflow: false
+
+struct Foo {
+ x: u32,
+ yy: u32, // comment
+ zzz: u32,
+}
+
+pub struct Bar {
+ x: u32,
+ yy: u32,
+ zzz: u32,
+
+ xxxxxxx: u32,
+}
+
+fn main() {
+ let foo = Foo {
+ x: 0,
+ yy: 1,
+ zzz: 2,
+ };
+
+ let bar = Bar {
+ x: 0,
+ yy: 1,
+ zzz: 2,
+
+ xxxxxxx: 3,
+ };
+}
+
+ /// A Doc comment
+#[AnAttribute]
+pub struct Foo {
+ #[rustfmt_skip]
+ f : SomeType, // Comment beside a field
+ f: SomeType, // Comment beside a field
+ // Comment on a field
+ #[AnAttribute]
+ g: SomeOtherType,
+ /// A doc comment on a field
+ h: AThirdType,
+ pub i: TypeForPublicField
+}
+
+// #1029
+pub struct Foo {
+ #[doc(hidden)]
+ // This will NOT get deleted!
+ bar: String, // hi
+}
+
+// #1029
+struct X {
+ // `x` is an important number.
+ #[allow(unused)] // TODO: use
+ x: u32,
+}
+
+// #410
+#[allow(missing_docs)]
+pub struct Writebatch<K: Key> {
+ #[allow(dead_code)] //only used for holding the internal pointer
+ writebatch: RawWritebatch,
+ marker: PhantomData<K>,
+}
+
+struct Bar;
+
+struct NewType(Type, OtherType);
+
+struct
+NewInt <T: Copy>(pub i32, SomeType /* inline comment */, T /* sup */
+
+
+ );
+
+struct Qux<'a,
+ N: Clone + 'a,
+ E: Clone + 'a,
+ G: Labeller<'a, N, E> + GraphWalk<'a, N, E>,
+ W: Write + Copy>
+(
+ AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA, // Comment
+ BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB,
+ #[AnAttr]
+ // Comment
+ /// Testdoc
+ G,
+ pub W,
+);
+
+struct Tuple(/*Comment 1*/ AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA,
+ /* Comment 2 */ BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB,);
+
+// With a where clause and generics.
+pub struct Foo<'a, Y: Baz>
+ where X: Whatever
+{
+ f: SomeType, // Comment beside a field
+}
+
+struct Baz {
+
+ a: A, // Comment A
+ b: B, // Comment B
+ c: C, // Comment C
+
+}
+
+struct Baz {
+ a: A, // Comment A
+
+ b: B, // Comment B
+
+
+
+
+ c: C, // Comment C
+}
+
+struct Baz {
+
+ a: A,
+
+ b: B,
+ c: C,
+
+
+
+
+ d: D
+
+}
+
+struct Baz
+{
+ // Comment A
+ a: A,
+
+ // Comment B
+b: B,
+ // Comment C
+ c: C,}
+
+// Will this be a one-liner?
+struct Tuple(
+ A, //Comment
+ B
+);
+
+pub struct State<F: FnMut() -> time::Timespec> { now: F }
+
+pub struct State<F: FnMut() -> ()> { now: F }
+
+pub struct State<F: FnMut()> { now: F }
+
+struct Palette { /// A map of indices in the palette to a count of pixels in approximately that color
+ foo: i32}
+
+// Splitting a single line comment into a block previously had a misalignment
+// when the field had attributes
+struct FieldsWithAttributes {
+ // Pre Comment
+ #[rustfmt_skip] pub host:String, // Post comment BBBBBBBBBBBBBB BBBBBBBBBBBBBBBB BBBBBBBBBBBBBBBB BBBBBBBBBBBBBBBBB BBBBBBBBBBB
+ //Another pre comment
+ #[attr1]
+ #[attr2] pub id: usize // CCCCCCCCCCCCCCCCCCC CCCCCCCCCCCCCCCCCCC CCCCCCCCCCCCCCCC CCCCCCCCCCCCCCCCCC CCCCCCCCCCCCCC CCCCCCCCCCCC
+}
+
+struct Deep {
+ deeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeep: node::Handle<IdRef<'id, Node<K, V>>,
+ Type,
+ NodeType>,
+}
+
+struct Foo<T>(T);
+struct Foo<T>(T) where T: Copy, T: Eq;
+struct Foo<T>(TTTTTTTTTTTTTTTTT, UUUUUUUUUUUUUUUUUUUUUUUU, TTTTTTTTTTTTTTTTTTT, UUUUUUUUUUUUUUUUUUU);
+struct Foo<T>(TTTTTTTTTTTTTTTTTT, UUUUUUUUUUUUUUUUUUUUUUUU, TTTTTTTTTTTTTTTTTTT) where T: PartialEq;
+struct Foo<T>(TTTTTTTTTTTTTTTTT, UUUUUUUUUUUUUUUUUUUUUUUU, TTTTTTTTTTTTTTTTTTTTT) where T: PartialEq;
+struct Foo<T>(TTTTTTTTTTTTTTTTT, UUUUUUUUUUUUUUUUUUUUUUUU, TTTTTTTTTTTTTTTTTTT, UUUUUUUUUUUUUUUUUUU) where T: PartialEq;
+struct Foo<T>(TTTTTTTTTTTTTTTTT, // Foo
+ UUUUUUUUUUUUUUUUUUUUUUUU /* Bar */,
+ // Baz
+ TTTTTTTTTTTTTTTTTTT,
+ // Qux (FIXME #572 - doc comment)
+ UUUUUUUUUUUUUUUUUUU);
+
+mod m {
+ struct X<T> where T: Sized {
+ a: T,
+ }
+}
+
+struct Foo<T>(TTTTTTTTTTTTTTTTTTT,
+ /// Qux
+ UUUUUUUUUUUUUUUUUUU);
+
+struct Issue677 {
+ pub ptr: *const libc::c_void,
+ pub trace: fn( obj:
+ *const libc::c_void, tracer : *mut JSTracer ),
+}
+
+struct Foo {}
+struct Foo {
+ }
+struct Foo {
+ // comment
+ }
+struct Foo {
+ // trailing space ->
+
+
+ }
+struct Foo { /* comment */ }
+struct Foo( /* comment */ );
+
+struct LongStruct {
+ a: A,
+ the_quick_brown_fox_jumps_over_the_lazy_dog:AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA,
+}
+
+struct Deep {
+ deeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeep: node::Handle<IdRef<'id, Node<Key, Value>>,
+ Type,
+ NodeType>,
+}
+
+struct Foo<C=()>(String);
+
+// #1364
+fn foo() {
+ convex_shape.set_point(0, &Vector2f { x: 400.0, y: 100.0 });
+ convex_shape.set_point(1, &Vector2f { x: 500.0, y: 70.0 });
+ convex_shape.set_point(2, &Vector2f { x: 450.0, y: 100.0 });
+ convex_shape.set_point(3, &Vector2f { x: 580.0, y: 150.0 });
+}
+
+fn main() {
+ let x = Bar;
+
+ // Comment
+ let y = Foo {a: x };
+
+ Foo { a: foo() /* comment*/, /* comment*/ b: bar(), ..something };
+
+ Fooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo { a: f(), b: b(), };
+
+ Foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo { a: f(), b: b(), };
+
+ Foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo {
+ // Comment
+ a: foo(), // Comment
+ // Comment
+ b: bar(), // Comment
+ };
+
+ Foo { a:Bar,
+ b:f() };
+
+ Quux { x: if cond { bar(); }, y: baz() };
+
+ A {
+ // Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec a diam lectus. Sed sit amet ipsum mauris. Maecenas congue ligula ac quam viverra nec consectetur ante hendrerit. Donec et mollis dolor.
+ first: item(),
+ // Praesent et diam eget libero egestas mattis sit amet vitae augue.
+ // Nam tincidunt congue enim, ut porta lorem lacinia consectetur.
+ second: Item
+ };
+
+ Some(Data::MethodCallData(MethodCallData {
+ span: sub_span.unwrap(),
+ scope: self.enclosing_scope(id),
+ ref_id: def_id,
+ decl_id: Some(decl_id),
+ }));
+
+ Diagram { /* o This graph demonstrates how
+ * / \ significant whitespace is
+ * o o preserved.
+ * /|\ \
+ * o o o o */
+ graph: G, }
+}
+
+fn matcher() {
+ TagTerminatedByteMatcher {
+ matcher: ByteMatcher {
+ pattern: b"<HTML",
+ mask: b"\xFF\xDF\xDF\xDF\xDF\xFF",
+ },
+ };
+}
+
+fn issue177() {
+ struct Foo<T> { memb: T }
+ let foo = Foo::<i64> { memb: 10 };
+}
+
+fn issue201() {
+ let s = S{a:0, .. b};
+}
+
+fn issue201_2() {
+ let s = S{a: S2{ .. c}, .. b};
+}
+
+fn issue278() {
+ let s = S {
+ a: 0,
+ //
+ b: 0,
+ };
+ let s1 = S {
+ a: 0,
+ // foo
+ //
+ // bar
+ b: 0,
+ };
+}
+
+fn struct_exprs() {
+ Foo
+ { a : 1, b:f( 2)};
+ Foo{a:1,b:f(2),..g(3)};
+ LoooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooongStruct { ..base };
+ IntrinsicISizesContribution { content_intrinsic_sizes: IntrinsicISizes { minimum_inline_size: 0, }, };
+}
+
+fn issue123() {
+ Foo { a: b, c: d, e: f };
+
+ Foo { a: bb, c: dd, e: ff };
+
+ Foo { a: ddddddddddddddddddddd, b: cccccccccccccccccccccccccccccccccccccc };
+}
+
+fn issue491() {
+ Foo {
+ guard: None,
+ arm: 0, // Comment
+ };
+
+ Foo {
+ arm: 0, // Comment
+ };
+
+ Foo { a: aaaaaaaaaa, b: bbbbbbbb, c: cccccccccc, d: dddddddddd, /* a comment */
+ e: eeeeeeeee };
+}
+
+fn issue698() {
+ Record {
+ ffffffffffffffffffffffffffields: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
+ };
+ Record {
+ ffffffffffffffffffffffffffields: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
+ }
+}
+
+fn issue835() {
+ MyStruct {};
+ MyStruct { /* a comment */ };
+ MyStruct {
+ // Another comment
+ };
+ MyStruct {}
+}
+
+fn field_init_shorthand() {
+ MyStruct { x, y, z };
+ MyStruct { x, y, z, .. base };
+ Foo { aaaaaaaaaa, bbbbbbbb, cccccccccc, dddddddddd, /* a comment */
+ eeeeeeeee };
+ Record { ffffffffffffffffffffffffffieldsaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa };
+}
--- /dev/null
+// rustfmt-indent_style: Block
+// Struct literal-style
+
+fn main() {
+ let lorem = Lorem { ipsum: dolor, sit: amet };
+}
--- /dev/null
+// rustfmt-indent_style: Visual
+// Struct literal-style
+
+fn main() {
+ let lorem = Lorem { ipsum: dolor, sit: amet };
+}
--- /dev/null
+// rustfmt-struct_lit_single_line: false
+// Struct literal multiline-style
+
+fn main() {
+ let lorem = Lorem { ipsum: dolor, sit: amet };
+}
--- /dev/null
+// rustfmt-tab_spaces: 2
+// rustfmt-max_width: 30
+// rustfmt-indent_style: Block
+// Tab spaces
+
+fn lorem() {
+let ipsum = dolor();
+let sit = vec![
+"amet", "consectetur", "adipiscing", "elit."
+];
+}
--- /dev/null
+// rustfmt-tab_spaces: 4
+// rustfmt-max_width: 30
+// rustfmt-indent_style: Block
+// Tab spaces
+
+fn lorem() {
+let ipsum = dolor();
+let sit = vec![
+"amet", "consectetur", "adipiscing", "elit."
+];
+}
--- /dev/null
+// rustfmt-trailing_comma: Always
+// Trailing comma
+
+fn main() {
+ let Lorem { ipsum, dolor, sit, } = amet;
+ let Lorem { ipsum, dolor, sit, amet, consectetur, adipiscing } = elit;
+}
--- /dev/null
+// rustfmt-trailing_comma: Never
+// Trailing comma
+
+fn main() {
+ let Lorem { ipsum, dolor, sit, } = amet;
+ let Lorem { ipsum, dolor, sit, amet, consectetur, adipiscing } = elit;
+
+ // #1544
+ if let VrMsg::ClientReply {request_num: reply_req_num, value, ..} = msg {
+ let _ = safe_assert_eq!(reply_req_num, request_num, op);
+ return Ok((request_num, op, value));
+ }
+
+ // #1710
+ pub struct FileInput {
+ input: StringInput,
+ file_name: OsString,
+ }
+ match len {
+ Some(len) => Ok(new(self.input, self.pos + len)),
+ None => Err(self),
+ }
+}
--- /dev/null
+// rustfmt-trailing_comma: Vertical
+// Trailing comma
+
+fn main() {
+ let Lorem { ipsum, dolor, sit, } = amet;
+ let Lorem { ipsum, dolor, sit, amet, consectetur, adipiscing } = elit;
+}
--- /dev/null
+// rustfmt-type_punctuation_density: Compressed
+// Type punctuation density
+
+fn lorem<Ipsum:Dolor+Sit=Amet>() {
+ // body
+}
--- /dev/null
+// rustfmt-type_punctuation_density: Wide
+// Type punctuation density
+
+fn lorem<Ipsum:Dolor+Sit=Amet>() {
+ // body
+}
--- /dev/null
+// rustfmt-use_try_shorthand: false
+// Use try! shorthand
+
+fn main() {
+ let lorem = try!(ipsum.map(|dolor| dolor.sit()));
+}
--- /dev/null
+// rustfmt-use_try_shorthand: true
+// Use try! shorthand
+
+fn main() {
+ let lorem = try!(ipsum.map(|dolor| dolor.sit()));
+}
--- /dev/null
+// rustfmt-indent_style: Block
+// Where predicate indent
+
+fn lorem<Ipsum, Dolor, Sit, Amet>() -> T where Ipsum: Eq, Dolor: Eq, Sit: Eq, Amet: Eq {
+ // body
+}
--- /dev/null
+// rustfmt-indent_style: Visual
+// Where predicate indent
+
+fn lorem<Ipsum, Dolor, Sit, Amet>() -> T where Ipsum: Eq, Dolor: Eq, Sit: Eq, Amet: Eq {
+ // body
+}
--- /dev/null
+// rustfmt-where_single_line: true
+// Where style
+
+
+fn lorem_two_items<Ipsum, Dolor, Sit, Amet>() -> T where Ipsum: Eq, Lorem: Eq {
+ // body
+}
+
+fn lorem_multi_line<Ipsum, Dolor, Sit, Amet>(
+ a: Aaaaaaaaaaaaaaa,
+ b: Bbbbbbbbbbbbbbbb,
+ c: Ccccccccccccccccc,
+ d: Ddddddddddddddddddddddddd,
+ e: Eeeeeeeeeeeeeeeeeee,
+) -> T
+where
+ Ipsum: Eq,
+{
+ // body
+}
+
+fn lorem<Ipsum, Dolor, Sit, Amet>() -> T where Ipsum: Eq {
+ // body
+}
--- /dev/null
+// rustfmt-indent_style: Visual
+// Where style
+
+fn lorem<Ipsum, Dolor, Sit, Amet>() -> T where Ipsum: Eq, Dolor: Eq, Sit: Eq, Amet: Eq {
+ // body
+}
--- /dev/null
+// rustfmt-indent_style: Block
+// Where style
+
+fn lorem<Ipsum, Dolor, Sit, Amet>() -> T where Ipsum: Eq, Dolor: Eq, Sit: Eq, Amet: Eq {
+ // body
+}
--- /dev/null
+// rustfmt-wrap_comments: false
+// rustfmt-max_width: 50
+// rustfmt-error_on_line_overflow: false
+// Wrap comments
+
+fn main() {
+ // Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
+}
--- /dev/null
+// rustfmt-wrap_comments: true
+// rustfmt-max_width: 50
+// Wrap comments
+
+fn main() {
+ // Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
+}
+
+fn code_block() {
+ // ```rust
+ // let x = 3;
+ //
+ // println!("x = {}", x);
+ // ```
+}
+++ /dev/null
-// rustfmt-indent_style: Block
-// Array layout
-
-fn main() {
- let lorem = vec![
- "ipsum",
- "dolor",
- "sit",
- "amet",
- "consectetur",
- "adipiscing",
- "elit",
- ];
-}
+++ /dev/null
-// rustfmt-indent_style: Visual
-// Array layout
-
-fn main() {
- let lorem = vec!["ipsum",
- "dolor",
- "sit",
- "amet",
- "consectetur",
- "adipiscing",
- "elit"];
-}
+++ /dev/null
-// rustfmt-blank_lines_lower_bound: 1
-
-fn foo() {}
-
-fn bar() {}
-
-// comment
-fn foobar() {}
-
-fn foo1() {}
-
-fn bar1() {}
-
-// comment
-
-fn foobar1() {}
+++ /dev/null
-// rustfmt-indent_style: Block
-// Chain indent
-
-fn main() {
- let lorem = ipsum
- .dolor()
- .sit()
- .amet()
- .consectetur()
- .adipiscing()
- .elite();
-}
+++ /dev/null
-// rustfmt-indent_style: Visual
-// Chain indent
-
-fn main() {
- let lorem = ipsum.dolor()
- .sit()
- .amet()
- .consectetur()
- .adipiscing()
- .elite();
-}
+++ /dev/null
-// rustfmt-indent_style: Block
-// rustfmt-combine_control_expr: false
-// Combining openings and closings. See https://github.com/rust-lang-nursery/fmt-rfcs/issues/61.
-
-fn main() {
- // Call
- foo(bar(
- aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
- bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb,
- ));
-
- // Mac
- foo(foo!(
- aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
- bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb,
- ));
-
- // MethodCall
- foo(x.foo::<Bar, Baz>(
- aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
- bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb,
- ));
-
- // Block
- foo!({
- foo();
- bar();
- });
-
- // Closure
- foo(|x| {
- let y = x + 1;
- y
- });
-
- // Match
- foo(match opt {
- Some(x) => x,
- None => y,
- });
-
- // Struct
- foo(Bar {
- aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
- bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb,
- });
-
- // If
- foo!(
- if x {
- foo();
- } else {
- bar();
- }
- );
-
- // IfLet
- foo!(
- if let Some(..) = x {
- foo();
- } else {
- bar();
- }
- );
-
- // While
- foo!(
- while x {
- foo();
- bar();
- }
- );
-
- // WhileLet
- foo!(
- while let Some(..) = x {
- foo();
- bar();
- }
- );
-
- // ForLoop
- foo!(
- for x in y {
- foo();
- bar();
- }
- );
-
- // Loop
- foo!(
- loop {
- foo();
- bar();
- }
- );
-
- // Tuple
- foo((
- aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
- bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb,
- ));
-
- // AddrOf
- foo(&bar(
- aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
- bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb,
- ));
-
- // Box
- foo(box Bar {
- aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
- bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb,
- });
-
- // Unary
- foo(!bar(
- aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
- bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb,
- ));
-
- // Try
- foo(bar(
- aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
- bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb,
- )?);
-
- // Cast
- foo(Bar {
- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx,
- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx,
- } as i64);
-}
+++ /dev/null
-// rustfmt-indent_style: Block
-// rustfmt-combine_control_expr: true
-// Combining openings and closings. See https://github.com/rust-lang-nursery/fmt-rfcs/issues/61.
-
-fn main() {
- // Call
- foo(bar(
- aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
- bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb,
- ));
-
- // Mac
- foo(foo!(
- aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
- bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb,
- ));
-
- // MethodCall
- foo(x.foo::<Bar, Baz>(
- aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
- bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb,
- ));
-
- // Block
- foo!({
- foo();
- bar();
- });
-
- // Closure
- foo(|x| {
- let y = x + 1;
- y
- });
-
- // Match
- foo(match opt {
- Some(x) => x,
- None => y,
- });
-
- // Struct
- foo(Bar {
- aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
- bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb,
- });
-
- // If
- foo!(if x {
- foo();
- } else {
- bar();
- });
-
- // IfLet
- foo!(if let Some(..) = x {
- foo();
- } else {
- bar();
- });
-
- // While
- foo!(while x {
- foo();
- bar();
- });
-
- // WhileLet
- foo!(while let Some(..) = x {
- foo();
- bar();
- });
-
- // ForLoop
- foo!(for x in y {
- foo();
- bar();
- });
-
- // Loop
- foo!(loop {
- foo();
- bar();
- });
-
- // Tuple
- foo((
- aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
- bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb,
- ));
-
- // AddrOf
- foo(&bar(
- aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
- bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb,
- ));
-
- // Box
- foo(box Bar {
- aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
- bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb,
- });
-
- // Unary
- foo(!bar(
- aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
- bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb,
- ));
-
- // Try
- foo(bar(
- aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
- bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb,
- )?);
-
- // Cast
- foo(Bar {
- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx,
- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx,
- } as i64);
-}
+++ /dev/null
-// rustfmt-comment_width: 40
-// rustfmt-wrap_comments: true
-// Comment width
-
-fn main() {
- // Lorem ipsum dolor sit amet,
- // consectetur adipiscing elit.
-}
+++ /dev/null
-// rustfmt-comment_width: 80
-// rustfmt-wrap_comments: true
-// Comment width
-
-fn main() {
- // Lorem ipsum dolor sit amet, consectetur adipiscing elit.
-}
+++ /dev/null
-// rustfmt-comment_width: 40
-// rustfmt-wrap_comments: false
-// Comment width
-
-fn main() {
- // Lorem ipsum dolor sit amet, consectetur adipiscing elit.
-}
+++ /dev/null
-// rustfmt-condense_wildcard_suffixes: false
-// Condense wildcard suffixes
-
-fn main() {
- let (lorem, ipsum, _, _) = (1, 2, 3, 4);
-}
+++ /dev/null
-// rustfmt-condense_wildcard_suffixes: true
-// Condense wildcard suffixes
-
-fn main() {
- let (lorem, ipsum, ..) = (1, 2, 3, 4);
-}
+++ /dev/null
-// rustfmt-control_brace_style: AlwaysNextLine
-// Control brace style
-
-fn main() {
- if lorem
- {
- println!("ipsum!");
- }
- else
- {
- println!("dolor!");
- }
- match magi
- {
- Homura => "Akemi",
- Madoka => "Kaname",
- }
-}
+++ /dev/null
-// rustfmt-control_brace_style: AlwaysSameLine
-// Control brace style
-
-fn main() {
- if lorem {
- println!("ipsum!");
- } else {
- println!("dolor!");
- }
- match magi {
- Homura => "Akemi",
- Madoka => "Kaname",
- }
-}
+++ /dev/null
-// rustfmt-control_brace_style: ClosingNextLine
-// Control brace style
-
-fn main() {
- if lorem {
- println!("ipsum!");
- }
- else {
- println!("dolor!");
- }
- match magi {
- Homura => "Akemi",
- Madoka => "Kaname",
- }
-}
+++ /dev/null
-// 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;
- }
- _ => {}
- }
- }
- }
-}
+++ /dev/null
-// rustfmt-disable_all_formatting: false
-// Disable all formatting
-
-fn main() {
- if lorem {
- println!("ipsum!");
- } else {
- println!("dolor!");
- }
-}
+++ /dev/null
-// rustfmt-disable_all_formatting: true
-// Disable all formatting
-
-fn main() {
- if lorem{println!("ipsum!");}else{println!("dolor!");}
-}
+++ /dev/null
-// rustfmt-empty_item_single_line: false
-// Empty impl on single line
-
-impl Lorem {
-}
-
-impl Ipsum {
-}
-
-fn lorem() {
-}
-
-fn lorem() {
-
-}
+++ /dev/null
-// rustfmt-empty_item_single_line: true
-// Empty impl on single line
-
-impl Lorem {}
-
-impl Ipsum {}
-
-fn lorem() {}
-
-fn lorem() {}
+++ /dev/null
-// rustfmt-error_on_line_overflow: false
-// Error on line overflow
-
-fn main() {
- let lorem_ipsum_dolor_sit_amet_consectetur_adipiscing_elit_lorem_ipsum_dolor_sit_amet_consectetur_adipiscing_elit;
-}
+++ /dev/null
-// rustfmt-error_on_unformatted: false
-// Error on line overflow comment or string literals.
-
-// aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
-fn main() {
- // aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
-
- let x = " ";
- let a = "
-
-";
-}
+++ /dev/null
-// rustfmt-fn_args_density: Compressed
-// Function arguments density
-
-trait Lorem {
- fn lorem(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet);
-
- fn lorem(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet) {
- // body
- }
-
- fn lorem(
- ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet, consectetur: onsectetur,
- adipiscing: Adipiscing, elit: Elit,
- );
-
- fn lorem(
- ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet, consectetur: onsectetur,
- adipiscing: Adipiscing, elit: Elit,
- ) {
- // body
- }
-}
+++ /dev/null
-// rustfmt-fn_args_density: Tall
-// Function arguments density
-
-trait Lorem {
- fn lorem(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet);
-
- fn lorem(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet) {
- // body
- }
-
- fn lorem(
- ipsum: Ipsum,
- dolor: Dolor,
- sit: Sit,
- amet: Amet,
- consectetur: onsectetur,
- adipiscing: Adipiscing,
- elit: Elit,
- );
-
- fn lorem(
- ipsum: Ipsum,
- dolor: Dolor,
- sit: Sit,
- amet: Amet,
- consectetur: onsectetur,
- adipiscing: Adipiscing,
- elit: Elit,
- ) {
- // body
- }
-}
+++ /dev/null
-// rustfmt-fn_args_density: Vertical
-// Function arguments density
-
-trait Lorem {
- fn lorem(
- ipsum: Ipsum,
- dolor: Dolor,
- sit: Sit,
- amet: Amet,
- );
-
- fn lorem(
- ipsum: Ipsum,
- dolor: Dolor,
- sit: Sit,
- amet: Amet,
- ) {
- // body
- }
-
- fn lorem(
- ipsum: Ipsum,
- dolor: Dolor,
- sit: Sit,
- amet: Amet,
- consectetur: onsectetur,
- adipiscing: Adipiscing,
- elit: Elit,
- );
-
- fn lorem(
- ipsum: Ipsum,
- dolor: Dolor,
- sit: Sit,
- amet: Amet,
- consectetur: onsectetur,
- adipiscing: Adipiscing,
- elit: Elit,
- ) {
- // body
- }
-}
+++ /dev/null
-// 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,
-) {
-}
+++ /dev/null
-// 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;
-}
+++ /dev/null
-// rustfmt-brace_style: AlwaysNextLine
-// Function brace style
-
-fn lorem()
-{
- // body
-}
-
-fn lorem(ipsum: usize)
-{
- // body
-}
-
-fn lorem<T>(ipsum: T)
-where
- T: Add + Sub + Mul + Div,
-{
- // body
-}
+++ /dev/null
-// rustfmt-brace_style: PreferSameLine
-// Function brace style
-
-fn lorem() {
- // body
-}
-
-fn lorem(ipsum: usize) {
- // body
-}
-
-fn lorem<T>(ipsum: T)
-where
- T: Add + Sub + Mul + Div, {
- // body
-}
+++ /dev/null
-// rustfmt-brace_style: SameLineWhere
-// Function brace style
-
-fn lorem() {
- // body
-}
-
-fn lorem(ipsum: usize) {
- // body
-}
-
-fn lorem<T>(ipsum: T)
-where
- T: Add + Sub + Mul + Div,
-{
- // body
-}
+++ /dev/null
-// 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());
- }
-}
+++ /dev/null
-// rustfmt-indent_style: Block
-// rustfmt-max_width: 80
-// rustfmt-tab_spaces: 2
-
-// #1427
-fn main() {
- exceptaions::config(move || {
- (
- NmiConfig {},
- HardFaultConfig {},
- SysTickConfig { gpio_sbsrr },
- )
- });
-}
+++ /dev/null
-// 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(),
- );
-}
+++ /dev/null
-// rustfmt-indent_style: Visual
-// Function call style
-
-fn main() {
- lorem("lorem",
- "ipsum",
- "dolor",
- "sit",
- "amet",
- "consectetur",
- "adipiscing",
- "elit");
-}
+++ /dev/null
-// 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:");
-}
+++ /dev/null
-// rustfmt-fn_single_line: false
-// Single-expression function on single line
-
-fn lorem() -> usize {
- 42
-}
-
-fn lorem() -> usize {
- let ipsum = 42;
- ipsum
-}
+++ /dev/null
-// rustfmt-fn_single_line: true
-// Single-expression function on single line
-
-fn lorem() -> usize { 42 }
-
-fn lorem() -> usize {
- let ipsum = 42;
- ipsum
-}
+++ /dev/null
-// rustfmt-force_explicit_abi: false
-// Force explicit abi
-
-extern {
- pub static lorem: c_int;
-}
+++ /dev/null
-// rustfmt-force_explicit_abi: true
-// Force explicit abi
-
-extern "C" {
- pub static lorem: c_int;
-}
+++ /dev/null
-// rustfmt-force_multiline_blocks: false
-// Option forces multiline match arm and closure bodies to be wrapped in a block
-
-fn main() {
- match lorem {
- Lorem::Ipsum => {
- if ipsum {
- println!("dolor");
- }
- }
- Lorem::Dolor => println!("amet"),
- }
-}
-
-fn main() {
- result.and_then(|maybe_value| match maybe_value {
- None => Err("oops"),
- Some(value) => Ok(1),
- });
-}
+++ /dev/null
-// rustfmt-force_multiline_blocks: true
-// Option forces multiline match arm and closure bodies to be wrapped in a block
-
-fn main() {
- match lorem {
- Lorem::Ipsum => {
- if ipsum {
- println!("dolor");
- }
- }
- Lorem::Dolor => println!("amet"),
- }
-}
-
-fn main() {
- result.and_then(|maybe_value| {
- match maybe_value {
- None => Err("oops"),
- Some(value) => Ok(1),
- }
- });
-}
+++ /dev/null
-// rustfmt-format_strings: false
-// rustfmt-max_width: 50
-// rustfmt-error_on_line_overflow: false
-// Force format strings
-
-fn main() {
- let lorem = "ipsum dolor sit amet consectetur adipiscing elit lorem ipsum dolor sit";
-}
+++ /dev/null
-// rustfmt-format_strings: true
-// rustfmt-max_width: 50
-// Force format strings
-
-fn main() {
- let lorem = "ipsum dolor sit amet \
- consectetur adipiscing elit \
- lorem ipsum dolor sit";
-}
+++ /dev/null
-// 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
-}
+++ /dev/null
-// 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
-}
+++ /dev/null
-// rustfmt-hard_tabs: false
-// Hard tabs
-
-fn lorem() -> usize {
- 42 // spaces before 42
-}
+++ /dev/null
-// rustfmt-hard_tabs: true
-// Hard tabs
-
-fn lorem() -> usize {
- 42 // spaces before 42
-}
+++ /dev/null
-// rustfmt-imports_indent: Block
-
-use lists::{
- definitive_tactic, itemize_list, shape_for_tactic, struct_lit_formatting, struct_lit_shape,
- struct_lit_tactic, write_list, DefinitiveListTactic, ListFormatting, ListItem, ListTactic,
- SeparatorTactic,
-};
+++ /dev/null
-// rustfmt-imports_indent: Block
-// rustfmt-imports_layout: HorizontalVertical
-
-use comment::{contains_comment, recover_comment_removed, rewrite_comment, FindUncommented};
-use lists::{
- definitive_tactic,
- itemize_list,
- shape_for_tactic,
- struct_lit_formatting,
- struct_lit_shape,
- struct_lit_tactic,
- write_list,
- DefinitiveListTactic,
- ListFormatting,
- ListItem,
- ListTactic,
- SeparatorTactic,
-};
+++ /dev/null
-// rustfmt-imports_indent: Block
-// rustfmt-imports_layout: Mixed
-
-use comment::{contains_comment, recover_comment_removed, rewrite_comment, FindUncommented};
-use lists::{
- definitive_tactic, itemize_list, shape_for_tactic, struct_lit_formatting, struct_lit_shape,
- struct_lit_tactic, write_list, DefinitiveListTactic, ListFormatting, ListItem, ListTactic,
- SeparatorTactic,
-};
+++ /dev/null
-// rustfmt-brace_style: AlwaysNextLine
-// Item brace style
-
-enum Foo {}
-
-struct Bar {}
-
-struct Lorem
-{
- ipsum: bool,
-}
-
-struct Dolor<T>
-where
- T: Eq,
-{
- sit: T,
-}
-
-#[cfg(test)]
-mod tests
-{
- #[test]
- fn it_works()
- {
- }
-}
+++ /dev/null
-// rustfmt-brace_style: PreferSameLine
-// Item brace style
-
-struct Lorem {
- ipsum: bool,
-}
-
-struct Dolor<T>
-where
- T: Eq, {
- sit: T,
-}
-
-#[cfg(test)]
-mod tests {
- #[test]
- fn it_works() {}
-}
+++ /dev/null
-// rustfmt-brace_style: SameLineWhere
-// Item brace style
-
-struct Lorem {
- ipsum: bool,
-}
-
-struct Dolor<T>
-where
- T: Eq,
-{
- sit: T,
-}
-
-#[cfg(test)]
-mod tests {
- #[test]
- fn it_works() {}
-}
+++ /dev/null
-// rustfmt-match_arm_blocks: false
-// Wrap match-arms
-
-fn main() {
- match lorem {
- true =>
- foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo(x),
- false => println!("{}", sit),
- }
-}
+++ /dev/null
-// rustfmt-match_arm_blocks: true
-// Wrap match-arms
-
-fn main() {
- match lorem {
- true => {
- foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo(x)
- }
- false => println!("{}", sit),
- }
-}
+++ /dev/null
-// rustfmt-match_block_trailing_comma: false
-// Match block trailing comma
-
-fn main() {
- match lorem {
- Lorem::Ipsum => {
- println!("ipsum");
- }
- Lorem::Dolor => println!("dolor"),
- }
-}
+++ /dev/null
-// rustfmt-match_block_trailing_comma: true
-// Match block trailing comma
-
-fn main() {
- match lorem {
- Lorem::Ipsum => {
- println!("ipsum");
- },
- Lorem::Dolor => println!("dolor"),
- }
-}
+++ /dev/null
-// rustfmt-merge_derives: true
-// Merge multiple derives to a single one.
-
-#[bar]
-#[derive(Eq, PartialEq)]
-#[foo]
-#[derive(Debug)]
-#[foobar]
-#[derive(Copy, Clone)]
-pub enum Foo {}
-
-#[derive(Eq, PartialEq, Debug)]
-#[foobar]
-#[derive(Copy, Clone)]
-pub enum Bar {}
-
-#[derive(Eq, PartialEq, Debug, Copy, Clone)]
-pub enum FooBar {}
-
-mod foo {
- #[bar]
- #[derive(Eq, PartialEq)]
- #[foo]
- #[derive(Debug)]
- #[foobar]
- #[derive(Copy, Clone)]
- pub enum Foo {}
-}
-
-mod bar {
- #[derive(Eq, PartialEq, Debug)]
- #[foobar]
- #[derive(Copy, Clone)]
- pub enum Bar {}
-}
-
-mod foobar {
- #[derive(Eq, PartialEq, Debug, Copy, Clone)]
- pub enum FooBar {}
-}
+++ /dev/null
-// rustfmt-normalize_comments: false
-// Normalize comments
-
-// Lorem ipsum:
-fn dolor() -> usize {}
-
-/* sit amet: */
-fn adipiscing() -> usize {}
-
-// #652
-////////////////////////////////////////////////////////////////////////////////
-// Basic slice extension methods
-////////////////////////////////////////////////////////////////////////////////
+++ /dev/null
-// rustfmt-normalize_comments: true
-// Normalize comments
-
-// Lorem ipsum:
-fn dolor() -> usize {}
-
-// sit amet:
-fn adipiscing() -> usize {}
-
-// #652
-////////////////////////////////////////////////////////////////////////////////
-// Basic slice extension methods
-////////////////////////////////////////////////////////////////////////////////
+++ /dev/null
-// rustfmt-reorder_imported_names: false
-// Reorder imported names
-
-use super::{lorem, ipsum, dolor, sit};
+++ /dev/null
-// rustfmt-reorder_imported_names: true
-// Reorder imported names
-
-use super::{dolor, ipsum, lorem, sit};
+++ /dev/null
-// rustfmt-reorder_imports: false
-// Reorder imports
-
-use lorem;
-use ipsum;
-use dolor;
-use sit;
+++ /dev/null
-// rustfmt-reorder_imports: true
-// Reorder imports
-
-use dolor;
-use ipsum;
-use lorem;
-use sit;
-
-fn foo() {
- use A;
- use B;
- use C;
-
- bar();
-
- use D;
- use E;
- use F;
-}
+++ /dev/null
-// rustfmt-reorder_imports: true
-// rustfmt-reorder_imports_in_group: false
-// Reorder imports in group
-
-use dolor;
-/// This comment should stay with `use ipsum;`
-use ipsum;
-use lorem;
-use sit;
-use std::io;
-/// This comment should stay with `use std::mem;`
-use std::mem;
+++ /dev/null
-// rustfmt-reorder_imports: true
-// rustfmt-reorder_imports_in_group: true
-// Reorder imports in group
-
-use std::io;
-/// This comment should stay with `use std::mem;`
-use std::mem;
-
-use dolor;
-/// This comment should stay with `use ipsum;`
-use ipsum;
-use lorem;
-use sit;
+++ /dev/null
-// rustfmt-same_line_attributes: false
-// Option to place attributes on the same line as fields and variants where possible
-
-enum Lorem {
- #[serde(skip_serializing)]
- Ipsum,
- #[serde(skip_serializing)]
- Dolor,
- #[serde(skip_serializing)]
- Amet,
-}
-
-struct Lorem {
- #[serde(rename = "Ipsum")]
- ipsum: usize,
- #[serde(rename = "Dolor")]
- dolor: usize,
- #[serde(rename = "Amet")]
- amet: usize,
-}
-
-// #1943
-pub struct Bzip2 {
- #[serde(rename = "level")]
- level: i32,
-}
+++ /dev/null
-// rustfmt-same_line_attributes: true
-// Option to place attributes on the same line as fields and variants where possible
-
-enum Lorem {
- #[serde(skip_serializing)] Ipsum,
- #[serde(skip_serializing)] Dolor,
- #[serde(skip_serializing)] Amet,
-}
-
-struct Lorem {
- #[serde(rename = "Ipsum")] ipsum: usize,
- #[serde(rename = "Dolor")] dolor: usize,
- #[serde(rename = "Amet")] amet: usize,
-}
+++ /dev/null
-// rustfmt-space_before_colon: true
-// Space before colon
-
-fn lorem<T : Eq>(t : T) {
- let ipsum : Dolor = sit;
-}
-
-const LOREM : Lorem = Lorem {
- ipsum : dolor,
- sit : amet,
-};
+++ /dev/null
-// rustfmt-spaces_around_ranges: false
-// Spaces around ranges
-
-fn main() {
- let lorem = 0..10;
-}
+++ /dev/null
-// rustfmt-spaces_around_ranges: true
-// Spaces around ranges
-
-fn main() {
- let lorem = 0 .. 10;
-}
+++ /dev/null
-// rustfmt-spaces_within_parens_and_brackets: false
-// Spaces within parens and brackets
-
-fn lorem<T: Eq>(t: T) {
- let lorem = (ipsum, dolor);
- let lorem: [usize; 2] = [ipsum, dolor];
-}
+++ /dev/null
-// rustfmt-spaces_within_parens_and_brackets: true
-// Spaces within parens and brackets
-
-fn lorem< T: Eq >( t: T ) {
- let lorem = ( ipsum, dolor );
- let lorem: [ usize; 2 ] = [ ipsum, dolor ];
-}
-
-enum E {
- A( u32 ),
- B( u32, u32 ),
- C( u32, u32, u32 ),
- D(),
-}
-
-struct TupleStruct0();
-struct TupleStruct1( u32 );
-struct TupleStruct2( u32, u32 );
-
-fn fooEmpty() {}
-
-fn foo( e: E, _: u32 ) -> ( u32, u32 ) {
- // Tuples
- let t1 = ();
- let t2 = ( 1, );
- let t3 = ( 1, 2 );
-
- let ts0 = TupleStruct0();
- let ts1 = TupleStruct1( 1 );
- let ts2 = TupleStruct2( 1, 2 );
-
- // Tuple pattern
- let ( a, b, c ) = ( 1, 2, 3 );
-
- // Expressions
- let x = ( 1 + 2 ) * ( 3 );
-
- // Function call
- fooEmpty();
- foo( 1, 2 );
-
- // Pattern matching
- match e {
- A( _ ) => (),
- B( _, _ ) => (),
- C( .. ) => (),
- D => (),
- }
-
- ( 1, 2 )
-}
-
-struct Foo< T > {
- i: T,
-}
-
-struct Bar< T, E > {
- i: T,
- e: E,
-}
-
-struct Foo< 'a > {
- i: &'a str,
-}
-
-enum E< T > {
- T( T ),
-}
-
-enum E< T, S > {
- T( T ),
- S( S ),
-}
-
-fn foo< T >( a: T ) {
- foo::< u32 >( 10 );
-}
-
-fn foo< T, E >( a: T, b: E ) {
- foo::< u32, str >( 10, "bar" );
-}
-
-fn foo< T: Send, E: Send >( a: T, b: E ) {
- foo::< u32, str >( 10, "bar" );
-
- let opt: Option< u32 >;
- let res: Result< u32, String >;
-}
-
-fn foo< 'a >( a: &'a str ) {
- foo( "foo" );
-}
-
-fn foo< 'a, 'b >( a: &'a str, b: &'b str ) {
- foo( "foo", "bar" );
-}
-
-impl Foo {
- fn bar() {
- < Foo as Foo >::bar();
- }
-}
-
-trait MyTrait< A, D > {}
-impl< A: Send, D: Send > MyTrait< A, D > for Foo {}
-
-fn foo()
-where
- for< 'a > u32: 'a,
-{
-}
-
-fn main() {
- let arr: [ i32; 5 ] = [ 1, 2, 3, 4, 5 ];
- let arr: [ i32; 500 ] = [ 0; 500 ];
-
- let v = vec![ 1, 2, 3 ];
- assert_eq!( arr, [ 1, 2, 3 ] );
-
- let i = arr[ 0 ];
-
- let slice = &arr[ 1..2 ];
-
- let line100_________________________________________________________________________ = [ 1, 2 ];
- let line101__________________________________________________________________________ =
- [ 1, 2 ];
- let line102___________________________________________________________________________ =
- [ 1, 2 ];
- let line103____________________________________________________________________________ =
- [ 1, 2 ];
- let line104_____________________________________________________________________________ =
- [ 1, 2 ];
-
- let line100_____________________________________________________________________ = vec![ 1, 2 ];
- let line101______________________________________________________________________ =
- vec![ 1, 2 ];
- let line102_______________________________________________________________________ =
- vec![ 1, 2 ];
- let line103________________________________________________________________________ =
- vec![ 1, 2 ];
- let line104_________________________________________________________________________ =
- vec![ 1, 2 ];
-}
-
-fn f( slice: &[ i32 ] ) {}
+++ /dev/null
-// rustfmt-struct_field_align_threshold: 20
-// rustfmt-normalize_comments: true
-// rustfmt-wrap_comments: true
-// rustfmt-error_on_line_overflow: false
-
-struct Foo {
- x: u32,
- yy: u32, // comment
- zzz: u32,
-}
-
-pub struct Bar {
- x: u32,
- yy: u32,
- zzz: u32,
-
- xxxxxxx: u32,
-}
-
-fn main() {
- let foo = Foo {
- x: 0,
- yy: 1,
- zzz: 2,
- };
-
- let bar = Bar {
- x: 0,
- yy: 1,
- zzz: 2,
-
- xxxxxxx: 3,
- };
-}
-
-/// A Doc comment
-#[AnAttribute]
-pub struct Foo {
- #[rustfmt_skip]
- f : SomeType, // Comment beside a field
- f: SomeType, // Comment beside a field
- // Comment on a field
- #[AnAttribute] g: SomeOtherType,
- /// A doc comment on a field
- h: AThirdType,
- pub i: TypeForPublicField,
-}
-
-// #1029
-pub struct Foo {
- #[doc(hidden)]
- // This will NOT get deleted!
- bar: String, // hi
-}
-
-// #1029
-struct X {
- // `x` is an important number.
- #[allow(unused)] // TODO: use
- x: u32,
-}
-
-// #410
-#[allow(missing_docs)]
-pub struct Writebatch<K: Key> {
- #[allow(dead_code)] // only used for holding the internal pointer
- writebatch: RawWritebatch,
- marker: PhantomData<K>,
-}
-
-struct Bar;
-
-struct NewType(Type, OtherType);
-
-struct NewInt<T: Copy>(
- pub i32,
- SomeType, // inline comment
- T, // sup
-);
-
-struct Qux<
- 'a,
- N: Clone + 'a,
- E: Clone + 'a,
- G: Labeller<'a, N, E> + GraphWalk<'a, N, E>,
- W: Write + Copy,
->(
- AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA, // Comment
- BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB,
- #[AnAttr]
- // Comment
- /// Testdoc
- G,
- pub W,
-);
-
-struct Tuple(
- // Comment 1
- AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA,
- // Comment 2
- BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB,
-);
-
-// With a where clause and generics.
-pub struct Foo<'a, Y: Baz>
-where
- X: Whatever,
-{
- f: SomeType, // Comment beside a field
-}
-
-struct Baz {
- a: A, // Comment A
- b: B, // Comment B
- c: C, // Comment C
-}
-
-struct Baz {
- a: A, // Comment A
-
- b: B, // Comment B
-
- c: C, // Comment C
-}
-
-struct Baz {
- a: A,
-
- b: B,
- c: C,
-
- d: D,
-}
-
-struct Baz {
- // Comment A
- a: A,
-
- // Comment B
- b: B,
- // Comment C
- c: C,
-}
-
-// Will this be a one-liner?
-struct Tuple(
- A, // Comment
- B,
-);
-
-pub struct State<F: FnMut() -> time::Timespec> {
- now: F,
-}
-
-pub struct State<F: FnMut() -> ()> {
- now: F,
-}
-
-pub struct State<F: FnMut()> {
- now: F,
-}
-
-struct Palette {
- /// A map of indices in the palette to a count of pixels in approximately
- /// that color
- foo: i32,
-}
-
-// Splitting a single line comment into a block previously had a misalignment
-// when the field had attributes
-struct FieldsWithAttributes {
- // Pre Comment
- #[rustfmt_skip] pub host:String, /* Post comment BBBBBBBBBBBBBB BBBBBBBBBBBBBBBB
- * BBBBBBBBBBBBBBBB BBBBBBBBBBBBBBBBB BBBBBBBBBBB */
- // Another pre comment
- #[attr1]
- #[attr2]
- pub id: usize, /* CCCCCCCCCCCCCCCCCCC CCCCCCCCCCCCCCCCCCC CCCCCCCCCCCCCCCC
- * CCCCCCCCCCCCCCCCCC CCCCCCCCCCCCCC CCCCCCCCCCCC */
-}
-
-struct Deep {
- deeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeep:
- node::Handle<IdRef<'id, Node<K, V>>, Type, NodeType>,
-}
-
-struct Foo<T>(T);
-struct Foo<T>(T)
-where
- T: Copy,
- T: Eq;
-struct Foo<T>(
- TTTTTTTTTTTTTTTTT,
- UUUUUUUUUUUUUUUUUUUUUUUU,
- TTTTTTTTTTTTTTTTTTT,
- UUUUUUUUUUUUUUUUUUU,
-);
-struct Foo<T>(
- TTTTTTTTTTTTTTTTTT,
- UUUUUUUUUUUUUUUUUUUUUUUU,
- TTTTTTTTTTTTTTTTTTT,
-)
-where
- T: PartialEq;
-struct Foo<T>(
- TTTTTTTTTTTTTTTTT,
- UUUUUUUUUUUUUUUUUUUUUUUU,
- TTTTTTTTTTTTTTTTTTTTT,
-)
-where
- T: PartialEq;
-struct Foo<T>(
- TTTTTTTTTTTTTTTTT,
- UUUUUUUUUUUUUUUUUUUUUUUU,
- TTTTTTTTTTTTTTTTTTT,
- UUUUUUUUUUUUUUUUUUU,
-)
-where
- T: PartialEq;
-struct Foo<T>(
- TTTTTTTTTTTTTTTTT, // Foo
- UUUUUUUUUUUUUUUUUUUUUUUU, // Bar
- // Baz
- TTTTTTTTTTTTTTTTTTT,
- // Qux (FIXME #572 - doc comment)
- UUUUUUUUUUUUUUUUUUU,
-);
-
-mod m {
- struct X<T>
- where
- T: Sized,
- {
- a: T,
- }
-}
-
-struct Foo<T>(
- TTTTTTTTTTTTTTTTTTT,
- /// Qux
- UUUUUUUUUUUUUUUUUUU,
-);
-
-struct Issue677 {
- pub ptr: *const libc::c_void,
- pub trace: fn(obj: *const libc::c_void, tracer: *mut JSTracer),
-}
-
-struct Foo {}
-struct Foo {}
-struct Foo {
- // comment
-}
-struct Foo {
- // trailing space ->
-}
-struct Foo { /* comment */ }
-struct Foo( /* comment */ );
-
-struct LongStruct {
- a: A,
- the_quick_brown_fox_jumps_over_the_lazy_dog:
- AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA,
-}
-
-struct Deep {
- deeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeep:
- node::Handle<IdRef<'id, Node<Key, Value>>, Type, NodeType>,
-}
-
-struct Foo<C = ()>(String);
-
-// #1364
-fn foo() {
- convex_shape.set_point(0, &Vector2f { x: 400.0, y: 100.0 });
- convex_shape.set_point(1, &Vector2f { x: 500.0, y: 70.0 });
- convex_shape.set_point(2, &Vector2f { x: 450.0, y: 100.0 });
- convex_shape.set_point(3, &Vector2f { x: 580.0, y: 150.0 });
-}
-
-fn main() {
- let x = Bar;
-
- // Comment
- let y = Foo { a: x };
-
- Foo {
- a: foo(), // comment
- // comment
- b: bar(),
- ..something
- };
-
- Fooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo { a: f(), b: b() };
-
- Foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo {
- a: f(),
- b: b(),
- };
-
- Foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo {
- // Comment
- a: foo(), // Comment
- // Comment
- b: bar(), // Comment
- };
-
- Foo { a: Bar, b: f() };
-
- Quux {
- x: if cond {
- bar();
- },
- y: baz(),
- };
-
- A {
- // Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec a diam lectus. Sed sit
- // amet ipsum mauris. Maecenas congue ligula ac quam viverra nec consectetur ante
- // hendrerit. Donec et mollis dolor.
- first: item(),
- // Praesent et diam eget libero egestas mattis sit amet vitae augue.
- // Nam tincidunt congue enim, ut porta lorem lacinia consectetur.
- second: Item,
- };
-
- Some(Data::MethodCallData(MethodCallData {
- span: sub_span.unwrap(),
- scope: self.enclosing_scope(id),
- ref_id: def_id,
- decl_id: Some(decl_id),
- }));
-
- Diagram {
- // o This graph demonstrates how
- // / \ significant whitespace is
- // o o preserved.
- // /|\ \
- // o o o o
- graph: G,
- }
-}
-
-fn matcher() {
- TagTerminatedByteMatcher {
- matcher: ByteMatcher {
- pattern: b"<HTML",
- mask: b"\xFF\xDF\xDF\xDF\xDF\xFF",
- },
- };
-}
-
-fn issue177() {
- struct Foo<T> {
- memb: T,
- }
- let foo = Foo::<i64> { memb: 10 };
-}
-
-fn issue201() {
- let s = S { a: 0, ..b };
-}
-
-fn issue201_2() {
- let s = S { a: S2 { ..c }, ..b };
-}
-
-fn issue278() {
- let s = S {
- a: 0,
- //
- b: 0,
- };
- let s1 = S {
- a: 0,
- // foo
- //
- // bar
- b: 0,
- };
-}
-
-fn struct_exprs() {
- Foo { a: 1, b: f(2) };
- Foo {
- a: 1,
- b: f(2),
- ..g(3)
- };
- LoooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooongStruct {
- ..base
- };
- IntrinsicISizesContribution {
- content_intrinsic_sizes: IntrinsicISizes {
- minimum_inline_size: 0,
- },
- };
-}
-
-fn issue123() {
- Foo { a: b, c: d, e: f };
-
- Foo {
- a: bb,
- c: dd,
- e: ff,
- };
-
- Foo {
- a: ddddddddddddddddddddd,
- b: cccccccccccccccccccccccccccccccccccccc,
- };
-}
-
-fn issue491() {
- Foo {
- guard: None,
- arm: 0, // Comment
- };
-
- Foo {
- arm: 0, // Comment
- };
-
- Foo {
- a: aaaaaaaaaa,
- b: bbbbbbbb,
- c: cccccccccc,
- d: dddddddddd, // a comment
- e: eeeeeeeee,
- };
-}
-
-fn issue698() {
- Record {
- ffffffffffffffffffffffffffields: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
- };
- Record {
- ffffffffffffffffffffffffffields:
- aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
- }
-}
-
-fn issue835() {
- MyStruct {};
- MyStruct { /* a comment */ };
- MyStruct {
- // Another comment
- };
- MyStruct {}
-}
-
-fn field_init_shorthand() {
- MyStruct { x, y, z };
- MyStruct { x, y, z, ..base };
- Foo {
- aaaaaaaaaa,
- bbbbbbbb,
- cccccccccc,
- dddddddddd, // a comment
- eeeeeeeee,
- };
- Record {
- ffffffffffffffffffffffffffieldsaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
- };
-}
+++ /dev/null
-// rustfmt-indent_style: Block
-// Struct literal-style
-
-fn main() {
- let lorem = Lorem {
- ipsum: dolor,
- sit: amet,
- };
-}
+++ /dev/null
-// rustfmt-indent_style: Visual
-// Struct literal-style
-
-fn main() {
- let lorem = Lorem { ipsum: dolor,
- sit: amet, };
-}
+++ /dev/null
-// rustfmt-struct_lit_single_line: false
-// Struct literal multiline-style
-
-fn main() {
- let lorem = Lorem {
- ipsum: dolor,
- sit: amet,
- };
-}
+++ /dev/null
-// rustfmt-tab_spaces: 2
-// rustfmt-max_width: 30
-// rustfmt-indent_style: Block
-// Tab spaces
-
-fn lorem() {
- let ipsum = dolor();
- let sit = vec![
- "amet",
- "consectetur",
- "adipiscing",
- "elit.",
- ];
-}
+++ /dev/null
-// rustfmt-tab_spaces: 4
-// rustfmt-max_width: 30
-// rustfmt-indent_style: Block
-// Tab spaces
-
-fn lorem() {
- let ipsum = dolor();
- let sit = vec![
- "amet",
- "consectetur",
- "adipiscing",
- "elit.",
- ];
-}
+++ /dev/null
-// rustfmt-trailing_comma: Always
-// Trailing comma
-
-fn main() {
- let Lorem { ipsum, dolor, sit, } = amet;
- let Lorem {
- ipsum,
- dolor,
- sit,
- amet,
- consectetur,
- adipiscing,
- } = elit;
-}
+++ /dev/null
-// rustfmt-trailing_comma: Never
-// Trailing comma
-
-fn main() {
- let Lorem { ipsum, dolor, sit } = amet;
- let Lorem {
- ipsum,
- dolor,
- sit,
- amet,
- consectetur,
- adipiscing
- } = elit;
-
- // #1544
- if let VrMsg::ClientReply {
- request_num: reply_req_num,
- value,
- ..
- } = msg
- {
- let _ = safe_assert_eq!(reply_req_num, request_num, op);
- return Ok((request_num, op, value));
- }
-
- // #1710
- pub struct FileInput {
- input: StringInput,
- file_name: OsString
- }
- match len {
- Some(len) => Ok(new(self.input, self.pos + len)),
- None => Err(self)
- }
-}
+++ /dev/null
-// rustfmt-trailing_comma: Vertical
-// Trailing comma
-
-fn main() {
- let Lorem { ipsum, dolor, sit } = amet;
- let Lorem {
- ipsum,
- dolor,
- sit,
- amet,
- consectetur,
- adipiscing,
- } = elit;
-}
+++ /dev/null
-// rustfmt-trailing_semicolon: false
-
-#![feature(loop_break_value)]
-
-fn main() {
- 'a: loop {
- break 'a
- }
-
- let mut done = false;
- 'b: while !done {
- done = true;
- continue 'b
- }
-
- let x = loop {
- break 5
- };
-
- let x = 'c: loop {
- break 'c 5
- };
-}
-
-fn foo() -> usize {
- return 0
-}
+++ /dev/null
-// rustfmt-trailing_semicolon: true
-
-#![feature(loop_break_value)]
-
-fn main() {
- 'a: loop {
- break 'a;
- }
-
- let mut done = false;
- 'b: while !done {
- done = true;
- continue 'b;
- }
-
- let x = loop {
- break 5;
- };
-
- let x = 'c: loop {
- break 'c 5;
- };
-}
-
-fn foo() -> usize {
- return 0;
-}
+++ /dev/null
-// rustfmt-type_punctuation_density: Compressed
-// Type punctuation density
-
-fn lorem<Ipsum: Dolor+Sit=Amet>() {
- // body
-}
+++ /dev/null
-// rustfmt-type_punctuation_density: Wide
-// Type punctuation density
-
-fn lorem<Ipsum: Dolor + Sit = Amet>() {
- // body
-}
+++ /dev/null
-// rustfmt-use_try_shorthand: false
-// Use try! shorthand
-
-fn main() {
- let lorem = try!(ipsum.map(|dolor| dolor.sit()));
-}
+++ /dev/null
-// rustfmt-use_try_shorthand: true
-// Use try! shorthand
-
-fn main() {
- let lorem = ipsum.map(|dolor| dolor.sit())?;
-}
+++ /dev/null
-// rustfmt-indent_style: Block
-// Where predicate indent
-
-fn lorem<Ipsum, Dolor, Sit, Amet>() -> T
-where
- Ipsum: Eq,
- Dolor: Eq,
- Sit: Eq,
- Amet: Eq,
-{
- // body
-}
+++ /dev/null
-// rustfmt-indent_style: Visual
-// Where predicate indent
-
-fn lorem<Ipsum, Dolor, Sit, Amet>() -> T
- where Ipsum: Eq,
- Dolor: Eq,
- Sit: Eq,
- Amet: Eq
-{
- // body
-}
+++ /dev/null
-// rustfmt-where_single_line: true
-// Where style
-
-fn lorem_two_items<Ipsum, Dolor, Sit, Amet>() -> T
-where
- Ipsum: Eq,
- Lorem: Eq,
-{
- // body
-}
-
-fn lorem_multi_line<Ipsum, Dolor, Sit, Amet>(
- a: Aaaaaaaaaaaaaaa,
- b: Bbbbbbbbbbbbbbbb,
- c: Ccccccccccccccccc,
- d: Ddddddddddddddddddddddddd,
- e: Eeeeeeeeeeeeeeeeeee,
-) -> T
-where
- Ipsum: Eq,
-{
- // body
-}
-
-fn lorem<Ipsum, Dolor, Sit, Amet>() -> T
-where Ipsum: Eq {
- // body
-}
+++ /dev/null
-// rustfmt-indent_style: Visual
-// Where style
-
-fn lorem<Ipsum, Dolor, Sit, Amet>() -> T
- where Ipsum: Eq,
- Dolor: Eq,
- Sit: Eq,
- Amet: Eq
-{
- // body
-}
+++ /dev/null
-// rustfmt-indent_style: Block
-// Where style
-
-fn lorem<Ipsum, Dolor, Sit, Amet>() -> T
-where
- Ipsum: Eq,
- Dolor: Eq,
- Sit: Eq,
- Amet: Eq,
-{
- // body
-}
+++ /dev/null
-// rustfmt-wrap_comments: false
-// rustfmt-max_width: 50
-// rustfmt-error_on_line_overflow: false
-// Wrap comments
-
-fn main() {
- // Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
-}
+++ /dev/null
-// rustfmt-wrap_comments: true
-// rustfmt-max_width: 50
-// Wrap comments
-
-fn main() {
- // Lorem ipsum dolor sit amet, consectetur
- // adipiscing elit, sed do eiusmod tempor
- // incididunt ut labore et dolore magna
- // aliqua. Ut enim ad minim veniam, quis
- // nostrud exercitation ullamco laboris nisi
- // ut aliquip ex ea commodo consequat.
-}
-
-fn code_block() {
- // ```rust
- // let x = 3;
- //
- // println!("x = {}", x);
- // ```
-}
--- /dev/null
+// rustfmt-indent_style: Block
+// Array layout
+
+fn main() {
+ let lorem = vec![
+ "ipsum",
+ "dolor",
+ "sit",
+ "amet",
+ "consectetur",
+ "adipiscing",
+ "elit",
+ ];
+}
--- /dev/null
+// rustfmt-indent_style: Visual
+// Array layout
+
+fn main() {
+ let lorem = vec!["ipsum",
+ "dolor",
+ "sit",
+ "amet",
+ "consectetur",
+ "adipiscing",
+ "elit"];
+}
--- /dev/null
+// rustfmt-blank_lines_lower_bound: 1
+
+fn foo() {}
+
+fn bar() {}
+
+// comment
+fn foobar() {}
+
+fn foo1() {}
+
+fn bar1() {}
+
+// comment
+
+fn foobar1() {}
--- /dev/null
+// rustfmt-indent_style: Block
+// Chain indent
+
+fn main() {
+ let lorem = ipsum
+ .dolor()
+ .sit()
+ .amet()
+ .consectetur()
+ .adipiscing()
+ .elite();
+}
--- /dev/null
+// rustfmt-indent_style: Visual
+// Chain indent
+
+fn main() {
+ let lorem = ipsum.dolor()
+ .sit()
+ .amet()
+ .consectetur()
+ .adipiscing()
+ .elite();
+}
--- /dev/null
+// rustfmt-indent_style: Block
+// rustfmt-combine_control_expr: false
+// Combining openings and closings. See https://github.com/rust-lang-nursery/fmt-rfcs/issues/61.
+
+fn main() {
+ // Call
+ foo(bar(
+ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
+ bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb,
+ ));
+
+ // Mac
+ foo(foo!(
+ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
+ bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb,
+ ));
+
+ // MethodCall
+ foo(x.foo::<Bar, Baz>(
+ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
+ bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb,
+ ));
+
+ // Block
+ foo!({
+ foo();
+ bar();
+ });
+
+ // Closure
+ foo(|x| {
+ let y = x + 1;
+ y
+ });
+
+ // Match
+ foo(match opt {
+ Some(x) => x,
+ None => y,
+ });
+
+ // Struct
+ foo(Bar {
+ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
+ bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb,
+ });
+
+ // If
+ foo!(
+ if x {
+ foo();
+ } else {
+ bar();
+ }
+ );
+
+ // IfLet
+ foo!(
+ if let Some(..) = x {
+ foo();
+ } else {
+ bar();
+ }
+ );
+
+ // While
+ foo!(
+ while x {
+ foo();
+ bar();
+ }
+ );
+
+ // WhileLet
+ foo!(
+ while let Some(..) = x {
+ foo();
+ bar();
+ }
+ );
+
+ // ForLoop
+ foo!(
+ for x in y {
+ foo();
+ bar();
+ }
+ );
+
+ // Loop
+ foo!(
+ loop {
+ foo();
+ bar();
+ }
+ );
+
+ // Tuple
+ foo((
+ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
+ bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb,
+ ));
+
+ // AddrOf
+ foo(&bar(
+ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
+ bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb,
+ ));
+
+ // Box
+ foo(box Bar {
+ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
+ bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb,
+ });
+
+ // Unary
+ foo(!bar(
+ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
+ bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb,
+ ));
+
+ // Try
+ foo(bar(
+ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
+ bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb,
+ )?);
+
+ // Cast
+ foo(Bar {
+ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx,
+ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx,
+ } as i64);
+}
--- /dev/null
+// rustfmt-indent_style: Block
+// rustfmt-combine_control_expr: true
+// Combining openings and closings. See https://github.com/rust-lang-nursery/fmt-rfcs/issues/61.
+
+fn main() {
+ // Call
+ foo(bar(
+ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
+ bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb,
+ ));
+
+ // Mac
+ foo(foo!(
+ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
+ bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb,
+ ));
+
+ // MethodCall
+ foo(x.foo::<Bar, Baz>(
+ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
+ bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb,
+ ));
+
+ // Block
+ foo!({
+ foo();
+ bar();
+ });
+
+ // Closure
+ foo(|x| {
+ let y = x + 1;
+ y
+ });
+
+ // Match
+ foo(match opt {
+ Some(x) => x,
+ None => y,
+ });
+
+ // Struct
+ foo(Bar {
+ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
+ bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb,
+ });
+
+ // If
+ foo!(if x {
+ foo();
+ } else {
+ bar();
+ });
+
+ // IfLet
+ foo!(if let Some(..) = x {
+ foo();
+ } else {
+ bar();
+ });
+
+ // While
+ foo!(while x {
+ foo();
+ bar();
+ });
+
+ // WhileLet
+ foo!(while let Some(..) = x {
+ foo();
+ bar();
+ });
+
+ // ForLoop
+ foo!(for x in y {
+ foo();
+ bar();
+ });
+
+ // Loop
+ foo!(loop {
+ foo();
+ bar();
+ });
+
+ // Tuple
+ foo((
+ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
+ bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb,
+ ));
+
+ // AddrOf
+ foo(&bar(
+ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
+ bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb,
+ ));
+
+ // Box
+ foo(box Bar {
+ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
+ bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb,
+ });
+
+ // Unary
+ foo(!bar(
+ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
+ bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb,
+ ));
+
+ // Try
+ foo(bar(
+ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
+ bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb,
+ )?);
+
+ // Cast
+ foo(Bar {
+ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx,
+ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx,
+ } as i64);
+}
--- /dev/null
+// rustfmt-comment_width: 40
+// rustfmt-wrap_comments: true
+// Comment width
+
+fn main() {
+ // Lorem ipsum dolor sit amet,
+ // consectetur adipiscing elit.
+}
--- /dev/null
+// rustfmt-comment_width: 80
+// rustfmt-wrap_comments: true
+// Comment width
+
+fn main() {
+ // Lorem ipsum dolor sit amet, consectetur adipiscing elit.
+}
--- /dev/null
+// rustfmt-comment_width: 40
+// rustfmt-wrap_comments: false
+// Comment width
+
+fn main() {
+ // Lorem ipsum dolor sit amet, consectetur adipiscing elit.
+}
--- /dev/null
+// rustfmt-condense_wildcard_suffixes: false
+// Condense wildcard suffixes
+
+fn main() {
+ let (lorem, ipsum, _, _) = (1, 2, 3, 4);
+}
--- /dev/null
+// rustfmt-condense_wildcard_suffixes: true
+// Condense wildcard suffixes
+
+fn main() {
+ let (lorem, ipsum, ..) = (1, 2, 3, 4);
+}
--- /dev/null
+// rustfmt-control_brace_style: AlwaysNextLine
+// Control brace style
+
+fn main() {
+ if lorem
+ {
+ println!("ipsum!");
+ }
+ else
+ {
+ println!("dolor!");
+ }
+ match magi
+ {
+ Homura => "Akemi",
+ Madoka => "Kaname",
+ }
+}
--- /dev/null
+// rustfmt-control_brace_style: AlwaysSameLine
+// Control brace style
+
+fn main() {
+ if lorem {
+ println!("ipsum!");
+ } else {
+ println!("dolor!");
+ }
+ match magi {
+ Homura => "Akemi",
+ Madoka => "Kaname",
+ }
+}
--- /dev/null
+// rustfmt-control_brace_style: ClosingNextLine
+// Control brace style
+
+fn main() {
+ if lorem {
+ println!("ipsum!");
+ }
+ else {
+ println!("dolor!");
+ }
+ match magi {
+ Homura => "Akemi",
+ Madoka => "Kaname",
+ }
+}
--- /dev/null
+// 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;
+ }
+ _ => {}
+ }
+ }
+ }
+}
--- /dev/null
+// rustfmt-disable_all_formatting: false
+// Disable all formatting
+
+fn main() {
+ if lorem {
+ println!("ipsum!");
+ } else {
+ println!("dolor!");
+ }
+}
--- /dev/null
+// rustfmt-disable_all_formatting: true
+// Disable all formatting
+
+fn main() {
+ if lorem{println!("ipsum!");}else{println!("dolor!");}
+}
--- /dev/null
+// rustfmt-empty_item_single_line: false
+// Empty impl on single line
+
+impl Lorem {
+}
+
+impl Ipsum {
+}
+
+fn lorem() {
+}
+
+fn lorem() {
+
+}
--- /dev/null
+// rustfmt-empty_item_single_line: true
+// Empty impl on single line
+
+impl Lorem {}
+
+impl Ipsum {}
+
+fn lorem() {}
+
+fn lorem() {}
--- /dev/null
+// rustfmt-error_on_line_overflow: false
+// Error on line overflow
+
+fn main() {
+ let lorem_ipsum_dolor_sit_amet_consectetur_adipiscing_elit_lorem_ipsum_dolor_sit_amet_consectetur_adipiscing_elit;
+}
--- /dev/null
+// rustfmt-error_on_unformatted: false
+// Error on line overflow comment or string literals.
+
+// aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+fn main() {
+ // aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+
+ let x = " ";
+ let a = "
+
+";
+}
--- /dev/null
+// rustfmt-fn_args_density: Compressed
+// Function arguments density
+
+trait Lorem {
+ fn lorem(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet);
+
+ fn lorem(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet) {
+ // body
+ }
+
+ fn lorem(
+ ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet, consectetur: onsectetur,
+ adipiscing: Adipiscing, elit: Elit,
+ );
+
+ fn lorem(
+ ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet, consectetur: onsectetur,
+ adipiscing: Adipiscing, elit: Elit,
+ ) {
+ // body
+ }
+}
--- /dev/null
+// rustfmt-fn_args_density: Tall
+// Function arguments density
+
+trait Lorem {
+ fn lorem(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet);
+
+ fn lorem(ipsum: Ipsum, dolor: Dolor, sit: Sit, amet: Amet) {
+ // body
+ }
+
+ fn lorem(
+ ipsum: Ipsum,
+ dolor: Dolor,
+ sit: Sit,
+ amet: Amet,
+ consectetur: onsectetur,
+ adipiscing: Adipiscing,
+ elit: Elit,
+ );
+
+ fn lorem(
+ ipsum: Ipsum,
+ dolor: Dolor,
+ sit: Sit,
+ amet: Amet,
+ consectetur: onsectetur,
+ adipiscing: Adipiscing,
+ elit: Elit,
+ ) {
+ // body
+ }
+}
--- /dev/null
+// rustfmt-fn_args_density: Vertical
+// Function arguments density
+
+trait Lorem {
+ fn lorem(
+ ipsum: Ipsum,
+ dolor: Dolor,
+ sit: Sit,
+ amet: Amet,
+ );
+
+ fn lorem(
+ ipsum: Ipsum,
+ dolor: Dolor,
+ sit: Sit,
+ amet: Amet,
+ ) {
+ // body
+ }
+
+ fn lorem(
+ ipsum: Ipsum,
+ dolor: Dolor,
+ sit: Sit,
+ amet: Amet,
+ consectetur: onsectetur,
+ adipiscing: Adipiscing,
+ elit: Elit,
+ );
+
+ fn lorem(
+ ipsum: Ipsum,
+ dolor: Dolor,
+ sit: Sit,
+ amet: Amet,
+ consectetur: onsectetur,
+ adipiscing: Adipiscing,
+ elit: Elit,
+ ) {
+ // body
+ }
+}
--- /dev/null
+// 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,
+) {
+}
--- /dev/null
+// 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;
+}
--- /dev/null
+// rustfmt-brace_style: AlwaysNextLine
+// Function brace style
+
+fn lorem()
+{
+ // body
+}
+
+fn lorem(ipsum: usize)
+{
+ // body
+}
+
+fn lorem<T>(ipsum: T)
+where
+ T: Add + Sub + Mul + Div,
+{
+ // body
+}
--- /dev/null
+// rustfmt-brace_style: PreferSameLine
+// Function brace style
+
+fn lorem() {
+ // body
+}
+
+fn lorem(ipsum: usize) {
+ // body
+}
+
+fn lorem<T>(ipsum: T)
+where
+ T: Add + Sub + Mul + Div, {
+ // body
+}
--- /dev/null
+// rustfmt-brace_style: SameLineWhere
+// Function brace style
+
+fn lorem() {
+ // body
+}
+
+fn lorem(ipsum: usize) {
+ // body
+}
+
+fn lorem<T>(ipsum: T)
+where
+ T: Add + Sub + Mul + Div,
+{
+ // body
+}
--- /dev/null
+// 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());
+ }
+}
--- /dev/null
+// rustfmt-indent_style: Block
+// rustfmt-max_width: 80
+// rustfmt-tab_spaces: 2
+
+// #1427
+fn main() {
+ exceptaions::config(move || {
+ (
+ NmiConfig {},
+ HardFaultConfig {},
+ SysTickConfig { gpio_sbsrr },
+ )
+ });
+}
--- /dev/null
+// 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(),
+ );
+}
--- /dev/null
+// rustfmt-indent_style: Visual
+// Function call style
+
+fn main() {
+ lorem("lorem",
+ "ipsum",
+ "dolor",
+ "sit",
+ "amet",
+ "consectetur",
+ "adipiscing",
+ "elit");
+}
--- /dev/null
+// 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:");
+}
--- /dev/null
+// rustfmt-fn_single_line: false
+// Single-expression function on single line
+
+fn lorem() -> usize {
+ 42
+}
+
+fn lorem() -> usize {
+ let ipsum = 42;
+ ipsum
+}
--- /dev/null
+// rustfmt-fn_single_line: true
+// Single-expression function on single line
+
+fn lorem() -> usize { 42 }
+
+fn lorem() -> usize {
+ let ipsum = 42;
+ ipsum
+}
--- /dev/null
+// rustfmt-force_explicit_abi: false
+// Force explicit abi
+
+extern {
+ pub static lorem: c_int;
+}
--- /dev/null
+// rustfmt-force_explicit_abi: true
+// Force explicit abi
+
+extern "C" {
+ pub static lorem: c_int;
+}
--- /dev/null
+// rustfmt-force_multiline_blocks: false
+// Option forces multiline match arm and closure bodies to be wrapped in a block
+
+fn main() {
+ match lorem {
+ Lorem::Ipsum => {
+ if ipsum {
+ println!("dolor");
+ }
+ }
+ Lorem::Dolor => println!("amet"),
+ }
+}
+
+fn main() {
+ result.and_then(|maybe_value| match maybe_value {
+ None => Err("oops"),
+ Some(value) => Ok(1),
+ });
+}
--- /dev/null
+// rustfmt-force_multiline_blocks: true
+// Option forces multiline match arm and closure bodies to be wrapped in a block
+
+fn main() {
+ match lorem {
+ Lorem::Ipsum => {
+ if ipsum {
+ println!("dolor");
+ }
+ }
+ Lorem::Dolor => println!("amet"),
+ }
+}
+
+fn main() {
+ result.and_then(|maybe_value| {
+ match maybe_value {
+ None => Err("oops"),
+ Some(value) => Ok(1),
+ }
+ });
+}
--- /dev/null
+// rustfmt-format_strings: false
+// rustfmt-max_width: 50
+// rustfmt-error_on_line_overflow: false
+// Force format strings
+
+fn main() {
+ let lorem = "ipsum dolor sit amet consectetur adipiscing elit lorem ipsum dolor sit";
+}
--- /dev/null
+// rustfmt-format_strings: true
+// rustfmt-max_width: 50
+// Force format strings
+
+fn main() {
+ let lorem = "ipsum dolor sit amet \
+ consectetur adipiscing elit \
+ lorem ipsum dolor sit";
+}
--- /dev/null
+// 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
+}
--- /dev/null
+// 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
+}
--- /dev/null
+// rustfmt-hard_tabs: false
+// Hard tabs
+
+fn lorem() -> usize {
+ 42 // spaces before 42
+}
--- /dev/null
+// rustfmt-hard_tabs: true
+// Hard tabs
+
+fn lorem() -> usize {
+ 42 // spaces before 42
+}
--- /dev/null
+// rustfmt-imports_indent: Block
+
+use lists::{
+ definitive_tactic, itemize_list, shape_for_tactic, struct_lit_formatting, struct_lit_shape,
+ struct_lit_tactic, write_list, DefinitiveListTactic, ListFormatting, ListItem, ListTactic,
+ SeparatorTactic,
+};
--- /dev/null
+// rustfmt-imports_indent: Block
+// rustfmt-imports_layout: HorizontalVertical
+
+use comment::{contains_comment, recover_comment_removed, rewrite_comment, FindUncommented};
+use lists::{
+ definitive_tactic,
+ itemize_list,
+ shape_for_tactic,
+ struct_lit_formatting,
+ struct_lit_shape,
+ struct_lit_tactic,
+ write_list,
+ DefinitiveListTactic,
+ ListFormatting,
+ ListItem,
+ ListTactic,
+ SeparatorTactic,
+};
--- /dev/null
+// rustfmt-imports_indent: Block
+// rustfmt-imports_layout: Mixed
+
+use comment::{contains_comment, recover_comment_removed, rewrite_comment, FindUncommented};
+use lists::{
+ definitive_tactic, itemize_list, shape_for_tactic, struct_lit_formatting, struct_lit_shape,
+ struct_lit_tactic, write_list, DefinitiveListTactic, ListFormatting, ListItem, ListTactic,
+ SeparatorTactic,
+};
--- /dev/null
+// rustfmt-brace_style: AlwaysNextLine
+// Item brace style
+
+enum Foo {}
+
+struct Bar {}
+
+struct Lorem
+{
+ ipsum: bool,
+}
+
+struct Dolor<T>
+where
+ T: Eq,
+{
+ sit: T,
+}
+
+#[cfg(test)]
+mod tests
+{
+ #[test]
+ fn it_works()
+ {
+ }
+}
--- /dev/null
+// rustfmt-brace_style: PreferSameLine
+// Item brace style
+
+struct Lorem {
+ ipsum: bool,
+}
+
+struct Dolor<T>
+where
+ T: Eq, {
+ sit: T,
+}
+
+#[cfg(test)]
+mod tests {
+ #[test]
+ fn it_works() {}
+}
--- /dev/null
+// rustfmt-brace_style: SameLineWhere
+// Item brace style
+
+struct Lorem {
+ ipsum: bool,
+}
+
+struct Dolor<T>
+where
+ T: Eq,
+{
+ sit: T,
+}
+
+#[cfg(test)]
+mod tests {
+ #[test]
+ fn it_works() {}
+}
--- /dev/null
+// rustfmt-match_arm_blocks: false
+// Wrap match-arms
+
+fn main() {
+ match lorem {
+ true =>
+ foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo(x),
+ false => println!("{}", sit),
+ }
+}
--- /dev/null
+// rustfmt-match_arm_blocks: true
+// Wrap match-arms
+
+fn main() {
+ match lorem {
+ true => {
+ foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo(x)
+ }
+ false => println!("{}", sit),
+ }
+}
--- /dev/null
+// rustfmt-match_block_trailing_comma: false
+// Match block trailing comma
+
+fn main() {
+ match lorem {
+ Lorem::Ipsum => {
+ println!("ipsum");
+ }
+ Lorem::Dolor => println!("dolor"),
+ }
+}
--- /dev/null
+// rustfmt-match_block_trailing_comma: true
+// Match block trailing comma
+
+fn main() {
+ match lorem {
+ Lorem::Ipsum => {
+ println!("ipsum");
+ },
+ Lorem::Dolor => println!("dolor"),
+ }
+}
--- /dev/null
+// rustfmt-merge_derives: true
+// Merge multiple derives to a single one.
+
+#[bar]
+#[derive(Eq, PartialEq)]
+#[foo]
+#[derive(Debug)]
+#[foobar]
+#[derive(Copy, Clone)]
+pub enum Foo {}
+
+#[derive(Eq, PartialEq, Debug)]
+#[foobar]
+#[derive(Copy, Clone)]
+pub enum Bar {}
+
+#[derive(Eq, PartialEq, Debug, Copy, Clone)]
+pub enum FooBar {}
+
+mod foo {
+ #[bar]
+ #[derive(Eq, PartialEq)]
+ #[foo]
+ #[derive(Debug)]
+ #[foobar]
+ #[derive(Copy, Clone)]
+ pub enum Foo {}
+}
+
+mod bar {
+ #[derive(Eq, PartialEq, Debug)]
+ #[foobar]
+ #[derive(Copy, Clone)]
+ pub enum Bar {}
+}
+
+mod foobar {
+ #[derive(Eq, PartialEq, Debug, Copy, Clone)]
+ pub enum FooBar {}
+}
--- /dev/null
+// rustfmt-normalize_comments: false
+// Normalize comments
+
+// Lorem ipsum:
+fn dolor() -> usize {}
+
+/* sit amet: */
+fn adipiscing() -> usize {}
+
+// #652
+////////////////////////////////////////////////////////////////////////////////
+// Basic slice extension methods
+////////////////////////////////////////////////////////////////////////////////
--- /dev/null
+// rustfmt-normalize_comments: true
+// Normalize comments
+
+// Lorem ipsum:
+fn dolor() -> usize {}
+
+// sit amet:
+fn adipiscing() -> usize {}
+
+// #652
+////////////////////////////////////////////////////////////////////////////////
+// Basic slice extension methods
+////////////////////////////////////////////////////////////////////////////////
--- /dev/null
+// rustfmt-reorder_imported_names: false
+// Reorder imported names
+
+use super::{lorem, ipsum, dolor, sit};
--- /dev/null
+// rustfmt-reorder_imported_names: true
+// Reorder imported names
+
+use super::{dolor, ipsum, lorem, sit};
--- /dev/null
+// rustfmt-reorder_imports: false
+// Reorder imports
+
+use lorem;
+use ipsum;
+use dolor;
+use sit;
--- /dev/null
+// rustfmt-reorder_imports: true
+// Reorder imports
+
+use dolor;
+use ipsum;
+use lorem;
+use sit;
+
+fn foo() {
+ use A;
+ use B;
+ use C;
+
+ bar();
+
+ use D;
+ use E;
+ use F;
+}
--- /dev/null
+// rustfmt-reorder_imports: true
+// rustfmt-reorder_imports_in_group: false
+// Reorder imports in group
+
+use dolor;
+/// This comment should stay with `use ipsum;`
+use ipsum;
+use lorem;
+use sit;
+use std::io;
+/// This comment should stay with `use std::mem;`
+use std::mem;
--- /dev/null
+// rustfmt-reorder_imports: true
+// rustfmt-reorder_imports_in_group: true
+// Reorder imports in group
+
+use std::io;
+/// This comment should stay with `use std::mem;`
+use std::mem;
+
+use dolor;
+/// This comment should stay with `use ipsum;`
+use ipsum;
+use lorem;
+use sit;
--- /dev/null
+// rustfmt-same_line_attributes: false
+// Option to place attributes on the same line as fields and variants where possible
+
+enum Lorem {
+ #[serde(skip_serializing)]
+ Ipsum,
+ #[serde(skip_serializing)]
+ Dolor,
+ #[serde(skip_serializing)]
+ Amet,
+}
+
+struct Lorem {
+ #[serde(rename = "Ipsum")]
+ ipsum: usize,
+ #[serde(rename = "Dolor")]
+ dolor: usize,
+ #[serde(rename = "Amet")]
+ amet: usize,
+}
+
+// #1943
+pub struct Bzip2 {
+ #[serde(rename = "level")]
+ level: i32,
+}
--- /dev/null
+// rustfmt-same_line_attributes: true
+// Option to place attributes on the same line as fields and variants where possible
+
+enum Lorem {
+ #[serde(skip_serializing)] Ipsum,
+ #[serde(skip_serializing)] Dolor,
+ #[serde(skip_serializing)] Amet,
+}
+
+struct Lorem {
+ #[serde(rename = "Ipsum")] ipsum: usize,
+ #[serde(rename = "Dolor")] dolor: usize,
+ #[serde(rename = "Amet")] amet: usize,
+}
--- /dev/null
+// rustfmt-space_before_colon: true
+// Space before colon
+
+fn lorem<T : Eq>(t : T) {
+ let ipsum : Dolor = sit;
+}
+
+const LOREM : Lorem = Lorem {
+ ipsum : dolor,
+ sit : amet,
+};
--- /dev/null
+// rustfmt-spaces_around_ranges: false
+// Spaces around ranges
+
+fn main() {
+ let lorem = 0..10;
+}
--- /dev/null
+// rustfmt-spaces_around_ranges: true
+// Spaces around ranges
+
+fn main() {
+ let lorem = 0 .. 10;
+}
--- /dev/null
+// rustfmt-spaces_within_parens_and_brackets: false
+// Spaces within parens and brackets
+
+fn lorem<T: Eq>(t: T) {
+ let lorem = (ipsum, dolor);
+ let lorem: [usize; 2] = [ipsum, dolor];
+}
--- /dev/null
+// rustfmt-spaces_within_parens_and_brackets: true
+// Spaces within parens and brackets
+
+fn lorem< T: Eq >( t: T ) {
+ let lorem = ( ipsum, dolor );
+ let lorem: [ usize; 2 ] = [ ipsum, dolor ];
+}
+
+enum E {
+ A( u32 ),
+ B( u32, u32 ),
+ C( u32, u32, u32 ),
+ D(),
+}
+
+struct TupleStruct0();
+struct TupleStruct1( u32 );
+struct TupleStruct2( u32, u32 );
+
+fn fooEmpty() {}
+
+fn foo( e: E, _: u32 ) -> ( u32, u32 ) {
+ // Tuples
+ let t1 = ();
+ let t2 = ( 1, );
+ let t3 = ( 1, 2 );
+
+ let ts0 = TupleStruct0();
+ let ts1 = TupleStruct1( 1 );
+ let ts2 = TupleStruct2( 1, 2 );
+
+ // Tuple pattern
+ let ( a, b, c ) = ( 1, 2, 3 );
+
+ // Expressions
+ let x = ( 1 + 2 ) * ( 3 );
+
+ // Function call
+ fooEmpty();
+ foo( 1, 2 );
+
+ // Pattern matching
+ match e {
+ A( _ ) => (),
+ B( _, _ ) => (),
+ C( .. ) => (),
+ D => (),
+ }
+
+ ( 1, 2 )
+}
+
+struct Foo< T > {
+ i: T,
+}
+
+struct Bar< T, E > {
+ i: T,
+ e: E,
+}
+
+struct Foo< 'a > {
+ i: &'a str,
+}
+
+enum E< T > {
+ T( T ),
+}
+
+enum E< T, S > {
+ T( T ),
+ S( S ),
+}
+
+fn foo< T >( a: T ) {
+ foo::< u32 >( 10 );
+}
+
+fn foo< T, E >( a: T, b: E ) {
+ foo::< u32, str >( 10, "bar" );
+}
+
+fn foo< T: Send, E: Send >( a: T, b: E ) {
+ foo::< u32, str >( 10, "bar" );
+
+ let opt: Option< u32 >;
+ let res: Result< u32, String >;
+}
+
+fn foo< 'a >( a: &'a str ) {
+ foo( "foo" );
+}
+
+fn foo< 'a, 'b >( a: &'a str, b: &'b str ) {
+ foo( "foo", "bar" );
+}
+
+impl Foo {
+ fn bar() {
+ < Foo as Foo >::bar();
+ }
+}
+
+trait MyTrait< A, D > {}
+impl< A: Send, D: Send > MyTrait< A, D > for Foo {}
+
+fn foo()
+where
+ for< 'a > u32: 'a,
+{
+}
+
+fn main() {
+ let arr: [ i32; 5 ] = [ 1, 2, 3, 4, 5 ];
+ let arr: [ i32; 500 ] = [ 0; 500 ];
+
+ let v = vec![ 1, 2, 3 ];
+ assert_eq!( arr, [ 1, 2, 3 ] );
+
+ let i = arr[ 0 ];
+
+ let slice = &arr[ 1..2 ];
+
+ let line100_________________________________________________________________________ = [ 1, 2 ];
+ let line101__________________________________________________________________________ =
+ [ 1, 2 ];
+ let line102___________________________________________________________________________ =
+ [ 1, 2 ];
+ let line103____________________________________________________________________________ =
+ [ 1, 2 ];
+ let line104_____________________________________________________________________________ =
+ [ 1, 2 ];
+
+ let line100_____________________________________________________________________ = vec![ 1, 2 ];
+ let line101______________________________________________________________________ =
+ vec![ 1, 2 ];
+ let line102_______________________________________________________________________ =
+ vec![ 1, 2 ];
+ let line103________________________________________________________________________ =
+ vec![ 1, 2 ];
+ let line104_________________________________________________________________________ =
+ vec![ 1, 2 ];
+}
+
+fn f( slice: &[ i32 ] ) {}
--- /dev/null
+// rustfmt-struct_field_align_threshold: 20
+// rustfmt-normalize_comments: true
+// rustfmt-wrap_comments: true
+// rustfmt-error_on_line_overflow: false
+
+struct Foo {
+ x: u32,
+ yy: u32, // comment
+ zzz: u32,
+}
+
+pub struct Bar {
+ x: u32,
+ yy: u32,
+ zzz: u32,
+
+ xxxxxxx: u32,
+}
+
+fn main() {
+ let foo = Foo {
+ x: 0,
+ yy: 1,
+ zzz: 2,
+ };
+
+ let bar = Bar {
+ x: 0,
+ yy: 1,
+ zzz: 2,
+
+ xxxxxxx: 3,
+ };
+}
+
+/// A Doc comment
+#[AnAttribute]
+pub struct Foo {
+ #[rustfmt_skip]
+ f : SomeType, // Comment beside a field
+ f: SomeType, // Comment beside a field
+ // Comment on a field
+ #[AnAttribute] g: SomeOtherType,
+ /// A doc comment on a field
+ h: AThirdType,
+ pub i: TypeForPublicField,
+}
+
+// #1029
+pub struct Foo {
+ #[doc(hidden)]
+ // This will NOT get deleted!
+ bar: String, // hi
+}
+
+// #1029
+struct X {
+ // `x` is an important number.
+ #[allow(unused)] // TODO: use
+ x: u32,
+}
+
+// #410
+#[allow(missing_docs)]
+pub struct Writebatch<K: Key> {
+ #[allow(dead_code)] // only used for holding the internal pointer
+ writebatch: RawWritebatch,
+ marker: PhantomData<K>,
+}
+
+struct Bar;
+
+struct NewType(Type, OtherType);
+
+struct NewInt<T: Copy>(
+ pub i32,
+ SomeType, // inline comment
+ T, // sup
+);
+
+struct Qux<
+ 'a,
+ N: Clone + 'a,
+ E: Clone + 'a,
+ G: Labeller<'a, N, E> + GraphWalk<'a, N, E>,
+ W: Write + Copy,
+>(
+ AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA, // Comment
+ BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB,
+ #[AnAttr]
+ // Comment
+ /// Testdoc
+ G,
+ pub W,
+);
+
+struct Tuple(
+ // Comment 1
+ AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA,
+ // Comment 2
+ BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB,
+);
+
+// With a where clause and generics.
+pub struct Foo<'a, Y: Baz>
+where
+ X: Whatever,
+{
+ f: SomeType, // Comment beside a field
+}
+
+struct Baz {
+ a: A, // Comment A
+ b: B, // Comment B
+ c: C, // Comment C
+}
+
+struct Baz {
+ a: A, // Comment A
+
+ b: B, // Comment B
+
+ c: C, // Comment C
+}
+
+struct Baz {
+ a: A,
+
+ b: B,
+ c: C,
+
+ d: D,
+}
+
+struct Baz {
+ // Comment A
+ a: A,
+
+ // Comment B
+ b: B,
+ // Comment C
+ c: C,
+}
+
+// Will this be a one-liner?
+struct Tuple(
+ A, // Comment
+ B,
+);
+
+pub struct State<F: FnMut() -> time::Timespec> {
+ now: F,
+}
+
+pub struct State<F: FnMut() -> ()> {
+ now: F,
+}
+
+pub struct State<F: FnMut()> {
+ now: F,
+}
+
+struct Palette {
+ /// A map of indices in the palette to a count of pixels in approximately
+ /// that color
+ foo: i32,
+}
+
+// Splitting a single line comment into a block previously had a misalignment
+// when the field had attributes
+struct FieldsWithAttributes {
+ // Pre Comment
+ #[rustfmt_skip] pub host:String, /* Post comment BBBBBBBBBBBBBB BBBBBBBBBBBBBBBB
+ * BBBBBBBBBBBBBBBB BBBBBBBBBBBBBBBBB BBBBBBBBBBB */
+ // Another pre comment
+ #[attr1]
+ #[attr2]
+ pub id: usize, /* CCCCCCCCCCCCCCCCCCC CCCCCCCCCCCCCCCCCCC CCCCCCCCCCCCCCCC
+ * CCCCCCCCCCCCCCCCCC CCCCCCCCCCCCCC CCCCCCCCCCCC */
+}
+
+struct Deep {
+ deeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeep:
+ node::Handle<IdRef<'id, Node<K, V>>, Type, NodeType>,
+}
+
+struct Foo<T>(T);
+struct Foo<T>(T)
+where
+ T: Copy,
+ T: Eq;
+struct Foo<T>(
+ TTTTTTTTTTTTTTTTT,
+ UUUUUUUUUUUUUUUUUUUUUUUU,
+ TTTTTTTTTTTTTTTTTTT,
+ UUUUUUUUUUUUUUUUUUU,
+);
+struct Foo<T>(
+ TTTTTTTTTTTTTTTTTT,
+ UUUUUUUUUUUUUUUUUUUUUUUU,
+ TTTTTTTTTTTTTTTTTTT,
+)
+where
+ T: PartialEq;
+struct Foo<T>(
+ TTTTTTTTTTTTTTTTT,
+ UUUUUUUUUUUUUUUUUUUUUUUU,
+ TTTTTTTTTTTTTTTTTTTTT,
+)
+where
+ T: PartialEq;
+struct Foo<T>(
+ TTTTTTTTTTTTTTTTT,
+ UUUUUUUUUUUUUUUUUUUUUUUU,
+ TTTTTTTTTTTTTTTTTTT,
+ UUUUUUUUUUUUUUUUUUU,
+)
+where
+ T: PartialEq;
+struct Foo<T>(
+ TTTTTTTTTTTTTTTTT, // Foo
+ UUUUUUUUUUUUUUUUUUUUUUUU, // Bar
+ // Baz
+ TTTTTTTTTTTTTTTTTTT,
+ // Qux (FIXME #572 - doc comment)
+ UUUUUUUUUUUUUUUUUUU,
+);
+
+mod m {
+ struct X<T>
+ where
+ T: Sized,
+ {
+ a: T,
+ }
+}
+
+struct Foo<T>(
+ TTTTTTTTTTTTTTTTTTT,
+ /// Qux
+ UUUUUUUUUUUUUUUUUUU,
+);
+
+struct Issue677 {
+ pub ptr: *const libc::c_void,
+ pub trace: fn(obj: *const libc::c_void, tracer: *mut JSTracer),
+}
+
+struct Foo {}
+struct Foo {}
+struct Foo {
+ // comment
+}
+struct Foo {
+ // trailing space ->
+}
+struct Foo { /* comment */ }
+struct Foo( /* comment */ );
+
+struct LongStruct {
+ a: A,
+ the_quick_brown_fox_jumps_over_the_lazy_dog:
+ AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA,
+}
+
+struct Deep {
+ deeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeep:
+ node::Handle<IdRef<'id, Node<Key, Value>>, Type, NodeType>,
+}
+
+struct Foo<C = ()>(String);
+
+// #1364
+fn foo() {
+ convex_shape.set_point(0, &Vector2f { x: 400.0, y: 100.0 });
+ convex_shape.set_point(1, &Vector2f { x: 500.0, y: 70.0 });
+ convex_shape.set_point(2, &Vector2f { x: 450.0, y: 100.0 });
+ convex_shape.set_point(3, &Vector2f { x: 580.0, y: 150.0 });
+}
+
+fn main() {
+ let x = Bar;
+
+ // Comment
+ let y = Foo { a: x };
+
+ Foo {
+ a: foo(), // comment
+ // comment
+ b: bar(),
+ ..something
+ };
+
+ Fooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo { a: f(), b: b() };
+
+ Foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo {
+ a: f(),
+ b: b(),
+ };
+
+ Foooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo {
+ // Comment
+ a: foo(), // Comment
+ // Comment
+ b: bar(), // Comment
+ };
+
+ Foo { a: Bar, b: f() };
+
+ Quux {
+ x: if cond {
+ bar();
+ },
+ y: baz(),
+ };
+
+ A {
+ // Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec a diam lectus. Sed sit
+ // amet ipsum mauris. Maecenas congue ligula ac quam viverra nec consectetur ante
+ // hendrerit. Donec et mollis dolor.
+ first: item(),
+ // Praesent et diam eget libero egestas mattis sit amet vitae augue.
+ // Nam tincidunt congue enim, ut porta lorem lacinia consectetur.
+ second: Item,
+ };
+
+ Some(Data::MethodCallData(MethodCallData {
+ span: sub_span.unwrap(),
+ scope: self.enclosing_scope(id),
+ ref_id: def_id,
+ decl_id: Some(decl_id),
+ }));
+
+ Diagram {
+ // o This graph demonstrates how
+ // / \ significant whitespace is
+ // o o preserved.
+ // /|\ \
+ // o o o o
+ graph: G,
+ }
+}
+
+fn matcher() {
+ TagTerminatedByteMatcher {
+ matcher: ByteMatcher {
+ pattern: b"<HTML",
+ mask: b"\xFF\xDF\xDF\xDF\xDF\xFF",
+ },
+ };
+}
+
+fn issue177() {
+ struct Foo<T> {
+ memb: T,
+ }
+ let foo = Foo::<i64> { memb: 10 };
+}
+
+fn issue201() {
+ let s = S { a: 0, ..b };
+}
+
+fn issue201_2() {
+ let s = S { a: S2 { ..c }, ..b };
+}
+
+fn issue278() {
+ let s = S {
+ a: 0,
+ //
+ b: 0,
+ };
+ let s1 = S {
+ a: 0,
+ // foo
+ //
+ // bar
+ b: 0,
+ };
+}
+
+fn struct_exprs() {
+ Foo { a: 1, b: f(2) };
+ Foo {
+ a: 1,
+ b: f(2),
+ ..g(3)
+ };
+ LoooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooongStruct {
+ ..base
+ };
+ IntrinsicISizesContribution {
+ content_intrinsic_sizes: IntrinsicISizes {
+ minimum_inline_size: 0,
+ },
+ };
+}
+
+fn issue123() {
+ Foo { a: b, c: d, e: f };
+
+ Foo {
+ a: bb,
+ c: dd,
+ e: ff,
+ };
+
+ Foo {
+ a: ddddddddddddddddddddd,
+ b: cccccccccccccccccccccccccccccccccccccc,
+ };
+}
+
+fn issue491() {
+ Foo {
+ guard: None,
+ arm: 0, // Comment
+ };
+
+ Foo {
+ arm: 0, // Comment
+ };
+
+ Foo {
+ a: aaaaaaaaaa,
+ b: bbbbbbbb,
+ c: cccccccccc,
+ d: dddddddddd, // a comment
+ e: eeeeeeeee,
+ };
+}
+
+fn issue698() {
+ Record {
+ ffffffffffffffffffffffffffields: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
+ };
+ Record {
+ ffffffffffffffffffffffffffields:
+ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
+ }
+}
+
+fn issue835() {
+ MyStruct {};
+ MyStruct { /* a comment */ };
+ MyStruct {
+ // Another comment
+ };
+ MyStruct {}
+}
+
+fn field_init_shorthand() {
+ MyStruct { x, y, z };
+ MyStruct { x, y, z, ..base };
+ Foo {
+ aaaaaaaaaa,
+ bbbbbbbb,
+ cccccccccc,
+ dddddddddd, // a comment
+ eeeeeeeee,
+ };
+ Record {
+ ffffffffffffffffffffffffffieldsaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
+ };
+}
--- /dev/null
+// rustfmt-indent_style: Block
+// Struct literal-style
+
+fn main() {
+ let lorem = Lorem {
+ ipsum: dolor,
+ sit: amet,
+ };
+}
--- /dev/null
+// rustfmt-indent_style: Visual
+// Struct literal-style
+
+fn main() {
+ let lorem = Lorem { ipsum: dolor,
+ sit: amet, };
+}
--- /dev/null
+// rustfmt-struct_lit_single_line: false
+// Struct literal multiline-style
+
+fn main() {
+ let lorem = Lorem {
+ ipsum: dolor,
+ sit: amet,
+ };
+}
--- /dev/null
+// rustfmt-tab_spaces: 2
+// rustfmt-max_width: 30
+// rustfmt-indent_style: Block
+// Tab spaces
+
+fn lorem() {
+ let ipsum = dolor();
+ let sit = vec![
+ "amet",
+ "consectetur",
+ "adipiscing",
+ "elit.",
+ ];
+}
--- /dev/null
+// rustfmt-tab_spaces: 4
+// rustfmt-max_width: 30
+// rustfmt-indent_style: Block
+// Tab spaces
+
+fn lorem() {
+ let ipsum = dolor();
+ let sit = vec![
+ "amet",
+ "consectetur",
+ "adipiscing",
+ "elit.",
+ ];
+}
--- /dev/null
+// rustfmt-trailing_comma: Always
+// Trailing comma
+
+fn main() {
+ let Lorem { ipsum, dolor, sit, } = amet;
+ let Lorem {
+ ipsum,
+ dolor,
+ sit,
+ amet,
+ consectetur,
+ adipiscing,
+ } = elit;
+}
--- /dev/null
+// rustfmt-trailing_comma: Never
+// Trailing comma
+
+fn main() {
+ let Lorem { ipsum, dolor, sit } = amet;
+ let Lorem {
+ ipsum,
+ dolor,
+ sit,
+ amet,
+ consectetur,
+ adipiscing
+ } = elit;
+
+ // #1544
+ if let VrMsg::ClientReply {
+ request_num: reply_req_num,
+ value,
+ ..
+ } = msg
+ {
+ let _ = safe_assert_eq!(reply_req_num, request_num, op);
+ return Ok((request_num, op, value));
+ }
+
+ // #1710
+ pub struct FileInput {
+ input: StringInput,
+ file_name: OsString
+ }
+ match len {
+ Some(len) => Ok(new(self.input, self.pos + len)),
+ None => Err(self)
+ }
+}
--- /dev/null
+// rustfmt-trailing_comma: Vertical
+// Trailing comma
+
+fn main() {
+ let Lorem { ipsum, dolor, sit } = amet;
+ let Lorem {
+ ipsum,
+ dolor,
+ sit,
+ amet,
+ consectetur,
+ adipiscing,
+ } = elit;
+}
--- /dev/null
+// rustfmt-trailing_semicolon: false
+
+#![feature(loop_break_value)]
+
+fn main() {
+ 'a: loop {
+ break 'a
+ }
+
+ let mut done = false;
+ 'b: while !done {
+ done = true;
+ continue 'b
+ }
+
+ let x = loop {
+ break 5
+ };
+
+ let x = 'c: loop {
+ break 'c 5
+ };
+}
+
+fn foo() -> usize {
+ return 0
+}
--- /dev/null
+// rustfmt-trailing_semicolon: true
+
+#![feature(loop_break_value)]
+
+fn main() {
+ 'a: loop {
+ break 'a;
+ }
+
+ let mut done = false;
+ 'b: while !done {
+ done = true;
+ continue 'b;
+ }
+
+ let x = loop {
+ break 5;
+ };
+
+ let x = 'c: loop {
+ break 'c 5;
+ };
+}
+
+fn foo() -> usize {
+ return 0;
+}
--- /dev/null
+// rustfmt-type_punctuation_density: Compressed
+// Type punctuation density
+
+fn lorem<Ipsum: Dolor+Sit=Amet>() {
+ // body
+}
--- /dev/null
+// rustfmt-type_punctuation_density: Wide
+// Type punctuation density
+
+fn lorem<Ipsum: Dolor + Sit = Amet>() {
+ // body
+}
--- /dev/null
+// rustfmt-use_try_shorthand: false
+// Use try! shorthand
+
+fn main() {
+ let lorem = try!(ipsum.map(|dolor| dolor.sit()));
+}
--- /dev/null
+// rustfmt-use_try_shorthand: true
+// Use try! shorthand
+
+fn main() {
+ let lorem = ipsum.map(|dolor| dolor.sit())?;
+}
--- /dev/null
+// rustfmt-indent_style: Block
+// Where predicate indent
+
+fn lorem<Ipsum, Dolor, Sit, Amet>() -> T
+where
+ Ipsum: Eq,
+ Dolor: Eq,
+ Sit: Eq,
+ Amet: Eq,
+{
+ // body
+}
--- /dev/null
+// rustfmt-indent_style: Visual
+// Where predicate indent
+
+fn lorem<Ipsum, Dolor, Sit, Amet>() -> T
+ where Ipsum: Eq,
+ Dolor: Eq,
+ Sit: Eq,
+ Amet: Eq
+{
+ // body
+}
--- /dev/null
+// rustfmt-where_single_line: true
+// Where style
+
+fn lorem_two_items<Ipsum, Dolor, Sit, Amet>() -> T
+where
+ Ipsum: Eq,
+ Lorem: Eq,
+{
+ // body
+}
+
+fn lorem_multi_line<Ipsum, Dolor, Sit, Amet>(
+ a: Aaaaaaaaaaaaaaa,
+ b: Bbbbbbbbbbbbbbbb,
+ c: Ccccccccccccccccc,
+ d: Ddddddddddddddddddddddddd,
+ e: Eeeeeeeeeeeeeeeeeee,
+) -> T
+where
+ Ipsum: Eq,
+{
+ // body
+}
+
+fn lorem<Ipsum, Dolor, Sit, Amet>() -> T
+where Ipsum: Eq {
+ // body
+}
--- /dev/null
+// rustfmt-indent_style: Visual
+// Where style
+
+fn lorem<Ipsum, Dolor, Sit, Amet>() -> T
+ where Ipsum: Eq,
+ Dolor: Eq,
+ Sit: Eq,
+ Amet: Eq
+{
+ // body
+}
--- /dev/null
+// rustfmt-indent_style: Block
+// Where style
+
+fn lorem<Ipsum, Dolor, Sit, Amet>() -> T
+where
+ Ipsum: Eq,
+ Dolor: Eq,
+ Sit: Eq,
+ Amet: Eq,
+{
+ // body
+}
--- /dev/null
+// rustfmt-wrap_comments: false
+// rustfmt-max_width: 50
+// rustfmt-error_on_line_overflow: false
+// Wrap comments
+
+fn main() {
+ // Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
+}
--- /dev/null
+// rustfmt-wrap_comments: true
+// rustfmt-max_width: 50
+// Wrap comments
+
+fn main() {
+ // Lorem ipsum dolor sit amet, consectetur
+ // adipiscing elit, sed do eiusmod tempor
+ // incididunt ut labore et dolore magna
+ // aliqua. Ut enim ad minim veniam, quis
+ // nostrud exercitation ullamco laboris nisi
+ // ut aliquip ex ea commodo consequat.
+}
+
+fn code_block() {
+ // ```rust
+ // let x = 3;
+ //
+ // println!("x = {}", x);
+ // ```
+}