Skip to content

Passing a Fn to an fn now requires explicit lifetimes for the Fn and all references passed to it when invoked #25310

Closed
@codyps

Description

@codyps
use std::env;
use std::ffi::OsString;

/* Explicit lifetimes are required by rust-2015-05-11 nightly (newer than playpen at the moment)
 * Previously implicit lifetimes worked fine */
fn foo<'a, F>(bar: &'a F) -> Option<OsString>
    where F: Fn(&'a str) -> Option<OsString>
{
    bar("HOME")
}

fn main() {
    println!("{:?}", foo(&env::var_os));
}

Playpen: http://is.gd/LYhXZx

Might be caused by: #25212

I'm unsure if this is an actual issue that can be fixed, but figured I'd open an issue in case it was.

Metadata

Metadata

Assignees

Labels

A-closuresArea: Closures (`|…| { … }`)P-highHigh priorityT-langRelevant to the language team, which will review and decide on the PR/issue.regression-from-stable-to-nightlyPerformance or correctness regression from stable to nightly.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions