fn parse_module_declaration(
        &mut self,
        context: &mut Context,
        mod_name: &Ident,
    ) -> Result<(), Vec<CollectedErrors>> {
        let child_file_id = context
            .file_manager
            .resolve_path(self.file_id, &mod_name.0.contents)
            .map_err(|_| {
                let err = DefCollectorErrorKind::UnresolvedModuleDecl {
                    mod_name: mod_name.clone(),
                };

                vec![CollectedErrors {
                    file_id: self.file_id,
                    errors: vec![err.to_diagnostic()],
                }]
            })?;

        // Parse the AST for the module we just found and then recursively look for it's defs
        let ast = parse_file(&mut context.file_manager, child_file_id)?;

        // Add module into def collector and get a ModuleId
        let child_mod_id = self.push_child_module(mod_name, child_file_id)?;

        ModCollector {
            def_collector: self.def_collector,
            ast,
            file_id: child_file_id,
            module_id: child_mod_id,
        }
        .collect_defs(context)
    }
/// Search for a module named `mod_name`
/// Parse it, add it as a child to the parent module in which it was declared
/// and then collect all definitions of the child module
Search for a module named `mod_name`
Parse it, add it as a child to the parent module in which it was declared
and then collect all definitions of the child module
Search for a module named ` mod_name ` Parse it add it as a child to the parent module in which it was declared and then collect all definitions of the child module
fn parse_module_declaration(
        &mut self,
        context: &mut Context,
        mod_name: &Ident,
    ) -> Result<(), Vec<CollectedErrors>> {
        let child_file_id = context
            .file_manager
            .resolve_path(self.file_id, &mod_name.0.contents)
            .map_err(|_| {
                let err = DefCollectorErrorKind::UnresolvedModuleDecl {
                    mod_name: mod_name.clone(),
                };
                vec![CollectedErrors {
                    file_id: self.file_id,
                    errors: vec![err.to_diagnostic()],
                }]
            })?;
        // Parse the AST for the module we just found and then recursively look for it's defs
        let ast = parse_file(&mut context.file_manager, child_file_id)?;
        // Add module into def collector and get a ModuleId
        let child_mod_id = self.push_child_module(mod_name, child_file_id)?;
        ModCollector {
            def_collector: self.def_collector,
            ast,
            file_id: child_file_id,
            module_id: child_mod_id,
        }
        .collect_defs(context)
    }
fn parse_module_declaration ( & mut self , context : & mut Context , mod_name : & Ident , ) -> Result < ( ) , Vec < CollectedErrors > > { let child_file_id = context . file_manager . resolve_path ( self . file_id , & mod_name . 0 . contents ) . map_err ( | _ | { let err = DefCollectorErrorKind :: UnresolvedModuleDecl { mod_name : mod_name . clone ( ) , } ; vec ! [ CollectedErrors { file_id self file_id errors vec [ err to_diagnostic ( ) ] } ] } ) ? ; // Parse the AST for the module we just found and then recursively look for it's defs let ast = parse_file ( & mut context . file_manager , child_file_id ) ? ; // Add module into def collector and get a ModuleId let child_mod_id = self . push_child_module ( mod_name , child_file_id ) ? ; ModCollector { def_collector : self . def_collector , ast , file_id : child_file_id , module_id : child_mod_id , } . collect_defs ( context ) }
Search for a module named `mod_name`
Parse it, add it as a child to the parent module in which it was declared
and then collect all definitions of the child module
Search for a module named ` mod_name ` Parse it add it as a child to the parent module in which it was declared and then collect all definitions of the child module
&mut self
context
&mut Context
mod_name
&Ident
&mut self
context
&mut Context
mod_name
&Ident