Skip to content

Add a regression test for Issue 7198 and hide parse errors in test output - #7199

Merged
ytmimi merged 2 commits into
rust-lang:mainfrom
ytmimi:issue_7198
Oct 19, 2026
Merged

ytmimi merged 2 commits into
rust-lang:mainfrom
ytmimi:issue_7198

Conversation

@ytmimi

@ytmimi ytmimi commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor
  • I did not use an LLM to create a change in this PR.
  • I used an LLM to create a change in this PR, and I have explained below how it was used.

Closes #7198
Also hides parse errors for tests added in #7171

@rustbot rustbot added the S-waiting-on-review Status: awaiting review from the assignee but also interested parties. label Oct 19, 2026
@ytmimi
ytmimi requested a review from jieyouxu October 19, 2026 14:18

@ytmimi ytmimi Oct 19, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Tests no longer output this parse error:

error: missing parameters for function definition
 --> tests/source/cfg-select-valid-then-invalid-item-error-count-leak.rs:6:31
  |
6 | cfg_select! { unix => { fn foo {} } }
  |                               ^
  |
help: add a parameter list
  |
6 | cfg_select! { unix => { fn foo() {} } }
  |                               ++

View changes since the review

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is it expected that rustfmt emits these errors, given that rustc might not emit an error (if the condition is false)?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

rustfmt still needs to format all the cfg_select! arms even if they won't all be compiled so it seems reasonable to me that rustfmt would emit the parse error.

@ytmimi ytmimi Oct 19, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Without show_parse_errors: false the test output gets cluttered with this output:

error: expected identifier, found keyword `unsafe`
 --> tests/target/issue_7198.rs:8:17
  |
8 |                 unsafe extern "C" fn(*mut libc::c_void),
  |                 ^^^^^^ expected identifier, found keyword

error: expected one of `:` or `|`, found keyword `extern`
 --> tests/target/issue_7198.rs:8:24
  |
8 |                 unsafe extern "C" fn(*mut libc::c_void),
  |                        ^^^^^^ expected one of `:` or `|`

error: expected parameter name, found `*`
 --> tests/target/issue_7198.rs:9:17
  |
9 |                 *mut libc::c_void,
  |                 ^ expected parameter name

error: expected parameter name, found `*`
  --> tests/target/issue_7198.rs:10:17
   |
10 |                 *mut libc::c_void,
   |                 ^ expected parameter name


View changes since the review

@@ -1,4 +1,7 @@
//@ rustfmt-unstable: true
//@ rustfmt-show_parse_errors: false

@matthewhughes934 matthewhughes934 Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

thanks for this, I was about to get up a change for the same thing!

View changes since the review

@ytmimi
ytmimi added this pull request to the merge queue Oct 19, 2026
Merged via the queue into rust-lang:main with commit d6a8ce1 Oct 19, 2026
33 checks passed
@rustbot rustbot added release-notes Needs an associated changelog entry and removed S-waiting-on-review Status: awaiting review from the assignee but also interested parties. labels Oct 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release-notes Needs an associated changelog entry

Projects

None yet

Development

Successfully merging this pull request may close these issues.

invalid syntax inside cfg_select leads to nonsense output

4 participants