Associated type and FnOnce bound problem 2.0

Hey folks,

I read this topic and tried to understand the problem in it a little bit better therefore I boiled down the code to this.

Unfortunately I still have no clue which problem the compiler has with the code. @quinedot mentioned an open issue on GitHub in the other topic but I don't understand how it relates to the problem.

Could anybody explain this to me? I would be very grateful for that! :slight_smile: I don't have a practical problem related to this, I'm just curious. :wink:

Regards
keks

Your reduction shows it's not actually a higher-ranked issue, but more generally a normalization issue.

Here's another possible root cause.

2 Likes

Thanks! :slight_smile: It also looks to me as if this might be the problem here indeed... now I can sleep well again. :smile:

EDIT: When you don't use the AT it works, so this really seems to be the problem here. :slight_smile:

What is "normalization issue"? Some issue with selecting correct associated type?

Normalization is about resolving an associated type path (also called a projection) into a defined type, or at least into some other canonical form where it can compare types or otherwise perform trait solving.

The error from the OP says

   = note: expected a closure with arguments `(<TaskCreatorImpl as TaskCreator>::TaskCtx,)`
              found a closure with arguments `(TaskCtxImpl,)`

But the error in question is within an implementation like so

impl TaskCreator for TaskCreatorImpl {
    type TaskCtx = TaskCtxImpl;

So <TaskCreatorImpl as TaskCreator>::TaskCtx and TaskCtxImpl are the same thing, but the compiler is failing to recognize it (failing to normalize the former or too-eagerly normalizing the latter).

1 Like

Thank you, @quinedot .

1 Like