From 3238b4bbbdd5b0a8c64ebeaedfa989d1babb3c21 Mon Sep 17 00:00:00 2001 From: Jeffrey Seyfried Date: Mon, 11 Apr 2016 18:30:48 +0000 Subject: [PATCH] Add comments --- src/librustc_resolve/resolve_imports.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/librustc_resolve/resolve_imports.rs b/src/librustc_resolve/resolve_imports.rs index 2f2c5b77dd0..1404b8cf3ad 100644 --- a/src/librustc_resolve/resolve_imports.rs +++ b/src/librustc_resolve/resolve_imports.rs @@ -317,6 +317,8 @@ pub fn add_import_directive(&self, fn update_resolution(&self, name: Name, ns: Namespace, update: F) -> T where F: FnOnce(&mut NameResolution<'a>) -> T { + // Ensure that `resolution` isn't borrowed during `define_in_glob_importers`, + // where it might end up getting re-defined via a glob cycle. let (new_binding, t) = { let mut resolution = &mut *self.resolution(name, ns).borrow_mut(); let was_known = resolution.binding().is_some(); @@ -650,6 +652,8 @@ fn resolve_glob_import(&mut self, target_module: Module<'b>, directive: &'b Impo // Add to target_module's glob_importers target_module.glob_importers.borrow_mut().push((module_, directive)); + // Ensure that `resolutions` isn't borrowed during `try_define_child`, + // since it might get updated via a glob cycle. let bindings = target_module.resolutions.borrow().iter().filter_map(|(name, resolution)| { resolution.borrow().binding().map(|binding| (*name, binding)) }).collect::>(); -- 2.44.0