Different impl for types won't work anymore


#1

Not sure if this is intended or a regresion. Until some days ago it was possible to do:

struct SomeStruct{
...
}
type Other = SomeStruct;

impl SomeStruct{
    pub fn new() -> SomeStruct{
    ....
    }
}


impl Other{
    pub fn new() -> Other{
    ....
    }
}

but now that produces an error:

error: multiple applicable methods in scope

#2

Seems natural. type doesn’t create a new type. It even lets you do this:

struct Foo;

impl Foo {
    fn foo(&self) { }
}

type Bar = Foo;

impl Bar {
    fn bar(&self) { }
}

fn main() {
    let x: Foo = Foo;
    x.bar();
}

#3

i know but it has changed from being possible (even having different behaviours for the different types which was kind of handy) to not work. so wondering if it was a bug before or now since i can’t find anything in the breaking changes list


#4

I think it’s important to note that the aliased types aren’t different. So this isn’t the way to implement poor man’s inheritance for example.


#5

This was never intended to work, and it’s hard to believe it ever did (because it was never in my particular mental model of Rust at least). Definitely a bug, if it was exactly like that.