Skip to content

Commit 5d93003

Browse files
noxzakorgy
authored andcommitted
Remove the custom PartialEq implementations on TypeId enums
rust-lang/rust#33593 made them useless.
1 parent f64c3ea commit 5d93003

File tree

3 files changed

+3
-64
lines changed

3 files changed

+3
-64
lines changed

components/script/dom/bindings/codegen/CodegenRust.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6377,9 +6377,7 @@ def type_id_variant(name):
63776377
if not config.getInterface(base).getExtendedAttribute("Abstract"):
63786378
variants.append(CGGeneric(base))
63796379
variants += [CGGeneric(type_id_variant(derivedName)) for derivedName in derived]
6380-
derives = "Clone, Copy, Debug"
6381-
if base != 'EventTarget' and base != 'HTMLElement':
6382-
derives += ", PartialEq"
6380+
derives = "Clone, Copy, Debug, PartialEq"
63836381
typeIdCode.append(CGWrapper(CGIndenter(CGList(variants, ",\n"), 4),
63846382
pre="#[derive(%s)]\npub enum %sTypeId {\n" % (derives, base),
63856383
post="\n}\n\n"))

components/script/dom/eventtarget.rs

Lines changed: 2 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use dom::bindings::codegen::Bindings::EventTargetBinding::EventTargetMethods;
1313
use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods;
1414
use dom::bindings::codegen::UnionTypes::EventOrString;
1515
use dom::bindings::error::{Error, Fallible, report_pending_exception};
16-
use dom::bindings::inheritance::{Castable, EventTargetTypeId};
16+
use dom::bindings::inheritance::Castable;
1717
use dom::bindings::js::Root;
1818
use dom::bindings::reflector::{Reflectable, Reflector};
1919
use dom::element::Element;
@@ -35,8 +35,8 @@ use std::ffi::CString;
3535
use std::hash::BuildHasherDefault;
3636
use std::mem;
3737
use std::ops::{Deref, DerefMut};
38+
use std::ptr;
3839
use std::rc::Rc;
39-
use std::{intrinsics, ptr};
4040
use string_cache::Atom;
4141
use url::Url;
4242
use util::str::DOMString;
@@ -62,42 +62,6 @@ pub enum ListenerPhase {
6262
Bubbling,
6363
}
6464

65-
impl PartialEq for EventTargetTypeId {
66-
#[inline]
67-
fn eq(&self, other: &EventTargetTypeId) -> bool {
68-
match (*self, *other) {
69-
(EventTargetTypeId::Node(this_type), EventTargetTypeId::Node(other_type)) => {
70-
this_type == other_type
71-
}
72-
_ => self.eq_slow(other)
73-
}
74-
}
75-
}
76-
77-
impl EventTargetTypeId {
78-
#[allow(unsafe_code)]
79-
fn eq_slow(&self, other: &EventTargetTypeId) -> bool {
80-
match (*self, *other) {
81-
(EventTargetTypeId::Node(this_type), EventTargetTypeId::Node(other_type)) => {
82-
this_type == other_type
83-
}
84-
(EventTargetTypeId::WorkerGlobalScope(this_type),
85-
EventTargetTypeId::WorkerGlobalScope(other_type)) => {
86-
this_type == other_type
87-
}
88-
(EventTargetTypeId::XMLHttpRequestEventTarget(this_type),
89-
EventTargetTypeId::XMLHttpRequestEventTarget(other_type)) => {
90-
this_type == other_type
91-
}
92-
(_, _) => {
93-
unsafe {
94-
intrinsics::discriminant_value(self) == intrinsics::discriminant_value(other)
95-
}
96-
}
97-
}
98-
}
99-
}
100-
10165
/// https://html.spec.whatwg.org/multipage/#internal-raw-uncompiled-handler
10266
#[derive(JSTraceable, Clone, PartialEq)]
10367
pub struct InternalRawUncompiledHandler {

components/script/dom/htmlelement.rs

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ use dom::virtualmethods::VirtualMethods;
3232
use std::ascii::AsciiExt;
3333
use std::borrow::ToOwned;
3434
use std::default::Default;
35-
use std::intrinsics;
3635
use std::rc::Rc;
3736
use string_cache::Atom;
3837
use style::element_state::*;
@@ -488,25 +487,3 @@ impl VirtualMethods for HTMLElement {
488487
self.update_sequentially_focusable_status();
489488
}
490489
}
491-
492-
impl PartialEq for HTMLElementTypeId {
493-
#[inline]
494-
#[allow(unsafe_code)]
495-
fn eq(&self, other: &HTMLElementTypeId) -> bool {
496-
match (*self, *other) {
497-
(HTMLElementTypeId::HTMLMediaElement(this_type),
498-
HTMLElementTypeId::HTMLMediaElement(other_type)) => {
499-
this_type == other_type
500-
}
501-
(HTMLElementTypeId::HTMLTableCellElement(this_type),
502-
HTMLElementTypeId::HTMLTableCellElement(other_type)) => {
503-
this_type == other_type
504-
}
505-
(_, _) => {
506-
unsafe {
507-
intrinsics::discriminant_value(self) == intrinsics::discriminant_value(other)
508-
}
509-
}
510-
}
511-
}
512-
}

0 commit comments

Comments
 (0)