I'm having a lot of trouble getting macros from another crate to work in Rust. My lib.rs file looks like this:
#[macro_use]
extern crate session_types;
mod main;
And here's a simplified part of my main.rs, demonstrating proper use of the offer!
macro:
use session_types::*;
type Server = Offer<Choose<Var<Z>, Var<Z>>, Choose<Var<Z>, Var<Z>>>;
struct Foo;
impl Foo {
fn server(&self, c: Chan<(), Rec<Server>>) {
let mut c = c.enter();
loop {
c = offer!{ c,
LEFT_BRANCH => c.sel1().zero(),
RIGHT_BRANCH => c.sel2().zero()
};
}
}
}
I know the compiler is able to expand offer!
because I've debugged code in blocks inside that macro, and I get warnings about unused variables in that macro which look like this:
<session_types macros>:1:1: 5:16 note: in expansion of offer!
src/main.rs:107:21: 133:14 note: expansion site
<session_types macros>:3:53: 3:57: warning: unused variable: 'right', #[warn(unused_variables)] on by default
<session_types macros>:3 Branch:: Left ( $id ) => $code, Branch:: Right ( $id ) => offer! {
which obviously includes part of the macro. However, I get compilation errors saying that, on the lines they're used, the macro offer!
is undefined.
src/main.rs:107:21: 133:14 note: in this expansion of offer! (defined in <session_types macros>)
src/main.rs:57:17: 57:22 error: macro undefined: 'offer!'
src/main.rs:57 c = offer!{ c,
^~~~~
src/main.rs:107:21: 107:26 error: macro undefined: 'offer!'
src/main.rs:107 night = offer!{ night,
Note: this occurs on the nightly branch of the compiler.