Skip to content

Compiler suggests [type error] when encountering placeholder in fn return type #91371

Closed
@spookyvision

Description

@spookyvision

Given the following code:

fn make() -> Option<_> {}

The current output is:

error[E0121]: the type placeholder `_` is not allowed within types on item signatures for return types
 --> src/lib.rs:1:21
  |
1 | fn make() -> Option<_> {}
  |              -------^-
  |              |      |
  |              |      not allowed in type signatures
  |              help: replace with the correct return type: `Option<[type error]>`

Ideally the output should look like:


error[E0121]: the type placeholder `_` is not allowed within types on item signatures for return types
 --> src/lib.rs:1:21
  |
1 | fn make() -> Option<_> {}
  |              -------^-
  |              |      |
  |              |      not allowed in type signatures
  |              help: put a fully specified type here

this issue might be related/helpful.

Metadata

Metadata

Assignees

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsC-bugCategory: This is a bug.D-invalid-suggestionDiagnostics: A structured suggestion resulting in incorrect code.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