Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

resolve: strange corner case in overlapping method names #18674

Closed
aturon opened this issue Nov 5, 2014 · 1 comment · Fixed by #18694
Closed

resolve: strange corner case in overlapping method names #18674

aturon opened this issue Nov 5, 2014 · 1 comment · Fixed by #18694
Assignees

Comments

@aturon
Copy link
Member

aturon commented Nov 5, 2014

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

@nikomatsakis
Copy link
Contributor

I plan to open a PR soon for a revamp of method resolution. This code compiles successfully on that branch.

@nikomatsakis nikomatsakis self-assigned this Nov 5, 2014
bors added a commit that referenced this issue Nov 8, 2014
…2, r=nrc

This is a pretty major refactoring of the method dispatch infrastructure. It is intended to avoid gross inefficiencies and enable caching and other optimizations (e.g. #17995), though it itself doesn't seem to execute particularly faster yet. It also solves some cases where we were failing to resolve methods that we theoretically should have succeeded with.

Fixes #18674.

cc #18208
bors added a commit that referenced this issue Nov 17, 2014
…2, r=nrc

This is a pretty major refactoring of the method dispatch infrastructure. It is intended to avoid gross inefficiencies and enable caching and other optimizations (e.g. #17995), though it itself doesn't seem to execute particularly faster yet. It also solves some cases where we were failing to resolve methods that we theoretically should have succeeded with.

Fixes #18674.

cc #18208
lnicola pushed a commit to lnicola/rust that referenced this issue Dec 16, 2024
Show expansion errors in expand_macro feature
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants