about summary refs log tree commit diff
diff options
context:
space:
mode:
authorTrevor Gross <tmgross@umich.edu>2023-07-04 04:05:44 -0400
committerTrevor Gross <tmgross@umich.edu>2023-07-04 05:00:46 -0400
commit3c9a7491c2e2f54fa0ea59246c798017fcb8ce3f (patch)
treed42fc78fbe8699b66006db468cd7bd324769eed0
parent0130c3a06e50ebb166655f81997ce28b9e4029b0 (diff)
downloadrust-3c9a7491c2e2f54fa0ea59246c798017fcb8ce3f.tar.gz
rust-3c9a7491c2e2f54fa0ea59246c798017fcb8ce3f.zip
Add a test for `PartialEq` across `Allocator`s 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 001b081cc1b (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.
-rw-r--r--tests/ui/type-inference/issue-113283-alllocator-trait-eq.rs18
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/ui/type-inference/issue-113283-alllocator-trait-eq.rs b/tests/ui/type-inference/issue-113283-alllocator-trait-eq.rs
new file mode 100644
index 00000000000..5d0e456d9dd
--- /dev/null
+++ b/tests/ui/type-inference/issue-113283-alllocator-trait-eq.rs
@@ -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![]);
+}