Stream: general

Topic: Continuation of #52234 discussion


Chase Wilson (Mar 11 2020 at 19:29, on Zulip):

@Vadim Petrochenkov This works, but isn't really ergonomic for users, as they have to manually import the internal macro

mod macros {
    macro_rules! meta_macro {
        () => {
            #[macro_export]
            macro_rules! created {
                () => { };
            }
        };
    }

    meta_macro!();

    #[macro_export]
    macro_rules! consumer {
        () => {
            created!();
        };
    }

    // Works here
    consumer!();
}

mod other {
    // Not here, have to manually `use` it
    crate::consumer!();
}

I also tried to use use $crate::created;, but original error

Chase Wilson (Mar 11 2020 at 19:34, on Zulip):

I also attempted to move the meta-macro's declaration and calling to the root of the crate, but it still produces an error

Chase Wilson (Mar 11 2020 at 19:35, on Zulip):

I understand the reasoning behind the change and I know it's a really specific usecase, but it really hurts library authors trying to do this cleanly

Vadim Petrochenkov (Mar 11 2020 at 20:31, on Zulip):

Well, I certainly agree that it's annoying.

Vadim Petrochenkov (Mar 11 2020 at 20:31, on Zulip):

It's rather a hard-to-fix bug, than a rule that we'd want to be in the language.

Chase Wilson (Mar 11 2020 at 20:51, on Zulip):

Ok, thank you for your help!

Last update: Jun 05 2020 at 23:05UTC