Skip to content
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

impl Into<B>.into() has type {unknown} #15521

Closed
Geo25rey opened this issue Aug 27, 2023 · 2 comments
Closed

impl Into<B>.into() has type {unknown} #15521

Geo25rey opened this issue Aug 27, 2023 · 2 comments
Labels
C-bug Category: bug

Comments

@Geo25rey
Copy link

rust-analyzer version: 0.3.1623-standalone (2fbe69d 2023-08-12)

rustc version: rustc 1.72.0 (5680fa18f 2023-08-23)

relevant settings: all default settings on stable version channel

Description

In the main function below, let b should be annotated with : B as the rust compiler understands, but instead generates no annotation and when highlighted has type {unknown}. Additionally, on the following line, b.a does not generate an error, does not provide any type information, and has white syntax highlighting on the a instead of the blue that you get when manually adding the : B annotation on the previous line.

Code to Reproduce

pub struct B {
    a: u64,
}

#[derive(Clone)]
pub struct A(u64);

impl Into<B> for A {
    fn into(self) -> B {
        B { a: self.0 }
    }
}

fn main() {
    let a: A = A(8);
    let b = a_to_b(&a).into(); // this is type B but rust-analyzer says the type is {unknown}
    println!("b.a = {}", b.a)
}

fn a_to_b(b_compat: &(impl Into<B> + Clone)) -> impl Into<B> {
    b_compat.clone()
}
@Geo25rey Geo25rey added the C-bug Category: bug label Aug 27, 2023
@laundmo
Copy link

laundmo commented Aug 27, 2023

a much easier reproduction of what i belive to be the same bug

fn impl_into(arg: impl Into<f64>){
    let a = arg.into();
    //  ^ this fails to resolve, shows {unknown}
    dbg!(a);
}

fn main() {
    impl_into(1.1f32);    
}

i tested multiple old versions and the current pre-release, and the issue persists in all of them

@HKalbasi
Copy link
Member

Duplicate of #5514

@HKalbasi HKalbasi marked this as a duplicate of #5514 Aug 27, 2023
@HKalbasi HKalbasi closed this as not planned Won't fix, can't repro, duplicate, stale Aug 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: bug
Projects
None yet
Development

No branches or pull requests

3 participants