Fix applicable on let-else for convert_to_guarded_return
Example
---
```rust
fn foo() -> bool {
let$0 Some(x) = Some(2) else { return false };
}
```
**Before this PR**:
```rust
fn foo() -> bool {
let Some(Some(x)) = Some(2) else { return };
}
```
**After this PR**:
Assist not applicable
This commit is contained in:
parent
986bb35e75
commit
1597162eea
1 changed files with 14 additions and 1 deletions
|
|
@ -182,7 +182,7 @@ fn let_stmt_to_guarded_return(
|
|||
let cursor_in_range =
|
||||
let_token_range.cover(let_pattern_range).contains_range(ctx.selection_trimmed());
|
||||
|
||||
if !cursor_in_range {
|
||||
if !cursor_in_range || let_stmt.let_else().is_some() {
|
||||
return None;
|
||||
}
|
||||
|
||||
|
|
@ -911,6 +911,19 @@ fn main() {
|
|||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ignore_let_else_branch() {
|
||||
check_assist_not_applicable(
|
||||
convert_to_guarded_return,
|
||||
r#"
|
||||
//- minicore: option
|
||||
fn main() {
|
||||
let$0 Some(x) = Some(2) else { return };
|
||||
}
|
||||
"#,
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ignore_statements_after_if() {
|
||||
check_assist_not_applicable(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue