Skip to content

FnBox is not callable with function call syntax if it has a bound lifetime argument #33811

Closed
@bluss

Description

@bluss

The following does not compile, but I expect it to! If the argument type is changed from &str to i32 (and the call site adapted), then it compiles. Playground

#![feature(fnbox)]

use std::boxed::FnBox;

struct Func {
    out: Box<FnBox(&str)>
}

impl Func {
    fn callme(self) {
        let s = String::new();
        (self.out)(&s);
    }
}
error: expected function, found `Box<for<'r> std::boxed::FnBox<(&'r str,), Output=()> + 'static>`
  --> <anon>:12:9
12 |>         (self.out)(&s);
   |>         ^^^^^^^^^^^^^^

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.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