Skip to content

E0121 suggests the use of the unique type of a generator #80844

Closed
@PatchMixolydic

Description

@PatchMixolydic

cc #80179

This still fails on generators (playground):

#![feature(generators)]

fn foo() -> _ {
    || yield 4i32
}
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
 --> src/lib.rs:3:13
  |
3 | fn foo() -> _ {
  |             ^
  |             |
  |             not allowed in type signatures
  |             help: replace with the correct return type: [generator@src/lib.rs:4:5: 4:18 {i32, ()}]

Tested on:

cargo 1.50.0-nightly (75d5d8cff 2020-12-22)
release: 1.50.0
commit-hash: 75d5d8cffe3464631f82dcd3c470b78dc1dda8bb
commit-date: 2020-12-22

I'm working on a PR to fix this as well as making this suggestion and E0308's try adding a return type suggestion use the same mechanism for checking if a type is suggestable directly.

@rustbot claim
@rustbot modify labels: +A-diagnostics +D-invalid-suggestion +F-generators +T-compiler

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsD-invalid-suggestionDiagnostics: A structured suggestion resulting in incorrect code.F-coroutines`#![feature(coroutines)]`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