Skip to content

[next-trait] expected &dyn T found &Y #20487

@jhgg

Description

@jhgg

cc #20443 - this does not repro in stable release.

rust-analyzer version: 0.4.2586-standalone (a905e3b 2025-08-18)

rustc version: rustc 1.89.0-nightly (99e7c15 2025-06-01)

editor or extension: VSCode

relevant settings: N/A

code snippet to reproduce:

trait Foo {
    fn bar(&self) -> u32 {
        0xCAFE
    }
}

fn debug(_: &dyn Foo) {}

impl Foo for i32 {}

fn main() {
    debug(&1);
     //   ^^ expected &dyn Foo, found &i32
}

Similar to #20489, the error does not occur if the impl of Foo has no methods, e.g.

trait Foo { }

Metadata

Metadata

Assignees

Labels

A-new-solverBugs from the new solver migration - should be fixed before stable releaseC-bugCategory: bug

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions