mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-11-10 23:24:29 +00:00
fix block with no termination in or patterns
This commit is contained in:
parent
8ce5a53934
commit
8593132a43
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::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]
|
||||
fn respect_allow_unused_mut() {
|
||||
// FIXME: respect
|
||||
|
|
Loading…
Reference in a new issue