-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat: Allow generics in method return types and arguments. #62
Conversation
Partial fix fo nrxus#18 This changeset allows generics to method return types and arguments. Generic impl traits are still not supported in return position (yet?).
Sometimes Generics expose some static function relevant for a given type. This doesn't mean they arent't used. This changeset allows to mock those as well. Note that calling such mocks in faux::when! requires the receiver args syntax.
I've just added support for Generics that aren't necesarily used in the function signature (because they might expose static methods for example). Happy to update the docs, or split it into an other PR if you feel this contribution would prove useful! :) |
Hey thanks for the PR, I haven't dove into the code yet but the tests look great. Two things though:
|
Hi, thanks a lot for your reply! I'll try to work on both points you mentionned this week :) |
…ric type name to the error message in case a stub is missing
502bef6
to
f0eead8
Compare
Hi! I've just adressed the first part, and added the generic name in the error messages when a stub is missing. Let me know if it's worth a try (potentially in an other PR, I'd like this one to not grow too much 😅)
Indeed, I'm not sure if/how to deal with that, but I'll send a message your way if I figure something out sometimes. |
I have a poorly written yet somewhat working implementation of the Callsite information seems to be propagated for both aync and async calls, but there are probably cornercases I haven't seen. The main issue at the moment is that I rely on I stumbled upon this idea while trying to chase the second point you mentioned, but I keep hitting walls such as Sized bounds, opaque types being different etc. Happy to dig further if you think it might be interesting! |
I am currently on a trip and I have misplaced my laptop so I won't get a chance to take a deep look on this again until this coming weekend but from what I can see through my phone it looks great and I will probably merge it as is. So thanks a lot! Regarding the track call site, it's a pretty interesting idea and I am not opposed to bumping the MSRV for it (as long as it's all documented). From what I remember about the |
It seems like the "Capture rules" evolved in edition 2021 indeed (TIL!), so we would need to be mindful of that. I'll open a separate issue to the repo so we can discuss it separately if that works for you. https://rust-lang.github.io/rfcs/3617-precise-capturing.html#lifetime-capture-rules-2024 |
opening a separate issue/PR for that makes sense. I finally had time to go through this PR more in depth and everything looks great thank you! I will probably take a bit to do a release with this because there is some lints/warnings (unrelated to this PR) that I need to sort through on the latest rust version but I will try to one without too much delay |
Hm it actually fails tests when run in release mode (I didn't notice until after I merged). Any chance you can take a look at why? I am guessing there is some optimization happening that makes the two structs that are used as the generic param collapse into one? |
I figured out the issue and fixed it so I did a release with this. There is still the not-related new set of warnings that the macro expansions are creating regarding elided lifetimes that I gotta figure out but that's existing so I'll try to make another patch for that at a later time (unless you really like looking at macro code and feel like addressing that :p) Thank you for your PR! |
Oh gosh sorry I'm on gh notification bankrupcy and didn't notice that one, glad you figured it out! I might have a bit of time available to see if there's any followups I can hop on |
Partial fix fo #18
This changeset allows generics to method return types and arguments.
Generic impl traits are still not supported in return position (yet?).