Skip to content

Unhelpful error message for async method on invalid type #72590

Description

@euclio

I tried this code:

Playground

struct Foo {
    foo: Nonexistent,
}

impl Foo {
    async fn frob(mut self) {}
}

I expected to see this happen: resolution error reported for Nonexistent type.

Instead, this happened: In addition to the resolution error, the compiler emitted errors complaining that it couldn't determine the size of Foo. That error is also emitted twice. These errors should be silent, since the true error is that Foo isn't fully formed.

error[E0412]: cannot find type `Nonexistent` in this scope
 --> src/lib.rs:2:10
  |
2 |     foo: Nonexistent,
  |          ^^^^^^^^^^^ not found in this scope

error[E0161]: cannot move a value of type Foo: the size of Foo cannot be statically determined
 --> src/lib.rs:6:19
  |
6 |     async fn frob(mut self) {}
  |                   ^^^^^^^^

error[E0161]: cannot move a value of type Foo: the size of Foo cannot be statically determined
 --> src/lib.rs:6:19
  |
6 |     async fn frob(mut self) {}
  |                   ^^^^^^^^

warning: variable does not need to be mutable
 --> src/lib.rs:6:19
  |
6 |     async fn frob(mut self) {}
  |                   ----^^^^
  |                   |
  |                   help: remove this `mut`
  |
  = note: `#[warn(unused_mut)]` on by default

error: aborting due to 3 previous errors; 1 warning emitted

Some errors have detailed explanations: E0161, E0412.
For more information about an error, try `rustc --explain E0161`.

Meta

rustc --version --verbose:

rustc 1.45.0-nightly (a74d1862d 2020-05-14)
binary: rustc
commit-hash: a74d1862d4d87a56244958416fd05976c58ca1a8
commit-date: 2020-05-14
host: x86_64-unknown-linux-gnu
release: 1.45.0-nightly
LLVM version: 9.0
Backtrace

<backtrace>

Activity

  1. added
    A-diagnosticsArea: Messages for errors, warnings, and lints
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    on May 25, 2020
  2. added
    D-confusingDiagnostics: Confusing error or lint that should be reworked.
    AsyncAwait-TriagedAsync-await issues that have been triaged during a working group meeting.
    on May 26, 2020
  3. added a commit that references this issue on May 26, 2020
    1c30c9e
  4. added 2 commits that reference this issue on May 27, 2020
    fc7afd1
    bf4ba5b
  5. added a commit that references this issue on May 30, 2020
    7624ac7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-async-awaitArea: Async & AwaitA-diagnosticsArea: Messages for errors, warnings, and lintsAsyncAwait-TriagedAsync-await issues that have been triaged during a working group meeting.C-bugCategory: This is a bug.D-confusingDiagnostics: Confusing error or lint that should be reworked.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