Skip to content

resolve: strange corner case in overlapping method names #18674

Closed
@aturon

Description

@aturon

The following code fails to compile:

use std::kinds::Sized;

// Note: this must be generic for the problem to show up
trait Foo<A> for Sized? {
    fn foo(&self);
}

impl Foo<u8> for [u8] {
    fn foo(&self) {}
}

impl<'a, A, T> Foo<A> for &'a T where T: Foo<A> {
    fn foo(&self) {
        Foo::foo(*self)
    }
}

trait Bar {
    fn foo(&self);
}

struct MyType;

impl Bar for MyType {
    fn foo(&self) {}
}

fn main() {
    let mut m = MyType;
    (&mut m).foo()
}

with the error

<anon>:31:9: 31:23 error: the trait `Foo<_>` is not implemented for the type `MyType`
<anon>:31         (&mut m).foo()
                  ^~~~~~~~~~~~~~

As noted above, this seems to depend on one of the traits using generics.

Real code this is blocking: #18638

cc @nikomatsakis
cc @japaric

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions