1 // check-pass
2 #![allow(dead_code)]
3 #![allow(unused_mut)]
4 /*
5 # if b { x } else { y } requires identical types for x and y
6 */
7
print1(b: bool, s1: &str, s2: &str)8 fn print1(b: bool, s1: &str, s2: &str) {
9 println!("{}", if b { s1 } else { s2 });
10 }
print2<'a, 'b>(b: bool, s1: &'a str, s2: &'b str)11 fn print2<'a, 'b>(b: bool, s1: &'a str, s2: &'b str) {
12 println!("{}", if b { s1 } else { s2 });
13 }
print3(b: bool, s1: &str, s2: &str)14 fn print3(b: bool, s1: &str, s2: &str) {
15 let mut s: &str;
16 if b { s = s1; } else { s = s2; }
17 println!("{}", s);
18 }
print4<'a, 'b>(b: bool, s1: &'a str, s2: &'b str)19 fn print4<'a, 'b>(b: bool, s1: &'a str, s2: &'b str) {
20 let mut s: &str;
21 if b { s = s1; } else { s = s2; }
22 println!("{}", s);
23 }
24
main()25 pub fn main() {}
26