We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent adda6db commit ec6a7f0Copy full SHA for ec6a7f0
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
};
48
let analyzer = ctx.source_analyzer(bind_pat.syntax(), None);
49
let refs = analyzer.find_all_refs(&bind_pat);
50
+ if refs.is_empty() {
51
+ return None;
52
+ };
53
54
let mut wrap_in_parens = vec![true; refs.len()];
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
+ "
657
+fn foo() {
658
+ let <|>a = 0;
659
+}
660
+ ",
661
+ )
662
+ }
663
0 commit comments