Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

the type placeholder _ is not allowed within types on item signatures should hint at generics #27435

Closed
oli-obk opened this issue Jul 31, 2015 · 4 comments · Fixed by #67597
Closed
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-enhancement Category: An issue proposing an enhancement or a PR with one. D-newcomer-roadblock Confusing diagnostic error hard to understand for new users E-medium Call for participation: Experience needed to fix: Medium / intermediate P-medium Medium priority

Comments

@oli-obk
Copy link
Contributor

oli-obk commented Jul 31, 2015

The following signature yields the mentioned error

fn shuffle(args: Vec<_>) -> Vec<_>

it should be replaced by

fn shuffle<T>(args: Vec<T>) -> Vec<T>

There should be an error hint suggesting this change.

@aatxe
Copy link
Member

aatxe commented Jul 31, 2015

👍

I've actually wanted this to be sugar for a while. (As well as sugar to make Vec equivalent to Vec<_>, but I imagine that might be unpopular.)

@arielb1
Copy link
Contributor

arielb1 commented Aug 1, 2015

@aatxe

Generic Elision isn't going to be a supported feature (you do need to be able to specify type parameters in paths - e.g. foo::<T>).

@steveklabnik steveklabnik added the A-diagnostics Area: Messages for errors, warnings, and lints label Aug 4, 2015
@cyplo
Copy link
Contributor

cyplo commented Jun 1, 2016

Hi ! @arielb1, @oli-obk: does it mean this issue can be closed ?

@steveklabnik steveklabnik removed the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Mar 9, 2017
@Mark-Simulacrum Mark-Simulacrum added the C-enhancement Category: An issue proposing an enhancement or a PR with one. label Jul 22, 2017
@estebank
Copy link
Contributor

estebank commented Jan 28, 2018

Current output:

error[E0121]: the type placeholder `_` is not allowed within types on item signatures
 --> src/main.rs:1:22
  |
1 | fn shuffle(args: Vec<_>) -> Vec<_> {}
  |                      ^ not allowed in type signatures

error[E0121]: the type placeholder `_` is not allowed within types on item signatures
 --> src/main.rs:1:33
  |
1 | fn shuffle(args: Vec<_>) -> Vec<_> {}
  |                                 ^ not allowed in type signatures

I agree that it should teach the generic type argument syntax on a suggestion.

Proposed output:

error[E0121]: the type placeholder `_` is not allowed within types on item signatures
 --> src/main.rs:1:22
  |
1 | fn shuffle(args: Vec<_>) -> Vec<_> {}
  |                      ^          ^ not allowed in type signatures
  |                      |
  |                      not allowed in type signatures
help: instead use a generic type argument
  |
1 | fn shuffle<T>(args: Vec<T>) -> Vec<T> {}
  |           ^^^           ^          ^

@estebank estebank added E-medium Call for participation: Experience needed to fix: Medium / intermediate P-medium Medium priority labels May 25, 2019
@estebank estebank added the D-newcomer-roadblock Confusing diagnostic error hard to understand for new users label Oct 4, 2019
@bors bors closed this as completed in 71bb0ff Dec 31, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-enhancement Category: An issue proposing an enhancement or a PR with one. D-newcomer-roadblock Confusing diagnostic error hard to understand for new users E-medium Call for participation: Experience needed to fix: Medium / intermediate P-medium Medium priority
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants