]> git.proxmox.com Git - rustc.git/blob - src/tools/clippy/tests/ui-toml/functions_maxlines/test.rs
New upstream version 1.62.1+dfsg1
[rustc.git] / src / tools / clippy / tests / ui-toml / functions_maxlines / test.rs
1 #![warn(clippy::too_many_lines)]
2 #![allow(clippy::let_unit_value)]
3
4 // This function should be considered one line.
5 fn many_comments_but_one_line_of_code() {
6 /* println!("This is good."); */
7 // println!("This is good.");
8 /* */ // println!("This is good.");
9 /* */ // println!("This is good.");
10 /* */ // println!("This is good.");
11 /* */ // println!("This is good.");
12 /* println!("This is good.");
13 println!("This is good.");
14 println!("This is good."); */
15 println!("This is good.");
16 }
17
18 // This should be considered two and a fail.
19 fn too_many_lines() {
20 println!("This is bad.");
21 println!("This is bad.");
22 }
23
24 // This should only fail once (#7517).
25 async fn async_too_many_lines() {
26 println!("This is bad.");
27 println!("This is bad.");
28 }
29
30 // This should fail only once, without failing on the closure.
31 fn closure_too_many_lines() {
32 let _ = {
33 println!("This is bad.");
34 println!("This is bad.");
35 };
36 }
37
38 // This should be considered one line.
39 #[rustfmt::skip]
40 fn comment_starts_after_code() {
41 let _ = 5; /* closing comment. */ /*
42 this line shouldn't be counted theoretically.
43 */
44 }
45
46 // This should be considered one line.
47 fn comment_after_code() {
48 let _ = 5; /* this line should get counted once. */
49 }
50
51 // This should fail since it is technically two lines.
52 #[rustfmt::skip]
53 fn comment_before_code() {
54 let _ = "test";
55 /* This comment extends to the front of
56 the code but this line should still count. */ let _ = 5;
57 }
58
59 // This should be considered one line.
60 fn main() {}