Skip to content

Struct with an error magically becomes a function, causing misleading diagnostics (arc is a function, perhaps you wish to call it) #82323

Closed
@kornelski

Description

fn main() {
    let arc = std::sync::Arc::new(oops);
    arc.clone();
}

It correctly diagnoses that oops is undeclared. It should stop after this error, and not display any further errors related to the incomplete arc object.

But it continues and displays a second error, which doesn't make any sense and has a nonsense suggestion:

error[E0599]: no method named `clone` found for struct `Arc<_>` in the current scope
 --> src/main.rs:5:9
  |
5 |     arc.clone();
  |         ^^^^^ method not found in `Arc<_>`
  |
  = note: `arc` is a function, perhaps you wish to call it

Meta

rustc --version --verbose:

rustc 1.52.0-nightly (8e54a2113 2021-02-13)
binary: rustc
commit-hash: 8e54a21139ae96a2aca3129100b057662e2799b9
commit-date: 2021-02-13
host: x86_64-apple-darwin
release: 1.52.0-nightly
LLVM version: 11.0.1

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsC-bugCategory: This is a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions