Skip to content

Type inference is not correct #19473

Closed as duplicate of#5514
Closed as duplicate of#5514
@ADD-SP

Description

@ADD-SP

rust-analyzer version: rust-analyzer version: 0.3.2353-standalone (37acea8 2025-03-23)

rustc version: rustc 1.85.1 (4eb161250 2025-03-15)

editor:VsCode 1.98.2

editor or extension: rust-analyzer (VsCode): 0.3.2353

relevant settings: No special settings

repository link (if public, optional): N/A

code snippet to reproduce:

pub struct Foo {
    v: u8,
}

impl<T: Into<usize>> From<T> for Foo {
    fn from(v: T) -> Self {
        let v = v.into(); // RA thought the type of `v` is `u8` instead of  `usize`.
        Foo { v: v as u8 }
    }
}
Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-tytype system / type inference / traits / method resolutionC-bugCategory: bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions