Latest nightly rustc broke my mockers library. Generated methods now can't be compiled, failing with message “self
is not available in a static method. Maybe a self
argument is missing? [E0424]”.
The strange thing is that I have two ways to generate mock: custom derive clause and macro call. Custom derive clause receives parsed item description and macro parses item itself, but they both ways uses the same code-generation functions. And derive still works, but macro doesn't. I can't understand why.
I have extracted smallest plugin reproducing problem to https://github.com/kriomant/mockers_problem
$ cargo test
Compiling mockers_problem v0.0.1 (file:///Users/kriomant/from_self/mockers_macros)
tests/lib.rs:9:1: 14:2 error: `self` is not available in a static method. Maybe a `self` argument is missing? [E0424]
tests/lib.rs:9 mock!{
^
<std macros>:9:3: 9:42 note: in this expansion of format_args!
<std macros>:5:1: 7:6 note: in this expansion of panic! (defined in <std macros>)
tests/lib.rs:9:1: 14:2 note: in this expansion of unreachable! (defined in <std macros>)
tests/lib.rs:9:1: 14:2 note: in this expansion of mock! (defined in tests/lib.rs)
tests/lib.rs:9:1: 14:2 help: run `rustc --explain E0424` to see a detailed explanation
error: aborting due to previous error
error: Could not compile `mockers_problem`.
To learn more, run the command again with --verbose.
I have used -Z unstable-options --pretty=expanded
to view generated code and it seems to be identical.