aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide_db
diff options
context:
space:
mode:
authorMatt Niemeir <[email protected]>2020-03-10 02:18:55 +0000
committerMatt Niemeir <[email protected]>2020-03-10 03:14:17 +0000
commita9b6aec8a788d33ebe9667d53d127be59d93e555 (patch)
tree37a5e634178b35561851f79207f4045831dafca4 /crates/ra_ide_db
parent530ff9f57fd27505302d082a6007b49d8b98c8af (diff)
Struct field rename renames field in constructor field shorthand
Diffstat (limited to 'crates/ra_ide_db')
-rw-r--r--crates/ra_ide_db/src/search.rs22
1 files changed, 17 insertions, 5 deletions
diff --git a/crates/ra_ide_db/src/search.rs b/crates/ra_ide_db/src/search.rs
index 6f198df04..9436a7562 100644
--- a/crates/ra_ide_db/src/search.rs
+++ b/crates/ra_ide_db/src/search.rs
@@ -17,7 +17,7 @@ use rustc_hash::FxHashMap;
17use test_utils::tested_by; 17use test_utils::tested_by;
18 18
19use crate::{ 19use crate::{
20 defs::{classify_name_ref, Definition}, 20 defs::{classify_name_ref, Definition, NameRefClass},
21 RootDatabase, 21 RootDatabase,
22}; 22};
23 23
@@ -30,6 +30,7 @@ pub struct Reference {
30 30
31#[derive(Debug, Clone, PartialEq)] 31#[derive(Debug, Clone, PartialEq)]
32pub enum ReferenceKind { 32pub enum ReferenceKind {
33 StructFieldShorthand,
33 StructLiteral, 34 StructLiteral,
34 Other, 35 Other,
35} 36}
@@ -237,9 +238,8 @@ impl Definition {
237 // FIXME: reuse sb 238 // FIXME: reuse sb
238 // See https://github.com/rust-lang/rust/pull/68198#issuecomment-574269098 239 // See https://github.com/rust-lang/rust/pull/68198#issuecomment-574269098
239 240
240 if let Some(d) = classify_name_ref(&sema, &name_ref) { 241 match (classify_name_ref(&sema, &name_ref), self) {
241 let d = d.definition(); 242 (Some(NameRefClass::Definition(def)), _) if &def == self => {
242 if &d == self {
243 let kind = if is_record_lit_name_ref(&name_ref) 243 let kind = if is_record_lit_name_ref(&name_ref)
244 || is_call_expr_name_ref(&name_ref) 244 || is_call_expr_name_ref(&name_ref)
245 { 245 {
@@ -252,9 +252,21 @@ impl Definition {
252 refs.push(Reference { 252 refs.push(Reference {
253 file_range, 253 file_range,
254 kind, 254 kind,
255 access: reference_access(&d, &name_ref), 255 access: reference_access(&def, &name_ref),
256 }); 256 });
257 } 257 }
258 (
259 Some(NameRefClass::FieldShorthand { local, field: _ }),
260 Definition::StructField(_),
261 ) => {
262 let file_range = sema.original_range(name_ref.syntax());
263 refs.push(Reference {
264 file_range: file_range,
265 kind: ReferenceKind::StructFieldShorthand,
266 access: reference_access(&Definition::Local(local), &name_ref),
267 });
268 }
269 _ => {} // not a usage
258 } 270 }
259 } 271 }
260 } 272 }