Skip to content

Wrong Error Message "Add is not a Trait" #35987

Closed
@CryZe

Description

@CryZe

I made a mistake while implementing Add for a type. Instead of using + for specifying multiple constraints, I accidentally used , and for some reason the compiler can't handle this very well. Instead of complaining about the , it says that Add is not a Trait

Playground Link

struct Okok<T: Clone>(T);

use std::ops::Add;

impl<T: Clone, Add> Add for Okok<T> {
    type Output = usize;

    fn add(self, rhs: Self) -> Self::Output {
        unimplemented!();
    }
}
...
error[E0404]: `Add` is not a trait
 --> <anon>:5:21
  |
5 | impl<T: Clone, Add> Add for Okok<T> {
  |                     ^^^ not a trait

error: cannot continue compilation due to previous error

This happens on both Nightly, Beta and Stable.

Metadata

Metadata

Assignees

No one assigned

    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