Error message for accessing associated type on concrete type is misleading #92499
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
C-bug
Category: This is a bug.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
I tried this code:
I expected to see this happen: Compiler emits an error reporting that I cannot access associated types from concrete types, and must use fully-qualified syntax to specify the desired trait.
Instead, this happened: Compiler emits an error reporting that
AssocTy
is ambiguous:This made me wonder why it's ambiguous, since there's only one trait implemented for
u8
that has that type name. The suggestion only added more confusion, because it only shows a placeholder trait name instead of listing the actual names of potential traits. I thought that maybe there was another trait implemented foru8
that used the same associated type name, until I realized that you must specify the trait name when accessing an associated type from a concrete type.Note that this error message is also emitted for non-existent associated types, and even for types that are specified with invalid syntax. See more examples in this UI test.
Related to #59225.
Meta
rustc --version --verbose
:The text was updated successfully, but these errors were encountered: