Add a test for PartialEq across Allocators breaking inference (#113283)

Verify that `PartialEq` implementations do not break type inference
when comparing types across different allocators. This catches a
regression in current nightly introduced in 001b081cc1 (alloc: Allow
comparing `Box`s over different allocators")

`Box` is the only type that currently impelements this, but tests are
included for `Rc` and `Arc` to prevent future regresssions.
This commit is contained in:
Trevor Gross 2023-07-04 04:05:44 -04:00
parent 0130c3a06e
commit 3c9a7491c2

View 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![]);
}