4 pub struct ParseError
{
10 pub enum ParseErrorKind
{
14 expected
: &'
static str,
17 IncompleteExpr(&'
static str),
18 UnterminatedExpression(String
),
19 InvalidTarget(String
),
20 InvalidCfgName(String
),
21 InvalidCfgKey(String
),
27 impl fmt
::Display
for ParseError
{
28 fn fmt(&self, f
: &mut fmt
::Formatter
) -> fmt
::Result
{
31 "failed to parse `{}` as a cfg expression: {}",
37 impl fmt
::Display
for ParseErrorKind
{
38 fn fmt(&self, f
: &mut fmt
::Formatter
) -> fmt
::Result
{
39 use ParseErrorKind
::*;
41 UnterminatedString
=> write
!(f
, "unterminated string in cfg"),
42 UnexpectedChar(ch
) => write
!(
44 "unexpected character `{}` in cfg, expected parens, a comma, \
45 an identifier, or a string",
48 UnexpectedToken { expected, found }
=> {
49 write
!(f
, "expected {}, found {}", expected
, found
)
51 IncompleteExpr(expected
) => {
52 write
!(f
, "expected {}, but cfg expression ended", expected
)
54 UnterminatedExpression(s
) => {
55 write
!(f
, "unexpected content `{}` found after cfg expression", s
)
57 InvalidTarget(s
) => write
!(f
, "invalid target specifier: {}", s
),
58 InvalidCfgName(name
) => write
!(f
, "invalid name in target cfg: {}", name
),
59 InvalidCfgKey(name
) => write
!(f
, "invalid key in target cfg: {}", name
),
60 __Nonexhaustive
=> unreachable
!(),
65 impl std
::error
::Error
for ParseError {}
68 pub fn new(orig
: &str, kind
: ParseErrorKind
) -> ParseError
{
71 orig
: orig
.to_string(),