Skip to content

A misdiagnosed case of type mismatch #11847

@xffxff

Description

@xffxff

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()
}

Metadata

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
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions