Skip to content

expected types of closure arguments are not inferred when coercing to a fn #41755

Closed
@nikomatsakis

Description

@nikomatsakis

Type inference for the expected type of arguments doesn't work when coercing from a closure expression. For example, this code does not compile https://is.gd/FNoLWg (at least, not without an explicit x: Vec<u32> annotation):

#![feature(closure_to_fn_coercion)]

fn foo(f: fn(Vec<u32>) -> usize) { }

fn main() {
    foo(|x| x.len())
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-type-systemArea: Type systemE-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions