nrxus / faux

Struct mocking library for Rust
https://nrxus.github.io/faux/
MIT License
411 stars 14 forks source link

`impl SomeType` as a parameter on a mocked method does not compile #15

Closed nrxus closed 4 years ago

nrxus commented 4 years ago

Example: if a parameter to a mocked function is &impl serde::Serialize, faux will fail to compile.

The culprit is this line:

let input: (#(#arg_types),*) = unsafe { std::mem::transmute((#(#arg_idents),*)) };

This becomes:

 let input: (&impl serde::Serialize) = unsafe { std::mem::transmute((_x0)) };

There is an issue for using impl on a let binding but I am unsure how the transmute might work with that: https://github.com/rust-lang/rust/issues/63065 :man_shrugging:

nrxus commented 4 years ago

The problem with the way the code is expanded is "fixed" in 500e9a9ea2d01396e6291129262bc7def8641d20 but impl arguments or any generic argument still does not work. Tracked in https://github.com/nrxus/faux/issues/18