Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Kixunil opened this issue Apr 24, 2020 · 1 comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-bug Category: This is a bug. D-terse Diagnostics: An error or lint that doesn't give enough information about the problem at hand. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@Kixunil
Copy link
Contributor

Kixunil commented Apr 24, 2020

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)
@Kixunil Kixunil added the C-bug Category: This is a bug. label Apr 24, 2020
@jonas-schievink jonas-schievink added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Apr 24, 2020
@estebank estebank added the D-terse Diagnostics: An error or lint that doesn't give enough information about the problem at hand. label Apr 24, 2020
@estebank
Copy link
Contributor

estebank commented Aug 3, 2023

Current output:

error[E0599]: no method named `extend` found for struct `HashMap` in the current scope
 --> src/main.rs:8:7
  |
8 |     b.extend(a);
  |       ^^^^^^ method not found in `HashMap<Foo, String>`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-bug Category: This is a bug. D-terse Diagnostics: An error or lint that doesn't give enough information about the problem at hand. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants