Closed
Description
I tried this code:
trait MyTrait {
type Assoc;
}
#[allow(dead_code)]
fn foo<S, T>(_s: S, _t: T)
where
S: MyTrait, T: MyTrait<Assoc == S::Assoc>
{}
Playground: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=adddc330eab816444616202cc576f88e
I expected to see this happen: The error message should indicate that the ==
should be a single =
.
Instead, this happened: The error message gives no hint of the correct syntax. It gives two errors, neither of which are helpful:
error: expected one of `,` or `>`, found `==`
--> src/lib.rs:8:34
|
8 | S: MyTrait, T: MyTrait<Assoc == S::Assoc>
| ^^ expected one of `,` or `>`
|
help: expressions must be enclosed in braces to be used as const generic arguments
|
8 | S: MyTrait, T: MyTrait<{ Assoc == S::Assoc }>
| ^ ^
This error is unhelpful because it says "expected one of ,
or >
", but =
is also allowed. Also, the suggestion to use curly braces is a red herring.
error[E0107]: this trait takes 0 const arguments but 1 const argument was supplied
--> src/lib.rs:8:20
|
8 | S: MyTrait, T: MyTrait<Assoc == S::Assoc>
| ^^^^^^^------------------- help: remove these generics
| |
| expected 0 const arguments
|
note: trait defined here, with 0 const parameters
--> src/lib.rs:1:7
|
1 | trait MyTrait {
| ^^^^^^^
This error is unhelpful because I am not specifying const arguments; I'm specifying associated types.
Meta
Rust version according to play.rust-lang.org: 1.53.0
Metadata
Metadata
Assignees
Labels
Area: Associated items (types, constants & functions)Area: Messages for errors, warnings, and lintsArea: The lexing & parsing of Rust source code to an ASTCategory: This is a bug.Diagnostics: Confusing error or lint; hard to understand for new users.Diagnostics: An error or lint that needs small tweaks.Relevant to the compiler team, which will review and decide on the PR/issue.