Skip to content

Rustc says method doesn't exist instead of hinting at unsatisfied trait bounds #71505

Open
@Kixunil

Description

@Kixunil

As described in #67642 (comment) when one attempts to call a triat method with unsatisfied bounds, the message says the method doesn't exist instead of explaining that the bounds weren't satisfied.

I tried this code:

use std::collections::HashMap;

struct Foo;

fn main() {
    let a: HashMap<Foo, String> = HashMap::default();
    let mut b: HashMap<Foo, String> = HashMap::default();
    b.extend(a);
}

I expected to see this happen: Rustc message saying that Eq and Hash aren't satisfied.

Instead, this happened: Rustc says that extend doesn't exist.

Meta

The bug is in nightly

Tested on the playground:

 1.44.0-nightly (2020-04-22 b2e36e6c2d229126b59e)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsC-bugCategory: This is a bug.D-terseDiagnostics: An error or lint that doesn't give enough information about the problem at hand.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