aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_assists/src/assists/inline_local_variable.rs15
1 files changed, 15 insertions, 0 deletions
diff --git a/crates/ra_assists/src/assists/inline_local_variable.rs b/crates/ra_assists/src/assists/inline_local_variable.rs
index d0c5c3b8c..83527d904 100644
--- a/crates/ra_assists/src/assists/inline_local_variable.rs
+++ b/crates/ra_assists/src/assists/inline_local_variable.rs
@@ -47,6 +47,9 @@ pub(crate) fn inline_local_variable(ctx: AssistCtx<impl HirDatabase>) -> Option<
47 }; 47 };
48 let analyzer = ctx.source_analyzer(bind_pat.syntax(), None); 48 let analyzer = ctx.source_analyzer(bind_pat.syntax(), None);
49 let refs = analyzer.find_all_refs(&bind_pat); 49 let refs = analyzer.find_all_refs(&bind_pat);
50 if refs.is_empty() {
51 return None;
52 };
50 53
51 let mut wrap_in_parens = vec![true; refs.len()]; 54 let mut wrap_in_parens = vec![true; refs.len()];
52 55
@@ -645,4 +648,16 @@ fn foo() {
645}", 648}",
646 ); 649 );
647 } 650 }
651
652 #[test]
653 fn test_not_applicable_if_variable_unused() {
654 check_assist_not_applicable(
655 inline_local_variable,
656 "
657fn foo() {
658 let <|>a = 0;
659}
660 ",
661 )
662 }
648} 663}