Skip to content

compiletest: prevent directives from having multiple revisions#156237

Open
lqd wants to merge 2 commits intorust-lang:mainfrom
lqd:compiletest-revisions
Open

compiletest: prevent directives from having multiple revisions#156237
lqd wants to merge 2 commits intorust-lang:mainfrom
lqd:compiletest-revisions

Conversation

@lqd
Copy link
Copy Markdown
Member

@lqd lqd commented May 6, 2026

Right now, a compiletest directive like //@ [foo,bar] compile-flags: -Z hello is accepted. While it looks similar to a //[foo,bar] error annotation matching multiple revisions, it will instead model a directive for a single revision named foo,bar and not for two revisions. Slightly inconsistent/confusing.

I don't know that it's common enough to make bigger changes to support it fully (miri's test harness seems to support that use-case), but since I hit that today, this PR prevents that case for now. Otherwise, I think we'd have to turn all uses of line_directive as possibly creating multiple line directives, one per revision, etc.

Such a directive will now yield an error, with a best-effort suggestion to split it into multiple single-revision directives:

multiple revisions aren't supported yet in `//@ [foo,bar] compile-flags: -Z hello`, split them like
//@ [foo]: compile-flags: -Z hello
//@ [bar]: compile-flags: -Z hello

@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented May 6, 2026

compiletest directives have been modified. Please add or update docs for the
new or modified directive in src/doc/rustc-dev-guide/.

Some changes occurred in src/tools/compiletest

cc @jieyouxu

@rustbot rustbot added A-compiletest Area: The compiletest test runner 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) labels May 6, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented May 6, 2026

r? @wesleywiser

rustbot has assigned @wesleywiser.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: @jieyouxu, @oli-obk, @wesleywiser, bootstrap
  • @jieyouxu, @oli-obk, @wesleywiser, bootstrap expanded to 8 candidates
  • Random selection from Mark-Simulacrum, clubby789, oli-obk, wesleywiser

@jieyouxu jieyouxu self-assigned this May 6, 2026
@fmease
Copy link
Copy Markdown
Member

fmease commented May 6, 2026

cc issue #123765

@lqd
Copy link
Copy Markdown
Member Author

lqd commented May 6, 2026

ah I knew there was an issue about this but couldn't find it with a quick search, thank you @fmease!

Copy link
Copy Markdown
Member

@wesleywiser wesleywiser left a comment

Choose a reason for hiding this comment

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

This seems very reasonable to me but let's see what @jieyouxu thinks.

View changes since this review

Copy link
Copy Markdown
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, this makes sense.

View changes since this review

@jieyouxu
Copy link
Copy Markdown
Member

jieyouxu commented May 7, 2026

