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

&dyn Display not match type of interger literal without explicit annotated #13150

Closed
occurrent opened this issue Aug 31, 2022 · 1 comment
Closed

Comments

@occurrent
Copy link

see example below

use std::{fmt::{Display, Formatter, Result}};

trait D{
    // copy from std lib
    fn fmt(&self, _: &mut Formatter<'_>) -> Result;
}

impl D for i32{
    fn fmt(&self, _: &mut Formatter<'_>) -> Result{
        todo!()
    }
}

fn main() {
    let i1 = 1;
    let i2 = 1i32;
    let i3: i32 = 1;

    // ra: error
    let _ : &dyn Display = &i1;
    // ra: pass
    let _ : &dyn Display = &i2;
    let _ : &dyn Display = &i3;

    // ra: error
    let _ : &dyn Display = &1;
    let _ : &dyn Display = &1.;

    // ra: pass
    let _ : &dyn D = &1;

    // ra: pass
    let _ : &dyn Display = &"";
    let _ : &dyn Display = &1i32;
    let _ : &dyn Display = &1f64;
}

The above code was reported as an error by ra, but passed by cargo check and rustc.

rust-analyzer version: 0.3.1186-standalone (e8e598f 2022-08-28)
rustc version: rustc 1.63.0 (4b91a6ea7 2022-08-08)

@ChayimFriedman2
Copy link
Contributor

Dup #11847.

@flodiebold flodiebold closed this as not planned Won't fix, can't repro, duplicate, stale Aug 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants