Repository navigation
Add a check against multiple only- directives in the same line #123730
Description
Activity
- addedneeds-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triagingThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
on Apr 10, 2024 The reason is that I believe compiletest directive parsing for
only-*assumes that the directive takes the form//@ only-<condition> [comment...]where anything following
only-<condition>is treated as an optional comment- addedA-testsuiteArea: The testsuite used to check the correctness of rustcArea: The testsuite used to check the correctness of rustcC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.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.and removedneeds-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triagingThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
on Apr 10, 2024 We are able to detect unknown directives on their own, because we just have a non-exhaustive list of known directives and match against that. I suppose we could just try a match against the same known directive list for
only-*comments to point out that you cannot chain directives in the same line? Although if we're doing it foronly-*comments, what about other directives? It's a bit tricky because IIRC some directives allow comments, other directives don't accept comments...?Brainstorming: maybe it'd be reasonable to require that the comment be in parens
//@ only-<condition> ([comment...])or
//@ only-<condition> because [comment...]or something like that?
It is reasonable, the problem is that we have a lot of pre-existing directives that don't take this form (and we'd have to do another massive migration pass). I'm also not sure what
ui_testdoes about this.Reacted by scottmcmThis would've been a less surprising directive grammar from the beginning, but of course hindsight is 20/20. I'm not sure it's worth the churn to change the grammar now.
What we can do now without churn, however, is to explicitly document that directives are intended to be one-per-line in the dev guide (rust-lang/rustc-dev-guide#1962).
Reacted by scottmcmWithout changing the syntax, we could probably still error out if the sentence right after the directive is a well known directive. That way we should be able to catch
@scottmcmmistake without massive change.Reacted by 许杰友 Jieyou Xu (Joe)- added a commit that references this issue
on Apr 11, 2024 This was done.
In 556b47e I wrote
which based on #123185 (comment) appears like it didn't run on just x64.
Assuming I'm right that this is what happened (if not, please close this) then it would be nice for the same helpful checker that tells me I did it wrong when I write
linux-onlyto also tell me that I can't put multipleonlychecks on the same line.