4 #![allow(unused_variables, unused_assignments, similar_names, blacklisted_name)]
5 #![deny(useless_let_if_seq)]
7 fn f() -> bool { true }
8 fn g(x: i32) -> i32 { x + 1 }
10 fn issue985() -> i32 {
19 fn issue985_alt() -> i32 {
30 fn issue975() -> String {
31 let mut udn = "dummy".to_string();
32 if udn.starts_with("uuid:") {
33 udn = String::from(&udn[5..]);
38 fn early_return() -> u8 {
39 // FIXME: we could extend the lint to include such cases:
58 //~^ ERROR `if _ { .. } else { .. }` is an expression
59 //~| HELP more idiomatic
60 //~| SUGGESTION let <mut> foo = if f() { 42 } else { 0 };
66 //~^ ERROR `if _ { .. } else { .. }` is an expression
67 //~| HELP more idiomatic
68 //~| SUGGESTION let <mut> bar = if f() { ..; 42 } else { ..; 0 };
78 //~^ ERROR `if _ { .. } else { .. }` is an expression
79 //~| HELP more idiomatic
80 //~| SUGGESTION let quz = if f() { 42 } else { 0 };
88 // `toto` is used several times
101 // found in libcore, the inner if is not a statement but the block's expr
110 // baz needs to be mut
112 //~^ ERROR `if _ { .. } else { .. }` is an expression
113 //~| HELP more idiomatic
114 //~| SUGGESTION let <mut> baz = if f() { 42 } else { 0 };