mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 06:44:35 +00:00
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 001b081cc1
and revert that commit. The test fails without the revert.
This commit is contained in:
commit
7913d76cb9
@ -1319,56 +1319,39 @@ impl Clone for Box<str> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
impl<T, A1, A2> PartialEq<Box<T, A2>> for Box<T, A1>
|
impl<T: ?Sized + PartialEq, A: Allocator> PartialEq for Box<T, A> {
|
||||||
where
|
|
||||||
T: ?Sized + PartialEq,
|
|
||||||
A1: Allocator,
|
|
||||||
A2: Allocator,
|
|
||||||
{
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn eq(&self, other: &Box<T, A2>) -> bool {
|
fn eq(&self, other: &Self) -> bool {
|
||||||
PartialEq::eq(&**self, &**other)
|
PartialEq::eq(&**self, &**other)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn ne(&self, other: &Box<T, A2>) -> bool {
|
fn ne(&self, other: &Self) -> bool {
|
||||||
PartialEq::ne(&**self, &**other)
|
PartialEq::ne(&**self, &**other)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
impl<T, A1, A2> PartialOrd<Box<T, A2>> for Box<T, A1>
|
impl<T: ?Sized + PartialOrd, A: Allocator> PartialOrd for Box<T, A> {
|
||||||
where
|
|
||||||
T: ?Sized + PartialOrd,
|
|
||||||
A1: Allocator,
|
|
||||||
A2: Allocator,
|
|
||||||
{
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn partial_cmp(&self, other: &Box<T, A2>) -> Option<Ordering> {
|
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
|
||||||
PartialOrd::partial_cmp(&**self, &**other)
|
PartialOrd::partial_cmp(&**self, &**other)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn lt(&self, other: &Box<T, A2>) -> bool {
|
fn lt(&self, other: &Self) -> bool {
|
||||||
PartialOrd::lt(&**self, &**other)
|
PartialOrd::lt(&**self, &**other)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn le(&self, other: &Box<T, A2>) -> bool {
|
fn le(&self, other: &Self) -> bool {
|
||||||
PartialOrd::le(&**self, &**other)
|
PartialOrd::le(&**self, &**other)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn ge(&self, other: &Box<T, A2>) -> bool {
|
fn ge(&self, other: &Self) -> bool {
|
||||||
PartialOrd::ge(&**self, &**other)
|
PartialOrd::ge(&**self, &**other)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn gt(&self, other: &Box<T, A2>) -> bool {
|
fn gt(&self, other: &Self) -> bool {
|
||||||
PartialOrd::gt(&**self, &**other)
|
PartialOrd::gt(&**self, &**other)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
impl<T: ?Sized + Ord, A: Allocator> Ord for Box<T, A> {
|
impl<T: ?Sized + Ord, A: Allocator> Ord for Box<T, A> {
|
||||||
#[inline]
|
#[inline]
|
||||||
|
18
tests/ui/type-inference/issue-113283-alllocator-trait-eq.rs
Normal file
18
tests/ui/type-inference/issue-113283-alllocator-trait-eq.rs
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
// run-pass
|
||||||
|
// Verify that PartialEq implementations do not break type inference when
|
||||||
|
// accepting types with different allocators
|
||||||
|
|
||||||
|
use std::rc::Rc;
|
||||||
|
use std::sync::Arc;
|
||||||
|
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let boxed: Vec<Box<i32>> = vec![];
|
||||||
|
assert_eq!(boxed, vec![]);
|
||||||
|
|
||||||
|
let rc: Vec<Rc<i32>> = vec![];
|
||||||
|
assert_eq!(rc, vec![]);
|
||||||
|
|
||||||
|
let arc: Vec<Arc<i32>> = vec![];
|
||||||
|
assert_eq!(arc, vec![]);
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user