(Eventually I'd like to move these validations to not panic everywhere and produce proper errors but rejecting loudly still much better than silently borked)

@jieyouxu
Copy link
Copy Markdown
Member

jieyouxu commented May 7, 2026

@bors r=wesleywiser,jieyouxu rollup

@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors Bot commented May 7, 2026

📌 Commit 325b013 has been approved by wesleywiser,jieyouxu

It is now in the queue for this repository.

@rust-bors rust-bors Bot 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-review Status: Awaiting review from the assignee but also interested parties. labels May 7, 2026
jhpratt added a commit to jhpratt/rust that referenced this pull request May 7, 2026
…ywiser,jieyouxu

compiletest: prevent directives from having multiple revisions

Right now, a compiletest directive like `//@ [foo,bar] compile-flags: -Z hello` is accepted. While it looks similar to a `//[foo,bar]` error annotation matching multiple revisions, it will instead model a directive for a single revision named `foo,bar` and not for two revisions. Slightly inconsistent/confusing.

I don't know that it's common enough to make bigger changes to support it fully (`miri`'s test harness seems to support that use-case), but since I hit that today, this PR prevents that case for now. Otherwise, I think we'd have to turn all uses of `line_directive` as possibly creating multiple line directives, one per revision, etc.

Such a directive will now yield an error, with a best-effort suggestion to split it into multiple single-revision directives:

```
multiple revisions aren't supported yet in `//@ [foo,bar] compile-flags: -Z hello`, split them like
//@ [foo]: compile-flags: -Z hello
//@ [bar]: compile-flags: -Z hello
```
jhpratt added a commit to jhpratt/rust that referenced this pull request May 7, 2026
…ywiser,jieyouxu

compiletest: prevent directives from having multiple revisions

Right now, a compiletest directive like `//@ [foo,bar] compile-flags: -Z hello` is accepted. While it looks similar to a `//[foo,bar]` error annotation matching multiple revisions, it will instead model a directive for a single revision named `foo,bar` and not for two revisions. Slightly inconsistent/confusing.

I don't know that it's common enough to make bigger changes to support it fully (`miri`'s test harness seems to support that use-case), but since I hit that today, this PR prevents that case for now. Otherwise, I think we'd have to turn all uses of `line_directive` as possibly creating multiple line directives, one per revision, etc.

Such a directive will now yield an error, with a best-effort suggestion to split it into multiple single-revision directives:

```
multiple revisions aren't supported yet in `//@ [foo,bar] compile-flags: -Z hello`, split them like
//@ [foo]: compile-flags: -Z hello
//@ [bar]: compile-flags: -Z hello
```
jhpratt added a commit to jhpratt/rust that referenced this pull request May 7, 2026
…ywiser,jieyouxu

compiletest: prevent directives from having multiple revisions

Right now, a compiletest directive like `//@ [foo,bar] compile-flags: -Z hello` is accepted. While it looks similar to a `//[foo,bar]` error annotation matching multiple revisions, it will instead model a directive for a single revision named `foo,bar` and not for two revisions. Slightly inconsistent/confusing.

I don't know that it's common enough to make bigger changes to support it fully (`miri`'s test harness seems to support that use-case), but since I hit that today, this PR prevents that case for now. Otherwise, I think we'd have to turn all uses of `line_directive` as possibly creating multiple line directives, one per revision, etc.

Such a directive will now yield an error, with a best-effort suggestion to split it into multiple single-revision directives:

```
multiple revisions aren't supported yet in `//@ [foo,bar] compile-flags: -Z hello`, split them like
//@ [foo]: compile-flags: -Z hello
//@ [bar]: compile-flags: -Z hello
```
rust-bors Bot pushed a commit that referenced this pull request May 7, 2026
Rollup of 14 pull requests

Successful merges:

 - #146273 (lint ImproperCTypes: refactor linting architecture (part 2))
 - #149509 (Lint unused pub items in binary crates)
 - #156173 (Fewer global node_id_to_def_id lookups)
 - #156177 (windows/time: avoid being too close to 0)
 - #155961 (Deny warnings in the test for crates that are available on stable)
 - #155981 (Use special DefIds for aliases)
 - #156109 (Migrate libraries from ptr::slice_from_raw_parts to .cast_slice)
 - #156130 (Fold/visit tweaks)
 - #156131 (Metadata macro/query cleanups)
 - #156202 (llvm: Use correct type for splat mask)
 - #156227 (Add Trusty OS to the generic error implementation.)
 - #156237 (compiletest: prevent directives from having multiple revisions)
 - #156241 (Move tests coercion)
 - #156258 (Document wasi-sdk minimum versions for WASI targets)
jhpratt added a commit to jhpratt/rust that referenced this pull request May 7, 2026
…ywiser,jieyouxu

compiletest: prevent directives from having multiple revisions

Right now, a compiletest directive like `//@ [foo,bar] compile-flags: -Z hello` is accepted. While it looks similar to a `//[foo,bar]` error annotation matching multiple revisions, it will instead model a directive for a single revision named `foo,bar` and not for two revisions. Slightly inconsistent/confusing.

I don't know that it's common enough to make bigger changes to support it fully (`miri`'s test harness seems to support that use-case), but since I hit that today, this PR prevents that case for now. Otherwise, I think we'd have to turn all uses of `line_directive` as possibly creating multiple line directives, one per revision, etc.

Such a directive will now yield an error, with a best-effort suggestion to split it into multiple single-revision directives:

```
multiple revisions aren't supported yet in `//@ [foo,bar] compile-flags: -Z hello`, split them like
//@ [foo]: compile-flags: -Z hello
//@ [bar]: compile-flags: -Z hello
```
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-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)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants