Two macro scoping questions

⚓ Rust    📅 2025-09-23    👤 surdeus    👁️ 9      

surdeus

Warning

This post was published 39 days ago. The information described in this article may have changed.

Info

This post is auto-generated from RSS feed The Rust Programming Language Forum - Latest topics. Source: Two macro scoping questions

Don't worry, they're the easy kind, nothing to do with hygiene...

  1. The standard library has a handful of macros you can't import from the crate root. The ones I know are std::pin::pin! and std::mem::offset_of!. User crates can't do that in stable Rust, right?

  2. It seems like #[macro_use] and #[macro_export] and the above restriction could all be forgotten if Rust allowed pub on macro_rules! macros. (I'm imagining it would cause the macro to have path-based scope.) Is there some reason that wouldn't work?

4 posts - 3 participants

Read full topic

🏷️ Rust_feed