Skip to content

"cannot find associated type" could hint existing associated types #87638

Closed
@oli-obk

Description

@oli-obk

The following error gives no hints for resolving it, even though there is an obvious solution, in this case the only existing associated type of std::ops::Deref.

Given the following code: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=976e4a98c62d7a0efb2d0d6325774495

fn main() {
    let s : <String as std::ops::Deref>::Output = "hey";
}

The current output is:

error[E0576]: cannot find associated type `Output` in trait `std::ops::Deref`
 --> src/main.rs:2:42
  |
2 |     let s : <String as std::ops::Deref>::Output = "hey";
  |                                          ^^^^^^ not found in `std::ops::Deref`

For more information about this error, try `rustc --explain E0576`.

Ideally the output should look like:

error[E0576]: cannot find associated type `Output` in trait `std::ops::Deref`
 --> src/main.rs:2:42
  |
2 |     let s : <String as std::ops::Deref>::Output = "hey";
  |                                          ^^^^^^ not found in `std::ops::Deref`

note: Did you mean `Target`?

For more information about this error, try `rustc --explain E0576`.

Metadata

Metadata

Assignees

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsT-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