Skip to content

clone of fn has odd lifetime issues that copy of fn does not #14820

@pnkfelix

Description

@pnkfelix

Code:

#![crate_type="lib"]

#[cfg(v1)]
pub fn foo(f: fn<'a>(x: &'a())) -> fn<'b>(y: &'b()) { f }

#[cfg(v2)]
pub fn foo(f: fn<'a>(x: &'a())) -> fn<'b>(y: &'b()) { f.clone() }

Transcript of compile attempts:

% rustc --cfg v1 /tmp/cf.rs
% rustc --cfg v2 /tmp/cf.rs
/tmp/cf.rs:7:55: 7:64 error: mismatched types: expected `fn(&'b ())` but found `fn(&())` (expected concrete lifetime, but found bound lifetime parameter 'b)
/tmp/cf.rs:7 pub fn foo(f: fn<'a>(x: &'a())) -> fn<'b>(y: &'b()) { f.clone() }
                                                                   ^~~~~~~~~
note: expected concrete lifetime is lifetime ReInfer(ReVar(middle::ty::RegionVid{id: 43u}))
error: aborting due to previous error
% 

Metadata

Metadata

Assignees

No one assigned

    Labels

    E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions