mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-12-27 16:07:46 +00:00
Merge pull request #21264 from A4-Tacks/bind-unused-not-applicable-on-closure
Fix bind_unused_param applicable on closure
This commit is contained in:
commit
7c063a52fc
@ -33,7 +33,7 @@ pub(crate) fn bind_unused_param(acc: &mut Assists, ctx: &AssistContext<'_>) -> O
|
||||
return None;
|
||||
}
|
||||
|
||||
let func = param.syntax().ancestors().find_map(ast::Fn::cast)?;
|
||||
let func = param.syntax().ancestors().nth(2).and_then(ast::Fn::cast)?;
|
||||
let stmt_list = func.body()?.stmt_list()?;
|
||||
let l_curly_range = stmt_list.l_curly_token()?.text_range();
|
||||
let r_curly_range = stmt_list.r_curly_token()?.text_range();
|
||||
@ -176,6 +176,18 @@ fn foo(x: i32, $0y: i32) { y; }
|
||||
bind_unused_param,
|
||||
r#"
|
||||
fn foo($0_x: i32, y: i32) {}
|
||||
"#,
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn not_applicable_closure() {
|
||||
check_assist_not_applicable(
|
||||
bind_unused_param,
|
||||
r#"
|
||||
fn foo() {
|
||||
let _ = |$0x| 2;
|
||||
}
|
||||
"#,
|
||||
);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user