mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-27 02:06:57 +00:00
Merge pull request #20688 from A4-Tacks/fix-applicable-after-l-curly-replace-is-method-with-if-let
Fix applicable after l_curly for replace_is_method_with_if_let_method
This commit is contained in:
commit
259a01d73d
1 changed files with 18 additions and 0 deletions
|
|
@ -31,6 +31,9 @@ pub(crate) fn replace_is_method_with_if_let_method(
|
||||||
ast::Expr::MethodCallExpr(call) => call,
|
ast::Expr::MethodCallExpr(call) => call,
|
||||||
_ => return None,
|
_ => return None,
|
||||||
};
|
};
|
||||||
|
if ctx.offset() > if_expr.then_branch()?.stmt_list()?.l_curly_token()?.text_range().end() {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
|
||||||
let name_ref = call_expr.name_ref()?;
|
let name_ref = call_expr.name_ref()?;
|
||||||
match name_ref.text().as_str() {
|
match name_ref.text().as_str() {
|
||||||
|
|
@ -188,6 +191,21 @@ fn main() {
|
||||||
let x = Ok(1);
|
let x = Ok(1);
|
||||||
if x.is_e$0rr() {}
|
if x.is_e$0rr() {}
|
||||||
}
|
}
|
||||||
|
"#,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn replace_is_some_with_if_let_some_not_applicable_after_l_curly() {
|
||||||
|
check_assist_not_applicable(
|
||||||
|
replace_is_method_with_if_let_method,
|
||||||
|
r#"
|
||||||
|
fn main() {
|
||||||
|
let x = Some(1);
|
||||||
|
if x.is_some() {
|
||||||
|
()$0
|
||||||
|
}
|
||||||
|
}
|
||||||
"#,
|
"#,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue