summaryrefslogtreecommitdiffstats
path: root/src/tools/rustfmt/tests/target/hard-tabs.rs
blob: aca7e09c0eacf1cada3a0d02ee4471c171194e30 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
// rustfmt-normalize_comments: true
// rustfmt-wrap_comments: true
// rustfmt-hard_tabs: true

fn main() {
	let x = Bar;

	let y = Foo { a: x };

	Foo {
		a: foo(), // comment
		// comment
		b: bar(),
		..something
	};

	fn foo(a: i32, a: i32, a: i32, a: i32, a: i32, a: i32, a: i32, a: i32, a: i32, a: i32, a: i32) {
	}

	let str = "AAAAAAAAAAAAAAaAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAaAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAaAa";

	if let (
		some_very_large,
		tuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuple,
	) = 1 + 2 + 3
	{}

	if cond() {
		something();
	} else if different_cond() {
		something_else();
	} else {
		aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
			+ aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
	}

	unsafe /* very looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong
	        * comment */ {
	}

	unsafe /* So this is a very long comment.
	        * Multi-line, too.
	        * Will it still format correctly? */ {
	}

	let chain = funktion_kall()
		.go_to_next_line_with_tab()
		.go_to_next_line_with_tab()
		.go_to_next_line_with_tab();

	let z = [
		xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx,
		yyyyyyyyyyyyyyyyyyyyyyyyyyy,
		zzzzzzzzzzzzzzzzzz,
		q,
	];

	fn generic<T>(arg: T) -> &SomeType
	where
		T: Fn(
			// First arg
			A,
			// Second argument
			B,
			C,
			D,
			// pre comment
			E, // last comment
		) -> &SomeType,
	{
		arg(a, b, c, d, e)
	}

	loong_func().quux(move || if true { 1 } else { 2 });

	fffffffffffffffffffffffffffffffffff(a, {
		SCRIPT_TASK_ROOT.with(|root| {
			*root.borrow_mut() = Some(&script_task);
		});
	});
	a.b.c.d();

	x().y(|| match cond() {
		true => (),
		false => (),
	});
}

// #2296
impl Foo {
	// a comment
	// on multiple lines
	fn foo() {
		// another comment
		// on multiple lines
		let x = true;
	}
}