Skip to content

Missing impl PartialEq<Vec<T>> for [T; N] #149017

@theemathas

Description

@theemathas

I tried this code:

fn main() {
    let x = vec![1];
    let y = [1];
    let _ = x == y;  // Works
    let _ = y == x;  // Compile error
}

I got the following compile error:

error[E0277]: can't compare `[{integer}; 1]` with `Vec<{integer}>`
 --> src/main.rs:5:15
  |
5 |     let _ = y == x;  // Compile error
  |               ^^ no implementation for `[{integer}; 1] == Vec<{integer}>`
  |
  = help: the trait `PartialEq<Vec<{integer}>>` is not implemented for `[{integer}; 1]`
help: consider dereferencing here
  |
5 |     let _ = y == *x;  // Compile error
  |                  +

For more information about this error, try `rustc --explain E0277`.

There's an impl PartialEq<[T; N]> for Vec<T> in std. However, the opposite impl (impl PartialEq<Vec<T>> for [T; N]) is missing.

I have not checked if any other "opposite impls" are also missing.

Meta

Reproducible on the playground with version 1.93.0-nightly (2025-11-16 518b428304e0008859cb)

Metadata

Metadata

Labels

C-bugCategory: This is a bug.E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions