fn build_indexed_entry(
        &mut self,
        span: Span,
        entry: IndexedEntry,
        used: Used,
    ) -> Result<CompileMeta, QueryError> {
        let IndexedEntry {
            item: query_item,
            indexed,
            source,
        } = entry;

        let path = source.path().map(ToOwned::to_owned);

        let kind = match indexed {
            Indexed::Enum => CompileMetaKind::Enum {
                type_hash: Hash::type_hash(&query_item.item),
            },
            Indexed::Variant(variant) => {
                let enum_item = self.item_for(query_item.location.span, Some(variant.enum_id))?;

                // Assert that everything is built for the enum.
                self.query_meta(span, &enum_item.item, Default::default())?;

                variant_into_item_decl(
                    &query_item.item,
                    variant.ast.body,
                    Some(&enum_item.item),
                    &self.storage,
                    &*source,
                )?
            }
            Indexed::Struct(st) => {
                struct_into_item_decl(&query_item.item, st.ast.body, None, &self.storage, &*source)?
            }
            Indexed::Function(f) => {
                self.queue.push_back(BuildEntry {
                    location: query_item.location,
                    item: query_item.clone(),
                    build: Build::Function(f),
                    source,
                    used,
                });

                CompileMetaKind::Function {
                    type_hash: Hash::type_hash(&query_item.item),
                    is_test: false,
                }
            }
            Indexed::Closure(c) => {
                let captures = c.captures.clone();
                let do_move = c.do_move;

                self.queue.push_back(BuildEntry {
                    location: query_item.location,
                    item: query_item.clone(),
                    build: Build::Closure(c),
                    source,
                    used,
                });

                CompileMetaKind::Closure {
                    type_hash: Hash::type_hash(&query_item.item),
                    captures,
                    do_move,
                }
            }
            Indexed::AsyncBlock(b) => {
                let captures = b.captures.clone();
                let do_move = b.do_move;

                self.queue.push_back(BuildEntry {
                    location: query_item.location,
                    item: query_item.clone(),
                    build: Build::AsyncBlock(b),
                    source,
                    used,
                });

                CompileMetaKind::AsyncBlock {
                    type_hash: Hash::type_hash(&query_item.item),
                    captures,
                    do_move,
                }
            }
            Indexed::Const(c) => {
                let mut const_compiler = IrInterpreter {
                    budget: IrBudget::new(1_000_000),
                    scopes: Default::default(),
                    module: c.module.clone(),
                    item: query_item.item.clone(),
                    consts: self.consts.clone(),
                    query: self,
                };

                let const_value = const_compiler.eval_const(&c.ir, used)?;

                if used.is_unused() {
                    self.queue.push_back(BuildEntry {
                        location: query_item.location,
                        item: query_item.clone(),
                        build: Build::Unused,
                        source,
                        used,
                    });
                }

                CompileMetaKind::Const { const_value }
            }
            Indexed::ConstFn(c) => {
                let mut ir_compiler = IrCompiler {
                    storage: self.storage.clone(),
                    source: source.clone(),
                    query: self,
                };

                let ir_fn = ir_compiler.compile(&*c.item_fn)?;

                let id = self.insert_const_fn(&query_item, ir_fn);

                if used.is_unused() {
                    self.queue.push_back(BuildEntry {
                        location: query_item.location,
                        item: query_item.clone(),
                        build: Build::Unused,
                        source,
                        used,
                    });
                }

                CompileMetaKind::ConstFn { id, is_test: false }
            }
            Indexed::Import(import) => {
                let module = import.entry.module.clone();
                let location = import.entry.location;
                let target = import.entry.target.clone();

                if !import.wildcard {
                    self.queue.push_back(BuildEntry {
                        location: query_item.location,
                        item: query_item.clone(),
                        build: Build::Import(import),
                        source,
                        used,
                    });
                }

                CompileMetaKind::Import {
                    module,
                    location,
                    target,
                }
            }
        };

        let source = CompileSource {
            source_id: query_item.location.source_id,
            span: query_item.location.span,
            path,
        };

        Ok(CompileMeta {
            item: query_item,
            kind,
            source: Some(source),
        })
    }
/// Build a single, indexed entry and return its metadata.
Build a single, indexed entry and return its metadata.
Build a single indexed entry and return its metadata .
fn build_indexed_entry(
        &mut self,
        span: Span,
        entry: IndexedEntry,
        used: Used,
    ) -> Result<CompileMeta, QueryError> {
        let IndexedEntry {
            item: query_item,
            indexed,
            source,
        } = entry;
        let path = source.path().map(ToOwned::to_owned);
        let kind = match indexed {
            Indexed::Enum => CompileMetaKind::Enum {
                type_hash: Hash::type_hash(&query_item.item),
            },
            Indexed::Variant(variant) => {
                let enum_item = self.item_for(query_item.location.span, Some(variant.enum_id))?;
                // Assert that everything is built for the enum.
                self.query_meta(span, &enum_item.item, Default::default())?;
                variant_into_item_decl(
                    &query_item.item,
                    variant.ast.body,
                    Some(&enum_item.item),
                    &self.storage,
                    &*source,
                )?
            }
            Indexed::Struct(st) => {
                struct_into_item_decl(&query_item.item, st.ast.body, None, &self.storage, &*source)?
            }
            Indexed::Function(f) => {
                self.queue.push_back(BuildEntry {
                    location: query_item.location,
                    item: query_item.clone(),
                    build: Build::Function(f),
                    source,
                    used,
                });
                CompileMetaKind::Function {
                    type_hash: Hash::type_hash(&query_item.item),
                    is_test: false,
                }
            }
            Indexed::Closure(c) => {
                let captures = c.captures.clone();
                let do_move = c.do_move;
                self.queue.push_back(BuildEntry {
                    location: query_item.location,
                    item: query_item.clone(),
                    build: Build::Closure(c),
                    source,
                    used,
                });
                CompileMetaKind::Closure {
                    type_hash: Hash::type_hash(&query_item.item),
                    captures,
                    do_move,
                }
            }
            Indexed::AsyncBlock(b) => {
                let captures = b.captures.clone();
                let do_move = b.do_move;
                self.queue.push_back(BuildEntry {
                    location: query_item.location,
                    item: query_item.clone(),
                    build: Build::AsyncBlock(b),
                    source,
                    used,
                });
                CompileMetaKind::AsyncBlock {
                    type_hash: Hash::type_hash(&query_item.item),
                    captures,
                    do_move,
                }
            }
            Indexed::Const(c) => {
                let mut const_compiler = IrInterpreter {
                    budget: IrBudget::new(1_000_000),
                    scopes: Default::default(),
                    module: c.module.clone(),
                    item: query_item.item.clone(),
                    consts: self.consts.clone(),
                    query: self,
                };
                let const_value = const_compiler.eval_const(&c.ir, used)?;
                if used.is_unused() {
                    self.queue.push_back(BuildEntry {
                        location: query_item.location,
                        item: query_item.clone(),
                        build: Build::Unused,
                        source,
                        used,
                    });
                }
                CompileMetaKind::Const { const_value }
            }
            Indexed::ConstFn(c) => {
                let mut ir_compiler = IrCompiler {
                    storage: self.storage.clone(),
                    source: source.clone(),
                    query: self,
                };
                let ir_fn = ir_compiler.compile(&*c.item_fn)?;
                let id = self.insert_const_fn(&query_item, ir_fn);
                if used.is_unused() {
                    self.queue.push_back(BuildEntry {
                        location: query_item.location,
                        item: query_item.clone(),
                        build: Build::Unused,
                        source,
                        used,
                    });
                }
                CompileMetaKind::ConstFn { id, is_test: false }
            }
            Indexed::Import(import) => {
                let module = import.entry.module.clone();
                let location = import.entry.location;
                let target = import.entry.target.clone();
                if !import.wildcard {
                    self.queue.push_back(BuildEntry {
                        location: query_item.location,
                        item: query_item.clone(),
                        build: Build::Import(import),
                        source,
                        used,
                    });
                }
                CompileMetaKind::Import {
                    module,
                    location,
                    target,
                }
            }
        };
        let source = CompileSource {
            source_id: query_item.location.source_id,
            span: query_item.location.span,
            path,
        };
        Ok(CompileMeta {
            item: query_item,
            kind,
            source: Some(source),
        })
    }
