genuinely what the fuck does "implementation of 'FnMut' is not general enough" mean

serious answer 

@0x57e11a Without seeing the code, I would guess that it means there are some ways in which it can be called that the implementation does not support (at least according to its signature)? In other words, the coverage of possible call signatures is not complete

re: serious answer 

@0x57e11a So my best guess as to what's going on there (although I'm not a Rust expert by any stretch of the imagination) is that the closure can be interpreted/typed in multiple ways, and in the first case, it gets a type hint from the specified return signature so it knows the type to interpret it as, but in the second case it doesn't have that information (as I don't think the type hint propagates backwards through `clos`?) and so it guesses the wrong type.

That doesn't really explain the error message, which I think is just wrong/vague and probably should be filed as a bug (error clarity bug at least). Maybe you can get more insight into what it expects by looking at the supposed type that the language server thinks `clos` has, and see how it differs from the return value signature?

Follow

re: serious answer 

@0x57e11a (Also you could probably force it into the correct shape by providing some sort of explicit type declaration for `clos` but that's... not great, and I'm not sure what declaration that would be exactly)

· · Web · 1 · 0 · 0

re: serious answer 

@joepie91 unfortunately, because the return type is `impl ...`, which is knowns as RPIT (Return Position Impl Trait), it's not something this one could name in a local, as RPIT is an opaque (but concrete) type that implements that trait

ultimately the workaround is to just allocate and have owned parameters, which isn't much when it's ~5x per file

re: serious answer 

@0x57e11a Yeah, I'm out of suggestions here unfortunately 😔 Pretty much every time I try to work with impl return types I have different but similar issues

re: serious answer 

@joepie91 probably also doesn't help that there *was* a `#![feature(impl_trait_in_bindings)]` nightly feature for a while, but it got removed due to causing ICEs :neobot_woozy:
Sign in to participate in the conversation
Pixietown

Small server part of the pixie.town infrastructure. Registration is closed.