Skip to content

Commit

Permalink
Replace WebIdlError enum with ParentMismatchError struct.
Browse files Browse the repository at this point in the history
  • Loading branch information
krk committed Apr 20, 2019
1 parent 6db7518 commit 0d3bee2
Showing 1 changed file with 18 additions and 20 deletions.
38 changes: 18 additions & 20 deletions components/script_plugins/webidl_must_inherit.rs
Expand Up @@ -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> {
Expand Down Expand Up @@ -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(),
Expand Down

0 comments on commit 0d3bee2

Please sign in to comment.