]> git.lizzy.rs Git - rust.git/blob - tests/target/hard-tabs.rs
Replace various small width heuristics with a single option
[rust.git] / tests / target / hard-tabs.rs
1 // rustfmt-normalize_comments: true
2 // rustfmt-wrap_comments: true
3 // rustfmt-hard_tabs: true
4 // rustfmt-error_on_line_overflow: false
5
6 fn main() {
7         let x = Bar;
8
9         let y = Foo { a: x };
10
11         Foo {
12                 a: foo(), // comment
13                 // comment
14                 b: bar(),
15                 ..something
16         };
17
18         fn foo(a: i32, a: i32, a: i32, a: i32, a: i32, a: i32, a: i32, a: i32, a: i32, a: i32, a: i32) {
19         }
20
21         let str = "AAAAAAAAAAAAAAaAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAaAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAaAa";
22
23         if let (
24                 some_very_large,
25                 tuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuple,
26         ) = 1 + 2 + 3
27         {}
28
29         if cond() {
30                 something();
31         } else if different_cond() {
32                 something_else();
33         } else {
34                 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
35                         + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
36         }
37
38         unsafe /* very looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong
39                 * comment */ {
40         }
41
42         unsafe /* So this is a very long comment.
43                 * Multi-line, too.
44                 * Will it still format correctly? */ {
45         }
46
47         let chain = funktion_kall()
48                 .go_to_next_line_with_tab()
49                 .go_to_next_line_with_tab()
50                 .go_to_next_line_with_tab();
51
52         let z = [
53                 xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx,
54                 yyyyyyyyyyyyyyyyyyyyyyyyyyy,
55                 zzzzzzzzzzzzzzzzzz,
56                 q,
57         ];
58
59         fn generic<T>(arg: T) -> &SomeType
60         where
61                 T: Fn(
62                         // First arg
63                         A,
64                         // Second argument
65                         B,
66                         C,
67                         D,
68                         // pre comment
69                         E, // last comment
70                 ) -> &SomeType,
71         {
72                 arg(a, b, c, d, e)
73         }
74
75         loong_func().quux(move || if true { 1 } else { 2 });
76
77         fffffffffffffffffffffffffffffffffff(a, {
78                 SCRIPT_TASK_ROOT.with(|root| {
79                         *root.borrow_mut() = Some(&script_task);
80                 });
81         });
82         a.b.c.d();
83
84         x().y(|| match cond() {
85                 true => (),
86                 false => (),
87         });
88 }