mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-30 05:45:12 +00:00
fix: False positive diagnostic for necessary else
This commit is contained in:
parent
ac1029fac3
commit
e9c80a9c25
2 changed files with 30 additions and 1 deletions
|
@ -384,6 +384,29 @@ fn test() {
|
|||
return bar;
|
||||
}
|
||||
}
|
||||
"#,
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn no_diagnostic_if_tail_exists_in_else_branch() {
|
||||
check_diagnostics_with_needless_return_disabled(
|
||||
r#"
|
||||
fn test1(a: bool) {
|
||||
let _x = if a {
|
||||
return;
|
||||
} else {
|
||||
1
|
||||
};
|
||||
}
|
||||
|
||||
fn test2(a: bool) -> i32 {
|
||||
if a {
|
||||
return 1;
|
||||
} else {
|
||||
0
|
||||
}
|
||||
}
|
||||
"#,
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue