Skip to content

Named functions don't implement Debug #31522

@asajeffrey

Description

@asajeffrey

Trying to compile (https://play.rust-lang.org/?gist=3b38f384f0f7ddecc142&version=stable):

fn foo() {}
fn main() {
    println!("{:?}", (foo as fn())); // Works
    println!("{:?}", foo);   // Fails
} 

It seem that named functions have to be coerced to anonymous ones in order to implement Debug. This means any structs containing functions don't derive Debug, which makes unit testing tricky.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-type-systemArea: Type systemC-feature-requestCategory: A feature request, i.e: not implemented / a PR.T-langRelevant to the language teamT-typesRelevant to the types team, which will review and decide on the PR/issue.

    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