Skip to content

Closure inference is based on expected type #2190

Closed
@brson

Description

@brson

UPDATE: I updated the title to reflect the root problem. "Closure inference" refers to detailing the specifics of a closure type, such as its bounds and so forth. Ideally, only the argument types would derive from the expected type (with a fallback to fresh type variables).

original issue report follows:

type t = {
    f: fn~()
};

fn main() {
    let _t: t = { f: {||()} };
}
../src/test/run-pass/test.rs:6:16: 6:29 error: mismatched types: expected `t` but found `{f: fn@()}` (in field `f`, closure protocol mismatch (fn~ vs fn@))
../src/test/run-pass/test.rs:6     let _t: t = { f: {||()} };

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions