galvanic-mock icon indicating copy to clipboard operation
galvanic-mock copied to clipboard

use_mocks isn't compatible with Rust 2018 uniform paths

Open asomers opened this issue 6 years ago • 0 comments

The #[use_mocks] macro panics when faced with use statements that use Rust 2018 uniform paths. For example, this code:

#![feature(proc_macro_hygiene)]
struct Foo();

#[cfg(test)]
mod tests {
    use galvanic_mock::*;

    #[use_mocks]
    mod t {
        use crate::Foo;
    }
}

will fail to build with this error:

error: custom attribute panicked
 --> src/lib.rs:8:5
  |
8 |     #[use_mocks]
  |     ^^^^^^^^^^^^
  |
  = help: message: called `Result::unwrap()` on an `Err` value: "failed to parse item: \"mod t {\\n    use crate::Foo;\\n}\""

error: aborting due to previous error

asomers avatar Jan 26 '19 17:01 asomers