1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
use std::{error, fmt};
#[derive(Debug, PartialEq)]
#[non_exhaustive]
pub enum Error {
InvalidCfg(cfg_expr::ParseError),
UnknownTargetTriple(String),
UnknownPlatformTriple(String),
UnknownPredicate(String),
CustomPlatformSummary,
}
impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Error::InvalidCfg(_) => write!(f, "invalid cfg() expression"),
Error::UnknownTargetTriple(triple) => write!(f, "unknown target triple: {}", triple),
Error::UnknownPlatformTriple(triple) => {
write!(f, "unknown platform triple: {}", triple)
}
Error::UnknownPredicate(pred) => {
write!(f, "cfg() expression has unknown predicate: {}", pred)
}
Error::CustomPlatformSummary => write!(
f,
"generating summaries for custom platforms is currently unsupported"
),
}
}
}
impl error::Error for Error {
fn source(&self) -> Option<&(dyn error::Error + 'static)> {
match self {
Error::InvalidCfg(err) => Some(err),
Error::UnknownTargetTriple(_) => None,
Error::UnknownPlatformTriple(_) => None,
Error::UnknownPredicate(_) => None,
Error::CustomPlatformSummary => None,
}
}
}