Skip to content

Commit 7286ab2

Browse files
Also compare Symbol/InternedString by pointer
1 parent 19e5b52 commit 7286ab2

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/libsyntax_pos/symbol.rs

+10
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ impl Decodable for Symbol {
157157
}
158158

159159
impl PartialEq<InternedString> for Symbol {
160+
#[inline]
160161
fn eq(&self, other: &InternedString) -> bool {
161162
// Compare pointers
162163
self.as_str() == *other
@@ -370,11 +371,20 @@ impl<U: ?Sized> ::std::convert::AsRef<U> for InternedString where str: ::std::co
370371
}
371372

372373
impl ::std::cmp::PartialEq<InternedString> for InternedString {
374+
#[inline]
373375
fn eq(&self, other: &InternedString) -> bool {
374376
self.as_ptr() == other.as_ptr()
375377
}
376378
}
377379

380+
impl PartialEq<Symbol> for InternedString {
381+
#[inline]
382+
fn eq(&self, other: &Symbol) -> bool {
383+
// Compare pointers
384+
*self == other.as_str()
385+
}
386+
}
387+
378388
macro_rules! impl_partial_eq_for_symbol_and_interned_string {
379389
($(impl $(<$impl_lt:lifetime>)* for $t:ty;)*) => ($(
380390
impl<$($impl_lt),*> ::std::cmp::PartialEq<$t> for InternedString {

0 commit comments

Comments
 (0)