/// Convert a primary name to a resolvable name.
///
/// Primary names are present in the AST as the initial parts of compound
/// names, e.g. in use clauses, or as standalone names, e.g. in functions.
/// The conversion fails if the primary name is a string literal (`"..."`)
/// which does not name a known operator.
Convert a primary name to a resolvable name.
Primary names are present in the AST as the initial parts of compound
names, e.g. in use clauses, or as standalone names, e.g. in functions.
The conversion fails if the primary name is a string literal (`"..."`)
which does not name a known operator.
Convert a primary name to a resolvable name . Primary names are present in the AST as the initial parts of compound names e . g . in use clauses or as standalone names e . g . in functions . The conversion fails if the primary name is a string literal ( ` " ... " ` ) which does not name a known operator .
pub fn from_primary_name<C>(
        primary: &ast::PrimaryName,
        context: C,
    ) -> Result<Spanned<ResolvableName>>
    where
        C: DiagEmitter,
    {
        match primary.kind {
            ast::PrimaryNameKind::Ident(n) => {
                Ok(Spanned::new(ResolvableName::Ident(n), primary.span))
            }
            ast::PrimaryNameKind::Char(c) => Ok(Spanned::new(ResolvableName::Bit(c), primary.span)),
            ast::PrimaryNameKind::String(s) => match Operator::from_name(s) {
                Some(op) => Ok(Spanned::new(ResolvableName::Operator(op), primary.span)),
                None => {
                    context.emit(
                        DiagBuilder2::error(format!("`{}` is not a valid operator symbol", s))
                            .span(primary.span)
                            .add_note("see IEEE 1076-2008 section 9.2 for a list of operators"),
                    );
                    Err(())
                }
            },
        }
    }
pub fn from_primary_name < C > ( primary : & ast :: PrimaryName , context : C , ) -> Result < Spanned < ResolvableName > > where C : DiagEmitter , { match primary . kind { ast :: PrimaryNameKind :: Ident ( n ) => { Ok ( Spanned :: new ( ResolvableName :: Ident ( n ) , primary . span ) ) } ast :: PrimaryNameKind :: Char ( c ) => Ok ( Spanned :: new ( ResolvableName :: Bit ( c ) , primary . span ) ) , ast :: PrimaryNameKind :: String ( s ) => match Operator :: from_name ( s ) { Some ( op ) => Ok ( Spanned :: new ( ResolvableName :: Operator ( op ) , primary . span ) ) , None => { context . emit ( DiagBuilder2 :: error ( format ! ( " " s ) ) . span ( primary . span ) . add_note ( " " ) , ) ; Err ( ( ) ) } } , } }
Convert a primary name to a resolvable name.
Convert a primary name to a resolvable name .
primary
&ast::PrimaryName
context
C