Skip to content

Commit 7913d76

Browse files
Rollup merge of #113318 - tgross35:113283-allocator-trait-eq, r=m-ou-se
Revert "alloc: Allow comparing Boxs over different allocators", add regression test Temporary fix for #113283 Adds a test to fix the regression introduced in 001b081 and revert that commit. The test fails without the revert.
2 parents 1cb31e7 + a635bf7 commit 7913d76

File tree

2 files changed

+27
-26
lines changed

2 files changed

+27
-26
lines changed

library/alloc/src/boxed.rs

+9-26
Original file line numberDiff line numberDiff line change
@@ -1319,56 +1319,39 @@ impl Clone for Box<str> {
13191319
}
13201320

13211321
#[stable(feature = "rust1", since = "1.0.0")]
1322-
impl<T, A1, A2> PartialEq<Box<T, A2>> for Box<T, A1>
1323-
where
1324-
T: ?Sized + PartialEq,
1325-
A1: Allocator,
1326-
A2: Allocator,
1327-
{
1322+
impl<T: ?Sized + PartialEq, A: Allocator> PartialEq for Box<T, A> {
13281323
#[inline]
1329-
fn eq(&self, other: &Box<T, A2>) -> bool {
1324+
fn eq(&self, other: &Self) -> bool {
13301325
PartialEq::eq(&**self, &**other)
13311326
}
1332-
13331327
#[inline]
1334-
fn ne(&self, other: &Box<T, A2>) -> bool {
1328+
fn ne(&self, other: &Self) -> bool {
13351329
PartialEq::ne(&**self, &**other)
13361330
}
13371331
}
1338-
13391332
#[stable(feature = "rust1", since = "1.0.0")]
1340-
impl<T, A1, A2> PartialOrd<Box<T, A2>> for Box<T, A1>
1341-
where
1342-
T: ?Sized + PartialOrd,
1343-
A1: Allocator,
1344-
A2: Allocator,
1345-
{
1333+
impl<T: ?Sized + PartialOrd, A: Allocator> PartialOrd for Box<T, A> {
13461334
#[inline]
1347-
fn partial_cmp(&self, other: &Box<T, A2>) -> Option<Ordering> {
1335+
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
13481336
PartialOrd::partial_cmp(&**self, &**other)
13491337
}
1350-
13511338
#[inline]
1352-
fn lt(&self, other: &Box<T, A2>) -> bool {
1339+
fn lt(&self, other: &Self) -> bool {
13531340
PartialOrd::lt(&**self, &**other)
13541341
}
1355-
13561342
#[inline]
1357-
fn le(&self, other: &Box<T, A2>) -> bool {
1343+
fn le(&self, other: &Self) -> bool {
13581344
PartialOrd::le(&**self, &**other)
13591345
}
1360-
13611346
#[inline]
1362-
fn ge(&self, other: &Box<T, A2>) -> bool {
1347+
fn ge(&self, other: &Self) -> bool {
13631348
PartialOrd::ge(&**self, &**other)
13641349
}
1365-
13661350
#[inline]
1367-
fn gt(&self, other: &Box<T, A2>) -> bool {
1351+
fn gt(&self, other: &Self) -> bool {
13681352
PartialOrd::gt(&**self, &**other)
13691353
}
13701354
}
1371-
13721355
#[stable(feature = "rust1", since = "1.0.0")]
13731356
impl<T: ?Sized + Ord, A: Allocator> Ord for Box<T, A> {
13741357
#[inline]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// run-pass
2+
// Verify that PartialEq implementations do not break type inference when
3+
// accepting types with different allocators
4+
5+
use std::rc::Rc;
6+
use std::sync::Arc;
7+
8+
9+
fn main() {
10+
let boxed: Vec<Box<i32>> = vec![];
11+
assert_eq!(boxed, vec![]);
12+
13+
let rc: Vec<Rc<i32>> = vec![];
14+
assert_eq!(rc, vec![]);
15+
16+
let arc: Vec<Arc<i32>> = vec![];
17+
assert_eq!(arc, vec![]);
18+
}

0 commit comments

Comments
 (0)