]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc_resolve/resolve_imports.rs
Add comments
[rust.git] / src / librustc_resolve / resolve_imports.rs
index 2f2c5b77dd0baec292702a1517e1b00c2af7ace0..1404b8cf3adf8b422fcd61f3627f93fa6f72c43a 100644 (file)
@@ -317,6 +317,8 @@ pub fn add_import_directive(&self,
     fn update_resolution<T, F>(&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::<Vec<_>>();