You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It seems that rustc isn't able to choose among multiple impls, and insists that some arbitrary one is the "right" one. (Note that type parameters are explicit to work around #3902)
Testcase
mod base {
trait HasNew<T> {
static pure fn new() -> T;
}
pub struct Foo {
dummy: (),
}
pub impl Foo : HasNew<Foo> {
static pure fn new() -> Foo {
Foo { dummy: () }
}
}
pub struct Bar {
dummy: (),
}
pub impl Bar : HasNew<Bar> {
static pure fn new() -> Bar {
Bar { dummy: () }
}
}
}
fn main() {
let f: base::Foo = base::new::<base::Foo, base::Foo>();
debug!("%?", f);
}
Error
[burg@host-5-178 Desktop]# rustc test.rs
test.rs:28:23: 28:56 error: mismatched types: expected `@base::HasNew<base::Bar>` but found `@base::HasNew<base::Foo>` (expected class base::Bar but found class base::Foo)
test.rs:28 let f: base::Foo = base::new::<base::Foo, base::Foo>();
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
test.rs:28:23: 28:56 error: mismatched types: expected `base::Foo` but found `base::Bar` (expected class base::Foo but found class base::Bar)
test.rs:28 let f: base::Foo = base::new::<base::Foo, base::Foo>();
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
test.rs:28:23: 28:56 error: mismatched types: expected `@base::HasNew<base::Bar>` but found `@base::HasNew<base::Foo>` (expected class base::Bar but found class base::Foo)
test.rs:28 let f: base::Foo = base::new::<base::Foo, base::Foo>();
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
test.rs:28:23: 28:56 error: mismatched types: expected `base::Foo` but found `base::Bar` (expected class base::Foo but found class base::Bar)
test.rs:28 let f: base::Foo = base::new::<base::Foo, base::Foo>();
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The text was updated successfully, but these errors were encountered:
It seems that rustc isn't able to choose among multiple impls, and insists that some arbitrary one is the "right" one. (Note that type parameters are explicit to work around #3902)
Testcase
Error
The text was updated successfully, but these errors were encountered: