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

Method dispatch doesn't look up in inherited traits #8079

Closed
farnoy opened this issue Jul 27, 2013 · 1 comment
Closed

Method dispatch doesn't look up in inherited traits #8079

farnoy opened this issue Jul 27, 2013 · 1 comment

Comments

@farnoy
Copy link
Contributor

farnoy commented Jul 27, 2013

Method dispatch does not search in traits that a compound trait inherits. Example below, on 0.8-pre @c5194740a78ec113cb6cbc937e7263e2548f62f6. Generics work though on compound traits.

struct A;

pub trait Method1Able {
    pub fn method1(&self);
}

pub trait Test : Method1Able {}

impl Method1Able for A {
    pub fn method1(&self) {()}
}

impl Test for A {}

fn generic<T: Test>(a: &T) {
  a.method1(); // works
}

fn main() {
    let mut a = A;
    generic(&a);
    {
        let mut b = &a as &Test;
        b.method1();
        // error: type `&Test<no-bounds>` does not
        // implement any method in scope named `method1`
    }
}
@huonw
Copy link
Member

huonw commented Jul 27, 2013

Thanks for the report! However, this looks like a dup of #4100.

@huonw huonw closed this as completed Jul 27, 2013
flip1995 pushed a commit to flip1995/rust that referenced this issue Jan 13, 2022
…s, r=flip1995

Allow primitive types in disallowed_methods

Fixes rust-lang#8079

changelog: `disallowed_methods`: Now can disallow methods of primitive types
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

No branches or pull requests

2 participants