Skip to content

Strange blanket impl error #20018

Closed
Closed
@dylanmckay

Description

@dylanmckay

When blanket impl'ing all types which implement a trait over the standard operators (in this case Add), we get the error:

error: cannot provide an extension implementation where both trait and type are not defined in this crate

error: conflicting implementations for trait `core::ops::Add`
note: conflicting implementation in crate `std`
error: conflicting implementations for trait `core::ops::Add`
note: conflicting implementation in crate `core`
error: conflicting implementations for trait `core::ops::Add`
note: conflicting implementation in crate `core`
...

The error is observed in the following Rust code (Playpen):

trait Vector<T: Add<T,T>>
{
    fn map_in_place(&mut self, f: |T| -> T);
}

impl<T: Add<T,T>, V: Vector<T>> Add<V,V> for V
{
    fn add(&self, rhs: &V) -> V
    {
        unimplemented!();
    }
}

fn main() { }

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions