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

Can define a method twice in a trait impl #8153

Closed
huonw opened this issue Jul 31, 2013 · 2 comments
Closed

Can define a method twice in a trait impl #8153

huonw opened this issue Jul 31, 2013 · 2 comments
Labels
A-trait-system Area: Trait system

Comments

@huonw
Copy link
Member

huonw commented Jul 31, 2013

struct Foo;

trait Bar {
    fn bar(&self) -> int;
}
impl Bar for Foo {
    fn bar(&self) -> int {1}
    fn bar(&self) -> int {2}
}

fn main() {
    printfln!(Foo.bar())
}
$ rustc double-def.rs
$ ./double-def
1
@sammykim
Copy link
Contributor

struct Foo;

trait Bar {
    fn bar(&self) -> int;
}
impl Bar for Foo {
    fn bar(&self) -> int {1}
    fn bar(&self) -> int {2}
}

fn main() {
    println!("{}",Foo.bar());
}
$ rustc 8153.rs
$ ./8153
$ 1

When I tested with this code based on reporter's code, It still shows same result.

@luqmana
Copy link
Member

luqmana commented Oct 22, 2013

I could've sworn I had fixed this in c6f3103 :(

The logic seems to have changed in resolve since then and even though it still seems to catch this case:

impl Bar {
    fn bar(&self) -> int {1}
    fn bar(&self) -> int {2}
}

The error message got less descriptive:
error: duplicate definition of value bar``

vs what it used to be:
error: duplicate definition of method bar``

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-trait-system Area: Trait system
Projects
None yet
Development

No branches or pull requests

3 participants