fn try_expand_internal_macro(
        &mut self,
        attributes: &mut attrs::Attributes,
        ast: &mut ast::MacroCall,
    ) -> Result<bool, CompileError> {
        let (_, builtin) = match attributes.try_parse::<attrs::BuiltIn>()? {
            Some(builtin) => builtin,
            None => return Ok(false),
        };

        let args = builtin.args(&self.storage, &self.source)?;

        // NB: internal macros are
        let ident = match ast.path.try_as_ident() {
            Some(ident) => ident,
            None => {
                return Err(CompileError::new(
                    ast.path.span(),
                    CompileErrorKind::NoSuchBuiltInMacro {
                        name: ast.path.resolve(&self.storage, &self.source)?,
                    },
                ))
            }
        };

        let ident = ident.resolve(&self.storage, &self.source)?;

        let mut internal_macro = match ident.as_ref() {
            "template" => self.expand_template_macro(ast, &args)?,
            "format" => self.expand_format_macro(ast, &args)?,
            "file" => self.expand_file_macro(ast)?,
            "line" => self.expand_line_macro(ast)?,
            _ => {
                return Err(CompileError::new(
                    ast.path.span(),
                    CompileErrorKind::NoSuchBuiltInMacro {
                        name: ast.path.resolve(&self.storage, &self.source)?,
                    },
                ))
            }
        };

        match &mut internal_macro {
            BuiltInMacro::Template(template) => {
                for expr in &mut template.exprs {
                    expr.index(self)?;
                }
            }
            BuiltInMacro::Format(format) => {
                format.value.index(self)?;
            }

            BuiltInMacro::Line(_) | BuiltInMacro::File(_) => { /* Nothing to index */ }
        }

        let id = self.query.insert_new_builtin_macro(internal_macro)?;
        ast.id = Some(id);
        Ok(true)
    }
/// Try to expand an internal macro.
Try to expand an internal macro.
Try to expand an internal macro .
fn try_expand_internal_macro(
        &mut self,
        attributes: &mut attrs::Attributes,
        ast: &mut ast::MacroCall,
    ) -> Result<bool, CompileError> {
        let (_, builtin) = match attributes.try_parse::<attrs::BuiltIn>()? {
            Some(builtin) => builtin,
            None => return Ok(false),
        };
        let args = builtin.args(&self.storage, &self.source)?;
        // NB: internal macros are
        let ident = match ast.path.try_as_ident() {
            Some(ident) => ident,
            None => {
                return Err(CompileError::new(
                    ast.path.span(),
                    CompileErrorKind::NoSuchBuiltInMacro {
                        name: ast.path.resolve(&self.storage, &self.source)?,
                    },
                ))
            }
        };
        let ident = ident.resolve(&self.storage, &self.source)?;
        let mut internal_macro = match ident.as_ref() {
            "template" => self.expand_template_macro(ast, &args)?,
            "format" => self.expand_format_macro(ast, &args)?,
            "file" => self.expand_file_macro(ast)?,
            "line" => self.expand_line_macro(ast)?,
            _ => {
                return Err(CompileError::new(
                    ast.path.span(),
                    CompileErrorKind::NoSuchBuiltInMacro {
                        name: ast.path.resolve(&self.storage, &self.source)?,
                    },
                ))
            }
        };
        match &mut internal_macro {
            BuiltInMacro::Template(template) => {
                for expr in &mut template.exprs {
                    expr.index(self)?;
                }
            }
            BuiltInMacro::Format(format) => {
                format.value.index(self)?;
            }
            BuiltInMacro::Line(_) | BuiltInMacro::File(_) => { /* Nothing to index */ }
        }
        let id = self.query.insert_new_builtin_macro(internal_macro)?;
        ast.id = Some(id);
        Ok(true)
    }
fn try_expand_internal_macro ( & mut self , attributes : & mut attrs :: Attributes , ast : & mut ast :: MacroCall , ) -> Result < bool , CompileError > { let ( _ , builtin ) = match attributes . try_parse :: < attrs :: BuiltIn > ( ) ? { Some ( builtin ) => builtin , None => return Ok ( false ) , } ; let args = builtin . args ( & self . storage , & self . source ) ? ; // NB: internal macros are let ident = match ast . path . try_as_ident ( ) { Some ( ident ) => ident , None => { return Err ( CompileError :: new ( ast . path . span ( ) , CompileErrorKind :: NoSuchBuiltInMacro { name : ast . path . resolve ( & self . storage , & self . source ) ? , } , ) ) } } ; let ident = ident . resolve ( & self . storage , & self . source ) ? ; let mut internal_macro = match ident . as_ref ( ) { " " => self . expand_template_macro ( ast , & args ) ? , " " => self . expand_format_macro ( ast , & args ) ? , " " => self . expand_file_macro ( ast ) ? , " " => self . expand_line_macro ( ast ) ? , _ => { return Err ( CompileError :: new ( ast . path . span ( ) , CompileErrorKind :: NoSuchBuiltInMacro { name : ast . path . resolve ( & self . storage , & self . source ) ? , } , ) ) } } ; match & mut internal_macro { BuiltInMacro :: Template ( template ) => { for expr in & mut template . exprs { expr . index ( self ) ? ; } } BuiltInMacro :: Format ( format ) => { format . value . index ( self ) ? ; } BuiltInMacro :: Line ( _ ) | BuiltInMacro :: File ( _ ) => { /* Nothing to index */ } } let id = self . query . insert_new_builtin_macro ( internal_macro ) ? ; ast . id = Some ( id ) ; Ok ( true ) }
Try to expand an internal macro.
Try to expand an internal macro .
&mut self
attributes
&mut attrs::Attributes
ast
&mut ast::MacroCall
&mut self
attributes
&mut attrs::Attributes
ast
&mut ast::MacroCall