133d722a9Sopenharmony_ciuse std::fmt::{self, Display};
233d722a9Sopenharmony_ci
333d722a9Sopenharmony_ci#[derive(Copy, Clone)]
433d722a9Sopenharmony_cipub struct Error {
533d722a9Sopenharmony_ci    pub msg: &'static str,
633d722a9Sopenharmony_ci    pub label: Option<&'static str>,
733d722a9Sopenharmony_ci    pub note: Option<&'static str>,
833d722a9Sopenharmony_ci}
933d722a9Sopenharmony_ci
1033d722a9Sopenharmony_ciimpl Display for Error {
1133d722a9Sopenharmony_ci    fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
1233d722a9Sopenharmony_ci        self.msg.fmt(formatter)
1333d722a9Sopenharmony_ci    }
1433d722a9Sopenharmony_ci}
1533d722a9Sopenharmony_ci
1633d722a9Sopenharmony_cipub static ERRORS: &[Error] = &[
1733d722a9Sopenharmony_ci    BOX_CXX_TYPE,
1833d722a9Sopenharmony_ci    CXXBRIDGE_RESERVED,
1933d722a9Sopenharmony_ci    CXX_STRING_BY_VALUE,
2033d722a9Sopenharmony_ci    CXX_TYPE_BY_VALUE,
2133d722a9Sopenharmony_ci    DISCRIMINANT_OVERFLOW,
2233d722a9Sopenharmony_ci    DOT_INCLUDE,
2333d722a9Sopenharmony_ci    DOUBLE_UNDERSCORE,
2433d722a9Sopenharmony_ci    RESERVED_LIFETIME,
2533d722a9Sopenharmony_ci    RUST_TYPE_BY_VALUE,
2633d722a9Sopenharmony_ci    UNSUPPORTED_TYPE,
2733d722a9Sopenharmony_ci    USE_NOT_ALLOWED,
2833d722a9Sopenharmony_ci];
2933d722a9Sopenharmony_ci
3033d722a9Sopenharmony_cipub static BOX_CXX_TYPE: Error = Error {
3133d722a9Sopenharmony_ci    msg: "Box of a C++ type is not supported yet",
3233d722a9Sopenharmony_ci    label: None,
3333d722a9Sopenharmony_ci    note: Some("hint: use UniquePtr<> or SharedPtr<>"),
3433d722a9Sopenharmony_ci};
3533d722a9Sopenharmony_ci
3633d722a9Sopenharmony_cipub static CXXBRIDGE_RESERVED: Error = Error {
3733d722a9Sopenharmony_ci    msg: "identifiers starting with cxxbridge are reserved",
3833d722a9Sopenharmony_ci    label: Some("reserved identifier"),
3933d722a9Sopenharmony_ci    note: Some("identifiers starting with cxxbridge are reserved"),
4033d722a9Sopenharmony_ci};
4133d722a9Sopenharmony_ci
4233d722a9Sopenharmony_cipub static CXX_STRING_BY_VALUE: Error = Error {
4333d722a9Sopenharmony_ci    msg: "C++ string by value is not supported",
4433d722a9Sopenharmony_ci    label: None,
4533d722a9Sopenharmony_ci    note: Some("hint: wrap it in a UniquePtr<>"),
4633d722a9Sopenharmony_ci};
4733d722a9Sopenharmony_ci
4833d722a9Sopenharmony_cipub static CXX_TYPE_BY_VALUE: Error = Error {
4933d722a9Sopenharmony_ci    msg: "C++ type by value is not supported",
5033d722a9Sopenharmony_ci    label: None,
5133d722a9Sopenharmony_ci    note: Some("hint: wrap it in a UniquePtr<> or SharedPtr<>"),
5233d722a9Sopenharmony_ci};
5333d722a9Sopenharmony_ci
5433d722a9Sopenharmony_cipub static DISCRIMINANT_OVERFLOW: Error = Error {
5533d722a9Sopenharmony_ci    msg: "discriminant overflow on value after ",
5633d722a9Sopenharmony_ci    label: Some("discriminant overflow"),
5733d722a9Sopenharmony_ci    note: Some("note: explicitly set `= 0` if that is desired outcome"),
5833d722a9Sopenharmony_ci};
5933d722a9Sopenharmony_ci
6033d722a9Sopenharmony_cipub static DOT_INCLUDE: Error = Error {
6133d722a9Sopenharmony_ci    msg: "#include relative to `.` or `..` is not supported in Cargo builds",
6233d722a9Sopenharmony_ci    label: Some("#include relative to `.` or `..` is not supported in Cargo builds"),
6333d722a9Sopenharmony_ci    note: Some("note: use a path starting with the crate name"),
6433d722a9Sopenharmony_ci};
6533d722a9Sopenharmony_ci
6633d722a9Sopenharmony_cipub static DOUBLE_UNDERSCORE: Error = Error {
6733d722a9Sopenharmony_ci    msg: "identifiers containing double underscore are reserved in C++",
6833d722a9Sopenharmony_ci    label: Some("reserved identifier"),
6933d722a9Sopenharmony_ci    note: Some("identifiers containing double underscore are reserved in C++"),
7033d722a9Sopenharmony_ci};
7133d722a9Sopenharmony_ci
7233d722a9Sopenharmony_cipub static RESERVED_LIFETIME: Error = Error {
7333d722a9Sopenharmony_ci    msg: "invalid lifetime parameter name: `'static`",
7433d722a9Sopenharmony_ci    label: Some("'static is a reserved lifetime name"),
7533d722a9Sopenharmony_ci    note: None,
7633d722a9Sopenharmony_ci};
7733d722a9Sopenharmony_ci
7833d722a9Sopenharmony_cipub static RUST_TYPE_BY_VALUE: Error = Error {
7933d722a9Sopenharmony_ci    msg: "opaque Rust type by value is not supported",
8033d722a9Sopenharmony_ci    label: None,
8133d722a9Sopenharmony_ci    note: Some("hint: wrap it in a Box<>"),
8233d722a9Sopenharmony_ci};
8333d722a9Sopenharmony_ci
8433d722a9Sopenharmony_cipub static UNSUPPORTED_TYPE: Error = Error {
8533d722a9Sopenharmony_ci    msg: "unsupported type: ",
8633d722a9Sopenharmony_ci    label: Some("unsupported type"),
8733d722a9Sopenharmony_ci    note: None,
8833d722a9Sopenharmony_ci};
8933d722a9Sopenharmony_ci
9033d722a9Sopenharmony_cipub static USE_NOT_ALLOWED: Error = Error {
9133d722a9Sopenharmony_ci    msg: "`use` items are not allowed within cxx bridge",
9233d722a9Sopenharmony_ci    label: Some("not allowed"),
9333d722a9Sopenharmony_ci    note: Some(
9433d722a9Sopenharmony_ci        "`use` items are not allowed within cxx bridge; only types defined\n\
9533d722a9Sopenharmony_ci         within your bridge, primitive types, or types exported by the cxx\n\
9633d722a9Sopenharmony_ci         crate may be used",
9733d722a9Sopenharmony_ci    ),
9833d722a9Sopenharmony_ci};
99