Skip to content

Generate function assist should default the return type to _ instead of () #10123

@jplatte

Description

@jplatte

This will unconditionally result in a compiler error, but a rather useful one:

fn f() -> _ {
    vec!["hello, world".to_owned()]
}
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
 --> src/lib.rs:1:11
  |
1 | fn f() -> _ {
  |           ^
  |           |
  |           not allowed in type signatures
  |           help: replace with the correct return type: `Vec<String>`

Maybe this error / assist could even be added to rust-analyzer, so after generating a function and filling in the body you would only have to accept its suggestion for filling the return type (as opposed to having to save, then wait for cargo check).

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-assistsS-actionableSomeone could pick this issue up and work on it right now

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions