mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-11-17 02:08:30 +00:00
Merge #2907
2907: fixed inline_local_variable bug #2900 r=matklad a=TomasKralCZ This also affects issues like #2666. Co-authored-by: Tomáš <tomas@kral.hk>
This commit is contained in:
commit
13743d1073
1 changed files with 15 additions and 0 deletions
|
@ -47,6 +47,9 @@ pub(crate) fn inline_local_variable(ctx: AssistCtx<impl HirDatabase>) -> Option<
|
|||
};
|
||||
let analyzer = ctx.source_analyzer(bind_pat.syntax(), None);
|
||||
let refs = analyzer.find_all_refs(&bind_pat);
|
||||
if refs.is_empty() {
|
||||
return None;
|
||||
};
|
||||
|
||||
let mut wrap_in_parens = vec![true; refs.len()];
|
||||
|
||||
|
@ -645,4 +648,16 @@ fn foo() {
|
|||
}",
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_not_applicable_if_variable_unused() {
|
||||
check_assist_not_applicable(
|
||||
inline_local_variable,
|
||||
"
|
||||
fn foo() {
|
||||
let <|>a = 0;
|
||||
}
|
||||
",
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue