Skip to content

Bug. Get doubled error message with impl_trait_in_bindings when no error must be #70997

@DustinByfuglien

Description

@DustinByfuglien

This example compiling with error message. And it's not obvious:

  1. what cycle is this message about?
  2. why this error is doubled in output?
  3. why error is at all? It seems no error must be.
#![feature(generator_trait)]
#![feature(generators)]
#![allow(incomplete_features)]
#![feature(impl_trait_in_bindings)]

use std::ops::Generator;

fn main() {
    let mut gen: impl Generator =
        || {
            yield;
        };
    std::pin::Pin::new(&mut gen).resume(());
}

(Playground)

Errors:

   Compiling playground v0.0.1 (/playground)
error[E0391]: cycle detected when processing `main::{{opaque}}#0`
  --> src/main.rs:9:18
   |
9  |     let mut gen: impl Generator =
   |                  ^^^^^^^^^^^^^^
   |
note: ...which requires type-checking `main`...
  --> src/main.rs:8:1
   |
8  | fn main() {
   | ^^^^^^^^^
   = note: ...which requires evaluating trait selection obligation `impl std::ops::Generator: std::marker::Unpin`...
   = note: ...which again requires processing `main::{{opaque}}#0`, completing the cycle
note: cycle used when checking item types in top-level module
  --> src/main.rs:1:1
   |
1  | / #![feature(generator_trait)]
2  | | #![feature(generators)]
3  | | #![allow(incomplete_features)]
4  | | #![feature(impl_trait_in_bindings)]
...  |
13 | |     std::pin::Pin::new(&mut gen).resume(());
14 | | }
   | |_^

error[E0391]: cycle detected when processing `main::{{opaque}}#0`
  --> src/main.rs:9:18
   |
9  |     let mut gen: impl Generator =
   |                  ^^^^^^^^^^^^^^
   |
note: ...which requires type-checking `main`...
  --> src/main.rs:8:1
   |
8  | fn main() {
   | ^^^^^^^^^
   = note: ...which again requires processing `main::{{opaque}}#0`, completing the cycle
note: cycle used when checking item types in top-level module
  --> src/main.rs:1:1
   |
1  | / #![feature(generator_trait)]
2  | | #![feature(generators)]
3  | | #![allow(incomplete_features)]
4  | | #![feature(impl_trait_in_bindings)]
...  |
13 | |     std::pin::Pin::new(&mut gen).resume(());
14 | | }
   | |_^

error: aborting due to 2 previous errors

May be must tracked by #63065

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-coroutinesArea: CoroutinesA-diagnosticsArea: Messages for errors, warnings, and lintsA-impl-traitArea: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.C-enhancementCategory: An issue proposing an enhancement or a PR with one.D-verboseDiagnostics: Too much output caused by a single piece of incorrect code.F-coroutines`#![feature(coroutines)]`F-impl_trait_in_bindings`#![feature(impl_trait_in_bindings)]`P-lowLow priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.requires-nightlyThis issue requires a nightly compiler in some way. When possible, use a F-* label instead.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions