Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
25 changes: 25 additions & 0 deletions tests/ui/lub-glb/if-else-arms-use-lub.rs

@zedddie zedddie Jul 15, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this one doesn't seem to be a move (it also overlaps with #159308 which is already merged, so this will likely produce a duplicate).

View changes since the review

Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//@ check-pass
#![allow(dead_code)]
#![allow(unused_mut)]
/*
# if b { x } else { y } requires identical types for x and y
*/

fn print1(b: bool, s1: &str, s2: &str) {
println!("{}", if b { s1 } else { s2 });
}
fn print2<'a, 'b>(b: bool, s1: &'a str, s2: &'b str) {
println!("{}", if b { s1 } else { s2 });
}
fn print3(b: bool, s1: &str, s2: &str) {
let mut s: &str;
if b { s = s1; } else { s = s2; }
println!("{}", s);
}
fn print4<'a, 'b>(b: bool, s1: &'a str, s2: &'b str) {
let mut s: &str;
if b { s = s1; } else { s = s2; }
println!("{}", s);
}

pub fn main() {}