Box<impl Trait> `peg` 0.8.1 regression
fmorency opened this issue · 1 comments
fmorency commented
Compilation of a peg::parser
containing a function returning a Box<impl Trait>
will fail with peg 0.8.1
but succeed with peg 0.8.0
.
E.g.
peg::parser!{
grammar list_parser() for str {
rule number() -> u64
= n:$(['0'..='9']+) {? n.parse().or(Err("u64")) }
pub rule list() -> Box<impl FooTrait>
= n:(number()) { Box::new(FooStruct { val: n }) }
}
}
kevinmehall commented
Oops, this is from adding a type annotation to help type inference (#317), but impl Trait
can't be named except in a return type position. We'll have to figure out how to fix type inference in that case without explicitly naming the type.