Improve diagnostic for patterns in function pointer types - #160282
Merged
Conversation
Collaborator
|
The parser was modified, potentially altering the grammar of (stable) Rust cc @fmease |
Collaborator
|
rustbot has assigned @petrochenkov. Use Why was this reviewer chosen?The reviewer was selected based on:
|
Contributor
|
@bors r+ |
Contributor
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), | ```
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-bors Bot
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-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), | ```
This was referenced Aug 2, 2026
pull Bot
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In preparation for some work for #158499
Diagnostic before:
Diagnostic after: