Skip to content

A misdiagnosed case of type mismatch #11847

Open

Description

rust-analyzer version: bc08b8e 2022-03-28 stable

rustc version: 1.59.0 (9d1b2106e 2022-02-23)

image
I tried the example in https://smallcultfollowing.com/babysteps//blog/2022/03/29/dyn-can-we-make-dyn-sized/ and found that r-a gives wrong diagnostics.

The source code:

use std::fmt::Debug;

fn print_me_later(x: &dyn Debug) -> impl FnOnce() + '_ {
    move || println!("{x:?}")
}

fn main() {
    let f = print_me_later(&22);
    f()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    A-tytype system / type inference / traits / method resolutionC-bugCategory: bugS-actionableSomeone could pick this issue up and work on it right now

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions