Skip to content

Comments

Improve runtest revision redundant cfg check#152925

Open
Hoverbear wants to merge 3 commits intorust-lang:mainfrom
ferrocene:hoverbear/improve-revision-flag-check
Open

Improve runtest revision redundant cfg check#152925
Hoverbear wants to merge 3 commits intorust-lang:mainfrom
ferrocene:hoverbear/improve-revision-flag-check

Conversation

@Hoverbear
Copy link
Contributor

While attempting to ingest #148034 via ferrocene/ferrocene#2172 we noticed a test failure, as we add some compile_flags to tests.

We saw a failure looking like this:

Testing stage1 with compiletest suite=mir-opt mode=mir-opt (x86_64-unknown-linux-gnu)

running 2 tests
2026-02-20T20:21:28.846102Z ERROR compiletest::runtest: redundant cfg argument `copy` is already created by the revision

[mir-opt] tests/mir-opt/pre-codegen/copy_and_clone.rs#COPY ... F
.

While my Rust checkout passed:

Testing stage1 with compiletest suite=mir-opt mode=mir-opt (x86_64-unknown-linux-gnu)

running 2 tests
..

test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 381 filtered out; finished in 107.10ms

This caused me to add some debugging statements.

Ferrocene:

2026-02-20T21:05:39.808427Z ERROR compiletest::runtest: "copy": does ["--edition=2015", "--cfg=copy"] contain `"--cfg=copy"` or `["--cfg", "copy"]`? true
2026-02-20T21:05:39.808427Z ERROR compiletest::runtest: "clone": does ["--edition=2015"] contain `"--cfg=clone"` or `["--cfg", "clone"]`? false
2026-02-20T21:05:39.808435Z ERROR compiletest::runtest: redundant cfg argument `copy` is already created by the revision

Rust:

2026-02-20T21:04:18.493158Z ERROR compiletest::runtest: "copy": does ["--cfg=copy"] contain `"--cfg=copy"` or `["--cfg", "copy"]`? false
2026-02-20T21:04:18.493158Z ERROR compiletest::runtest: "clone": does [] contain `"--cfg=clone"` or `["--cfg", "clone"]`? false

I noticed while reviewing the related functionality that there is a call to .windows(2) in the relevant check for redundant cfgs:

if self
.props
.compile_flags
.windows(2)
.any(|args| args == cfg_arg || args[0] == arg || args[1] == arg)

Noting:

/// Returns an iterator over all contiguous windows of length
/// `size`. The windows overlap. If the slice is shorter than
/// `size`, the iterator returns no values.

Because of this, the revision check was getting an empty iterator when self.props.compile_flags was length 0 or 1.

This fix adjusts the check to handle such cases.

I went ahead and fixed the relevant test (4b3cd9b) that was impacted by this. I do not suspect there are others, at least within the scope that Ferrocene tests, as we have not previously seen this failure.

Previously, `self.props.compile_flags.windows(2)` would return an empty
iterator in the case where `self.props.compile_flags` was 1 or 0 length.

This created incorrectness where tests like
`tests/mir-opt/pre-codegen/copy_and_clone.rs` would pass when they should fail.
@rustbot
Copy link
Collaborator

rustbot commented Feb 20, 2026

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. labels Feb 20, 2026
@rustbot rustbot added T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Feb 20, 2026
@rustbot
Copy link
Collaborator

rustbot commented Feb 20, 2026

r? @clubby789

rustbot has assigned @clubby789.
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, jieyouxu

@Hoverbear Hoverbear changed the title Improve revision flag check Improve runtest revision redundant cfg check Feb 20, 2026
Copy link
Contributor

@clubby789 clubby789 left a comment

Choose a reason for hiding this comment

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

A quick comment about the reason for the two iterations might be useful to avoid needing to remember/lookup the exact semantics of windows(), up to you. LGTM otherwise, r=me if green

View changes since this review

@Hoverbear
Copy link
Contributor Author

@clubby789 I'm not someone who can merge so someone else, like you, needs to do the honors!

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
@bors r=clubby789,jieyouxu rollup

View changes since this review

@rust-bors
Copy link
Contributor

rust-bors bot commented Feb 21, 2026

📌 Commit 3c9ca9b has been approved by clubby789,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 Feb 21, 2026
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Feb 21, 2026
…on-flag-check, r=clubby789,jieyouxu

Improve runtest revision redundant cfg check

While attempting to ingest rust-lang#148034 via ferrocene/ferrocene#2172 we noticed a test failure, as we add some `compile_flags` to tests.

We saw a failure looking like this:

```
Testing stage1 with compiletest suite=mir-opt mode=mir-opt (x86_64-unknown-linux-gnu)

running 2 tests
2026-02-20T20:21:28.846102Z ERROR compiletest::runtest: redundant cfg argument `copy` is already created by the revision

[mir-opt] tests/mir-opt/pre-codegen/copy_and_clone.rs#COPY ... F
.
```

While my Rust checkout passed:

```
Testing stage1 with compiletest suite=mir-opt mode=mir-opt (x86_64-unknown-linux-gnu)

running 2 tests
..

test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 381 filtered out; finished in 107.10ms
```

This caused me to add some debugging statements.

Ferrocene:

```
2026-02-20T21:05:39.808427Z ERROR compiletest::runtest: "copy": does ["--edition=2015", "--cfg=copy"] contain `"--cfg=copy"` or `["--cfg", "copy"]`? true
2026-02-20T21:05:39.808427Z ERROR compiletest::runtest: "clone": does ["--edition=2015"] contain `"--cfg=clone"` or `["--cfg", "clone"]`? false
2026-02-20T21:05:39.808435Z ERROR compiletest::runtest: redundant cfg argument `copy` is already created by the revision
```

Rust:

```
2026-02-20T21:04:18.493158Z ERROR compiletest::runtest: "copy": does ["--cfg=copy"] contain `"--cfg=copy"` or `["--cfg", "copy"]`? false
2026-02-20T21:04:18.493158Z ERROR compiletest::runtest: "clone": does [] contain `"--cfg=clone"` or `["--cfg", "clone"]`? false
```

I noticed while reviewing the related functionality that there is a call to `.windows(2)` in the relevant check for redundant cfgs:

https://github.com/rust-lang/rust/blob/0376d43d443cba463a0b6a6ec9140ea17d7b7130/src/tools/compiletest/src/runtest.rs#L507-L511

Noting:

https://github.com/rust-lang/rust/blob/0376d43d443cba463a0b6a6ec9140ea17d7b7130/library/core/src/slice/mod.rs#L1064-L1066

Because of this, the revision check was getting an empty iterator when `self.props.compile_flags` was length 0 or 1.

This fix adjusts the check to handle such cases.

I went ahead and fixed the relevant test (4b3cd9b) that was impacted by this. I do not suspect there are others, at least within the scope that Ferrocene tests, as we have not previously seen this failure.
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Feb 21, 2026
…on-flag-check, r=clubby789,jieyouxu

Improve runtest revision redundant cfg check

While attempting to ingest rust-lang#148034 via ferrocene/ferrocene#2172 we noticed a test failure, as we add some `compile_flags` to tests.

We saw a failure looking like this:

```
Testing stage1 with compiletest suite=mir-opt mode=mir-opt (x86_64-unknown-linux-gnu)

running 2 tests
2026-02-20T20:21:28.846102Z ERROR compiletest::runtest: redundant cfg argument `copy` is already created by the revision

[mir-opt] tests/mir-opt/pre-codegen/copy_and_clone.rs#COPY ... F
.
```

While my Rust checkout passed:

```
Testing stage1 with compiletest suite=mir-opt mode=mir-opt (x86_64-unknown-linux-gnu)

running 2 tests
..

test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 381 filtered out; finished in 107.10ms
```

This caused me to add some debugging statements.

Ferrocene:

```
2026-02-20T21:05:39.808427Z ERROR compiletest::runtest: "copy": does ["--edition=2015", "--cfg=copy"] contain `"--cfg=copy"` or `["--cfg", "copy"]`? true
2026-02-20T21:05:39.808427Z ERROR compiletest::runtest: "clone": does ["--edition=2015"] contain `"--cfg=clone"` or `["--cfg", "clone"]`? false
2026-02-20T21:05:39.808435Z ERROR compiletest::runtest: redundant cfg argument `copy` is already created by the revision
```

Rust:

```
2026-02-20T21:04:18.493158Z ERROR compiletest::runtest: "copy": does ["--cfg=copy"] contain `"--cfg=copy"` or `["--cfg", "copy"]`? false
2026-02-20T21:04:18.493158Z ERROR compiletest::runtest: "clone": does [] contain `"--cfg=clone"` or `["--cfg", "clone"]`? false
```

I noticed while reviewing the related functionality that there is a call to `.windows(2)` in the relevant check for redundant cfgs:

https://github.com/rust-lang/rust/blob/0376d43d443cba463a0b6a6ec9140ea17d7b7130/src/tools/compiletest/src/runtest.rs#L507-L511

Noting:

https://github.com/rust-lang/rust/blob/0376d43d443cba463a0b6a6ec9140ea17d7b7130/library/core/src/slice/mod.rs#L1064-L1066

Because of this, the revision check was getting an empty iterator when `self.props.compile_flags` was length 0 or 1.

This fix adjusts the check to handle such cases.

I went ahead and fixed the relevant test (4b3cd9b) that was impacted by this. I do not suspect there are others, at least within the scope that Ferrocene tests, as we have not previously seen this failure.
rust-bors bot pushed a commit that referenced this pull request Feb 21, 2026
Rollup of 6 pull requests

Successful merges:

 - #152929 (Tighten the `!range` bounds on alignments in vtables)
 - #151603 (Stabilize `str_as_str`)
 - #152878 (Remove two more flaky assertions from `oneshot` tests)
 - #152915 (Error on attempt to construct scalable vector type)
 - #152925 (Improve runtest revision redundant cfg check)
 - #152928 (Update wasm-component-ld)
rust-bors bot pushed a commit that referenced this pull request Feb 21, 2026
Rollup of 6 pull requests

Successful merges:

 - #152929 (Tighten the `!range` bounds on alignments in vtables)
 - #151603 (Stabilize `str_as_str`)
 - #152878 (Remove two more flaky assertions from `oneshot` tests)
 - #152915 (Error on attempt to construct scalable vector type)
 - #152925 (Improve runtest revision redundant cfg check)
 - #152928 (Update wasm-component-ld)
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) T-compiler Relevant to the compiler 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