1 #![allow(dead_code, clippy::eval_order_dependence)]
2 #![deny(clippy::if_same_then_else, clippy::branches_sharing_code)]
4 // This tests the branches_sharing_code lint at the start of blocks
11 println!("Hello World!");
12 println!("I'm branch nr: 1");
14 println!("Hello World!");
15 println!("I'm branch nr: 2");
21 println!("The value y was set to: `{}`", y);
24 println!("I'm the true start index of arrays");
27 println!("The value y was set to: `{}`", y);
30 println!("I start counting from 1 so my array starts from `1`");
33 println!("The value y was set to: `{}`", y);
36 println!("Ha, Pascal allows you to start the array where you want")
42 println!("What can I say except: \"you're welcome?\"");
47 println!("Thank you");
52 /// Simple examples where the move can cause some problems due to moved values
53 fn simple_but_suggestion_is_invalid() {
56 // Can't be automatically moved because used_value_name is getting used again
57 let used_value_name = 19;
59 let used_value_name = "Different type";
60 println!("Str: {}", used_value_name);
63 let used_value_name = "Different type";
64 println!("Str: {}", used_value_name);
67 let _ = used_value_name;
69 // This can be automatically moved as `can_be_overridden` is not used again
70 let can_be_overridden = 8;
71 let _ = can_be_overridden;
73 let can_be_overridden = "Move me";
74 println!("I'm also moveable");
77 let can_be_overridden = "Move me";
78 println!("I'm also moveable");
83 /// This function tests that the `IS_SAME_THAN_ELSE` only covers the lint if it's enabled.
84 fn check_if_same_than_else_mask() {
87 #[allow(clippy::if_same_then_else)]
89 println!("This should trigger the `SHARED_CODE_IN_IF_BLOCKS` lint.");
90 println!("Because `IF_SAME_THEN_ELSE` is allowed here");
92 println!("This should trigger the `SHARED_CODE_IN_IF_BLOCKS` lint.");
93 println!("Because `IF_SAME_THEN_ELSE` is allowed here");
97 println!("This should trigger `IS_SAME_THAN_ELSE` as usual");
99 println!("This should trigger `IS_SAME_THAN_ELSE` as usual");
103 #[allow(clippy::vec_init_then_push)]
104 fn pf_local_with_inferred_type_issue7053() {
106 let mut v = Vec::new();
109 let mut v = Vec::new();