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

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

Closed
spookyvision opened this issue Nov 29, 2021 · 1 comment · Fixed by #91450
Closed
Assignees
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-bug Category: This is a bug. D-invalid-suggestion Diagnostics: A structured suggestion resulting in incorrect code. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@spookyvision
Copy link
Contributor

spookyvision commented Nov 29, 2021

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.

@spookyvision spookyvision added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Nov 29, 2021
@hkmatsumoto
Copy link
Member

@rustbot claim

@inquisitivecrystal inquisitivecrystal added C-bug Category: This is a bug. D-invalid-suggestion Diagnostics: A structured suggestion resulting in incorrect code. labels Dec 2, 2021
@bors bors closed this as completed in 609d9a0 Dec 5, 2021
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-bug Category: This is a bug. D-invalid-suggestion Diagnostics: A structured suggestion resulting in incorrect code. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants