Skip to content

Vague error message when using generics #71924

Closed
@Suibeom

Description

@Suibeom

I received the following error while working on an Amethyst project;

error[E0107]: wrong number of type arguments: expected at least 1, found 0
  --> src/main.rs:67:26
   |
67 |         WriteStorage<'a, TileMap>,
   |                          ^^^^^^^ expected at least 1 type argument

After scratching my head for a while and searching the Amethyst Discord, and finally StackOverflow, I realized I was having a brainfart and the type I was using was a generic and I wasn't fully defining it. I had been having some trouble getting an import to work successfully, so I was unsure if the type was even successfully being added to my namespace in the first place, which left me completely confused as to how to interpret this error. Was the compiler telling me 'TileMap' is not a type..??

This error does not seem in line with the level of explicitness of most of the first-pass compiler errors, and does not contain any resolution suggestions. At least one past issue exists about this particular type of error and several stackoverflow threads exist asking, essentially, 'What does this error mean?' (with successful resolutions of the form, 'That's a generic type with missing type parameters') which seems like a good indicator that the error could be more helpful and explicit. (e.g. 'This generic type is expecting _ type parameters but only found _')

This issue has been assigned to @Patryk27 via this comment.

Metadata

Metadata

Assignees

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`C-enhancementCategory: An issue proposing an enhancement or a PR with one.D-confusingDiagnostics: Confusing error or lint that should be reworked.D-newcomer-roadblockDiagnostics: Confusing error or lint; hard to understand for new users.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