Skip to content

MarkerEq doesn't specialize on unsized types #154998

@Gaming32

Description

@Gaming32

If you write the following code, the a == b will not specialize to pointer comparisons purely because str is unsized. If a String were used, the address would be compared.

let a: Rc<str> = "example".into();
let b = Rc::clone(a);
a == b;

You can see an example on Godbolt here: https://godbolt.org/z/qeKMYvPo1.

The bug itself narrows down to, as far as I can see, the following code using T: Eq instead of T: ?Sized + Eq. Notably the code just below uses ?Sized + MarkerEq, which will never occur unless a std type were to manually implement MarkerEq for some reason, leading me to believe that this is likely an unintended for this bound to fail on unsized types.

Meta

rustc --version --verbose:

rustc 1.94.0 (4a4ef493e 2026-03-02)
binary: rustc
commit-hash: 4a4ef493e3a1488c6e321570238084b38948f6db
commit-date: 2026-03-02
host: x86_64-pc-windows-msvc
release: 1.94.0
LLVM version: 21.1.8

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions