Skip to content

Commit 8fddaab

Browse files
committed
Auto merge of rust-lang#80209 - erikdesjardins:ptrcmp, r=Mark-Simulacrum
Remove pointer comparison from slice equality This resurrects rust-lang#71735. Fixes rust-lang#71602, helps with rust-lang#80140. r? `@Mark-Simulacrum`
2 parents 1072c45 + 3c592dc commit 8fddaab

File tree

1 file changed

+0
-27
lines changed

1 file changed

+0
-27
lines changed

core/src/slice/cmp.rs

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -75,28 +75,6 @@ where
7575
}
7676
}
7777

78-
// Use an equal-pointer optimization when types are `Eq`
79-
// We can't make `A` and `B` the same type because `min_specialization` won't
80-
// allow it.
81-
impl<A, B> SlicePartialEq<B> for [A]
82-
where
83-
A: MarkerEq<B>,
84-
{
85-
default fn equal(&self, other: &[B]) -> bool {
86-
if self.len() != other.len() {
87-
return false;
88-
}
89-
90-
// While performance would suffer if `guaranteed_eq` just returned `false`
91-
// for all arguments, correctness and return value of this function are not affected.
92-
if self.as_ptr().guaranteed_eq(other.as_ptr() as *const A) {
93-
return true;
94-
}
95-
96-
self.iter().zip(other.iter()).all(|(x, y)| x == y)
97-
}
98-
}
99-
10078
// Use memcmp for bytewise equality when the types allow
10179
impl<A, B> SlicePartialEq<B> for [A]
10280
where
@@ -107,11 +85,6 @@ where
10785
return false;
10886
}
10987

110-
// While performance would suffer if `guaranteed_eq` just returned `false`
111-
// for all arguments, correctness and return value of this function are not affected.
112-
if self.as_ptr().guaranteed_eq(other.as_ptr() as *const A) {
113-
return true;
114-
}
11588
// SAFETY: `self` and `other` are references and are thus guaranteed to be valid.
11689
// The two slices have been checked to have the same size above.
11790
unsafe {

0 commit comments

Comments
 (0)