4 pub struct ParseError
{
10 pub enum ParseErrorKind
{
14 expected
: &'
static str,
17 IncompleteExpr(&'
static str),
18 UnterminatedExpression(String
),
19 InvalidTarget(String
),
25 impl fmt
::Display
for ParseError
{
26 fn fmt(&self, f
: &mut fmt
::Formatter
) -> fmt
::Result
{
29 "failed to parse `{}` as a cfg expression: {}",
35 impl fmt
::Display
for ParseErrorKind
{
36 fn fmt(&self, f
: &mut fmt
::Formatter
) -> fmt
::Result
{
37 use ParseErrorKind
::*;
39 UnterminatedString
=> write
!(f
, "unterminated string in cfg"),
40 UnexpectedChar(ch
) => write
!(
42 "unexpected character `{}` in cfg, expected parens, a comma, \
43 an identifier, or a string",
46 UnexpectedToken { expected, found }
=> {
47 write
!(f
, "expected {}, found {}", expected
, found
)
49 IncompleteExpr(expected
) => {
50 write
!(f
, "expected {}, but cfg expression ended", expected
)
52 UnterminatedExpression(s
) => {
53 write
!(f
, "unexpected content `{}` found after cfg expression", s
)
55 InvalidTarget(s
) => write
!(f
, "invalid target specifier: {}", s
),
56 __Nonexhaustive
=> unreachable
!(),
61 impl std
::error
::Error
for ParseError {}
64 pub fn new(orig
: &str, kind
: ParseErrorKind
) -> ParseError
{
67 orig
: orig
.to_string(),