Skip to content

Improve diagnostic for patterns in function pointer types - #160282

Merged
rust-bors[bot] merged 2 commits into
rust-lang:mainfrom
JonathanBrouwer:arg-pattern
Aug 1, 2026
Merged

Improve diagnostic for patterns in function pointer types#160282
rust-bors[bot] merged 2 commits into
rust-lang:mainfrom
JonathanBrouwer:arg-pattern

Conversation

@JonathanBrouwer

Copy link
Copy Markdown
Member

In preparation for some work for #158499

Diagnostic before:

error[E0642]: patterns aren't allowed in methods without bodies
--> $DIR/fn-ptr-pattern.rs:4:14
|
LL | pat2: fn(1..3: bool),
| ^^^^
|
help: give this argument a name or use an underscore to ignore it
|
LL - pat2: fn(1..3: bool),
LL + pat2: fn(_: bool),
|

Diagnostic after:

error[E0642]: patterns aren't allowed in function pointer types
--> $DIR/fn-ptr-pattern.rs:4:14
|
LL | pat2: fn(1..3: bool),
| ^^^^
|
help: give this argument a name or use an underscore to ignore it
|
LL - pat2: fn(1..3: bool),
LL + pat2: fn(_: bool),
|

@rustbot

Copy link
Copy Markdown
Collaborator

The parser was modified, potentially altering the grammar of (stable) Rust
which would be a breaking change.

cc @fmease

@rustbotrustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jul 31, 2026
@rustbot

Copy link
Copy Markdown
Collaborator

r? @petrochenkov

rustbot has assigned @petrochenkov.
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: compiler
  • compiler expanded to 75 candidates
  • Random selection from 17 candidates

@JonathanBrouwerJonathanBrouwer added the A-diagnostics Area: Messages for errors, warnings, and lints label Jul 31, 2026
@petrochenkov

Copy link
Copy Markdown
Contributor

@bors r+

@rust-bors

rust-borsBot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

📌 Commit c1bcbb4 has been approved by petrochenkov

It is now in the queue for this repository.

@rust-borsrust-borsBot 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 Jul 31, 2026
jhpratt added a commit to jhpratt/rust that referenced this pull request Aug 1, 2026
…rochenkov
Improve diagnostic for patterns in function pointer types
In preparation for some work for rust-lang#158499
Diagnostic before:
```
error[E0642]: patterns aren't allowed in methods without bodies
--> $DIR/fn-ptr-pattern.rs:4:14
|
LL | pat2: fn(1..3: bool),
| ^^^^
|
help: give this argument a name or use an underscore to ignore it
|
LL - pat2: fn(1..3: bool),
LL + pat2: fn(_: bool),
|
```
Diagnostic after:
```
error[E0642]: patterns aren't allowed in function pointer types
--> $DIR/fn-ptr-pattern.rs:4:14
|
LL | pat2: fn(1..3: bool),
| ^^^^
|
help: give this argument a name or use an underscore to ignore it
|
LL - pat2: fn(1..3: bool),
LL + pat2: fn(_: bool),
|
```
@jhprattjhpratt mentioned this pull request Aug 1, 2026
jhpratt added a commit to jhpratt/rust that referenced this pull request Aug 1, 2026
…rochenkov
Improve diagnostic for patterns in function pointer types
In preparation for some work for rust-lang#158499
Diagnostic before:
```
error[E0642]: patterns aren't allowed in methods without bodies
--> $DIR/fn-ptr-pattern.rs:4:14
|
LL | pat2: fn(1..3: bool),
| ^^^^
|
help: give this argument a name or use an underscore to ignore it
|
LL - pat2: fn(1..3: bool),
LL + pat2: fn(_: bool),
|
```
Diagnostic after:
```
error[E0642]: patterns aren't allowed in function pointer types
--> $DIR/fn-ptr-pattern.rs:4:14
|
LL | pat2: fn(1..3: bool),
| ^^^^
|
help: give this argument a name or use an underscore to ignore it
|
LL - pat2: fn(1..3: bool),
LL + pat2: fn(_: bool),
|
```
This was referenced Aug 1, 2026
rust-borsBot pushed a commit that referenced this pull request Aug 1, 2026
Rollup of 14 pull requests
Successful merges:
- #159245 (Emit retags in codegen to support BorrowSanitizer (part 5))
- #159864 (Report "capacity overflow" for oversized Rc<[T]>/Arc<[T]>)
- #160079 (make atomic operations const)
- #160124 (Structurally prevent zero-count `BackendRepr::SimdVector`s)
- #160162 (Make `#[fundamental]` only apply to the first argument of `Box`)
- #160210 (Remove an outdated FIXME)
- #160282 (Improve diagnostic for patterns in function pointer types)
- #157928 (Eagerly fetch typeck results when linting)
- #159672 (Improve suggestions when multiples tuples implement the same trait)
- #159861 (Add documentation for the `non_exhaustive` attribute)
- #159907 (Fix `hidden_glob_reexports` in `rustc_ast`)
- #159998 (Align expect messages with guidance)
- #160145 (Expand checks for register_tool)
- #160307 (Update `minifier` version to `0.4.0`)
@rust-bors
rust-borsBot merged commit bf297d5 into rust-lang:mainAug 1, 2026
13 checks passed
@rustbotrustbot added this to the 1.99.0 milestone Aug 1, 2026
rust-timer added a commit that referenced this pull request Aug 1, 2026
Rollup merge of #160282 - JonathanBrouwer:arg-pattern, r=petrochenkov
Improve diagnostic for patterns in function pointer types
In preparation for some work for #158499
Diagnostic before:
```
error[E0642]: patterns aren't allowed in methods without bodies
--> $DIR/fn-ptr-pattern.rs:4:14
|
LL | pat2: fn(1..3: bool),
| ^^^^
|
help: give this argument a name or use an underscore to ignore it
|
LL - pat2: fn(1..3: bool),
LL + pat2: fn(_: bool),
|
```
Diagnostic after:
```
error[E0642]: patterns aren't allowed in function pointer types
--> $DIR/fn-ptr-pattern.rs:4:14
|
LL | pat2: fn(1..3: bool),
| ^^^^
|
help: give this argument a name or use an underscore to ignore it
|
LL - pat2: fn(1..3: bool),
LL + pat2: fn(_: bool),
|
```
pullBot pushed a commit to xtqqczze/rust-lang-miri that referenced this pull request Aug 2, 2026
Rollup of 14 pull requests
Successful merges:
- rust-lang/rust#159245 (Emit retags in codegen to support BorrowSanitizer (part 5))
- rust-lang/rust#159864 (Report "capacity overflow" for oversized Rc<[T]>/Arc<[T]>)
- rust-lang/rust#160079 (make atomic operations const)
- rust-lang/rust#160124 (Structurally prevent zero-count `BackendRepr::SimdVector`s)
- rust-lang/rust#160162 (Make `#[fundamental]` only apply to the first argument of `Box`)
- rust-lang/rust#160210 (Remove an outdated FIXME)
- rust-lang/rust#160282 (Improve diagnostic for patterns in function pointer types)
- rust-lang/rust#157928 (Eagerly fetch typeck results when linting)
- rust-lang/rust#159672 (Improve suggestions when multiples tuples implement the same trait)
- rust-lang/rust#159861 (Add documentation for the `non_exhaustive` attribute)
- rust-lang/rust#159907 (Fix `hidden_glob_reexports` in `rustc_ast`)
- rust-lang/rust#159998 (Align expect messages with guidance)
- rust-lang/rust#160145 (Expand checks for register_tool)
- rust-lang/rust#160307 (Update `minifier` version to `0.4.0`)
jhpratt added a commit to jhpratt/rust that referenced this pull request Aug 3, 2026
…t, r=khyperia
Improve the test for patterns in fn pointers
Follow up of rust-lang#160282
The goal is to cover more cases of the behaviour of patterns in fn pointers.
rust-timer added a commit that referenced this pull request Aug 3, 2026
Rollup merge of #160380 - JonathanBrouwer:improve-fn-ptr-test, r=khyperia
Improve the test for patterns in fn pointers
Follow up of #160282
The goal is to cover more cases of the behaviour of patterns in fn pointers.
flip1995 pushed a commit to flip1995/rust-clippy that referenced this pull request Aug 17, 2026
Rollup of 14 pull requests
Successful merges:
- rust-lang/rust#159245 (Emit retags in codegen to support BorrowSanitizer (part 5))
- rust-lang/rust#159864 (Report "capacity overflow" for oversized Rc<[T]>/Arc<[T]>)
- rust-lang/rust#160079 (make atomic operations const)
- rust-lang/rust#160124 (Structurally prevent zero-count `BackendRepr::SimdVector`s)
- rust-lang/rust#160162 (Make `#[fundamental]` only apply to the first argument of `Box`)
- rust-lang/rust#160210 (Remove an outdated FIXME)
- rust-lang/rust#160282 (Improve diagnostic for patterns in function pointer types)
- rust-lang/rust#157928 (Eagerly fetch typeck results when linting)
- rust-lang/rust#159672 (Improve suggestions when multiples tuples implement the same trait)
- rust-lang/rust#159861 (Add documentation for the `non_exhaustive` attribute)
- rust-lang/rust#159907 (Fix `hidden_glob_reexports` in `rustc_ast`)
- rust-lang/rust#159998 (Align expect messages with guidance)
- rust-lang/rust#160145 (Expand checks for register_tool)
- rust-lang/rust#160307 (Update `minifier` version to `0.4.0`)
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsS-waiting-on-borsStatus: Waiting on bors to run and complete tests. Bors will change the label on completion.T-compilerRelevant 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.

3 participants

@JonathanBrouwer@rustbot@petrochenkov