mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-25 11:17:13 +00:00
Fix applicable after l_curly for replace_is_method_with_if_let_method
This commit is contained in:
parent
2268a56350
commit
d3748517c9
@ -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
|
||||
}
|
||||
}
|
||||
"#,
|
||||
);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user