intellij-rust / intellij-rust

Rust plugin for the IntelliJ Platform
https://intellij-rust.github.io
MIT License
4.54k stars 380 forks source link

False-positive "x doesn't implement `Display` (required by {})" #10508

Open s-titov opened 1 year ago

s-titov commented 1 year ago

Environment

Problem description

I've implemented fmt::Display for Point2D and it works, but IDE still shows me error.

image

Steps to reproduce

use std::fmt;

struct Point2D {
    x: f64,
    y: f64,
}

impl fmt::Display for Point2D {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        write!(f, "x: {}, y: {}", self.x, self.y)
    }
}

fn main() {
    let point = Point2D { x: 3.3, y: 7.2 };
    println!("Display: {}", point);
}
asorgejr commented 1 year ago

I have observed this consistently happening when I add a local crate as a dependency. Everything compiles fine, however the IDE only recognizes the type and not the implementation of Display, or any implemented method for that matter.