You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: typespec.rs
    path of file: ./repos/erg/crates/erg_parser
    
    the code of the file until where you have to start completion: use erg_common::switch_lang;
use erg_common::traits::{Locational, Stream};

use crate::ast::*;
use crate::desugar::Desugarer;
use crate::error::ParseError;
use crate::token::TokenKind;
use crate::Parser;

// The APIs defined below are also used by `ASTLowerer` to interpret expressions as types.
impl Parser {
    pub fn validate_const_expr(expr: Expr) -> Result<ConstExpr, ParseError> {
        match expr {
            Expr::Literal(l) => Ok(ConstExpr::Lit(l)),
            Expr::Accessor(acc) => match acc {
                Accessor::Ident(local) => Ok(ConstExpr::Accessor(ConstAccessor::Local(local))),
                Accessor::Attr(attr) => {
                    let expr = Self::validate_const_expr(*attr.obj)?;
                    Ok(ConstExpr::Accessor(ConstAccessor::Attr(
                        ConstAttribute::new(expr, attr.ident),
                    )))
                }
                other => Err(ParseError::feature_error(
                    line!() as usize,
                    other.loc(),
                    "complex const accessor",
                )),

    
    fn record_to_record_type_spec(record: Record) -> Result<RecordTypeSpec, ParseError> {
        let (l, r) = record.braces();
        let braces = (l.clone(), r.clone());
        let attrs = match record {
            Record::Normal(rec) => rec
                .attrs
                .into_iter()
                .map(|mut def| {
                    let ident = def.sig.ident().unwrap().clone();
                    // TODO: check block.len() == 1
                    let value = Self::expr_to_type_spec(def.body.block.pop().unwrap())?;
                    Ok((ident, value))
                })
                .collect::<Result<Vec<_>, ParseError>>(),
            Record::Mixed(rec) => rec
                .attrs
                .into_iter()
                .map(|attr_or_ident| match attr_or_ident {
                    RecordAttrOrIdent::Attr(mut def) => {
                        let ident = def.sig.ident().unwrap().clone();
                        // TODO: check block.len() == 1
                        let value = Self::expr_to_type_spec(def.body.block.pop().unwrap())?;
                        Ok((ident, value))
                    }
                    RecordAttrOrIdent::Ident(_ident) => {
                        todo!("TypeSpec for shortened record is not implemented.")
                    }
                })
                .collect::<Result<Vec<_>, ParseError>>(),
        }?;
        Ok(RecordTypeSpec::new(Some(braces), attrs))
    }