Skip to content

Commit ec6a7f0

Browse files
author
Tomáš
committed
fixed inline_local_variable bug
1 parent adda6db commit ec6a7f0

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

crates/ra_assists/src/assists/inline_local_variable.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ pub(crate) fn inline_local_variable(ctx: AssistCtx<impl HirDatabase>) -> Option<
4747
};
4848
let analyzer = ctx.source_analyzer(bind_pat.syntax(), None);
4949
let refs = analyzer.find_all_refs(&bind_pat);
50+
if refs.is_empty() {
51+
return None;
52+
};
5053

5154
let mut wrap_in_parens = vec![true; refs.len()];
5255

@@ -645,4 +648,16 @@ fn foo() {
645648
}",
646649
);
647650
}
651+
652+
#[test]
653+
fn test_not_applicable_if_variable_unused() {
654+
check_assist_not_applicable(
655+
inline_local_variable,
656+
"
657+
fn foo() {
658+
let <|>a = 0;
659+
}
660+
",
661+
)
662+
}
648663
}

0 commit comments

Comments
 (0)