fn build_indexed_entry ( & mut self , span : Span , entry : IndexedEntry , used : Used , ) -> Result < CompileMeta , QueryError > { let IndexedEntry { item : query_item , indexed , source , } = entry ; let path = source . path ( ) . map ( ToOwned :: to_owned ) ; let kind = match indexed { Indexed :: Enum => CompileMetaKind :: Enum { type_hash : Hash :: type_hash ( & query_item . item ) , } , Indexed :: Variant ( variant ) => { let enum_item = self . item_for ( query_item . location . span , Some ( variant . enum_id ) ) ? ; // Assert that everything is built for the enum. self . query_meta ( span , & enum_item . item , Default :: default ( ) ) ? ; variant_into_item_decl ( & query_item . item , variant . ast . body , Some ( & enum_item . item ) , & self . storage , & * source , ) ? } Indexed :: Struct ( st ) => { struct_into_item_decl ( & query_item . item , st . ast . body , None , & self . storage , & * source ) ? } Indexed :: Function ( f ) => { self . queue . push_back ( BuildEntry { location : query_item . location , item : query_item . clone ( ) , build : Build :: Function ( f ) , source , used , } ) ; CompileMetaKind :: Function { type_hash : Hash :: type_hash ( & query_item . item ) , is_test : false , } } Indexed :: Closure ( c ) => { let captures = c . captures . clone ( ) ; let do_move = c . do_move ; self . queue . push_back ( BuildEntry { location : query_item . location , item : query_item . clone ( ) , build : Build :: Closure ( c ) , source , used , } ) ; CompileMetaKind :: Closure { type_hash : Hash :: type_hash ( & query_item . item ) , captures , do_move , } } Indexed :: AsyncBlock ( b ) => { let captures = b . captures . clone ( ) ; let do_move = b . do_move ; self . queue . push_back ( BuildEntry { location : query_item . location , item : query_item . clone ( ) , build : Build :: AsyncBlock ( b ) , source , used , } ) ; CompileMetaKind :: AsyncBlock { type_hash : Hash :: type_hash ( & query_item . item ) , captures , do_move , } } Indexed :: Const ( c ) => { let mut const_compiler = IrInterpreter { budget : IrBudget :: new ( 1_000_000 ) , scopes : Default :: default ( ) , module : c . module . clone ( ) , item : query_item . item . clone ( ) , consts : self . consts . clone ( ) , query : self , } ; let const_value = const_compiler . eval_const ( & c . ir , used ) ? ; if used . is_unused ( ) { self . queue . push_back ( BuildEntry { location : query_item . location , item : query_item . clone ( ) , build : Build :: Unused , source , used , } ) ; } CompileMetaKind :: Const { const_value } } Indexed :: ConstFn ( c ) => { let mut ir_compiler = IrCompiler { storage : self . storage . clone ( ) , source : source . clone ( ) , query : self , } ; let ir_fn = ir_compiler . compile ( & * c . item_fn ) ? ; let id = self . insert_const_fn ( & query_item , ir_fn ) ; if used . is_unused ( ) { self . queue . push_back ( BuildEntry { location : query_item . location , item : query_item . clone ( ) , build : Build :: Unused , source , used , } ) ; } CompileMetaKind :: ConstFn { id , is_test : false } } Indexed :: Import ( import ) => { let module = import . entry . module . clone ( ) ; let location = import . entry . location ; let target = import . entry . target . clone ( ) ; if ! import . wildcard { self . queue . push_back ( BuildEntry { location : query_item . location , item : query_item . clone ( ) , build : Build :: Import ( import ) , source , used , } ) ; } CompileMetaKind :: Import { module , location , target , } } } ; let source = CompileSource { source_id : query_item . location . source_id , span : query_item . location . span , path , } ; Ok ( CompileMeta { item : query_item , kind , source : Some ( source ) , } ) }
Build a single, indexed entry and return its metadata.
Build a single indexed entry and return its metadata .
&mut self
span
Span
entry
IndexedEntry
used
Used
&mut self
span
Span
entry
IndexedEntry
used
Used