Skip to content

Type inference is not correct #19473

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ADD-SP opened this issue Mar 29, 2025 · 1 comment
Closed

Type inference is not correct #19473

ADD-SP opened this issue Mar 29, 2025 · 1 comment
Labels
A-ty type system / type inference / traits / method resolution C-bug Category: bug

Comments

@ADD-SP
Copy link

ADD-SP commented Mar 29, 2025

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
@ADD-SP ADD-SP added the C-bug Category: bug label Mar 29, 2025
@ShoyuVanilla ShoyuVanilla added the A-ty type system / type inference / traits / method resolution label Mar 29, 2025
@ChayimFriedman2
Copy link
Contributor

This will be fixed when we switch to the new trait solver.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-ty type system / type inference / traits / method resolution C-bug Category: bug
Projects
None yet
Development

No branches or pull requests

3 participants