Skip to content

1.90.0 regression: type inference fails when comparing CString array with empty array literal #146782

@magicant

Description

@magicant

Code

I tried this code:

fn main() {
    let v: [std::ffi::CString; 0] = [];
    assert_eq!(v, []);
}

I expected to see this happen: successful build.

Instead, this happened:

$ cargo +stable r
   Compiling e0282 v0.1.0 (/home/magicant/Projects/e0282)
error[E0282]: type annotations needed
 --> src/main.rs:3:5
  |
3 |     assert_eq!(v, []);
  |     ^^^^^^^^^^^^^^^^^ cannot infer type
  |
  = note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info)

For more information about this error, try `rustc --explain E0282`.
error: could not compile `e0282` (bin "e0282") due to 1 previous error

Version it worked on

It most recently worked on: 1.89.0

Version with regression

rustc --version --verbose:

rustc 1.90.0 (1159e78c4 2025-09-14)
binary: rustc
commit-hash: 1159e78c4747b02ef996e55082b704c09b970588
commit-date: 2025-09-14
host: x86_64-unknown-linux-gnu
release: 1.90.0
LLVM version: 20.1.8

Backtrace

None. (No crash)

Additional notes

This might be related to the new PartialEq impls for CStr(ing) that were stabilized in 1.90.0.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions