diff options
Diffstat (limited to 'crates/ra_hir/src/nameres/collector.rs')
-rw-r--r-- | crates/ra_hir/src/nameres/collector.rs | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/crates/ra_hir/src/nameres/collector.rs b/crates/ra_hir/src/nameres/collector.rs index 10c32ffa1..3803c7185 100644 --- a/crates/ra_hir/src/nameres/collector.rs +++ b/crates/ra_hir/src/nameres/collector.rs | |||
@@ -631,6 +631,7 @@ where | |||
631 | modules[res].parent = Some(self.module_id); | 631 | modules[res].parent = Some(self.module_id); |
632 | modules[res].declaration = Some(declaration); | 632 | modules[res].declaration = Some(declaration); |
633 | modules[res].definition = definition; | 633 | modules[res].definition = definition; |
634 | // Cloning immutable map is lazy and fast | ||
634 | modules[res].scope.textual_macros = modules[self.module_id].scope.textual_macros.clone(); | 635 | modules[res].scope.textual_macros = modules[self.module_id].scope.textual_macros.clone(); |
635 | modules[self.module_id].children.insert(name.clone(), res); | 636 | modules[self.module_id].children.insert(name.clone(), res); |
636 | let resolution = Resolution { | 637 | let resolution = Resolution { |
@@ -707,6 +708,8 @@ where | |||
707 | } | 708 | } |
708 | 709 | ||
709 | fn import_all_textual_macros(&mut self, module_id: CrateModuleId) { | 710 | fn import_all_textual_macros(&mut self, module_id: CrateModuleId) { |
711 | // `clone()` is needed here to avoid mutable borrow `self.def_collector` when first borrow is alive | ||
712 | // Cloning immutable map is lazy and fast | ||
710 | let macros = self.def_collector.def_map[module_id].scope.textual_macros.clone(); | 713 | let macros = self.def_collector.def_map[module_id].scope.textual_macros.clone(); |
711 | for (name, macro_) in macros { | 714 | for (name, macro_) in macros { |
712 | self.def_collector.define_textual_macro(self.module_id, name.clone(), macro_.id); | 715 | self.def_collector.define_textual_macro(self.module_id, name.clone(), macro_.id); |