1 #![allow(dead_code, clippy::eval_order_dependence)]
2 #![deny(clippy::if_same_then_else, clippy::shared_code_in_if_blocks)]
4 // This tests the shared_code_in_if_blocks 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");