pub fn to_diagnostic(&self) -> Diagnostic {
        match *self {
            ParseError::Lexer(ref err) => err.to_diagnostic(),

            ParseError::ConstSuffixInvalid { span, ref suffix } => {
                Diagnostic::new_error(format!("invalid constant suffix: {}", suffix))
                    .with_label(Label::new_primary(span).with_message("invalid constant suffix"))
            }
            ParseError::ConstSuffixMissing { span } => {
                Diagnostic::new_error(format!("missing constant suffix"))
                    .with_label(Label::new_primary(span).with_message("suffix expected here"))
            }
            ParseError::InvalidHostTypeName { span, ref name } => {
                Diagnostic::new_error(format!("invalid host type name: {}", name))
                    .with_label(Label::new_primary(span).with_message("invalid host type name"))
            }

            ParseError::UnexpectedToken {
                span,
                ref token,
                ref expected,
            } => Diagnostic::new_error(format!("expected one of {}, found `{}`", expected, token))
                .with_label(Label::new_primary(span).with_message("unexpected token")),
            ParseError::UnexpectedEof { end, ref expected } => {
                Diagnostic::new_error(format!("expected one of {}, found `EOF`", expected))
                    .with_label(
                        Label::new_primary(ByteSpan::new(end, end)).with_message("unexpected EOF"),
                    )
            }
            ParseError::ExtraToken { span, ref token } => {
                Diagnostic::new_error(format!("extra token `{}`", token))
                    .with_label(Label::new_primary(span).with_message("extra token"))
            }
        }
    }
/// Convert the error into a diagnostic message
Convert the error into a diagnostic message
Convert the error into a diagnostic message
pub fn to_diagnostic(&self) -> Diagnostic {
        match *self {
            ParseError::Lexer(ref err) => err.to_diagnostic(),
            ParseError::ConstSuffixInvalid { span, ref suffix } => {
                Diagnostic::new_error(format!("invalid constant suffix: {}", suffix))
                    .with_label(Label::new_primary(span).with_message("invalid constant suffix"))
            }
            ParseError::ConstSuffixMissing { span } => {
                Diagnostic::new_error(format!("missing constant suffix"))
                    .with_label(Label::new_primary(span).with_message("suffix expected here"))
            }
            ParseError::InvalidHostTypeName { span, ref name } => {
                Diagnostic::new_error(format!("invalid host type name: {}", name))
                    .with_label(Label::new_primary(span).with_message("invalid host type name"))
            }
            ParseError::UnexpectedToken {
                span,
                ref token,
                ref expected,
            } => Diagnostic::new_error(format!("expected one of {}, found `{}`", expected, token))
                .with_label(Label::new_primary(span).with_message("unexpected token")),
            ParseError::UnexpectedEof { end, ref expected } => {
                Diagnostic::new_error(format!("expected one of {}, found `EOF`", expected))
                    .with_label(
                        Label::new_primary(ByteSpan::new(end, end)).with_message("unexpected EOF"),
                    )
            }
            ParseError::ExtraToken { span, ref token } => {
                Diagnostic::new_error(format!("extra token `{}`", token))
                    .with_label(Label::new_primary(span).with_message("extra token"))
            }
        }
    }
pub fn to_diagnostic ( & self ) -> Diagnostic { match * self { ParseError :: Lexer ( ref err ) => err . to_diagnostic ( ) , ParseError :: ConstSuffixInvalid { span , ref suffix } => { Diagnostic :: new_error ( format ! ( " " suffix ) ) . with_label ( Label :: new_primary ( span ) . with_message ( " " ) ) } ParseError :: ConstSuffixMissing { span } => { Diagnostic :: new_error ( format ! ( " " ) ) . with_label ( Label :: new_primary ( span ) . with_message ( " " ) ) } ParseError :: InvalidHostTypeName { span , ref name } => { Diagnostic :: new_error ( format ! ( " " name ) ) . with_label ( Label :: new_primary ( span ) . with_message ( " " ) ) } ParseError :: UnexpectedToken { span , ref token , ref expected , } => Diagnostic :: new_error ( format ! ( " " expected token ) ) . with_label ( Label :: new_primary ( span ) . with_message ( " " ) ) , ParseError :: UnexpectedEof { end , ref expected } => { Diagnostic :: new_error ( format ! ( " " expected ) ) . with_label ( Label :: new_primary ( ByteSpan :: new ( end , end ) ) . with_message ( " " ) , ) } ParseError :: ExtraToken { span , ref token } => { Diagnostic :: new_error ( format ! ( " " token ) ) . with_label ( Label :: new_primary ( span ) . with_message ( " " ) ) } } }
Convert the error into a diagnostic message
Convert the error into a diagnostic message
&self
&self