Skip to content

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

Description

@scottmcm

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.

Activity

  1. added
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Apr 10, 2024
  2. jieyouxu commented on Apr 10, 2024

    @jieyouxu
    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

  3. added
    A-testsuiteArea: The testsuite used to check the correctness of rustc
    C-enhancementCategory: 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.
    and removed
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Apr 10, 2024
  4. jieyouxu commented on Apr 10, 2024

    @jieyouxu
    Member

    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...?

  5. scottmcm commented on Apr 10, 2024

    @scottmcm
    MemberAuthor

    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?

  6. jieyouxu commented on Apr 10, 2024

    @jieyouxu
    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.

  7. jieyouxu commented on Apr 10, 2024

    @jieyouxu
    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).

  8. Urgau commented on Apr 10, 2024

    @Urgau
    Member

    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.

  9. added 2 commits that reference this issue on Apr 11, 2024
  10. added a commit that references this issue on Apr 11, 2024
  11. workingjubilee commented on Apr 27, 2024

    @workingjubilee
    Member

    This was done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-testsuiteArea: The testsuite used to check the correctness of rustcC-enhancementCategory: 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.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions