Skip to content

proc with a reference as an argument meets lifetime errors when inferring type #14037

Closed
@huonw

Description

@huonw
fn main() {
    let f = proc(_) {};
    let g: proc(&()) = f;
}
proc_ref_infer.rs:3:24: 3:25 error: mismatched types: expected `proc(&())` but found `proc(<generic #3>):Send` (expected concrete lifetime, but found bound lifetime parameter &)
proc_ref_infer.rs:3     let g: proc(&()) = f;
                                           ^
note: expected concrete lifetime is lifetime ReInfer(ReSkolemized(0u, BrAnon(0u)))
proc_ref_infer.rs:2:9: 2:23 error: cannot determine a type for this local variable: unconstrained type
proc_ref_infer.rs:2     let f = proc(_) {};
                            ^~~~~~~~~~~~~~
error: aborting due to 2 previous errors

Changing the argument type to something that's not a reference (e.g. just ()) works fine.

cc @nikomatsakis @pnkfelix

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-lifetimesArea: Lifetimes / regions

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions