pub fn collect_defs(
        crate_id: CrateId,
        context: &mut Context,
    ) -> Result<(), Vec<CollectedErrors>> {
        // Check if this Crate has already been compiled
        // XXX: There is probably a better alternative for this.
        // Without this check, the compiler will panic as it does not
        // expect the same crate to be processed twice. It would not
        // make the implementation wrong, if the same crate was processed twice, it just makes it slow.
        if context.def_map(crate_id).is_some() {
            return Ok(());
        }

        // First parse the root file.
        let root_file_id = context.crate_graph[crate_id].root_file_id;
        let ast = parse_file(&mut context.file_manager, root_file_id)?;

        // Allocate a default Module for the root, giving it a ModuleId
        let mut modules: Arena<ModuleData> = Arena::default();
        let root = modules.insert(ModuleData::default());

        // Set the origin of the root module
        modules[root].origin = ModuleOrigin::CrateRoot(root_file_id);

        let def_map = CrateDefMap {
            root: LocalModuleId(root),
            modules,
            krate: crate_id,
            extern_prelude: HashMap::new(),
        };

        // Now we want to populate the CrateDefMap using the DefCollector
        //
        DefCollector::collect(def_map, context, ast, root_file_id)
    }
/// Collect all definitions in the crate
Collect all definitions in the crate
Collect all definitions in the crate
pub fn collect_defs(
        crate_id: CrateId,
        context: &mut Context,
    ) -> Result<(), Vec<CollectedErrors>> {
        // Check if this Crate has already been compiled
        // XXX: There is probably a better alternative for this.
        // Without this check, the compiler will panic as it does not
        // expect the same crate to be processed twice. It would not
        // make the implementation wrong, if the same crate was processed twice, it just makes it slow.
        if context.def_map(crate_id).is_some() {
            return Ok(());
        }
        // First parse the root file.
        let root_file_id = context.crate_graph[crate_id].root_file_id;
        let ast = parse_file(&mut context.file_manager, root_file_id)?;
        // Allocate a default Module for the root, giving it a ModuleId
        let mut modules: Arena<ModuleData> = Arena::default();
        let root = modules.insert(ModuleData::default());
        // Set the origin of the root module
        modules[root].origin = ModuleOrigin::CrateRoot(root_file_id);
        let def_map = CrateDefMap {
            root: LocalModuleId(root),
            modules,
            krate: crate_id,
            extern_prelude: HashMap::new(),
        };
        // Now we want to populate the CrateDefMap using the DefCollector
        //
        DefCollector::collect(def_map, context, ast, root_file_id)
    }
pub fn collect_defs ( crate_id : CrateId , context : & mut Context , ) -> Result < ( ) , Vec < CollectedErrors > > { // Check if this Crate has already been compiled // XXX: There is probably a better alternative for this. // Without this check, the compiler will panic as it does not // expect the same crate to be processed twice. It would not // make the implementation wrong, if the same crate was processed twice, it just makes it slow. if context . def_map ( crate_id ) . is_some ( ) { return Ok ( ( ) ) ; } // First parse the root file. let root_file_id = context . crate_graph [ crate_id ] . root_file_id ; let ast = parse_file ( & mut context . file_manager , root_file_id ) ? ; // Allocate a default Module for the root, giving it a ModuleId let mut modules : Arena < ModuleData > = Arena :: default ( ) ; let root = modules . insert ( ModuleData :: default ( ) ) ; // Set the origin of the root module modules [ root ] . origin = ModuleOrigin :: CrateRoot ( root_file_id ) ; let def_map = CrateDefMap { root : LocalModuleId ( root ) , modules , krate : crate_id , extern_prelude : HashMap :: new ( ) , } ; // Now we want to populate the CrateDefMap using the DefCollector // DefCollector :: collect ( def_map , context , ast , root_file_id ) }
Collect all definitions in the crate
Collect all definitions in the crate
crate_id
CrateId
context
&mut Context
crate_id
CrateId
context
&mut Context