Skip to content

Compiletest: Simplify {Html,Json}DocCk directive handling #143850

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

fmease
Copy link
Member

@fmease fmease commented Jul 12, 2025

So much more maintainable and extensible.

r? @jieyouxu as discussed

@rustbot rustbot added A-compiletest Area: The compiletest test runner A-rustc-dev-guide Area: rustc-dev-guide A-rustdoc-json Area: Rustdoc JSON backend A-testsuite Area: The testsuite used to check the correctness of rustc S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Jul 12, 2025
@rustbot
Copy link
Collaborator

rustbot commented Jul 12, 2025

The rustc-dev-guide subtree was changed. If this PR only touches the dev guide consider submitting a PR directly to rust-lang/rustc-dev-guide otherwise thank you for updating the dev guide with your changes.

cc @BoxyUwU, @jieyouxu, @Kobzol, @tshepang

Some changes occurred in src/tools/compiletest

cc @jieyouxu

Comment on lines -215 to -217
if args and not args[:1].isspace():
print_err(lineno, line, "Invalid template syntax")
continue
Copy link
Member Author

@fmease fmease Jul 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In a roundabout way this used to check that the separator between the directive and its args was a space because the capture group args used to immediately follow the directive name.

@rust-log-analyzer

This comment has been minimized.

LINE_PATTERN = re.compile(
r"""
//@\s+
(?P<negated>!?)(?P<cmd>[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*)
(?P<negated>!?)(?P<cmd>.+?)
[\s:]
Copy link
Member Author

@fmease fmease Jul 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I basically had to extend the grammar of {Html,Json}DocCk directives to admit : as a legal separator besides whitespace.

Otherwise it would've either been included in the args if I hadn't relaxed cmd's grammar (so //@ has: ... would've meant [has, : ...]) which would've lead to bad diagnostics down the line like "unexpected argument" (because : ... would've been further split into [:, ...] by shlex) or it would've been accepted by compiletest but rejected ignored by HtmlDocCk (remember, we can't reject any unknown or malformed directives in HtmlDocCk since it no longer knows if it's a compiletest directive or not).

Disregarding the technical reasons, {Html,Json}DocCk directives should be extensions to regular compiletest directives, so it only makes sense that : is allowed as a separator.

@fmease fmease force-pushed the comptest-simp-docck-handling branch from c9870d8 to 48c3962 Compare July 12, 2025 17:58
@fmease fmease marked this pull request as draft July 12, 2025 18:04
@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 12, 2025
@fmease fmease force-pushed the comptest-simp-docck-handling branch from 48c3962 to 60471e3 Compare July 12, 2025 18:23
@fmease fmease marked this pull request as ready for review July 12, 2025 18:23
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jul 12, 2025
@rustbot

This comment was marked as off-topic.

@fmease fmease force-pushed the comptest-simp-docck-handling branch 3 times, most recently from 1be2c85 to 917171a Compare July 12, 2025 20:09
Copy link
Member

@jieyouxu jieyouxu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, two comment nits, otherwise LGTM.

@jieyouxu
Copy link
Member

Feel free to r=me with or without the comment nits.
@rustbot author

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 13, 2025
@fmease fmease force-pushed the comptest-simp-docck-handling branch from 917171a to e3ead19 Compare July 13, 2025 05:16
@fmease
Copy link
Member Author

fmease commented Jul 13, 2025

@bors r=jieyouxu rollup (meta)

@bors
Copy link
Collaborator

bors commented Jul 13, 2025

📌 Commit e3ead19 has been approved by jieyouxu

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jul 13, 2025
@fmease
Copy link
Member Author

fmease commented Jul 13, 2025

Will conflict with #143823, marking as blocked.

@bors r-
@rustbot blocked

@rustbot rustbot added the S-blocked Status: Blocked on something else such as an RFC or other implementation work. label Jul 13, 2025
@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. S-blocked Status: Blocked on something else such as an RFC or other implementation work. labels Jul 13, 2025
@fmease fmease added S-blocked Status: Blocked on something else such as an RFC or other implementation work. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jul 13, 2025
bors added a commit that referenced this pull request Jul 13, 2025
Rollup of 12 pull requests

Successful merges:

 - #143776 (std: move NuttX to use arc4random for random number generation)
 - #143778 (Some const_trait_impl test cleanups)
 - #143782 (Disambiguate between rustc vs std having debug assertions in `run-make-support` and `run-make` tests)
 - #143791 (Update sysinfo version to `0.36.0`)
 - #143796 (Fix ICE for parsed attributes with longer path not handled by CheckAttribute)
 - #143798 (Remove format short command trait)
 - #143803 (New tracking issues for const_ops and const_cmp)
 - #143814 (htmldocck: better error messages for some negative directives)
 - #143817 (Access `wasi_sdk_path` instead of reading environment variable in bootstrap)
 - #143822 (./x test miri: fix cleaning the miri_ui directory)
 - #143823 ([COMPILETEST-UNTANGLE 5/N] Test mode adjustments and other assorted cleanups)
 - #143841 (Label clippy changes with `T-clippy`)

Failed merges:

 - #143850 (Compiletest: Simplify {Html,Json}DocCk directive handling)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors

This comment was marked as resolved.

@fmease fmease force-pushed the comptest-simp-docck-handling branch from e3ead19 to 25794b1 Compare July 13, 2025 14:00
@fmease
Copy link
Member Author

fmease commented Jul 13, 2025

@bors r=jieyouxu

@bors
Copy link
Collaborator

bors commented Jul 13, 2025

📌 Commit 25794b1 has been approved by jieyouxu

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-blocked Status: Blocked on something else such as an RFC or other implementation work. labels Jul 13, 2025
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Jul 13, 2025
…g, r=jieyouxu

Compiletest: Simplify {Html,Json}DocCk directive handling

So much more maintainable and extensible.

r? `@jieyouxu` as discussed
bors added a commit that referenced this pull request Jul 13, 2025
Rollup of 8 pull requests

Successful merges:

 - #142885 (core: Add `BorrowedCursor::with_unfilled_buf`)
 - #143217 (Port #[link_ordinal] to the new attribute parsing infrastructure)
 - #143355 (wrapping shift: remove first bitmask and table)
 - #143448 (remote-test-client: Exit code `128 + <signal-number>` instead of `3`)
 - #143724 (Tidy cleanup)
 - #143820 (Fixed a core crate compilation failure when enabling the `optimize_for_size` feature on some targets)
 - #143850 (Compiletest: Simplify {Html,Json}DocCk directive handling)
 - #143880 (tests: Test line debuginfo for linebreaked function parameters)

Failed merges:

 - #143630 (Drop `./x suggest`)
 - #143733 (Change bootstrap's `tool.TOOL_NAME.features` to work on any subcommand)

r? `@ghost`
`@rustbot` modify labels: rollup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-compiletest Area: The compiletest test runner A-rustc-dev-guide Area: rustc-dev-guide A-rustdoc-json Area: Rustdoc JSON backend A-testsuite Area: The testsuite used to check the correctness of rustc S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants