Rust: Callback parameter names are missing from rustdoc

Created on 14 Sep 2017  路  3Comments  路  Source: rust-lang/rust

Reported in https://users.rust-lang.org/t/giving-names-to-callback-parameters/12877.

pub fn f(callback: fn(len: usize)) {}

Rustdoc shows this as:

pub fn f(callback: fn(_: usize))

This is with rustc 1.22.0-nightly (539f2083d 2017-09-13).

C-bug T-dev-tools T-rustdoc

Most helpful comment

Having originally reported this, I'd really like to take a stab at the fix. I'll start investigating over the weekend.

Edit: as I haven't had the time to look at this, someone else can feel free to take over.

All 3 comments

Having originally reported this, I'd really like to take a stab at the fix. I'll start investigating over the weekend.

Edit: as I haven't had the time to look at this, someone else can feel free to take over.

@rust-lang/compiler @petrochenkov Oh wow why do we even allow this syntax?!
But if we want this it should be done like extern {...} functions (with no bodies), which keep a Vec of names, distinct from argument patterns in functions with bodies.

@eddyb

Oh wow why do we even allow this syntax?!

To support self-documenting arguments in callback types, roughly the same reason why names are supported in foreign functions.
Any patterns except _ and IDENT are prohibited there by the same check that prohibits them in foreign functions, so the legal ones can be lowered into "Vec of names".

Was this page helpful?
0 / 5 - 0 ratings