Skip to content
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

Add a check against multiple only- directives in the same line #123730

Closed
scottmcm opened this issue Apr 10, 2024 · 7 comments
Closed

Add a check against multiple only- directives in the same line #123730

scottmcm opened this issue Apr 10, 2024 · 7 comments
Labels
A-testsuite Area: The testsuite used to check the correctness of rustc C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@scottmcm
Copy link
Member

In 556b47e I wrote

//@ [OPT3LINX64] only-linux only-x86_64

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-only to also tell me that I can't put multiple only checks on the same line.

@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Apr 10, 2024
@jieyouxu
Copy link
Member

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

@jieyouxu jieyouxu added A-testsuite Area: The testsuite used to check the correctness of rustc C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Apr 10, 2024
@jieyouxu
Copy link
Member

jieyouxu commented 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 for only-* comments, what about other directives? It's a bit tricky because IIRC some directives allow comments, other directives don't accept comments...?

@scottmcm
Copy link
Member Author

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?

@jieyouxu
Copy link
Member

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_test does about this.

@jieyouxu
Copy link
Member

This 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).

@Urgau
Copy link
Member

Urgau commented Apr 10, 2024

Without 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 @scottmcm mistake without massive change.

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Apr 11, 2024
…ve, r=jieyouxu

compiletest: error when finding a trailing directive

This PR introduce a supplementary check that when checking for a compiletest directive, will also check that the next "word" after that directive is not also by itself a directive.

This is done to avoid situations like this `//@ only-linux only-x86_64` where one might think that both directives are being taken into account while in fact the second in a comment, and so was ignored, until now.

Related to rust-lang#123730
cc `@scottmcm`
r? `@jieyouxu`
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Apr 11, 2024
…ve, r=jieyouxu

compiletest: error when finding a trailing directive

This PR introduce a supplementary check that when checking for a compiletest directive, will also check that the next "word" after that directive is not also by itself a directive.

This is done to avoid situations like this `//@ only-linux only-x86_64` where one might think that both directives are being taken into account while in fact the second in a comment, and so was ignored, until now.

Related to rust-lang#123730
cc ``@scottmcm``
r? ``@jieyouxu``
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Apr 11, 2024
Rollup merge of rust-lang#123753 - Urgau:compiletest-trailing-directive, r=jieyouxu

compiletest: error when finding a trailing directive

This PR introduce a supplementary check that when checking for a compiletest directive, will also check that the next "word" after that directive is not also by itself a directive.

This is done to avoid situations like this `//@ only-linux only-x86_64` where one might think that both directives are being taken into account while in fact the second in a comment, and so was ignored, until now.

Related to rust-lang#123730
cc ``@scottmcm``
r? ``@jieyouxu``
@workingjubilee
Copy link
Member

This was done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-testsuite Area: The testsuite used to check the correctness of rustc C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

5 participants