]> git.lizzy.rs Git - rust.git/blob - src/test/run-pass/issues/issue-4025.rs
41af0826c00aa5089c476524b4d62c34faf4d399
[rust.git] / src / test / run-pass / issues / issue-4025.rs
1 // Copyright 2013 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 // run-pass
12 #![allow(dead_code)]
13 #![allow(unused_mut)]
14 /*
15 # if b { x } else { y } requires identical types for x and y
16 */
17
18 fn print1(b: bool, s1: &str, s2: &str) {
19     println!("{}", if b { s1 } else { s2 });
20 }
21 fn print2<'a, 'b>(b: bool, s1: &'a str, s2: &'b str) {
22     println!("{}", if b { s1 } else { s2 });
23 }
24 fn print3(b: bool, s1: &str, s2: &str) {
25     let mut s: &str;
26     if b { s = s1; } else { s = s2; }
27     println!("{}", s);
28 }
29 fn print4<'a, 'b>(b: bool, s1: &'a str, s2: &'b str) {
30     let mut s: &str;
31     if b { s = s1; } else { s = s2; }
32     println!("{}", s);
33 }
34
35 pub fn main() {}