diff options
Diffstat (limited to 'crates')
-rw-r--r-- | crates/ide_assists/src/handlers/inline_local_variable.rs | 17 | ||||
-rw-r--r-- | crates/rust-analyzer/src/cli/load_cargo.rs | 3 |
2 files changed, 20 insertions, 0 deletions
diff --git a/crates/ide_assists/src/handlers/inline_local_variable.rs b/crates/ide_assists/src/handlers/inline_local_variable.rs index f5dafc8cb..2441dbb8b 100644 --- a/crates/ide_assists/src/handlers/inline_local_variable.rs +++ b/crates/ide_assists/src/handlers/inline_local_variable.rs | |||
@@ -182,6 +182,10 @@ fn inline_usage(ctx: &AssistContext) -> Option<InlineData> { | |||
182 | PathResolution::Local(local) => local, | 182 | PathResolution::Local(local) => local, |
183 | _ => return None, | 183 | _ => return None, |
184 | }; | 184 | }; |
185 | if local.is_mut(ctx.sema.db) { | ||
186 | cov_mark::hit!(test_not_inline_mut_variable_use); | ||
187 | return None; | ||
188 | } | ||
185 | 189 | ||
186 | let bind_pat = match local.source(ctx.db()).value { | 190 | let bind_pat = match local.source(ctx.db()).value { |
187 | Either::Left(ident) => ident, | 191 | Either::Left(ident) => ident, |
@@ -427,6 +431,19 @@ fn foo() { | |||
427 | } | 431 | } |
428 | 432 | ||
429 | #[test] | 433 | #[test] |
434 | fn test_not_inline_mut_variable_use() { | ||
435 | cov_mark::check!(test_not_inline_mut_variable_use); | ||
436 | check_assist_not_applicable( | ||
437 | inline_local_variable, | ||
438 | r" | ||
439 | fn foo() { | ||
440 | let mut a = 1 + 1; | ||
441 | a$0 + 1; | ||
442 | }", | ||
443 | ); | ||
444 | } | ||
445 | |||
446 | #[test] | ||
430 | fn test_call_expr() { | 447 | fn test_call_expr() { |
431 | check_assist( | 448 | check_assist( |
432 | inline_local_variable, | 449 | inline_local_variable, |
diff --git a/crates/rust-analyzer/src/cli/load_cargo.rs b/crates/rust-analyzer/src/cli/load_cargo.rs index 75bad1112..8cee65478 100644 --- a/crates/rust-analyzer/src/cli/load_cargo.rs +++ b/crates/rust-analyzer/src/cli/load_cargo.rs | |||
@@ -4,6 +4,7 @@ use std::{path::Path, sync::Arc}; | |||
4 | 4 | ||
5 | use anyhow::Result; | 5 | use anyhow::Result; |
6 | use crossbeam_channel::{unbounded, Receiver}; | 6 | use crossbeam_channel::{unbounded, Receiver}; |
7 | use hir::db::DefDatabase; | ||
7 | use ide::{AnalysisHost, Change}; | 8 | use ide::{AnalysisHost, Change}; |
8 | use ide_db::base_db::CrateGraph; | 9 | use ide_db::base_db::CrateGraph; |
9 | use project_model::{ | 10 | use project_model::{ |
@@ -94,6 +95,8 @@ fn load_crate_graph( | |||
94 | let mut host = AnalysisHost::new(lru_cap); | 95 | let mut host = AnalysisHost::new(lru_cap); |
95 | let mut analysis_change = Change::new(); | 96 | let mut analysis_change = Change::new(); |
96 | 97 | ||
98 | host.raw_database_mut().set_enable_proc_attr_macros(true); | ||
99 | |||
97 | // wait until Vfs has loaded all roots | 100 | // wait until Vfs has loaded all roots |
98 | for task in receiver { | 101 | for task in receiver { |
99 | match task { | 102 | match task { |