-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Item macros do neither support import lines nor inner attributes #10716
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Allowing either seems like it would introduce some points that need to be carefully considered, e.g. for macro_rules! conflict {
() => {
use bar::foo;
fn inner() { foo::func() }
}
}
mod foo { pub fn func() {} } // A
mod bar {
pub mod foo { pub fn func() {} } // B
}
fn before() {
foo::func();
}
conflict!()
fn after() {
foo::func();
} I see 3 possibilities if the above were legal:
All three have their peculiarities; I think 1 may make Similarly for top-level attributes, one can have, e.g. a |
No change. |
/cc me |
both of these now compile just fine. |
…n, r=Manishearth Fixes rust-lang#10609: Adds lint to detect construction of unit struct using `default` Using `default` to construct a unit struct increases code complexity and adds a function call. This can be avoided by simply removing the call to `default` and simply construct by name. changelog: [`default_constructed_unit_structs`]: detects construction of unit structs using `default` fixes rust-lang#10609
I'm trying to switch a few of the libstd macros from generated module to multi item macros, and I've run in a few issues:
Import lines are not supported:
Inner attributes are not supported:
I'm not sure if those two are intentional limitations or not, but if they are, then not all use cases for macros-expanding-to-generated-modules can be replaced with item macros. (See
std::num::uint_macros
for a big example)The text was updated successfully, but these errors were encountered: