macro
Procedural macro hygiene and absolute paths
Generated names may interact with caller names. Prefer explicit absolute paths for known library items; this example selects core::cmp::max even when the caller declares its own max. Absolute paths do not solve every collision, so document generated identifiers. Example: two-crate workspace; see fixtures/proc-macro-workspace/consumer/src/bin/hygiene.rs. This caller is not a standalone rustc program. Expected stdout (not executed): '0 8\n' Common mistake: Relying on imports the consumer might not have.
Formal Syntax & Structure
rust syntaxrust
::core::cmp::max(3, 8)Working Example
Example Snippetrust
use teaching_macros::absolute_sum;fn max(_: u32, _: u32) -> u32 { 0 }fn main() { println!("{} {}", max(3, 8), absolute_sum!()); }