mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-27 21:43:37 +00:00
Don't inline mutable locals in 'inline_local_variable'
This commit is contained in:
parent
98395f29a4
commit
1bd04d9064
1 changed files with 17 additions and 0 deletions
|
@ -182,6 +182,10 @@ fn inline_usage(ctx: &AssistContext) -> Option<InlineData> {
|
||||||
PathResolution::Local(local) => local,
|
PathResolution::Local(local) => local,
|
||||||
_ => return None,
|
_ => return None,
|
||||||
};
|
};
|
||||||
|
if local.is_mut(ctx.sema.db) {
|
||||||
|
cov_mark::hit!(test_not_inline_mut_variable_use);
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
|
||||||
let bind_pat = match local.source(ctx.db()).value {
|
let bind_pat = match local.source(ctx.db()).value {
|
||||||
Either::Left(ident) => ident,
|
Either::Left(ident) => ident,
|
||||||
|
@ -426,6 +430,19 @@ fn foo() {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_not_inline_mut_variable_use() {
|
||||||
|
cov_mark::check!(test_not_inline_mut_variable_use);
|
||||||
|
check_assist_not_applicable(
|
||||||
|
inline_local_variable,
|
||||||
|
r"
|
||||||
|
fn foo() {
|
||||||
|
let mut a = 1 + 1;
|
||||||
|
a$0 + 1;
|
||||||
|
}",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_call_expr() {
|
fn test_call_expr() {
|
||||||
check_assist(
|
check_assist(
|
||||||
|
|
Loading…
Reference in a new issue