mirror of
https://github.com/servo/servo.git
synced 2025-07-24 15:50:21 +01:00
Replace WebIdlError enum with ParentMismatchError struct.
This commit is contained in:
parent
6db7518110
commit
0d3bee28c8
1 changed files with 18 additions and 20 deletions
|
@ -26,32 +26,30 @@ declare_lint!(
|
|||
pub struct WebIdlPass;
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub enum WebIdlError {
|
||||
ParentMismatch {
|
||||
name: String,
|
||||
rust_parent: String,
|
||||
webidl_parent: String,
|
||||
},
|
||||
pub struct ParentMismatchError {
|
||||
name: String,
|
||||
rust_parent: String,
|
||||
webidl_parent: String,
|
||||
}
|
||||
|
||||
impl fmt::Display for WebIdlError {
|
||||
impl fmt::Display for ParentMismatchError {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
match self {
|
||||
WebIdlError::ParentMismatch {
|
||||
name,
|
||||
rust_parent,
|
||||
webidl_parent,
|
||||
} => {
|
||||
return write!(f, "webidl-rust inheritance mismatch, rust: {:?}, rust parent: {:?}, webidl parent: {:?}",
|
||||
&name, &rust_parent, &webidl_parent);
|
||||
},
|
||||
}
|
||||
let ParentMismatchError {
|
||||
name,
|
||||
rust_parent,
|
||||
webidl_parent,
|
||||
} = self;
|
||||
write!(
|
||||
f,
|
||||
"webidl-rust inheritance mismatch, rust: {:?}, rust parent: {:?}, webidl parent: {:?}",
|
||||
&name, &rust_parent, &webidl_parent
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
impl Error for WebIdlError {
|
||||
impl Error for ParentMismatchError {
|
||||
fn description(&self) -> &str {
|
||||
"WebIdlError"
|
||||
"ParentMismatchError"
|
||||
}
|
||||
|
||||
fn cause(&self) -> Option<&Error> {
|
||||
|
@ -126,7 +124,7 @@ fn check_inherits(code: &str, name: &str, parent_name: &str) -> Result<(), Box<E
|
|||
return Ok(());
|
||||
}
|
||||
|
||||
Err(boxed::Box::from(WebIdlError::ParentMismatch {
|
||||
Err(boxed::Box::from(ParentMismatchError {
|
||||
name: name.to_string(),
|
||||
rust_parent: parent_name.to_string(),
|
||||
webidl_parent: inherits.to_string(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue