Skip to content

Incorrect inference for default methods on generic traits #4099

Closed
@brson

Description

@brson
trait A<T> {
    fn g(x: T) -> T { move x }
}

impl int: A<int> { }

fn main () {
    assert 0i.g(2i) == 2i;
}
/home/brian/dev/rust/src/test/run-pass/trait-default-method-bound-subst2.rs:8:16: 8:18 error: mismatched types: expected `'a` but found `int` (expected type parameter but found int)
/home/brian/dev/rust/src/test/run-pass/trait-default-method-bound-subst2.rs:8     assert 0i.g(2i) == 2i;
                                                                                              ^~
/home/brian/dev/rust/src/test/run-pass/trait-default-method-bound-subst2.rs:8:11: 8:25 error: binary operation == cannot be applied to type `'a`
/home/brian/dev/rust/src/test/run-pass/trait-default-method-bound-subst2.rs:8     assert 0i.g(2i) == 2i;
                                                                                         ^~~~~~~~~~~~~~
/home/brian/dev/rust/src/test/run-pass/trait-default-method-bound-subst2.rs:8:11: 8:25 error: mismatched types: expected `bool` but found `'a` (expected bool but found type parameter)
/home/brian/dev/rust/src/test/run-pass/trait-default-method-bound-subst2.rs:8     assert 0i.g(2i) == 2i;
                                                                                         ^~~~~~~~~~~~~~
error: aborting due to 3 previous errors


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