Open comex opened 7 years ago
@comex This is a classical induction problem: the compiler cannot reason, ahead of time, that there isn't an impl
for an arbitrarily large tuple where NewState
matches.
Although, in this case... did you mean type NewState = NewState;
? If so, this is specifically a limitation of the current implementation w.r.t type parameters which are only constrained by associated types.
I guess has to do with the order of considering constraints. It shouldn't have to go hunting for such an impl, because Insns
is forced to be Nil
by the parameter. Actually, if I add an explicit type parameter to print_bf
, it fails immediately:
print_bf::<_, Nil, _>(state, insns);
produces
error[E0277]: the trait bound `(_, Nil): BF` is not satisfied
cc @nikomatsakis
Duplicate of #38528?
Not resolved in #48296, the battle continues...
Found when trying to port my old type system Brainfuck interpreter to use associated types. Reduced case:
I don't really understand what's going on, but as written, rustc outputs:
However, increasing the recursion_limit dramatically increases the time it takes to report the error.
Note that writing the impl more normally as
fails instantly even with a high recursion limit. But I don't see why it should fail at all: the impl is sane enough, implementing
BF
for a larger type based on its implementation for a smaller type.