Skip to content

Strangly refmatch type #22324

@A4-Tacks

Description

@A4-Tacks

rust-analyzer version:
rust-analyzer 0.4.2892-standalone

rustc version:
rustc 1.97.0-nightly (36ba2c771 2026-04-23)

editor or extension: Vim

Related: #22285

Type::could_unify_with is a bit strange, cc @ChayimFriedman2

code snippet to reproduce:

struct S<T>(T);
fn foo<T>(s: &mut S<T>) {}
fn main() {
    let mut ssss = S(2u32);
    foo($0);
}

Before:

None~ None
S(…)~ S(T)

After:

&mut S(…)~ S(T)
&mut ssss~ S<u32>
&mut S~ S<{unknown}>
&mut Box~ Box<{unknown}, {unknown}>
None~ None
S(…)~ S(T)

Box should not appear, it may be strange for S~ to be added with 'ref match' and preferred

Expect:

&mut S(…)~ S(T)
&mut ssss~ S<u32>
None~ None
S(…)~ S(T)

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: 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