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:
Shoyu Vanilla (Flint) 2025-09-20 12:06:18 +00:00 committed by GitHub
commit 259a01d73d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -31,6 +31,9 @@ pub(crate) fn replace_is_method_with_if_let_method(
ast::Expr::MethodCallExpr(call) => call,
_ => 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()?;
match name_ref.text().as_str() {
@ -188,6 +191,21 @@ fn main() {
let x = Ok(1);
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
}
}
"#,
);
}