perform macro-expansion on doctests before checking for fn main
#57415
Labels
A-doctests
Area: Documentation tests, run by rustdoc
C-feature-request
Category: A feature request, i.e: not implemented / a PR.
T-rustdoc
Relevant to the rustdoc team, which will review and decide on the PR/issue.
As discussed in #57019, i'd like to refactor the doctest parsing/execution code in rustdoc so that it checks for
fn main
andextern crate
during compilation, not before. This allows us to take advantage of macro expansion and a proper parsing step to find multi-line attributes orextern crate
statements with the#[macro_use]
on a separate line.I believe it's possible to break up the compilation steps in
test::run_test
like incore::run_core
, except this time we'd stop afterphase_2
and inspect the crate for our desired items. If the test doesn't have afn main
or the rightextern crate
statement, then we can modify the crate in-place (or attempt to splice in the right text in the original text and run compilation again) before continuing. I haven't tried it, but i'd like to sketch it out soon.The text was updated successfully, but these errors were encountered: