In other words, try putting those two prints (in the macro) inside of a { }
block.
Cheers,
Jeaye
On Apr 9, 2013, at 7:12 PM, Jesse Luehrs wrote:
> On Tue, Apr 09, 2013 at 10:07:36PM -0400, Ashish Myles wrote:
>> Hi,
>>
>> I am running the rust compiler from trunk. My macro usage seems to be a
>>
>> ----
>> macro_rules! my_print(
>> ($a:expr, $b:expr) => (
>> io::println(fmt!("%d", a));
>> io::println(fmt!("%d", b));
>> );
>> )
>>
>> fn main() {
>> let a : int = 1;
>> let b : int = 2;
>> my_print!(a, b);
>> }
>> ----
>>
>> Compiling with "rustc tmp.rs" gives the following suspicious warning
>>
>> ----
>> tmp.rs:10:8: 10:11 warning: unused variable: `b`
>> tmp.rs:10 let b : int = 2;
>> ----
>>
>> and ./tmp prints only "1". Running "rustc tmp.rs --pretty expanded"
>> shows below that the second line "io::println(fmt!("%d", b));" was
>> ignored.
>>
>> ----
>> fn main() {
>> let a: int = 1;
>> let b: int = 2;
>> io::println({
>> let mut __fmtbuf = ~"";
>>
>> ::unstable::extfmt::rt::conv_int(::unstable::extfmt::rt::Conv{flags:
>>
>> ::unstable::extfmt::rt::flag_none,
>>
>> width:
>>
>> ::unstable::extfmt::rt::CountImplied,
>>
>> precision:
>>
>> ::unstable::extfmt::rt::CountImplied,
>>
>> ty:
>>
>> ::unstable::extfmt::rt::TyDefault,},
>> a, &mut __fmtbuf);
>> __fmtbuf
>> });
>> }
>> ----
>>
>> Can someone point me in the right direction here?
>
> Currently, macros can only expand to a single item. See
> https://github.com/mozilla/rust/issues/4375 for more details.
>
> -doy
> _______________________________________________
> Rust-dev mailing list
> [email protected]
> https://mail.mozilla.org/listinfo/rust-dev
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev