Why macro def needs to be located in the file above the line of first use

⚓ rust    📅 2025-06-18    👤 surdeus    👁️ 2      

surdeus

Title says it all. It came to me as a real surprise, that this is working "the old fashioned way", unlike everything else in rust with regards to definitions. For example the definition of fn may be at the end of file and yet we can call it from the definition of another function that is at the very beginning of the file.
What are the reasons, that this behavior doesn't work for macros?

1 post - 1 participant

Read full topic

🏷️ rust_feed