1 // Checks for `if` expressions with respect to default match bindings.
2 // Specifically, we do not accept `if cond { ... }` where `cond: &mut? bool`.
3 // Meanwhile, `match cond { true => ..., _ => ... }` does accept that.
5 // FIXME(@rust-lang/lang-team): consider relaxing this?
7 fn b_ref<'a>() -> &'a bool { &true }
8 fn b_mut_ref<'a>() -> &'a mut bool { &mut true }
12 match b_ref() { true => {}, _ => {} }
13 match b_mut_ref() { true => {}, _ => {} }
14 match &true { true => {}, _ => {} }
15 match &mut true { true => {}, _ => {} }
18 if b_ref() {} //~ ERROR mismatched types [E0308]
19 if b_mut_ref() {} //~ ERROR mismatched types [E0308]
20 if &true {} //~ ERROR mismatched types [E0308]
21 if &mut true {} //~ ERROR mismatched types [E0308]
24 while b_ref() {} //~ ERROR mismatched types [E0308]
25 while b_mut_ref() {} //~ ERROR mismatched types [E0308]
26 while &true {} //~ ERROR mismatched types [E0308]
27 while &mut true {} //~ ERROR mismatched types [E0308]