Skip to content

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

Open
@cyrgani

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

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`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