Skip to content

Unstable Fn<Args> syntax shouldn't be suggested on T: Fn #136407

Closed

Description

@cyrgani

Code

pub fn f<T: Fn>() {}

Current output

error[E0658]: the precise format of `Fn`-family traits' type parameters is subject to change
 --> src/lib.rs:1:13
  |
1 | pub fn f<T: Fn>() {}
  |             ^^ help: use parenthetical notation instead: `Fn() -> ()`
  |
  = note: see issue #29625 <https://github.com/rust-lang/rust/issues/29625> for more information
  = help: add `#![feature(unboxed_closures)]` to the crate attributes to enable
  = note: this compiler was built on 2025-01-31; consider upgrading it if it is out of date

error[E0107]: missing generics for trait `Fn`
  --> src/lib.rs:1:13
   |
1  | pub fn f<T: Fn>() {}
   |             ^^ expected 1 generic argument
   |
note: trait defined here, with 1 generic parameter: `Args`
  --> /playground/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:76:11
   |
76 | pub trait Fn<Args: Tuple>: FnMut<Args> {
   |           ^^ ----
help: add missing generic argument
   |
1  | pub fn f<T: Fn<Args>>() {}
   |               ++++++

Desired output

The unstable syntax shouldn't be mentioned.

Rationale and extra context

No response

Other cases

Rust Version

1.86.0-nightly

(2025-01-31 854f22563c8daf92709f)

Anything else?

No response

Activity

  1. added
    A-diagnosticsArea: Messages for errors, warnings, and lints
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    on Feb 1, 2025
  2. added
    D-papercutDiagnostics: An error or lint that needs small tweaks.
    D-invalid-suggestionDiagnostics: A structured suggestion resulting in incorrect code.
    on Sep 4, 2026
  3. added a commit that references this issue on Sep 9, 2026
    c237ab7
  4. added a commit that references this issue on Sep 9, 2026
    f77cf0d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`D-invalid-suggestionDiagnostics: A structured suggestion resulting in incorrect code.D-papercutDiagnostics: An error or lint that needs small tweaks.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions