Skip to content

Commit

Permalink
Remove the custom PartialEq implementations on TypeId enums
Browse files Browse the repository at this point in the history
rust-lang/rust#33593 made them useless.
  • Loading branch information
nox authored and zakorgy committed May 26, 2016
1 parent f64c3ea commit 5d93003
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 64 deletions.
4 changes: 1 addition & 3 deletions components/script/dom/bindings/codegen/CodegenRust.py
Original file line number Diff line number Diff line change
Expand Up @@ -6377,9 +6377,7 @@ def type_id_variant(name):
if not config.getInterface(base).getExtendedAttribute("Abstract"):
variants.append(CGGeneric(base))
variants += [CGGeneric(type_id_variant(derivedName)) for derivedName in derived]
derives = "Clone, Copy, Debug"
if base != 'EventTarget' and base != 'HTMLElement':
derives += ", PartialEq"
derives = "Clone, Copy, Debug, PartialEq"
typeIdCode.append(CGWrapper(CGIndenter(CGList(variants, ",\n"), 4),
pre="#[derive(%s)]\npub enum %sTypeId {\n" % (derives, base),
post="\n}\n\n"))
Expand Down
40 changes: 2 additions & 38 deletions components/script/dom/eventtarget.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use dom::bindings::codegen::Bindings::EventTargetBinding::EventTargetMethods;
use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods;
use dom::bindings::codegen::UnionTypes::EventOrString;
use dom::bindings::error::{Error, Fallible, report_pending_exception};
use dom::bindings::inheritance::{Castable, EventTargetTypeId};
use dom::bindings::inheritance::Castable;
use dom::bindings::js::Root;
use dom::bindings::reflector::{Reflectable, Reflector};
use dom::element::Element;
Expand All @@ -35,8 +35,8 @@ use std::ffi::CString;
use std::hash::BuildHasherDefault;
use std::mem;
use std::ops::{Deref, DerefMut};
use std::ptr;
use std::rc::Rc;
use std::{intrinsics, ptr};
use string_cache::Atom;
use url::Url;
use util::str::DOMString;
Expand All @@ -62,42 +62,6 @@ pub enum ListenerPhase {
Bubbling,
}

impl PartialEq for EventTargetTypeId {
#[inline]
fn eq(&self, other: &EventTargetTypeId) -> bool {
match (*self, *other) {
(EventTargetTypeId::Node(this_type), EventTargetTypeId::Node(other_type)) => {
this_type == other_type
}
_ => self.eq_slow(other)
}
}
}

impl EventTargetTypeId {
#[allow(unsafe_code)]
fn eq_slow(&self, other: &EventTargetTypeId) -> bool {
match (*self, *other) {
(EventTargetTypeId::Node(this_type), EventTargetTypeId::Node(other_type)) => {
this_type == other_type
}
(EventTargetTypeId::WorkerGlobalScope(this_type),
EventTargetTypeId::WorkerGlobalScope(other_type)) => {
this_type == other_type
}
(EventTargetTypeId::XMLHttpRequestEventTarget(this_type),
EventTargetTypeId::XMLHttpRequestEventTarget(other_type)) => {
this_type == other_type
}
(_, _) => {
unsafe {
intrinsics::discriminant_value(self) == intrinsics::discriminant_value(other)
}
}
}
}
}

/// https://html.spec.whatwg.org/multipage/#internal-raw-uncompiled-handler
#[derive(JSTraceable, Clone, PartialEq)]
pub struct InternalRawUncompiledHandler {
Expand Down
23 changes: 0 additions & 23 deletions components/script/dom/htmlelement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ use dom::virtualmethods::VirtualMethods;
use std::ascii::AsciiExt;
use std::borrow::ToOwned;
use std::default::Default;
use std::intrinsics;
use std::rc::Rc;
use string_cache::Atom;
use style::element_state::*;
Expand Down Expand Up @@ -488,25 +487,3 @@ impl VirtualMethods for HTMLElement {
self.update_sequentially_focusable_status();
}
}

impl PartialEq for HTMLElementTypeId {
#[inline]
#[allow(unsafe_code)]
fn eq(&self, other: &HTMLElementTypeId) -> bool {
match (*self, *other) {
(HTMLElementTypeId::HTMLMediaElement(this_type),
HTMLElementTypeId::HTMLMediaElement(other_type)) => {
this_type == other_type
}
(HTMLElementTypeId::HTMLTableCellElement(this_type),
HTMLElementTypeId::HTMLTableCellElement(other_type)) => {
this_type == other_type
}
(_, _) => {
unsafe {
intrinsics::discriminant_value(self) == intrinsics::discriminant_value(other)
}
}
}
}
}

0 comments on commit 5d93003

Please sign in to comment.