-
-
Notifications
You must be signed in to change notification settings - Fork 14.3k
Open
Labels
A-doctestsArea: Documentation tests, run by rustdocArea: Documentation tests, run by rustdocB-experimentalBlocker: In-tree experiment; RFC pending, not yet approved or unneeded (requires FCP to stabilize).Blocker: In-tree experiment; RFC pending, not yet approved or unneeded (requires FCP to stabilize).C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCCategory: An issue tracking the progress of sth. like the implementation of an RFCS-tracking-unimplementedStatus: The feature has not been implemented.Status: The feature has not been implemented.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.Relevant to the rustdoc team, which will review and decide on the PR/issue.
Description
Note
Tracking issues are used to record the overall progress of implementation.
They are also used as hubs connecting to other relevant issues, e.g., bugs or open design questions.
A tracking issue is however not meant for large scale discussion, questions, or bug reports.
Instead, open a dedicated issue for the specific matter or post in the #t-rustdoc Zulip channel.
Discussion comments will get marked as off-topic or deleted.
Repeated discussions on the tracking issue may lead to the tracking issue getting locked.
From: https://hackmd.io/@fmease/inject-doctests-into-host-crate.
The original idea was proposed by @Urgau.
This is a greenlit experiment that might not pan out!
Motivation
- Have doctest work in binary crate
- Have better warnings and errors reporting by having correct spans
- Handle doctests with different editions in the same compilation unit
- Simplify cross-compilation (deprecating all the --doctest-cross-arg ...)
- Better Cargo integration (parallel test exec, smarter
unused_crate_dependencies, ...)
Implementation
- Have a hook in the AST->HIR lowering that is only implemented by rustdoc:
- It would parse the doctests, create the AST nodes (by calling rustc_parse maybe?) and give back to rustc the AST nodes corresponding to
#[test] fn doctest_1234 { ... }with the doctest body inside
- It would parse the doctests, create the AST nodes (by calling rustc_parse maybe?) and give back to rustc the AST nodes corresponding to
- Rustdoc would give spans corresponding to the original doctest code in the doc comment. This could include a different edition for doctests that override that
- Problem: how would we get the spans to be correct given the presence of
///in the original code but not the new code given to rustc_parse? would it just work or does it need more invasive changes?
- Problem: how would we get the spans to be correct given the presence of
- These AST nodes would then be injected into the crate and lowered into HIR and go through the rest of the compilation
- Then we run them using the libtest harness.
- We need to run all rustc passes to make it work
Implementation History
Empty.
petrochenkov and mrchanteyUrgau, GuillaumeGomez, sourcefrog and mrchantey
Metadata
Metadata
Assignees
Labels
A-doctestsArea: Documentation tests, run by rustdocArea: Documentation tests, run by rustdocB-experimentalBlocker: In-tree experiment; RFC pending, not yet approved or unneeded (requires FCP to stabilize).Blocker: In-tree experiment; RFC pending, not yet approved or unneeded (requires FCP to stabilize).C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCCategory: An issue tracking the progress of sth. like the implementation of an RFCS-tracking-unimplementedStatus: The feature has not been implemented.Status: The feature has not been implemented.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.Relevant to the rustdoc team, which will review and decide on the PR/issue.
Type
Projects
Status
No status