Mod item in procedural macro output looks for the wrong source file #58818
Labels
A-macros
Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..)
C-bug
Category: This is a bug.
E-needs-test
Call for participation: An issue has been fixed and does not reproduce, but no test has been added.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
I have this crate layout:
where child.rs is an empty file and main.rs is:
This compiles successfully and we end up with a module at
crate::parent::child
backed by the file src/parent/child.rs.But if
mod child;
goes anywhere near a proc macro, it no longer works.where
noop!
is this macro:The error is:
so it is looking for a file corresponding to
mod child
as though themod child
were not contained inside ofmod parent
. I hit this while working on https://github.com/dtolnay/automod.The same problem does not occur if
noop!
is defined as a macro_rules macro.Repro script
Mentioning @petrochenkov who may know what is going wrong or whether there is a simple rustc fix.
The text was updated successfully, but these errors were encountered: