Auto merge of #14306 - HKalbasi:master, r=HKalbasi
fix block with no termination in or patterns fix #14298
This commit is contained in:
commit
14b9d182d5
2 changed files with 26 additions and 1 deletions
|
@ -1039,7 +1039,11 @@ impl MirLowerCtx<'_> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
(then_target, (!finished).then_some(current))
|
if !finished {
|
||||||
|
let ce = *current_else.get_or_insert_with(|| self.new_basic_block());
|
||||||
|
self.set_goto(current, ce);
|
||||||
|
}
|
||||||
|
(then_target, current_else)
|
||||||
}
|
}
|
||||||
Pat::Record { .. } => not_supported!("record pattern"),
|
Pat::Record { .. } => not_supported!("record pattern"),
|
||||||
Pat::Range { .. } => not_supported!("range pattern"),
|
Pat::Range { .. } => not_supported!("range pattern"),
|
||||||
|
|
|
@ -574,6 +574,27 @@ fn main() {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn or_pattern_no_terminator() {
|
||||||
|
check_diagnostics(
|
||||||
|
r#"
|
||||||
|
enum Foo {
|
||||||
|
A, B, C, D
|
||||||
|
}
|
||||||
|
|
||||||
|
use Foo::*;
|
||||||
|
|
||||||
|
fn f(inp: (Foo, Foo, Foo, Foo)) {
|
||||||
|
let ((A, B, _, x) | (B, C | D, x, _)) = inp else {
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
x = B;
|
||||||
|
//^^^^^ 💡 error: cannot mutate immutable variable `x`
|
||||||
|
}
|
||||||
|
"#,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn respect_allow_unused_mut() {
|
fn respect_allow_unused_mut() {
|
||||||
// FIXME: respect
|
// FIXME: respect
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue