Skip to content

calling impl Fn in defining scope #181

Open
rust-lang/rust
#140496
@compiler-errors

Description

@compiler-errors

impacts multiple crates:

struct ShExCompactPrinter;

struct TripleExpr;

impl ShExCompactPrinter {
    fn pp_triple_expr(&self) -> impl Fn(&TripleExpr, &ShExCompactPrinter) + '_ {
        move |te, printer| {
            printer.pp_triple_expr()(te, printer);
        }
    }
}
error[E0282]: type annotations needed
 --> /home/mgx/test.rs:8:13
  |
8 |             printer.pp_triple_expr()(te, printer);
  |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type

error[E0618]: expected function, found `impl for<'a, 'b> Fn(&'a TripleExpr, &'b ShExCompactPrinter) + '_`
 --> /home/mgx/test.rs:8:13
  |
8 |             printer.pp_triple_expr()(te, printer);
  |             ^^^^^^^^^^^^^^^^^^^^^^^^-------------
  |             |
  |             call expression requires function

Has to do with recursive definition of opaque.

Metadata

Metadata

Labels

from-craterA regression found via a crater run, not part of our test suite

Type

No type

Projects

Status

in progress

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions