Hi,
I have a small problem with importing a macro.
When I have a file like src/x.rs
then I can use the #quickcheck
macro when I have this in the src/lib.rs
:
#[cfg(test)]
extern crate quickcheck;
#[cfg(test)]
#[macro_use(quickcheck)]
extern crate quickcheck_macros;
I have moved all my tests to the tests
directory. This way it works:
#[cfg(test)]
#[macro_use(quickcheck)]
extern crate quickcheck_macros;
#[cfg(test)]
extern crate quickcheck;
#[cfg(test)]
mod tests {
#[quickcheck]
fn test(value: u8) -> bool {
assert_eq!(value, value);
true
}
}
When I added the module to the tests/mod.rs
:
mod t;
then I get this error:
error[E0468]: an `extern crate` loading macros must be at the crate root
--> tests/t.rs:3:1
|
3 | extern crate quickcheck_macros;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
It looks fine, just like in the src
directory, so've moved this to the tests/mod.rs
#[cfg(test)]
#[macro_use(quickcheck)]
extern crate quickcheck_macros;
#[cfg(test)]
extern crate quickcheck;
and now I get this:
error: cannot find attribute `quickcheck` in this scope
--> tests/t.rs:6:7
|
6 | #[quickcheck]
| ^^^^^^^^^^
And now I'm not sure how to fix it. Any ideas?
thanks,
Szymon